我有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);