deshan
02-11-2009 15:15:28
Hi
I have tried to bring the ogre wiki Intermediate Tutorial 1 to NxOgre. http://www.ogre3d.org/wiki/index.php/Intermediate_Tutorial_1
So far everything works fine except the rotation thing. In wiki tutorial they have applied the rotation to scenenode and here it would be OGRE3DBody right?
Here is the wiki code to rotate the scenenode
Here is mine
Am I do the things wrong? Because the body faces some weird directions
I have tried to bring the ogre wiki Intermediate Tutorial 1 to NxOgre. http://www.ogre3d.org/wiki/index.php/Intermediate_Tutorial_1
So far everything works fine except the rotation thing. In wiki tutorial they have applied the rotation to scenenode and here it would be OGRE3DBody right?
Here is the wiki code to rotate the scenenode
mDirection = mDestination - mNode->getPosition(); //mDestination is a Vector3 which is the point robot should face and go
mDistance = mDirection.normalise();
Vector3 src = mNode->getOrientation() * Vector3::UNIT_X;
Ogre::Quaternion quat = src.getRotationTo(mDirection);
mNode->rotate(quat);
Here is mine
mDirection = mDestination - enemyBody->getGlobalPosition().as<Ogre::Vector3>(); // enemyBody is the OGRE3DBody
mDistance = mDirection .normalise();
Vector3 src = enemyBody->getGlobalOrientationQuat().as<Ogre::Quaternion>()*Ogre::Vector3::UNIT_X;
Ogre::Quaternion quat = src.getRotationTo(robotDirection);
enemyBody->setGlobalOrientationQuat(quat);
Am I do the things wrong? Because the body faces some weird directions