D3DXMatrixRotationX really need help

Recommended Posts

v3n0w    122
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 on other sites
Endar    668
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 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 on other sites
jollyjeffers    1570
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 on other sites
v3n0w    122
Quote:
 Original post by jad_salloumu 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:

{
// 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 on other sites
thallish    202
Quote:
Original post by v3n0w
Quote:
 Original post by jad_salloumu 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:

{
// 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 on other sites
v3n0w    122
Quote:
Original post by thallish
Quote:
Original post by v3n0w
Quote:
 Original post by jad_salloumu 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:

{
// 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 on other sites
ItsDoh    162
each time you render the object, rotate, then move, then use that matrix as your world matrix when you render.

Share on other sites
v3n0w    122
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??