Jump to content
  • Advertisement
Sign in to follow this  
TAlchemist

3d movement - not pathfinding

This topic is 4996 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

to make things simpler let's consider your terrain is flat (so you don't really care about elevation).

You have two vectors:
- your character's direction (DIR)
- your target direction (R = TargetPoint - CurrentPos)

Assumming you normalize them.

angle ang = DIR dot R
axis A = R cross DIR (should be y axis or -y axis)

Now in order to turn your character you must rotate it around axis A with angle ang

For a real 3D case you need to adjust DIR and R (zero the y component) before normalizig them, and of course compute another rotation angle around your character's x axis.

Share this post


Link to post
Share on other sites
Advertisement
how would i use that since i dont use any angles for defining the movement or orientation of the character. He is controlled by a forward vector and up vector. He moves along his own axis's and such.

how can i use that with vectored directional axis's?

Share this post


Link to post
Share on other sites

Quote:
He is controlled by a forward vector and up vector


:) your forward vector is your character direction I was talking about (DIR)

Now after you find the angle ang, use a time of rotation (the time T you want your unit to complete it's rotation) make a rotation matrix around your up vector with the angle: and/T.

Now apply that matrix to your forward vector (and lateral vector if you have one) for T seconds and your unit should be rotated.

Share this post


Link to post
Share on other sites
i am still rewriting my code for object motion and i think what you said works but i dont have all the code for converting the 3 axis into a rotation matrix for setting the world matrix yet...the object seems to have a better movement now.

Share this post


Link to post
Share on other sites
To convert your axes in a matrix just place x axis on the first row, y axis on the second and z axis onm third, also you should place the position on the forth row.
The forth should be 0.0 except the 4x4 element wich should be 1.0, but there are some cases where this is not true (scale for ex.).
This works for DirectX but I'm not sure if you need to transpose the matrix on openGL.

Share this post


Link to post
Share on other sites
ok i got the axis's turned into the rotation and translation matrix and the object turns great now...now i need to tweak it alittle and i will have good following code so i can implement path following.

thank you all. i am working on smoothing the turn and standing still till i get the right forward vector.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!