Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotation

Started by ManaStone Jan 7, 2002 at 10:53 PM 5 replies 300+ views
Original Post
ManaStone
ManaStone
I''m trying to get a mesh to rotate around it''s own y Axis, but D3DMatrixRoationY() makes it rotate around the world axis. How would I do it just around it''s own axis?
-----------------------------Download my real time 3D RPG.
OutAxDx
OutAxDx
Use a simple 2d rotation method, around the y-axis. I forget how, but it just uses pi, and COS and SIN, its actually pretty simple to do.
CrazedGenius
CrazedGenius
Do you mean that it''s sitting on the center of the world and rotating around the center or that it''s "orbitting" around the center? If you mean the latter, the order of your matrix multiplications is wrong.

In any case, you can add translations and rotate around any point you want, but the multiplication order matters.

There shouldn''t be any reason to break out the ol'' trig book...
ManaStone
ManaStone
It rotates around the world''s y axis. When I move it way from the y axis the diameter of the rotation circle increases.

i''m using the keyboard controls to move and rotate the object.
-----------------------------Download my real time 3D RPG.
bahos
bahos
Make sure you apply your rotation matrix before applying your translation matrix. That way the object will rotate about its own axis. Also, don''t forget to start with an identity matrix. I would do it like this:

(IdentityMatrix * RotationMatrix) * TranslationMatrix

I think that would work. If you think about the ordering as CrazedGenius said you should be able to achieve any sort of transformation.
ManaStone
ManaStone
Thanks, I changed the order and it seemed to work.

But I don''t understand why you use the identity matrix. If you multiplying a matrix with it and it doesn’t change the matrix then why do it?
-----------------------------Download my real time 3D RPG.
bahos
bahos
I''m not totally clued up on my matrix maths but I read somewhere in the Direct X documents that if you don''t apply an identity matrix your transformations can do strange things. You could try it without the identity matrix and see what happens.

Topic Locked

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

Sign in to reply to this topic.