Advertisement

need help with movement

Started by August 03, 2001 06:16 PM
5 comments, last by Nibbles 23 years, 6 months ago
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."
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
Advertisement
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."
Yeah, you probably want to use quaternions for rotations to fend off that evil gimbal lock.
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."
I use directx 8''s vector and quanterion math stuff...
-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
Advertisement
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."

This topic is closed to new replies.

Advertisement