Free 3d rotation - ahhh the trig! help!
Im looking for a little help
The project im working on has 2 angles to keep track of my 3d rotation. The first is the XZ angle as i rotate around, the next is my vertical angle off of the XZ plane. Then i could simply find my normal unit offset vector in the direction the player is facing using:
xoff = cos(angley*DEG)*sin(anglex*DEG);
yoff = sin(angley*DEG);
zoff = -cos(angley*DEG)*cos(anglex*DEG);
DEG is just a constant radian to degree conversion PI/180
Then after tiring i realized that this wasn’t true 3d rotation. and i need to be able to roll (ack have to change the normal in gluLookAt(...) ).
then from that my sideways rotation would have to go in the direction normal to the plane the 2 vectors (the direction im looking, and the vector pointing strait up).
After spending hours drawing pictures I have only just confused my self. Does any one have any suggestions, or know of a tutorial or premade camera header and source file that does that?
Thanks for any help,
-The confused skow
Check the camera rotation of Apron''s camera tutorial, it does about the same thing for rotating...
http://home.no/apron/english/apron.htm
Marty
http://home.no/apron/english/apron.htm
Marty
_____ /____ /|| | || MtY | ||_____|/Marty
Thanks but thats not what i need, his cant even allow a full rotation along the Y axis. What i need is pretty complex, and involves changing the normal vector in the lookat(..)
Rotatation about the x axis:
x' = x
y' = (cos é * y) - (sin é * z)
z' = (sin é * y) + (cos é * z)
Rotation about the y axis:
x' = (cos é * x) + (sin é * z)
y' = y
z' = -(sin é * x) + (cos é * z)
Rotation about the z axis:
x' = (cos é * x) - (sin é * y)
y' = (sin é * x) + (cos é * y)
z' = z
Is that the answer?
[edited by - BGCJR on February 28, 2003 9:05:58 PM]
x' = x
y' = (cos é * y) - (sin é * z)
z' = (sin é * y) + (cos é * z)
Rotation about the y axis:
x' = (cos é * x) + (sin é * z)
y' = y
z' = -(sin é * x) + (cos é * z)
Rotation about the z axis:
x' = (cos é * x) - (sin é * y)
y' = (sin é * x) + (cos é * y)
z' = z
Is that the answer?
[edited by - BGCJR on February 28, 2003 9:05:58 PM]
Game Core
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement