Jump to content
  • Advertisement
Sign in to follow this  
Anddos

translate a oject on the currently rotated position

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

i am abit stuck with figuring out how to translate a object in the direction its currently rotated at , i do a simple rotate and see the D3DXMATRIX rotate vvalues change but i dont know after to say move in that direction its facing , probably change x and z cordinates of the translation so it can move at a specified angle , thanks pic of what i mean http://img90.imageshack.us/img90/4778/teapotty2.jpg

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Anddos
i am abit stuck with figuring out how to translate a object in the direction its currently rotated at , i do a simple rotate and see the D3DXMATRIX rotate vvalues change but i dont know after to say move in that direction its facing , probably change x and z cordinates of the translation so it can move at a specified angle , thanks

pic of what i mean
http://img90.imageshack.us/img90/4778/teapotty2.jpg
You just need to do the translation after the rotation:

D3DXMATRIX matRot, matTranslate, matFinal;
D3DXMatrixRotationY(&matRot, D3DX_PI);
D3DXMatrixTranslation(&matTranslate, 0, 0, 5); // Move along objects +Z by 5 units
matFinal = matRot * matTranslate; // Final = rotate then move

Share this post


Link to post
Share on other sites
thanks steve , but lets say i wanted the funnel part of the teapot that is the currection direction , i then want to translate that way the teapots funnel is point at , right now its just spinning on the point

Share this post


Link to post
Share on other sites
D3DXMATRIX matRotateY; // a matrix to store the rotation for each triangle
D3DXMatrixRotationY(&matRotateY, index); // the rotation matrix

//ive set x and z to move the teapot with WM_CHAR ,
case WM_CHAR:
switch(wParam)
{
case 'r': index +=0.1; break;
case 'w': z -= 0.1; break;
case 's': z += 0.1; break;

case 'a': x -= 0.1; break;
case 'd': x += 0.1; break;


}

matTranslate, matFinal;
D3DXMatrixTranslation(&matTranslate, x, 0,z); // Move along objects +Z by 5units

matFinal = matRotateY * matTranslate; // Final = rotate then move

d3ddev->SetTransform(D3DTS_WORLD, &(matFinal)); // set the world transform

after doing this , it just moves in the same direction and dosent move at a angle of the rotation

Share this post


Link to post
Share on other sites
this is a image in birds eye view of what i want

http://img81.imageshack.us/img81/4121/tbirdcb9.jpg

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!