I tried this code:
D3DXMatrixRotationX(&matRotate, rx);
D3DXMatrixRotationY(&matRotate, ry);
D3DXMatrixRotationZ(&matRotate, rz);
d3ddev->SetTransform(D3DTS_WORLD, &matRotate);
But it seems to always only rotate the last rotation (Z axis).
How do i rotate an object with all the XYZ axes at the same time? Im trying to find DirectX equivalent for OpenGL rotation:
glRotatef(rx, 1, 0, 0);
glRotatef(ry, 0, 1, 0);
glRotatef(rz, 0, 0, 1);
EDIT: Looks like i figured it out by myself:
D3DXMATRIX matRotateX;
D3DXMATRIX matRotateY;
D3DXMATRIX matRotateZ;
D3DXMatrixRotationX(&matRotateX, rx);
D3DXMatrixRotationY(&matRotateY, ry);
D3DXMatrixRotationZ(&matRotateZ, rz);
D3DXMATRIX matRotate = matRotateX*matRotateY*matRotateZ;
d3ddev->SetTransform(D3DTS_WORLD, &matRotate);
IF not, please comment. I cant post it as an answer until 8 hours has passed! (need +7 reputation to do it).
D3DXMatrixRotationX doesn't rotate a matrix but creates a matrix that can be used to rotate something.
So it you could use the matrix right afterwards each step and rotate something else or you could use D3DXMatrixRotationYawPitchRoll so that you only need to create one once...
D3DXMatrixRotationYawPitchRoll(&matRotate, ry, rx, rz);
EDIT: Your edit works too...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With