Skip to main content
gamedev.net
🔒 Locked

Chaining matrices correctly

Started by sipickles 3 replies 550+ views
Original Post
sipickles
sipickles
Hello! I have a mars rover. The body is one mesh, and the 6 wheels are another. The body moves correctly, with translation and rotation matrices, but when I try and add the wheels things go a bit weird. Each wheel has coords which define the displacement from the centre of the rover. That works fine : D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &wheelPos ); D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &roverWorld ); When I try to get the wheels to turn as the rover moves, they do all sorts of weirdness, wobbling around and turning sideways etc! I use : D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &wheelRot ); D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &wheelPos ); D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &roverWorld ); I've tried: D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &wheelRot ); D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &wheelPos ); D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &roverRot ); D3DXMatrixMultiply( &wheelWorld, &wheelWorld, &roverPos ); But this is still bad! Any suggestions thanks!!! Simon
JohnBolton
JohnBolton
Is wheelWorld is reset back to the identity matrix before each wheel's world matrix is computed? Is wheelRot being computed correctly?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
sipickles
sipickles
I will have to check this late, john, but is my theory correct?

I know the order of the matrix multiplications is important. Am I right doing the Rotations first?

Many thanks

Simon
JohnBolton
JohnBolton
Your math looks correct. If the order of the rotation and translation matrices were backwards, then the wheel would rotate around center of the rover rather than the center of the wheel.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
sipickles
sipickles
Yeh, found out what was wrong.

I was keeping track of the rotation of the rover, and applying that to the wheel as well, so the wheel was rotated twice.

It all alot simpler than I imagined.

Thanks for your patience, john!

Si

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.