Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -58,16 +58,21 @@ float HMDScriptingInterface::getIPD() const { · 57 unmodified lines | |||
| 58 | return Application::getInstance()->getActiveDisplayPlugin()->getIPD(); | 58 | return Application::getInstance()->getActiveDisplayPlugin()->getIPD(); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | glm::mat4 HMDScriptingInterface::getWorldHMDMatrix() const { | ||
| 62 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | ||
| 63 | return myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix(); | ||
| 64 | } | ||
| 65 | |||
| 61 | glm::vec3 HMDScriptingInterface::getPosition() const { | 66 | glm::vec3 HMDScriptingInterface::getPosition() const { |
| 62 | if (Application::getInstance()->getActiveDisplayPlugin()->isHmd()) { | 67 | if (Application::getInstance()->getActiveDisplayPlugin()->isHmd()) { |
| 63 | return glm::vec3(Application::getInstance()->getActiveDisplayPlugin()->getHeadPose()[3]); | 68 | return extractTranslation(getWorldHMDMatrix()); |
| 64 | } | 69 | } |
| 65 | return glm::vec3(); | 70 | return glm::vec3(); |
| 66 | } | 71 | } |
| 67 | 72 | ||
| 68 | glm::quat HMDScriptingInterface::getOrientation() const { | 73 | glm::quat HMDScriptingInterface::getOrientation() const { |
| 69 | if (Application::getInstance()->getActiveDisplayPlugin()->isHmd()) { | 74 | if (Application::getInstance()->getActiveDisplayPlugin()->isHmd()) { |
| 70 | return glm::quat_cast(Application::getInstance()->getActiveDisplayPlugin()->getHeadPose()); | 75 | return glm::normalize(glm::quat_cast(getWorldHMDMatrix())); |
| 71 | } | 76 | } |
| 72 | return glm::quat(); | 77 | return glm::quat(); |
| 73 | } | 78 | } |