I have a quad that I want to (1) rotate a quad around the Y axis and (2) rotate it around the quad's X axis. The problem is that it does the rotations one after the other, so it rotates it around the Y axis and then it rotates it around the world's X axis, not the quad's X axis.
Basically what I want to do is rotate the quad (randomly) around it's X and Y axis, and at the end I still want 2 of it's bottom vertices to have Y = 0.
This is the code I'm using right now:
_game._device.Transform.World = Matrix.RotationYawPitchRoll(_rotationValues(i).X, _rotationValues(i).Y, 0) * Matrix.Translation(_translationValues(i))
_game._device.DrawPrimitives(PrimitiveType.TriangleList, 0, 4)
_game._device.Transform.World = Matrix.Identity
I fixed it! Instead of the Matrix.RotationYawPitchRoll()
method I used Matrix.RotationX
and Matrix.RotationY
. Here is the code:
_game._device.Transform.World = Matrix.RotationX(_rotationValues(i).X) * Matrix.RotationY(_rotationValues(i).Y) * Matrix.Translation(_translationValues(i) + location)
_game._device.DrawPrimitives(PrimitiveType.TriangleList, 0, 4)
_game._device.Transform.World = Matrix.Identity