Jump to content
  • Advertisement
Sign in to follow this  
v3n0w

D3DXMatrixRotationX really need help

This topic is 4250 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

Im doing a tutorial of D3D, but the things are going really hard with this part of moving and rotating.. D3DXMatrixRotationX rotate the world, ok, but from where? Whats hes reference for rotate? In my progam im seeing, thats the reference is 0,0,0, its true? How i change it? How i put the rotate center in the center of my object? Im going realy crazy with this directx... brazilian greetings

Share this post


Link to post
Share on other sites
Advertisement
The origin (the point around which you rotate) is set by translating.

So, whatever the translate function is for D3D, I think 'D3DXMatrixTranslate', or something like that.

Share this post


Link to post
Share on other sites
u can use rotate around an axis RotationAxis() , or if u want to place the rotaion in the middle of ur object u need to transform the coordinates of ur project to the center of the world in the 3D software u r using , so in other words draw ur object in the position 0,0,0 and then export it to directX.

Hope this helps

Share this post


Link to post
Share on other sites
There's nothing special to Direct3D with this - it's a standard property of matrix maths. Might well be an idea to have a run through a text-book or some online material on the subject.

To rotate around an arbitrary point, P, you need to translate by -P, rotate and then translate by +P.

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jad_salloum
u can use rotate around an axis RotationAxis() , or if u want to place the rotaion in the middle of ur object u need to transform the coordinates of ur project to the center of the world in the 3D software u r using , so in other words draw ur object in the position 0,0,0 and then export it to directX.

Hope this helps


Hmmm, so if i want to rotate a quad i draw:

vertexsimples quad[4] =
{
// X Y Z
{ -1.0f, 1.0f, 0.0f, }
{ -1.0f, -1.0f, 0.0f, }
{ 1.0f, -1.0f, 0.0f, }
{ 1.0f, 1.0f, 0.0f, }

};

Than i translate for where i want and the rotate.... right?

And... D3DXMatrixTranslation, translate the world, from the 0,0,0, point too right?

So its an absolut valor?

if i: D3DXMatrixTranslation(&matWorld, 0.0f,0.0,20.0f);

and then: D3DXMatrixTranslation(&matWorld, 0.0f,0.0,0.0f);

the object backs for its initial position?

Share this post


Link to post
Share on other sites
Quote:
Original post by v3n0w
Quote:
Original post by jad_salloum
u can use rotate around an axis RotationAxis() , or if u want to place the rotaion in the middle of ur object u need to transform the coordinates of ur project to the center of the world in the 3D software u r using , so in other words draw ur object in the position 0,0,0 and then export it to directX.

Hope this helps


Hmmm, so if i want to rotate a quad i draw:

vertexsimples quad[4] =
{
// X Y Z
{ -1.0f, 1.0f, 0.0f, }
{ -1.0f, -1.0f, 0.0f, }
{ 1.0f, -1.0f, 0.0f, }
{ 1.0f, 1.0f, 0.0f, }

};

Than i translate for where i want and the rotate.... right?

And... D3DXMatrixTranslation, translate the world, from the 0,0,0, point too right?

So its an absolut valor?

if i: D3DXMatrixTranslation(&matWorld, 0.0f,0.0,20.0f);

and then: D3DXMatrixTranslation(&matWorld, 0.0f,0.0,0.0f);

the object backs for its initial position?


TO translate back you would have to use the inverse translation so if you translate by [0.0f,0.0f,20.0f] the inverse would be [0.0f,0.0f,-20.0f].

Share this post


Link to post
Share on other sites
Quote:
Original post by thallish
Quote:
Original post by v3n0w
Quote:
Original post by jad_salloum
u can use rotate around an axis RotationAxis() , or if u want to place the rotaion in the middle of ur object u need to transform the coordinates of ur project to the center of the world in the 3D software u r using , so in other words draw ur object in the position 0,0,0 and then export it to directX.

Hope this helps


Hmmm, so if i want to rotate a quad i draw:

vertexsimples quad[4] =
{
// X Y Z
{ -1.0f, 1.0f, 0.0f, }
{ -1.0f, -1.0f, 0.0f, }
{ 1.0f, -1.0f, 0.0f, }
{ 1.0f, 1.0f, 0.0f, }

};

Than i translate for where i want and the rotate.... right?

And... D3DXMatrixTranslation, translate the world, from the 0,0,0, point too right?

So its an absolut valor?

if i: D3DXMatrixTranslation(&matWorld, 0.0f,0.0,20.0f);

and then: D3DXMatrixTranslation(&matWorld, 0.0f,0.0,0.0f);

the object backs for its initial position?


TO translate back you would have to use the inverse translation so if you translate by [0.0f,0.0f,20.0f] the inverse would be [0.0f,0.0f,-20.0f].


Here noooo... :(((

Share this post


Link to post
Share on other sites
each time you render the object, rotate, then move, then use that matrix as your world matrix when you render.

Share this post


Link to post
Share on other sites
Well rotation é now ok, but i have another big problem...

All strings i send to functions, i have to send with TEXT("string"), macro...

Why? And now i have to send a char name[10];

But i cant just TEXT(name), i get error with this... I try (const wchar_t*)name.

But the strings apears with error... So, what i can do??

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!