Jump to content
  • Advertisement

Archived

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

AdmiralBinary

3D Directional Movement

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, I have a working 3d "engine" and a model of a horrible monster in it. I can display the monster. I can rotate the monster. I can light the monster. Now, my question is: How do i get the dang thing to move? I know basically how to change x,y,z co-ordinates etc. but what i don''t know is how to move an object IN THE DIRECTION IT''S FACING. This is what I know about the object: - Its x,y,z co-ords - Its x,y,z axis rotation - Its colour (sorry, three points lookz better ) "Playse Halp...Plaes Help" - Leeloo from the 5th Element --------------- I finally got it all together... ...and then forgot where I put it.

Share this post


Link to post
Share on other sites
Advertisement
pos.x += ZAxisRotation.x * MoveDist;
pos.y += ZAxisRotation.y * MoveDist;
pos.z += ZAxisRotation.z * MoveDist;

Assuming MoveDist is a none zero float, and ZAxisRotation is the direction vector from your orientation matrix.
( look in the dx SDK for the matrix definition of the axis etc).

[The views stated herein do not necessarily represent the view of the company Eurocom ]

Eurocom Entertainment Software
www.Eurocom.co.uk

The Jackal

Edited by - Mark Duffill on November 20, 2001 7:33:24 AM

Share this post


Link to post
Share on other sites
Well I suggest using a directx matrix. This will hold the position, rotation, scale, and velocity. just look in the sdk for all the functions that you can do. Order of operations is important.

usually you translate the position, then rotate the matrix, then scale (if you scaled first all the translating and rotating would be scaled also).

so now when you want to move the creature forward you just transalate the matrix by a forward like 0,0,1 this of course will move the creature forward on the creature''s current z-axis due to rotation. (note 0,0,1 here is relative to the creature and not abosulte to the world)

this saved me from having to constantly worry about how to handle rotations.

hope this helps
Pactuul

Share this post


Link to post
Share on other sites
Thanx evry1! I''ll try that... I didn''t know I should be storing the matrix lol.

---------------

I finally got it all together...
...and then forgot where I put it.

Share this post


Link to post
Share on other sites
Er...Sorry about this - I tried sum stuff but I''m still confused: How exactly do I get the "direction vector" from the "orientation matrix"???

---------------

I finally got it all together...
...and then forgot where I put it.

Share this post


Link to post
Share on other sites
OK here is the trick

I am assuming you have 4x4 matrix for the monster. The first 3 components of the first column (or row depending on whether your matrix is left or right handed) are the x,y,z components of a vector pointing up from your object. similarly the second column is a vector pointing to the right of the object and the third column is a vector pointing forward from the object.

if you have a matrix class, just make a method called GetIn(), which creates a vector from the third column. Then scale the vector by the amount you need and finally translate the matrix by that vector.

Hope that helps

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!