thanks Jeff,
I gived it a try to the example on that link but I`m not sure if its suitable for my problem, on wich the Z vector is first calculated based on pixel brightness from Video webcam, I`ve failed to add that vector to the Z vector on the sphere
Here`s my full code.
Code:
import processing.opengl.*;
import processing.video.*;
import peasy.*;
PeasyCam pCamera;
PImage a;
int squareList;
// Size of each cell in the grid/sphere
int cellSize = 8;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;
void setup() {
size(600, 600, OPENGL);
//hint( ENABLE_OPENGL_4X_SMOOTH );
//smooth();
cols = width / cellSize;
rows = height / cellSize;
colorMode(RGB, 255, 255, 255, 100);
fill(255,255,255,75);
pCamera = new PeasyCam(this, 0, 0, 0, width/2);
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 12);
}
void draw() {
background(0);
if (video.available()) {
video.read();
video.loadPixels();
float radius = width/2;
// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {
// Where are we, pixel-wise?
int x = i*cellSize;
int y = j*cellSize;
float z;
int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror the image
float r = red(video.pixels[loc]);
float g = green(video.pixels[loc]);
float b = blue(video.pixels[loc]);
// Make a new color with an alpha component
color c = color(r, g, b, 100);
float z1 = brightness(video.pixels[loc]);
//------------<< Spherical projection !
//uncomment
/*
// convert lat/long to radians
float latitude = PI * x / 180;
float longitude = PI * y / 180;
// adjust position by radians
// subtract 90 degrees (in radians)
latitude -= radians(90);
x = (int)((radius) * sin(latitude) * cos(longitude));
y = (int)((radius) * sin(latitude) * sin(longitude));
z = (int)(radius * sin(latitude) * cos(longitude));
*/
//--------------Spherical projection >> !
fill(c);
pushMatrix();
translate(x,y,z1);
ellipse(0,0, cellSize,cellSize);
popMatrix();
}//end for
}
}
}
Appreciate any help
Thank u.