# Direct3D XYZ

This topic is 3121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm experiencing some problems with coordinate system. I've loaded mesh. When I move it left by writing: D3DXMatrixTranslation(&translateA, -100.0f, 1.0f, 0.0f); it goes right. What I might be doing wrong? Another problem is with rotating, when I place mesh somewhere far from center on x axis and make it rotate, it rotates around 0;0;0. What function should I use to make it spin around it's own center instead of center of coordinate system?
	static float index = 0.0f; index += 0.01f;
D3DXMATRIX translateA;
D3DXMatrixTranslation(&translateA, 0.0f, 1.0f 0.0f);
D3DXMATRIX rotate;
D3DXMatrixRotationY(&rotate, index);
m_lpd3dDevice->SetTransform(D3DTS_WORLD, &(translateA * rotate));



##### Share on other sites
Do rotation before translation. That way object will rotate around its center instead of world center. As for D3DXMatrixTranslation(&translateA, -100.0f, 1.0f, 0.0f); part of the code, this will place your mesh on -100, 1, 0 coordinate in your world space, it will not "move" it -100 along x axis each time you do this translation.

##### Share on other sites
Regarding your first question, what is your camera? Think about it: an object might always move in the same direction, but depending on where you're standing, it will look as if it's moving to the left, right, forward, back, etc. So make sure your camera is where you expect the object to move to the left.

##### Share on other sites
Quote:
 Original post by SIIYADo rotation before translation.

Which means you just have to swap the matrices in the multiplication, so replace
translateA * rotate
with
rotate * translateA

##### Share on other sites
Thank you.
Now I finally understand why one page stated that "In Direct3D you must combine your matrix in SRT order (scale * rotation * translation)."
It also seems that I was using 200.0f in z axis instead of -200.0f, so camera was positioned behind the cube, not in front.
All rated as extremely helpful ;)

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 12
• 15
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633354
• Total Posts
3011492
• ### Who's Online (See full list)

There are no registered users currently online

×