# Camera clip problem

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.limit(0.5);

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!

1 Like

hi @vjjv, if you don’t mind, can you post your setup() and draw() functions? What have you tried so far to fix the issue?

thanks for reply. i dont think is any system problem. (setup and draw dont do so much, i dont post becouse is a very big and segment program, theres no information there) but basically this camera is render in a Pgraphics scene. i think that is a perspective problem, but i dont really know which

Without a very simple test sketch to see you using the class it is hard to know exactly what your problem is. It might be gimbal lock? If so, a good solution is to use PeasyCam.

Or, depending on how you are using the camera, a another full interactive camera library implementation (dollying, not centered) is QueasyCam.

1 Like