Advertisement

3D Movement Theory

Started by August 16, 2003 06:49 PM
3 comments, last by kogase 21 years, 6 months ago
Is there any site that can properly explain the theory of moving in 3D space (calculating the amount to move in the X/Z axis based on heading) in the context of 3D games made with OpenGL/D3D? I know that a method is displayed in NeHe''s lesson 10, Loading and Moving through a 3D world, and I know I could just memorize that method and use it, but I''d rather be able to properly understand it. Any help (pertinent help anyway) much appreciated.
ummmm, kogase dude
This might help.
http://www.lighthouse3d.com/opengl/glut/index.php3?6

Basically, you get the current rotation of your camera/object/whatever you want to move, and then sin the rotation value to get the offset for x and cos for z.

EG.
Rotation = 0
sin(Rotation) = 0 means 0 x offset
cos(Rotation) = 1 means 1 z offset

so if you were to move with 0 rotation, you would move 1 unit in the z plane.

Advertisement
Actually using what you just said, Gamer, the camera would only be able to move on a flat plane. Three dimensions is much more complicated but here is the theory and then i''ll give you the matrix you use to solve for x, y and z:

the Camera lies on the 3d point x1, y1, z1. To know what angle it faces, most programs use a normalized vector pointing in the direction of whatever it is facing. Essentially, a point that is exactly one unit away is manipulated to change the center of the viewing area of the camera. To change this point so it works right though is a little cantankerous.

(I hope this shows up right) Here is the matrix used to rotate a point along a sphere of radius 1 (Which would be the set of all points that reference point holding where the camera is viewing currently could possibly be) at http://www.makegames.com/3drotation/ There isn''t really a good way to learn it. I''ve taken a lot of math over the years and I haven''t learned it yet, but it all boils down to solving those matrices. Look under the heading Other Ways to Build a Rotation Matrix

My fellow Americans I have just signed legislation that outlaws Russia forever. Bombing will commence in five minutes.
Thank you both for your replies, it''s hard to get good advice on theory, when most people are more interested in just getting a snippet of code they can paste into "their" program.
ummmm, kogase dude
Hey uber_noob, I didn''t see that matrix you tried to show. Could you point me to where I might find it? I''ve worked out a way to find the angles to rotate so a vector is the same as another, then move along that vector. I know the math is right, but I have some problems, so I was going to use quaternions, but ... if this works, hopefully, I''ll use it. If you know a better way to find the angles to rotate to match a tire to an uneven terrain and move it in that direction, please tell me.

"Donkey, if it were me, you''d be dead."
I cna ytpe 300 wrods pre mniute.
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.

This topic is closed to new replies.

Advertisement