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

## Recommended Posts

I have a bunch of models, cubes, that are one infront of the other and what I wan to do is rotate then around the point of the first cube so that they all stay in line while they are rotating. How would I go about doing this??

##### Share on other sites
it depends on their current orientation, i forgot if d3d rotation is ordered differently than openGL rotation, but it should just be, rotate, then translate of course, this would have to be different for each one, rotate (same), translate (different)

hope that helps
-Dan

##### Share on other sites
hmm isnt there a function that woupld probably do this for me? i mean its Microsoft, they got functions for everything!

well i know that i would have to translate and then rotate and translate agian.

What im trying to do is basically draw an arm, almost, using cubes. so if i move the WHOLE arm, the hand portion is gonna move relitive to the angle of the bicep.

##### Share on other sites
Indeed there are several API functions available to help with what you're doing!

If you're after moving things relative to other things, matrix stacks and frame hierarchies are what you need. Take a look at this link:

A simpler way of doing things would be to rotate each cube around the same point. To do this you need to do what Ademan said - something like this (off the top of my head), on each cube:

float angle; // assign the rotation angle to thisD3DXVECTOR3 axis; // assign the axis of rotation to this (e.g. the 'hinge' of a joint in the arm)D3DXMATRIX mRotate;D3DXMatrixRotationAxis(&mRotate, &axis, angle);D3DXMATRIX mTranslate;float x, y, z; // the position of the cube in world spaceD3DXMatrixTranslation(&mTranslate, x, y, z);D3DXMatrixMultiply(&mTranslate, &mRotate, &mTranslate); // i.e. rotate, then translate

Good luck! :)

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633672
• Total Posts
3013272
×