D3DXMatrixRotationX really need help

Started by
7 comments, last by v3n0w 17 years, 4 months ago
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
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.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
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
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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?
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].

regards/thallishI don't care if I'm known, I'd rather people know me
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... :(((
each time you render the object, rotate, then move, then use that matrix as your world matrix when you render.
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??

This topic is closed to new replies.

Advertisement