Sign in to follow this  
v3n0w

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


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


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


Link to post
Share on other sites
v3n0w    122
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
thallish    202
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
v3n0w    122
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
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??

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this