Sign in to follow this  
steg

Combining transformations

Recommended Posts

steg    390
Hi all, I was wondering if it is possible to do rotations and translation in one matrix ? Example : D3DXMATRIX Rx, Transformed, Translated; D3DXMatrixTranslation( &Translated, m_fWorldXPos, m_fWorldYPos, m_fWorldZPos ); D3DXMatrixRotationX( &Rx, x ); Transformed = Rx * Translated; m_pDevice->SetTransform( D3DTS_WORLD, &Transformed ); Here I translate an objects x,y,z position, it firstly gets rotated on its x-axis and then translated. Just wondered if there is a way of doing this with one function ? Kind regards, Steve

Share this post


Link to post
Share on other sites
You can do more than that...

You can rotate, translate to a different origin, rotate about that, translate back to some other origin, scale from there... as many operations as you'd like.

To concatenate matrices, just multiply them
A = B * C
or
D3DXMatrixMultiply(&A, &B, &C);

When all you want to do is mix rotation and translation though, it's often easier to just plug the translation into the matrix yourself...

D3DXMatrixRotationYawPitchRoll(&A, y, p, r);
A._41 = translateX;
B._42 = translateY;
C._43 = translateZ;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this