Actor::set/get Global*() ?

Amnuriak

19-04-2010 14:14:18

How do I turn an actor ? Just yaw/pitch/whatever it.
I was able to "tilt" the actor but not in any way I could comprehend. I'm not trying to make it face a certain point, I only want the actor to turn (given a quat). I figured the Actor::get/setGlobalOrientation/Pose/etc. methods would do the trick but I get the strangest behaviour. Calls to Actor::setGlobalOrientationQuat will even deform the actor - sometimes. Now THAT's something I didn't expect.
If I call Actor::getGlobalOrientationQuat on a newly created Actor it will return w=1, x=0, y=, z=0. Hu ? What does this mean ? It's facing ... nowhere ? :shock: Out of curiosity I did setGlobalOrientation(0, 0, 0, 0) which caused the actor to keep falling INTO the underlying plane and reset to its initial position again and again and again and ...
I have to admit I'm not a quaternion expert but I think I understood how they are used. And I certainley did not expect them to deform the object in question.

Actor::getGlobalPose() "Retrieves the actors world space transform. " (Nx doc) so multiplying it with some quat (like Quat(10, 0, 1, 1)) and assign it to should do something. Well, at least I figured so and I figured wrong cause it will not do anything at all. Actor stays perfectly the same.

Some help with this please.

betajaen

19-04-2010 14:32:50

Quaternions don't work like that, you need a read of the Quaternion Primer -> http://www.ogre3d.org/wiki/index.php/Qu ... ion_Primer

Amnuriak

19-04-2010 15:18:16

I read that article before but thanks for the hint. The article doesn't tell me what I need to know about NxOgre/PhysX though - and it can't help me understand why there are such weird values, e.g. Actor::getGlobalOrientationQuat() returning w=1, x=0, y=, z=0 for a newly created actor. Maybe this method is not supposed to be called right away ? If those values are kind of "not-initialized" they would make "kind of" sense. Only "kind of" though.

I did manage to turn the actor the way I want it to but it required me to transform all necessary values to Ogre's quaternions:
Ogre::Quaternion testQuat1 = mActor->getGlobalOrientationQuat().as<Ogre::Quaternion>();
Ogre::Quaternion testQuat2(Ogre::Radian(0.5f), Ogre::Vector3(1, 0, 0));
Ogre::Quaternion testQuat3 = testQuat1 * testQuat2;
mActor->setGlobalOrientationQuat(Quat(testQuat3));
mActor->setGlobalPosition(mActor->getGlobalPosition() + Vec3(0, 5, 0));

did exactly what I expected it to do. This tells me I can't be too far off with my understanding of quats.
Nevertheless I find it rather ugly (and hopefully unnecessary) to transfrom everything into Ogre quats and (after I'm done) back into NxOgre type values to get the job done. That's why I tried this:
Quat quat1 = mActor->getGlobalOrientationQuat();
Quat quat2 = Quat(0.5f, 1, 0, 0); // also tried degrees instead of radian, no difference
Quat quat3 = quat1 * quat2;
mActor->setGlobalOrientationQuat(quat3);
mActor->setGlobalPosition(mActor->getGlobalPosition() + Vec3(0, 5, 0));

which *should* do the same as the code snippet with the transforms to Ogre's quats. But instead of rotating the object it will deform it.
Sorry if I'm missing some obvious point here but I *think* I did my research thoroughly enough.