2

オリエンテーションを機能させるために、私はそこに90%います。

私は最後のビットを解決しようとしています.誰かが私が作っているが見られない簡単なエラーを指摘してくれることを願っています.

私のコードは、人がカメラを左に見て実際に右に回転する場合を除いて機能します。逆に右を見ていると、カメラは左に回転します。

私がここで間違っていることは何か分かりますか?

次のように、Oculus Rift から向きを取得します。

OVR::Quatf OculusRiftOrientation = PredictedPose.Orientation;
glm::vec3 CurrentEulerAngles;
glm::quat CurrentOrientation;

OculusRiftOrientation.GetEulerAngles<OVR::Axis_X, OVR::Axis_Y, OVR::Axis_Z,
   OVR::Rotate_CW, OVR::Handed_R>
   (&CurrentEulerAngles.x, &CurrentEulerAngles.y, &CurrentEulerAngles.z);

CurrentOrientation = glm::quat(CurrentEulerAngles);

LookAt の計算方法は次のとおりです。

/*

DirectionOfWhereCameraIsFacing is calculated from mouse and standing position so that you are not constantly rotating after you move your head.

*/

glm::vec3 DirectionOfWhereCameraIsFacing;
glm::vec3 RiftDirectionOfWhereCameraIsFacing;
glm::vec3 RiftCenterOfWhatIsBeingLookedAt;
glm::vec3 PositionOfEyesOfPerson;
glm::vec3 CenterOfWhatIsBeingLookedAt;
glm::vec3 CameraPositionDelta;

RiftDirectionOfWhereCameraIsFacing = DirectionOfWhereCameraIsFacing;
RiftDirectionOfWhereCameraIsFacing = glm::rotate(CurrentOrientation, DirectionOfWhereCameraIsFacing);
PositionOfEyesOfPerson += CameraPositionDelta;
CenterOfWhatIsBeingLookedAt = PositionOfEyesOfPerson + DirectionOfWhereCameraIsFacing * 1.0f;
RiftCenterOfWhatIsBeingLookedAt = PositionOfEyesOfPerson + RiftDirectionOfWhereCameraIsFacing * 1.0f;

RiftView = glm::lookAt(PositionOfEyesOfPerson, RiftCenterOfWhatIsBeingLookedAt, DirectionOfUpForPerson);
4

0 に答える 0