Showing the changes to plugins/oculus/src/OculusControllerManager.cpp (1 of 5 files). Show all
Unified · Split
| @@ -326,19 +326,24 @@ void OculusControllerManager::TouchDevice::handlePose(float deltaTime, · 325 unmodified lines | ||
| 326 | 326 | void OculusControllerManager::TouchDevice::handleHeadPose(float deltaTime, |
| 327 | 327 | const controller::InputCalibrationData& inputCalibrationData, |
| 328 | 328 | const ovrPoseStatef& headPose) { |
| 329 | − auto poseId = controller::HEAD; | |
| 330 | − auto& pose = _poseStateMap[poseId]; | |
| 329 | + glm::mat4 mat = createMatFromQuatAndPos(toGlm(headPose.ThePose.Orientation), | |
| 330 | + toGlm(headPose.ThePose.Position)); | |
| 331 | 331 | |
| 332 | − static const glm::quat yFlip = glm::angleAxis(PI, Vectors::UNIT_Y); | |
| 333 | − pose.translation = toGlm(headPose.ThePose.Position); | |
| 334 | − pose.rotation = toGlm(headPose.ThePose.Orientation) * yFlip; | |
| 335 | − pose.angularVelocity = toGlm(headPose.AngularVelocity); | |
| 336 | − pose.velocity = toGlm(headPose.LinearVelocity); | |
| 337 | − pose.valid = true; | |
| 332 | + //perform a 180 flip to make the HMD face the +z instead of -z, beacuse the head faces +z | |
| 333 | + glm::mat4 matYFlip = mat * Matrices::Y_180; | |
| 334 | + controller::Pose pose(extractTranslation(matYFlip), | |
| 335 | + glmExtractRotation(matYFlip), | |
| 336 | + toGlm(headPose.LinearVelocity), // XXX * matYFlip ? | |
| 337 | + toGlm(headPose.AngularVelocity)); | |
| 338 | 338 | |
| 339 | − // transform into avatar frame | |
| 340 | − glm::mat4 controllerToAvatar = glm::inverse(inputCalibrationData.avatarMat) * inputCalibrationData.sensorToWorldMat; | |
| 341 | − pose = pose.transform(controllerToAvatar); | |
| 339 | + glm::mat4 sensorToAvatar = glm::inverse(inputCalibrationData.avatarMat) * inputCalibrationData.sensorToWorldMat; | |
| 340 | + glm::mat4 defaultHeadOffset = glm::inverse(inputCalibrationData.defaultCenterEyeMat) * | |
| 341 | + inputCalibrationData.defaultHeadMat; | |
| 342 | + | |
| 343 | + controller::Pose hmdHeadPose = pose.transform(sensorToAvatar); | |
| 344 | + | |
| 345 | + pose.valid = true; | |
| 346 | + _poseStateMap[controller::HEAD] = hmdHeadPose.postTransform(defaultHeadOffset); | |
| 342 | 347 | } |
| 343 | 348 | |
| 344 | 349 | void OculusControllerManager::TouchDevice::handleRotationForUntrackedHand(const controller::InputCalibrationData& inputCalibrationData, |