Objects shake while rotating using moveGlobalOrientationQuat

lombera14

31-10-2009 16:19:06

Hello everyone!!

Currently I'm developing a demo in which I need to implement a character controller.

Using the OGRE3DKinematicBody class I could attach a mesh for my physic object which is a box. So, no matter where that box is, the mesh is properly rendered. I'm moving it using moveGlobaPossition method.

The problem occurs when I try to rotate it. Each frame I'm trying to move it until the desired orientation as it is an
autonomous agent. Unfortunately it starts shaking when I use the following method: moveGloblaOrientationQuat

What it's really weird for me is the fact that if I disconnect the physic and replace just that interface for the Ogre's one
equivalent, I get the expected result. But this way of course is not suitable if a direct control motion is desired using xOgre.

In this case I'm using for Ogre the rotate method.

This is what I'm doing in both cases using Ogre and NxOgre. I have written both ways for clarity.

//Using Ogre
void EAPassenger::Rotate(Ogre::Vector3 axisOrientation, Ogre::Vector3 newDirection)
{

newDirection.normalise();

Ogre::Vector3 src = sceneNode->getOrientation() * axisOrientation;

Ogre::Quaternion q = src.getRotationTo(newDirection);
sceneNode->rotate(q);

}

//Using NxOgre

void EAPassenger::Rotate(Ogre::Vector3 axisOrientation, Ogre::Vector3 newDirection)
{

newDirection.normalise();

NxOgre::Quat q = kBody->getGlobalOrientationQuat();
Quaternion ogreQuat = q.as<Ogre::Quaternion>();
Vector3 src = ogreQuat * axisOrientation;

Ogre::Quaternion q = src.getRotationTo(newDirection);
Vec4 v;
v.set(q.w, q.x, q.y, q.z);
kBody->moveGlobalOrientationQuat(v);

}

Then, am I missing something or it's about some interpolation Ogre does intrinsically and I need to do it by myself when

using NxOgre.

I will appreciate any help you can give me

Thanks in advance

Lombera

lombera14

02-11-2009 21:14:06

I just fixed it. As I supposed all I need is to multiply the current quaternion with the new one computed to achieve the final orientation. Moving using the result quaternion gives the expected behavior.

Thanks anyway

Lombera