# 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.

## 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 on other sites
Quote:
 Original post by Anddosi 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 , thankspic of what i meanhttp://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 unitsmatFinal = matRot * matTranslate; // Final = rotate then move

##### 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 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 on other sites
this is a image in birds eye view of what i want

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

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013554
×