Transformations
I'm having some incredible trouble building transformation matrices to simulate a camera. This is for OpenGL specifically, but since I'm doing it by hand it doesn't matter.
Here's what's going on, I store the camera's position vector and orientation vectors, left/up/forward.
Every frame I do as follows, check for button presses, for left/right I yaw by some small increment, for up/down I pitch. Currently I pitch by the camera's left vector (creating a rotation matrix out of the left vector and applying it to the 3x3 matrix [L|U|F], and yaw by the up vector similarly. Then I build a view matrix out of the inverse orientation/position vectors and load it as the current modelview matrix. I don't load the identity matrix at all, since it makes no sense to load it then replace it.
The problem is that yaw + pitch isn't properly represented. For example if I yaw by 90, then pitch, i get a roll. I've calculated all this out by hand and it seems that the view matrix I load as the current modelview matrix isn't composed of the proper rotations.
Here is an example.
Pos = 0,0,0; L = 1,0,0; U = 0,1,0; F = 0,0,1;
R = [L|U|T]
T = -Rt*P
The resulting 4x4 view matrix is:
Rt|P
0001
Now, if I rotate R through L and build a new view matrix and load that all my geometry after that is rotated in the opposite direction, which is good. Now, if I take the newly rotated R and rotate through U and build a view matrix out of that the new view matrix doesn't represent represent a yaw, then a pitch, like I said, I get a yaw then a roll.
Can anyone point out my error to me? I'm really having a hard time here...
------------
- outRider -
Edited by - outRider on February 10, 2002 12:04:22 AM
I''m not quite sure but do OpenGL rowmajor matrices. You said you do i all by hand but do you glLoadMatrix that matrix?
Yes I load it every frame. I know OpenGL orients matrices differently, column major, but I declare my 4x4 matrices as float[16], so it shouldn''t matter.
------------
- outRider -
------------
- outRider -
"but I declare my 4x4 matrices as float[16], so it shouldn''t matter."
I matters still.
I matters still.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement