0
我想做一个简单的矢量旋转。旋转矢量
目标是领导我的第一人称摄像机,它正在指向目标t方向d到新方向d1的新目标t1。
d和d1之间的过渡应该是一个平滑的运动。
随着
public void FlyLookTo(Vector3 target) {
_flyTargetDirection = target - _cameraPosition;
_flyTargetDirection.Normalize();
_rotation = new Matrix();
_rotationAxis = Vector3.Cross(Direction, _flyTargetDirection);
// This bool tells the Update()-method to trigger the changeDirection() method.
_isLooking = true;
}
我开始与它的新参数的方向变化和
// this method gets executed by the Update()-method if the isLooking flag is up.
private void _changeDirection() {
dist = Vector3.Distance(Direction, _flyTargetDirection);
// check whether we have reached the desired direction
if (dist >= 0.00001f) {
_rotationAxis = Vector3.Cross(Direction, _flyTargetDirection);
_rotation = Matrix.CreateFromAxisAngle(_rotationAxis, MathHelper.ToRadians(_flyViewingSpeed - Math.ToRadians(rotationSpeed)));
// update the cameras direction.
Direction = Vector3.TransformNormal(Direction, _rotation);
} else {
_onDirectionReached();
_isLooking = false;
}
}
我执行实际的运动。
我的问题:实际运行工作正常,但移动速度减慢更多的电流方向越接近所期望的方向,如果连续执行数次,这使得它非常不愉快的运动。
如何使相机以相同的速度从方向d移动到方向d1?
看到我的答案在这里:http://gamedev.stackexchange.com/questions/38594/rotate-a-vector和在这里:http://stackoverflow.com/questions/12797811/rotation-axis-to-perform-回转 –