#### Archived

This topic is now archived and is closed to further replies.

# 3D Movement Theory

This topic is 5592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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.

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×