Archived

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

Nibbles

need help with movement

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
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
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