Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 8 files). Show all
Unified · Split
| @@ -20,15 +20,39 @@ · 19 unmodified lines | |||
| 20 | HMDScriptingInterface::HMDScriptingInterface() { | 20 | HMDScriptingInterface::HMDScriptingInterface() { |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const { | ||
| 24 | glm::vec3 result { position }; | ||
| 25 | qApp->getApplicationCompositor().calculateRayUICollisionPoint(position, direction, result); | ||
| 26 | return result; | ||
| 27 | } | ||
| 28 | |||
| 29 | glm::vec2 HMDScriptingInterface::overlayFromWorldPoint(const glm::vec3& position) const { | ||
| 30 | return qApp->getApplicationCompositor().overlayFromSphereSurface(position); | ||
| 31 | } | ||
| 32 | |||
| 33 | glm::vec2 HMDScriptingInterface::sphericalToOverlay(const glm::vec2 & position) const { | ||
| 34 | return qApp->getApplicationCompositor().sphericalToOverlay(position); | ||
| 35 | } | ||
| 36 | |||
| 37 | glm::vec2 HMDScriptingInterface::overlayToSpherical(const glm::vec2 & position) const { | ||
| 38 | return qApp->getApplicationCompositor().overlayToSpherical(position); | ||
| 39 | } | ||
| 40 | |||
| 41 | glm::vec2 HMDScriptingInterface::screenToOverlay(const glm::vec2 & position) const { | ||
| 42 | return qApp->getApplicationCompositor().screenToOverlay(position); | ||
| 43 | } | ||
| 44 | |||
| 45 | glm::vec2 HMDScriptingInterface::overlayToScreen(const glm::vec2 & position) const { | ||
| 46 | return qApp->getApplicationCompositor().overlayToScreen(position); | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | |||
| 23 | QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) { | 51 | QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) { |
| 24 | glm::vec3 hudIntersection; | 52 | glm::vec3 hudIntersection; |
| 25 | auto instance = DependencyManager::get<HMDScriptingInterface>(); | 53 | auto instance = DependencyManager::get<HMDScriptingInterface>(); |
| 26 | if (instance->getHUDLookAtPosition3D(hudIntersection)) { | 54 | if (instance->getHUDLookAtPosition3D(hudIntersection)) { |
| 27 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 55 | glm::vec2 overlayPos = qApp->getApplicationCompositor().overlayFromSphereSurface(hudIntersection); |
| 28 | glm::vec3 sphereCenter = myAvatar->getDefaultEyePosition(); | ||
| 29 | glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * (hudIntersection - sphereCenter); | ||
| 30 | glm::vec2 polar = glm::vec2(glm::atan(direction.x, -direction.z), glm::asin(direction.y)) * -1.0f; | ||
| 31 | auto overlayPos = qApp->getApplicationCompositor().sphericalToOverlay(polar); | ||
| 32 | return qScriptValueFromValue<glm::vec2>(engine, overlayPos); | 56 | return qScriptValueFromValue<glm::vec2>(engine, overlayPos); |
| 33 | } | 57 | } |
| 34 | return QScriptValue::NullValue; | 58 | return QScriptValue::NullValue; |