We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Cant understand camera() behaviour...
Page Index Toggle Pages: 1
Cant understand camera() behaviour... (Read 564 times)
Cant understand camera() behaviour...
Apr 30th, 2007, 7:13pm
 
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);

}

Re: Cant understand camera() behaviour...
Reply #1 - May 1st, 2007, 4:17am
 
mhh. I still haven't it clear but I came up with something 'working' anyway... here's the post:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1177985735
Re: Cant understand camera() behaviour...
Reply #2 - May 5th, 2007, 3:44pm
 
to rotate a point around y axis with the camera call just do sumtin like this:

float camdist = 300;
float angle = millis() * 0.001;
float height = 0.0;

camera( camdist*cos(angle), height, camdist*sin(angle), //camera position point
       0, 0, 0, // target point
       0, 1, 0 // up vector
       );

vic
Page Index Toggle Pages: 1