majc
17-08-2008 03:28:26
Im using this code i got from a post:
This is more or less working the problem is that the npc is always facing is side to me not the front it seems that the mesh front direction is his side.
How i change that?
Some help please.
Thanks in advance!
Ogre::Vector3 Destination, Position;
Ogre::Quaternion npcOrientation;
Ogre::Quaternion playerOrientation;
mPlayer->getBody()->getPositionOrientation(Destination,playerOrientation);
body->getPositionOrientation(Position,npcOrientation);
Ogre::Vector3 goalHeading = Destination;
goalHeading.y = 0.0f;
goalHeading.normalise();
Ogre::Vector3 curHeading = npcOrientation * Ogre::Vector3::UNIT_Z;
// angle between these vectors.
Ogre::Degree delta_o = Math::ACos( curHeading.dotProduct( goalHeading ) );
Ogre::Vector3 rot_axis = curHeading.crossProduct( goalHeading ).normalisedCopy();
body->addLocalForce(gravity * mNPC->getMass(), Ogre::Vector3::ZERO);
body->addTorque( (rot_axis * delta_o.valueDegrees() * 40.0f) - (body->getOmega()*100.0f) );
This is more or less working the problem is that the npc is always facing is side to me not the front it seems that the mesh front direction is his side.
How i change that?
Some help please.
Thanks in advance!