간단한 벡터 회전을하고 싶습니다.벡터 회전
목표는 현재 방향 t 인 대상 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;
}
으로 I는 한 방향의 새로운 매개 변수 변화
// 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;
}
}
I 실제 운동을 수행하고으로 개시하고있다.
내 문제 : 실제 움직임은 잘 작동하지만 현재 방향이 원하는 방향에 가까워 질수록 움직임 속도가 느려지므로 여러 번 연속 실행하면 매우 불쾌한 움직임을 만듭니다.
카메라를 움직임이 같은 속도로 d 방향에서 d1 방향으로 움직이게하려면 어떻게해야합니까?
내 대답보기 : http://gamedev.stackexchange.com/questions/38594/rotate-a-vector 여기 : http://stackoverflow.com/questions/12797811/rotation-axis-to-perform- 회전 –