Sign in to follow this  
jonathanschmidt

D3D Matrix - ODE position and rotation

Recommended Posts

My problem can be written down quite general, but I'm having this problem with a special case. So I write it down just like it is, maybe it looks a little more interesting in this way. The problem is that I've got a D3D 4x4 Matrix with rotation, translation and maybe also scale in it, And I would like to create a rigid body with the physics engine ODE at the location described by this matrix. (Trying to create a rigid body based on the last animated position of a joint in a skeletal animated mesh). The only methods for specifying the location and position of a rigid body in ODE are dBodySetPosition( /* a vector describing translation here */); and dBodySetQuaternion( /* a quaternion describing rotation here */); or dBodySetRotation( /* a 3x3 Matrix describing rotation here */); Extracting the three values for translation from the mD3D atrix and setting them when calling dBodySetPosition works. My problem is now the rotation. I tried to extract the 3x3 matrix from the first 3x3 fields of the D3D matrix and set them, but this doesn't look right, even when transposed before. Creating a d3d quaternion from the matrix and setting this failed too, the rotation simply is wrong. I've searched the web for a solution for this, but all convertions were the other way round, getting a D3D matrix from an ODE matrix and similar. So I would be glad for any help or ideas.

Share this post


Link to post
Share on other sites
Are you sure the ODE matrix is in the same order? DirectX stores its matrix as x-row, y-row, z-row. In that order. To remove scaling from a matrix, just normalize each first 3 floats in every row like a vector. eg D3DXVec3Normalize( (VECTOR*)&matrix._31 ) will normalize the z row.

Other than that, I can't imagine why it doesn't work.

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