[ODE] How to use the rotation matrix returned by dGeomGetRotation
Hannes Norda
norda at customred.com
Mon Oct 11 09:17:12 MST 2004
Hi,
also trying to be of help here ..:)
First off, the code-snippet Jon sent contained one error.
I'm sure he meant it to look like this: (leaving out beginning and end)
...
dReal const * P = dBodyGetPosition( myBody );
memcpy( &matrix[12], P, sizeof(float)*3 );
...
Also, one more thing in your code:
Duncan Frostick wrote:
>
> D3DXMATRIX compositeTransform;
>
> dReal const * rot = dGeomGetRotation( meshGeomID );
> dReal const * pos = dGeomGetPosition( meshGeomID );
>
> compositeTransform._11 = rot[0];
> compositeTransform._12 = rot[1];
> compositeTransform._13 = rot[2];
> compositeTransform._14 = pos[0];
> compositeTransform._21 = rot[4];
> compositeTransform._22 = rot[5];
> compositeTransform._23 = rot[6];
> compositeTransform._24 = pos[1];
> compositeTransform._31 = rot[7];
> compositeTransform._32 = rot[8];
> compositeTransform._33 = rot[9];
> compositeTransform._34 = pos[2];
> compositeTransform._41 = 0;
> compositeTransform._42 = 0;
> compositeTransform._43 = 0;
> compositeTransform._44 = 1;
Position goes into ._41, ._42, ._43 (or position 12-14 in a float[16])
So change it to this:
compositeTransform._11 = rot[0];
compositeTransform._12 = rot[1];
compositeTransform._13 = rot[2];
compositeTransform._14 = 0.0f;
compositeTransform._21 = rot[4];
compositeTransform._22 = rot[5];
compositeTransform._23 = rot[6];
compositeTransform._24 = 0.0f;
compositeTransform._31 = rot[7];
compositeTransform._32 = rot[8];
compositeTransform._33 = rot[9];
compositeTransform._34 = 0.0f;
compositeTransform._41 = pos[0];
compositeTransform._42 = pos[1];
compositeTransform._43 = pos[2];
compositeTransform._44 = 1.0f;
Cheers
/Hannes
More information about the ODE
mailing list