Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -90,6 +90,16 @@ glm::vec3 HMDScriptingInterface::getPosition() const { · 89 unmodified lines | ||
| 90 | 90 | return glm::vec3(); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | +void HMDScriptingInterface::setPosition(const glm::vec3& position) { | |
| 94 | + MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 95 | + glm::mat4 hmdToSensor = myAvatar->getHMDSensorMatrix(); | |
| 96 | + glm::mat4 sensorToWorld = myAvatar->getSensorToWorldMatrix(); | |
| 97 | + glm::mat4 hmdToWorld = sensorToWorld * hmdToSensor; | |
| 98 | + setTranslation(hmdToWorld, position); | |
| 99 | + sensorToWorld = hmdToWorld * glm::inverse(hmdToSensor); | |
| 100 | + myAvatar->setSensorToWorldMatrix(sensorToWorld); | |
| 101 | +} | |
| 102 | + | |
| 93 | 103 | glm::quat HMDScriptingInterface::getOrientation() const { |
| 94 | 104 | if (qApp->getActiveDisplayPlugin()->isHmd()) { |
| 95 | 105 | return glm::normalize(glm::quat_cast(getWorldHMDMatrix())); |
| @@ -139,3 +149,8 @@ bool HMDScriptingInterface::isKeyboardVisible() { · 43 unmodified lines | ||
| 139 | 149 | void HMDScriptingInterface::centerUI() { |
| 140 | 150 | QMetaObject::invokeMethod(qApp, "centerUI", Qt::QueuedConnection); |
| 141 | 151 | } |
| 152 | + | |
| 153 | +void HMDScriptingInterface::snapToAvatar() { | |
| 154 | + MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 155 | + myAvatar->updateSensorToWorldMatrix(); | |
| 156 | +} | |