gluLookAt Convert To glRotatef / glTranslatef

Started by
2 comments, last by PsyVision 22 years, 8 months ago
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.
PsYvIsIoN
Advertisement
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.



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
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
cheers for da help, i will have a play i think i can get it to work (i think i can work out the roll and stuff from what i have).
PsYvIsIoN

This topic is closed to new replies.

Advertisement