Reputation: 11012
I located my camera within 3D cube -
public void display(GLAutoDrawable drawable) {
...
glu.gluLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
...
}
It's look like that - (each color - side-lock ) -
Now I trying to rotate and camera looking (the three centerX, centerY, centerZ
) around axis X - according to this rotation formula -
It works well until it reach to the state which the Z's value become to negative - and after that the camera's looking start to rotate to the other side of X's axis .
I show you the (centerX,centerY,centerZ)
values in the range of this bug -
1.0 -1.2817129 0.59767246 //ok
1.0 -1.3289262 0.4836895 // ok
1.0 -1.3660256 0.36602536 //ok
1.0 -1.3927287 0.24557555 // ok
1.0 -1.4088323 0.12325676 //ok
1.0 -1.4142138 -9.784749E-8 // ok for last time
1.0 -1.4088323 -0.12325695 // rotate to other side of X
1.0 -1.3927287 -0.24557574 // so on ...
How you recommends for me to fix that and make it rotate on all over 360 degrees ?
Edit:
Does (upX,upY,upZ)
should by rotate in this case too ?
Upvotes: 1
Views: 662
Reputation: 185852
You need to rotate the direction vector about the X-axis, which is center - eye
, not center
. The overall computation should be center = eye + Rot(center - eye)
.
Upvotes: 1