Hello.
I'm trying to create a rotating camera along the Y axis in order to see how is my 3D scene.
The scene is made of a series of points aligned on a line made of segments randomly oriented.
Here's the problem:
(1) The drawing (made of straight lines) doesnt seem to rotate (as if seen by a rotating point of view)
Code:
int a = 0;
int dirX, dirY, dirZ, dirSteps;
int posX, posY, posZ;
void setup() {
size(500, 500, P3D);
background(255);
stroke(0);
noFill();
//Position for the first point
posX = width/2;
posY = height/2;
posZ = 0;
}
void draw() {
//The camera is looking at the center of the scene, at 0 height. The eye is rotating on the Y-up axis
camera(width/2 * cos(radians(a)), 0, height/2 * sin(radians(a)), width/2, height/2, 0, 0,1,0);
// 'a' is the angle at wich the camera is rotated
a = a + 1;
//If the leght of the segment has reduced to '0' generates new lenght and new directions for the X, Y, Z directions
if(dirSteps == 0) {
dirSteps = round(random(20,100));
dirX = round(pow(-1, round(random(1,2))));
dirY = round(pow(-1, round(random(1,2))));
dirZ = round(pow(-1, round(random(1,2))));
}
//Calculates the position for the point beign drawn
posX = posX + dirX;
posY = posY + dirY;
posZ = posZ + dirZ;
//Indicates how many points remain to be drawn for the current segment
dirSteps --;
//Draws the point
point(posX, posY, posZ);
}