Jump to content
  • Advertisement
Sign in to follow this  
Mastadex

n00b question about rotation.

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/advancedtopics/vertexpipe/matrixstack/matrixstack.asp

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 this
D3DXVECTOR3 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 space
D3DXMatrixTranslation(&mTranslate, x, y, z);

D3DXMatrixMultiply(&mTranslate, &mRotate, &mTranslate); // i.e. rotate, then translate



Good luck! :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!