NxMat33 and Ogre Quaternion

themadme

17-03-2008 23:39:53

Is there or has anyone had problems, when trying to convert a NxMat33 to Ogre::Quaternion?

betajaen

18-03-2008 00:01:18

I think you mean Quaternion, and no. I use them all the time.

NxMat33 m;
NxQuat q;
m.toQuat(q);
Ogre::Quaterion quat(q.w, q.x. q.y, q.z);

themadme

18-03-2008 00:09:58

yeah i did oops, Thanks for the reply.
Just not getting enough sleep and spending too much time on my games group project.

Hmm well that's what I'm doing in my code.

Just getting strange effects when I'm trying to set the orientation of a vehicle.
I am using NxMat33 because I find it much easier to use than quaternions.

I have this little function that contains this code




mat3RacerRotation = Racer->getNxActor()->getGlobalOrientation();

RacerAttributes[ usNumRacer ].vec3RacerSides = mat3RacerRotation.getRow( SIDE );
RacerAttributes[ usNumRacer ].vec3RacerUp = mat3RacerRotation.getRow( UP );
RacerAttributes[ usNumRacer ].vec3RacerFoward = mat3RacerRotation.getRow( FOWARD );

if( fHorSteering != 0.0 )
{
NxMat33 matRotationLocalY( NX_IDENTITY_MATRIX );
matRotationLocalY.rotY( NxMath::degToRad( fHorSteering * RacerAttributes[ usNumRacer ].fMaxGrip ) );

mat3RacerRotation.multiply( mat3RacerRotation, matRotationLocalY );

RacerAttributes[ usNumRacer ].vec3RacerSides = mat3RacerRotation.getRow( SIDE );
RacerAttributes[ usNumRacer ].vec3RacerUp = mat3RacerRotation.getRow( UP );
RacerAttributes[ usNumRacer ].vec3RacerFoward = mat3RacerRotation.getRow( FOWARD );

Racer->getNxActor()->setGlobalOrientation( mat3RacerRotation );
}


the RacerAttributes[ usNumRacer ].vec3RacerFoward is, as you would guess, the forward direction of the object.

When i rotate the object. The object rotates the opposite way of the RacerAttributes[ usNumRacer ].vec3RacerFoward as if it has went negative somewhere.

Of course later on my code, i change the matrix to quaternion, so ogre can set orientation with the same as physx orientation of the object

Any ideas?

themadme

19-03-2008 10:49:21

Solved my problem.

When setting the orientation of an object in Ogre, the Ogre quaternions are completely inverse of the PhysX quaternions.

kungfoomasta

19-03-2008 17:35:31

Are you saying that the quaternion of the PhysX shape needs to be inverted before setting the meshes orientation with this quaternion?

I've just started with PhysX and my objects have simple shapes, so I wouldn't really know if they were oriented wrong..

betajaen

19-03-2008 17:48:56

I haven't encountered a problem with this; NxQuat -> Ogre::Quaternion is a matter of copying w,x,y,z over.

alhobarata

02-04-2008 19:10:54

themadme, how do you solve you problem?

themadme

08-04-2008 09:59:42

well i was needing the global orientation of an object so i could move it in ogre. But in physX or Nx i was moving the objects by matrices, reason causes i found it to be easier.
so code below is used or get the right quaternion orinetation to be used later for ogre.


NxQuat quatOrientation;
mat3RacerRotation = Racer->getNxActor()->getGlobalOrientation( );
mat3RacerRotation.toQuat( quatOrientation );
quatOrientation.invert();


but if your using quaternions or nxogre ( cause it used quaternions
) then you just use
quatOrientation.invert(); part and i presume that would work.

also im using nxogre 0.9

alhobarata

08-04-2008 10:31:50

thank you.