View Full Version : Rotating camera in 4pi.

01-25-2009, 04:12 AM
After trying to keep track of angles to achieve a full rotation (alternativly around x or y or z axe) I fall in a lock loosing total control.

To figure out what is the goal, think to move the camera (actor point of view) using a 3 axis joystick.
Pushing/pulling forward/backward make rotation on the actor X axe.
Pushing left and right make rotation on the actor Z axe.
Rotating clockwise and counterclockwise make rotation on the actor y axe.

So that, using glulookat becomes quickly a mess :sorrow: .

The point is that:
ALL rotations are around the actor coordinate system [local system, isn't it ?] (like in a plane), so I have to make further and further rotations.

It there must be a solution. But it is far out of my ... screen
ANy help is wellcome.
Send private messages in case .... OK ???


01-25-2009, 06:15 AM

Im not absolutly sure what you are mean, but it can be that you are fall in the gimbal lock. It means that there is a case in the three dimensional room where you lost an axis. In this case you cannot different between all three axis.


If that is your case you should use quaternions, but it is noch so easy to understand it.

I hope that can help you.


01-25-2009, 06:29 AM
I have seen ... my way, and most strightforward, is the quaternions.
But this way don't pay the lot of work.
I have read that there is a way using matrices...

Do someone know more about it ???


01-25-2009, 07:05 AM
Have a look at this:


I suggest you learn about matrices. They are hard to grasp at first, but once you understand the basics, you will love them. Quaternions are cool too, both have their uses. Use matrices for camera orientations though, they have lots of useful secondary uses, such as extracting the 'up-vector' and viewing direction with no added computation.

Hint: a 3x3 rotation matrix is really no more than 3 vectors: 1 pointing up, one pointing sideways, and one pointing in the forward/backward direction.
(For some reason nearly all rotation matrix tutorials fail to mention that and suggest to think of a matrix as a 'black box' -- bad teaching!)