D3D Matrix - ODE position and rotation

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

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 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.

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 12
• 10
• Forum Statistics

• Total Topics
632578
• Total Posts
3007158

×