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 & HelpOpenGL and 3D Libraries › move camera around origin (OCD)
Page Index Toggle Pages: 1
move camera around origin (OCD) (Read 856 times)
move camera around origin (OCD)
Jun 10th, 2008, 12:33am
 
is it possible to move a OCD-camera around the center of a shape, e.g. a cube?
i have tried all of the methods like roll(), truck() and so on, but none seem to do this job.

i need the camera to move around the z-axis of an object and to still aim at the center of this object. rotateZ() doesn't work either.

any suggestions are highly appreciated,
thanks in advance.
Re: move camera around origin (OCD)
Reply #1 - Jun 10th, 2008, 1:33pm
 
use the camera eye and lookat properties:

http://processing.org/reference/camera_.html

Code:
camera(
cos(angle)*d, 0, sin(angle)*d,
0, 0, 0,
0, 1, 0
);
Re: move camera around origin (OCD)
Reply #2 - Jun 10th, 2008, 1:35pm
 
full example:

Code:
float angle = 0.0;
float d = 40;

void setup() {
size(400, 300, P3D);
}

void draw(){
angle += PI/300;
camera(
cos(angle)*d, 10, sin(angle)*d,
0, 0, 0,
0, -1, 0
);
background(255);
box(10);
}
Page Index Toggle Pages: 1