• 14
• 12
• 9
• 10
• 13

# Rotating an object

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

## Recommended Posts

Hy. I've got a object with his matrix. Now i would to rotate it on the X,Y or Z axes, but the object is not on that axes. So, knowing this trasformation:
		D3DXMatrixTranslation(&Alien.MeshData.ColladaBuffer.Objmatr,15.0f,-30.0f,25.0f);
D3DXMatrixScaling(&p,0.6f,0.6f,0.6f);
D3DXMatrixRotationX(&p,-1.3f);


I tried to rotate it in this way
	D3DXMATRIXA16 m,p,q,r;
D3DXMatrixTranslation(&q,15.0f,-30.0f,25.0f);
D3DXMatrixRotationZ(&r,-1.3f);
D3DXMatrixInverse(&m,NULL,&q);
D3DXMatrixRotationY(&p,f);
Alien.MeshData.ColladaBuffer.Objmatr = m * p * r * q;
f+=0.0001f;


But it does not give me the wishered result. If i remove the r multiplication, it rotates correctly, but it's not centred. Here is an image http://img213.imageshack.us/img213/1629/imghu3.jpg I should say that i do not know if the object, in it's starting position, it's in 0,0,0 point. Anyway... Can you give me an help?

##### Share on other sites
I'm not really sure what you are trying to achieve, but I think you need to rotate the object first and then translate it.