marce

07-23-2009, 04: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?

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

marce

07-23-2009, 04: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?

scratt

07-23-2009, 09: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.. :)

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.. :)

def

07-24-2009, 06: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.

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

marce

08-04-2009, 05: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?

awhig

08-05-2009, 03: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.

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

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

marce

08-05-2009, 09: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*()?

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*()?

awhig

08-05-2009, 10: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.

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.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.