Sign in to follow this  

a problem with rotation for my game , DX

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

ok i am still learning DX but i am making a game based on the CreateTeapot meshs i have rendered 2 meshs to screen and set mesh teapot -10 z on that axis what i do next is use Vec3Add to find the distance from teapot1 to teapot2 now i have the distance which is -10.0f , but what i am want todo is give the teapot some AI so it will rotate to the teapots 1 postion but if i put SetTransform Trans * Rot , the mesh decides to rot in a big circle and i just want it to rotate to the postion the other teapot is facing , ive tried many things with SetTransform and if i try with just rot then i cant postion it at -10.0f , ive heard if you call transform on the same matrix it overwrites it , so i how do i place the teampot -10.0f on z axis as well as rotate depending on what the ADD.z returns, i can do a diagram if you need one

Share this post


Link to post
Share on other sites
Rotate the teapot first, and then translate.

In matrix multiplication, order matters. If you translated first, and then rotated, the teapot will move in a big circle because you're always rotating around the origin after translating it.

But, if you rotate first and then translate, then the teapot will change it's facing first and then move into the new location.

If you keep in mind you're doing everything with respect to the origin, and order matters, you'll be fine. It takes a while to "get it" though, and it's tricky to visualize the first time around.

Share this post


Link to post
Share on other sites
hey thanks alot , so i understand is

d3ddev->SetTransform(D3DTS_WORLD , &(rot *TeapotMatrix2));

what ever order that is in it has to be in the same order in code

rotation then translation

now what i need todo is work out the current angle the teapot is at and rotate to face the other teapot ,

D3DXVECTOR3 vec3Add;
D3DXVec3Add(&vec3Add,&Teapot1Controls , &Teapot2Controls);
sprintf(gbuffer,"%s %f\n" , "vec3Add.z", vec3Add.z); //backbuffer desc
WriteConsole(Console , gbuffer, strlen(gbuffer),NULL,NULL); //output mouse

if(vec3Add.z < -10.0f)
{
sprintf(gbuffer,"%s\n" , "less"); //backbuffer desc
WriteConsole(Console , gbuffer, strlen(gbuffer),NULL,NULL); //output mouse
rotate = 6.0f; //i need to find the exact value to rotate to :D
}
else
{
rotate = 0.0f;
}


[Edited by - Anddos on November 14, 2008 5:19:29 AM]

Share this post


Link to post
Share on other sites

This topic is 3318 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.

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