Skip to main content
gamedev.net
🔒 Locked

Transformations

Started by PoTTy1234uk 2 replies 350+ views
Original Post
PoTTy1234uk
PoTTy1234uk
Hello all, Im writing a small car demo and im having trouble getting the wheels to rotate correctly. I am able to rotate the wheels so they turn round as the car moves. I am able to turn the wheels left and right The problem is that when i do them together, the rotations are applied at the same time and the wheels wobble all over the place! what i want is to apply the roll then apply the yaw so the wheel spins as it is turned left or right. any help would be great below is the code im using wYaw+=0.005; wRoll+= 0.005; D3DXMatrixRotationX(&wRotX, wPitch); D3DXMatrixRotationY(&wRotY, wYaw); D3DXMatrixRotationZ(&wRotZ, wRoll); D3DXMatrixMultiply(&wRotTemp, &wRotZ, &wRotTemp); D3DXMatrixMultiply(&wRotTemp, &wRotX, &wRotY); D3DXMatrixMultiply(&wTrans, &wRotTemp, &wTrans);
Pothead
Pothead
(If you dont understand matrices..)
try swapping the order they are multiplied.
--------------------------------------------------------I'm not crazy, It's the TV that's crazy. Aren't you, TV?--------------------------------------------------------
PoTTy1234uk
PoTTy1234uk
Opps yeah the order should be

D3DXMatrixMultiply(&wRotTemp, &wRotZ, &wRotX);
D3DXMatrixMultiply(&wRotTemp, &wRotY, &wRotTemp);
D3DXMatrixMultiply(&wTrans, &wRotTemp, &wTrans);

but all the rotations are build into the same matrix
so all rotations are applied at once

instead of rotating the wheel around a bit
then turning it left or right.

Topic Locked

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

Sign in to reply to this topic.