Jump to content
  • Advertisement
Sign in to follow this  
XVincentX

Rotating an object

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

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);
		D3DXMatrixMultiply(&Alien.MeshData.ColladaBuffer.Objmatr,&Alien.MeshData.ColladaBuffer.Objmatr,&p);
		D3DXMatrixRotationX(&p,-1.3f);
		D3DXMatrixMultiply(&Alien.MeshData.ColladaBuffer.Objmatr,&Alien.MeshData.ColladaBuffer.Objmatr,&p);


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 this post


Link to post
Share on other sites
Advertisement
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.

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!