URL87
URL87

Reputation: 11012

Rotate the camera look (3 center's arg) around axis X in gluLookAt

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 ) -

enter image description here

Now I trying to rotate and camera looking (the three centerX, centerY, centerZ ) around axis X - according to this rotation formula -

enter image description here

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

Answers (1)

Marcelo Cantos
Marcelo Cantos

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

Related Questions