単純なベクトル回転を行いたい。
目標は、現在方向 d のターゲット t を指している一人称カメラを、新しい方向 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 に同じ速度で移動させるにはどうすればよいですか?