View Full Version : Most common way to move around in a 3D world?

07-23-2009, 03:42 PM
I am into doing my first 3D world and I wonder what is the most common way to move around in it. Is it by rotating the environment by calling glRotate*() or is it by changing the gluLookAt() or a combination of them both?

07-23-2009, 08:26 PM
I'd recommend you perhaps look at some tutorials like NeHe's, and build a camera class of some sort.

If you fancy delving a little deeper I'd recommend learning about Quaternions right now and basing your rotations on those.. It will require some head-scratching now, but will save a lot of head-scratching later down the line.. :)

07-24-2009, 05:58 AM
gluLookAt is just an utility function and is equivalent to glMultMatrixf(), glTranslate() etc.

In OpenGL the "camera" (so-called) is always fixed in the origin and the scene has to be moved accordingly.

08-04-2009, 04:54 PM
Oh ok, so it dosnīt matter if I use gluLookAt() or glTranslate() to move around? No one is better than the other? Or is it in some cases?

08-05-2009, 02:08 AM
In some cases moving camera is better. The quaternions help in this case as it provides you free rotation.

Ex1: 3D First Person Shooter games prefer camera motion.

Ex2: A large scene where activities are going recommend object motion.

08-05-2009, 08:23 AM
Ex1: 3D First Person Shooter games prefer camera motion.
So in this case the quaternions are to prefer. I have read on quaternions on Wikipedia and just want to check if I have unsterstood it - in this case a quaternion is the "free space" where objects are in?

Ex2: A large scene where activities are going recommend object motion.
Here the camera is fixed and the objects are moving through a call to glTranslate*()?

08-05-2009, 09:37 AM
Q1. Yes. Quaternion is useful for providing free space rotation because it is a hypercomplex number and is in a way 4D vector. You can use glRotatef() but for complex rotations, the rotation matrix computation is expensive.

Ex: If you rotate around X ,then Y then Z , the total rotation matrix will be R = RzRyRx. In case of quaternion you have one vector only and changing components mean changing direction.It is compact. Wolf3D imo uses glRotatef where as Quake series use quaternions. So you can judge yourself.

Best way to understand quaternion is to take a sphere and then reach at any point using quaternion and using rotation matrix. The latter is sometimes hard to compute and get precise directions.The precise directions can be achieved through quaternion using slerp where as it is harder to achieve (sometimes) with matrix multiplication.

A2. Yes. Objects can rotate too.

A quaternion is generally associated with camera.