Jump to content
  • Advertisement

Archived

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

Nibbles

need help with movement

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

Hi, I can move an object easily enough along the z axis using:
  
  x -= (float)sin(-roty*(3.14f/180.0f)) * speed;
  z -= (float)cos(-roty*(3.14f/180.0f)) * speed;
  
but how would i go about moving on all three axis''? Based not just on heading, but on tilt too. Thanks, Scott Email Website
"If you try and don''t succeed, destroy all evidence that you tried."

Share this post


Link to post
Share on other sites
Advertisement
Linear algebra dude. Use matrices and vectors. When you say heading, i think you mean translation. And when you say tilt, i think you mean rotation.
    
Object::UpdatePosition(Vector dTranslation, float dxrot, float dyrot, float dzrot)
{
Matrix m;
m.LoadIdentity();

m = Matrix::GetXRotation(xrot);
m *= Matrix::GetYRotation(yrot);
m *= Matrix::GetZRotation(zrot);
m += dTranslation;

m_vPosition = m * m_vPreviousPosition;
m_vPreviousPosition = m_vPosition; // setup for next frame

}


The implementation of a Matrix and Vector class has been left as an exercise for the reader.

(Don't you hate it when textbooks say that)

Edited by - Parveen Kaler on August 3, 2001 8:44:19 PM

Share this post


Link to post
Share on other sites
hehe, i just got through the quaternion rotations + matrices... was hoping i didn''t have to go back

thanks,
Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

Share this post


Link to post
Share on other sites
anybody know of a good quaternion/matrix class(s) that will handle rotations and 3D movement?

purely C would be better, but i think i could manage either. Because classes i''m using right now are a cross of a bunch of different code, and they are just messing me up.

thanks,
Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

Share this post


Link to post
Share on other sites
i''m an OpenGL guy myself, would they still be usable?
and do they come with the SDK?

Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

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!