gluLookAt Convert To glRotatef / glTranslatef
hey,
I have some code that uses gluLookAt, it is from a camera class, although, for my other code that i have done i am using glRotatef and glTranslatef, i know the variables for glTranslatef, if i say that the variables i input into gluLookAt are camEye, camUp, camDir:
gluLookAt(camEye.x, camEye.y, camEye.z, camUp.x, camUp.y, camUp.z, camDir.x, camDir.y, camDir.z);
how can i change this so i can use glRotatef and glTranslatef ??
Thanks.
I would try to calculate the roll, pitch anf heading and then use
glRotated(roll, 0.0, 0.0, 1.0);
glRotated(pitch, 0.0, 1.0, 0.0);
glRotated(heading, 1.0, 0.0, 0.0);
glTranslated(-camEye.x, -camEye.y, -camEye.z);
You can also look in Mesa how it is implemented.
glRotated(roll, 0.0, 0.0, 1.0);
glRotated(pitch, 0.0, 1.0, 0.0);
glRotated(heading, 1.0, 0.0, 0.0);
glTranslated(-camEye.x, -camEye.y, -camEye.z);
You can also look in Mesa how it is implemented.
I think the roll, pitch, yaw is a completely different method of doing it though - it may not fit all situations as easily.
You can actually figure out the matrix and use glLoadMatrix or a series of rotations and translations. A 3D Math book will help out there.
I tried this when I started because I Was under the impression glu was like glut and wasn''t available everywhere. Don''t do it. Use gluLookAt - the driver will do it so much faster than you will.
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
You can actually figure out the matrix and use glLoadMatrix or a series of rotations and translations. A 3D Math book will help out there.
I tried this when I started because I Was under the impression glu was like glut and wasn''t available everywhere. Don''t do it. Use gluLookAt - the driver will do it so much faster than you will.
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement