3d camera

Started by
14 comments, last by StiNKy 22 years, 7 months ago
How can I do a 1st person view so the user can move forward in the exact direction they are looking at? without using freaking glu commands??? All the damn results for what I''m looking for is glu this, glu that. Some people don''t want to freaking use glu! Thanks in advanced.
Advertisement
Sorry, but...

gluLookAt() is the best way to do that. Why would you want to rewrite all of the code that is already written for you?
Cause I''m trying to write an engine using nothing but gl, ie no glu, no glut, nothing else but your standard gl. Working damn well so far.... Surely there IS a way.
glu is standard gl. It''s supported by the maintainers of OpenGL. it *is* gl. Why would you not want to use it??

With that said, some not-too-complex matrix math will give you your very own lookAt function. use gramm-schmidt orthonormalization to get three orthogonal unit vectors from your passed-in two(eye to target, and eye to up), make ''em into a matrix, and then use the eyepoint as a translation.
in quake, carmack doesn''t use gluLookAt(..) he uses MygluLookAt(..)
Well, this seems to be working for me so far:
glRotatef(rot.X, 0.1f, 0.0f, 0.0f);
glRotatef(rot.Y, 0.0f, 0.1f, 0.0f);
with rot.X being how much to rotate around the X axis, and rot.Y how much around the Y axis.
But if I''m storing the position at pos.X, pos.Y, and pos.Z how can I modify the pos.X, pos.Y, and pos.Z values so it moves forward in the world to exactly where the user is looking at? You can''t do that with gluLookAt()
easy find the direction the person is looking at
Dir = camera/person(first person) direction
cam = camera/person
gluLookAt( cam.x, cam.y, cam.z, cam.x+dir.x, cam.y+dir.y, cam.z+dir.z, 0,1,0 );

what?
I don''t like gluLookAt, glRotate, glTranslate, whatever. I compute my own camera matrix and load it via glLoadMatrix(), that''s it.
glRotatef(camera.yaw, 1, 0, 0);
glRotatef(camera.pitch, 0, 1, 0);
glRotatef(camera.roll, 0, 0, 1);
glTranslatef(-camera.x, -camera.y, -camera.z);

This topic is closed to new replies.

Advertisement