Code: Select all
// mDirection is the direction of the character Vector3 boneDir = getBoneWorldOrientation(mEntity, mHips) * mDirection; // This is the direction of the crosshair Vector3 dir = mCameraTrans->_getDerivedDirection(); Quaternion rot = boneDir.getRotationTo(dir); // The code below has been taken from the sinbad character controller and adapted to pitch, instead of yaw Real pitchToGoal = rot.getPitch().valueDegrees(); Real pitchAtSpeed = pitchToGoal / Ogre::Math::Abs(pitchToGoal) * timeSinceLastUpdate * 100.0f; if (pitchToGoal < 0) pitchToGoal = std::min<Real>(0, std::max<Real>(pitchToGoal, pitchAtSpeed)); //yawToGoal = Math::Clamp<Real>(yawToGoal, yawAtSpeed, 0); else if (pitchToGoal > 0) pitchToGoal = std::max<Real>(0, std::min<Real>(pitchToGoal, pitchAtSpeed)); //yawToGoal = Math::Clamp<Real>(yawToGoal, 0, yawAtSpeed); mHips->pitch(Degree(pitchToGoal));
It seems to work properly on +Z, it's shaking a bit on -Z, and it just continues to rotate on +X/-X.
I hope someone can help.
EDIT: I've sorta fixed this, see my second post.
Also, I've mirrored my topic to GameDev.net, you can find the topic here: http://www.gamedev.net/topic/644417-vec ... on-vector/