#### Archived

This topic is now archived and is closed to further replies.

# how do you control the rotation point?

This topic is 5841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

how do you control what a rotation matrix rotates around? hopefully it is the origin of the model file it was created in, that would make my current task a HELLUVA lot easier. is this the case? or is something else?

##### Share on other sites
rotation axis rotates about an axis, not a point. see d3dxmatrixrotationaxis.

---
Come to #directxdev IRC channel on AfterNET

##### Share on other sites
quote:
Original post by niyaw
rotation axis rotates about an axis, not a point. see d3dxmatrixrotationaxis.

---
Come to #directxdev IRC channel on AfterNET

i know but if a cubes vertices are moved over in a modeling program, then the axis is through the origin, but the vertices all rotate around it.
overhead view:                 +       +   O<----axis      vertices                 +       +

if this was rotated, the vertices wouldn''t rotate aroudn themselves, rather the axis. so it would spin around it. i hope this is how its set up.

##### Share on other sites
you can use d3dxmatrixrotation[x|y|z] to rotate about those axes, does this help?

---
Come to #directxdev IRC channel on AfterNET

##### Share on other sites
quote:
Original post by niyaw
you can use d3dxmatrixrotation[x|y|z] to rotate about those axes, does this help?

---
Come to #directxdev IRC channel on AfterNET

i know, but lets say i''m rotating those four vertices around the y-axis. that means from above, they are spinning around that point. they aren''t rotated amongst themselves, they are rotated around the origin in which 3D program they were created in. (at least, i hope they are)

##### Share on other sites
You control it by translating your vertices to a new origin. Say that you have your vertices arranged like in your example, first translate the vertices to the right, rotate them and then translate them back to where they were. That way they will rotate amongst themselves.

I''m not quite sure what your question really was, but when you rotate a vertex in D3D you rotate it around (0,0,0), the origin, which, if you haven''t tampered with the vertices after loading them from file, is the same origin as in your modeller.

##### Share on other sites
In essence, what 'nyStagmus' suggested is the right answer.
I'll make it little clearer (or confusing, depends on the way you take it) ...

If you want to rotate the model around it's own origin/center (which is the origin set in the modeller), you should pre-multiply the rotation matrix with the transformation matrix of the model.

If you wish to rotate the model around the world origin/center (like you want the model to run around in a circle), post-multiply the rotation matrix with the transformation matrix.

If you wish to rotate the model around an arbitrary point in the world (like you want the model to circle a flag kept in some position in world), then translate the model to the arbitrary point first, then post-multiply the rotation matrix, then translate back the model by using negative of the translation value used in the first translation.

hope this helps...

-------------------------------------------------------

There is no problem so complicated that it cannot be complicated further.

[edited by - aanand_420 on July 25, 2002 2:27:46 AM]

##### Share on other sites
i think i get what your saying, let me ''propose'' this situation: my modeler has made a hummer model, without all the parts that can be broken or damaged. each part can be damaged 3 times, then its broken away. now these parts are separate meshes, yet need to fit perfectly into the the hummer''s body model when rotated. if i just rotated all the parts and body, would they still be aligned? i''m having the modeler put say the door in the EXACT same place in space as it was on the model, just not with it there. so if i just rotated and then translated this model, would all its pieces still be lined up with the model? i''m making sure that when he exports the .x files from 3D studio that the door or window was in the exact same place in space as it was in the hummer model. because they are all the same relative to the origin, would they move incorrectly or do i have to figure out the new x, y, z and then rotate them? (a HUGE pain)

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002308
×