NOTE: this is in the Processing IDE
I am trying to get spherical orbiting down and i've almost got it. this is what i have so far:
float cameraTheta, cameraPhi, cameraRadius; //camera position in spherical coordinates
float camx, camy, camz;
void setup() {
size(500, 500, P3D);
background(255);
cameraRadius = 200.0f;
cameraTheta = 2.80;
cameraPhi = 2.0;
recomputeOrientation();
}
void draw() {
background(255);
lights();
mouseMotion();
camera(camx, camy, camz, 0, 0, 0, 0, -1, 0);
sphereDetail(10);
sphere(25);
}
void mouseMotion()
{
if (mousePressed) {
cameraTheta += (mouseX - pmouseX)*0.05;
cameraPhi += (mouseY - pmouseY)*0.05;
}
recomputeOrientation(); //update camera (x,y,z) based on (radius,theta,phi)
}
void recomputeOrientation()
{
camx = cameraRadius * sin(cameraTheta)*sin(cameraPhi);
camz = cameraRadius * -cos(cameraTheta)*sin(cameraPhi);
camy = cameraRadius * -cos(cameraPhi);
redraw();
}
the x rotation works great however the y rotation sort of tumbles from the top to the bottom and then back up again over and over as the mouseY changes, what i need is for it to continue to tumble in one direction as long as the mouse moves up and back the other direction as the mouse moves down. can anyone help me figure this out?