hello! this is my camera class, i`ve a problem when rotating at rx axes, it seems that clipping problem at 180 degrees in that axes. i want to be free to rotating full 360ª . what im doing wrong?
class Player {
PVector position;
PVector center;
PVector up;
PVector right;
PVector forward;
float pan;
float tilt;
PVector velocity;
float angle;
PVector vel2D;
Player() {
center = new PVector(0, 0, 1000);
position = new PVector(0, 0, 0);
up = new PVector(0f, 1f, 0f);
right = new PVector(0f, 0f, 0f);
forward = new PVector(0f, 0f, 1f);
velocity = new PVector(0f, 0f, 0f);
pan = HALF_PI;
tilt = 0;
}
void update(PGraphics a) {
float xx = (Float)spaceNavigator.get("x");
float yy = (Float)spaceNavigator.get("y");
float zz = (Float)spaceNavigator.get("z");
float rx = (Float)spaceNavigator.get("rx");
float ry = (Float)spaceNavigator.get("ry");
float rz = (Float)spaceNavigator.get("rz");
float b0 = (Float)spaceNavigator.get("b0");
float b1 = (Float)spaceNavigator.get("b1");
pan -= ry*0.5;
tilt -= -rx*0.5;
forward = new PVector(cos(pan), tan(tilt), sin(pan));
right = new PVector(cos(pan - PI/2), 0, sin(pan - PI/2));
forward.normalize();
velocity.add(PVector.mult(forward, (-zz*50.0)));
velocity.add(PVector.mult(right, (-xx*50.0)));
velocity.add(PVector.mult(up, (yy*50.0)));
position.add(velocity);
velocity.limit(0.5);
center = PVector.add(position, forward);
float fov = PI/2;
float cameraZ = (height/2) / tan(fov); // when i multiple this fov * 4, 8, the camera clips in different degrees up 180. maybe here is the problem
a.perspective(fov, float(width)/float(height), 0.1, cameraZ*20);
a.camera(position.x, position.y, position.z, center.x, center.y, center.z, up.x, up.y, up.z);
velocity.mult(0);
}
}
thanks!