Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 37 files). Show all
Unified · Split
| @@ -10,22 +10,27 @@ · 9 unmodified lines | |||
| 10 | // | 10 | // |
| 11 | 11 | ||
| 12 | #include "HMDScriptingInterface.h" | 12 | #include "HMDScriptingInterface.h" |
| 13 | #include "display-plugins/DisplayPlugin.h" | 13 | |
| 14 | #include <QtScript/QScriptContext> | ||
| 15 | |||
| 14 | #include <avatar/AvatarManager.h> | 16 | #include <avatar/AvatarManager.h> |
| 15 | 17 | ||
| 18 | #include "Application.h" | ||
| 19 | #include "display-plugins/DisplayPlugin.h" | ||
| 20 | |||
| 16 | HMDScriptingInterface& HMDScriptingInterface::getInstance() { | 21 | HMDScriptingInterface& HMDScriptingInterface::getInstance() { |
| 17 | static HMDScriptingInterface sharedInstance; | 22 | static HMDScriptingInterface sharedInstance; |
| 18 | return sharedInstance; | 23 | return sharedInstance; |
| 19 | } | 24 | } |
| 20 | 25 | ||
| 21 | bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const { | 26 | bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const { |
| 22 | Camera* camera = Application::getInstance()->getCamera(); | 27 | Camera* camera = qApp->getCamera(); |
| 23 | glm::vec3 position = camera->getPosition(); | 28 | glm::vec3 position = camera->getPosition(); |
| 24 | glm::quat orientation = camera->getOrientation(); | 29 | glm::quat orientation = camera->getOrientation(); |
| 25 | 30 | ||
| 26 | glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f); | 31 | glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f); |
| 27 | 32 | ||
| 28 | const auto& compositor = Application::getInstance()->getApplicationCompositor(); | 33 | const auto& compositor = qApp->getApplicationCompositor(); |
| 29 | 34 | ||
| 30 | return compositor.calculateRayUICollisionPoint(position, direction, result); | 35 | return compositor.calculateRayUICollisionPoint(position, direction, result); |
| 31 | } | 36 | } |
| @@ -40,7 +45,7 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* conte · 8 unmodified lines | |||
| 40 | glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * (hudIntersection - sphereCenter); | 45 | glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * (hudIntersection - sphereCenter); |
| 41 | glm::quat rotation = ::rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), direction); | 46 | glm::quat rotation = ::rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), direction); |
| 42 | glm::vec3 eulers = ::safeEulerAngles(rotation); | 47 | glm::vec3 eulers = ::safeEulerAngles(rotation); |
| 43 | return qScriptValueFromValue<glm::vec2>(engine, Application::getInstance()->getApplicationCompositor() | 48 | return qScriptValueFromValue<glm::vec2>(engine, qApp->getApplicationCompositor() |
| 44 | .sphericalToOverlay(glm::vec2(eulers.y, -eulers.x))); | 49 | .sphericalToOverlay(glm::vec2(eulers.y, -eulers.x))); |
| 45 | } | 50 | } |
| 46 | return QScriptValue::NullValue; | 51 | return QScriptValue::NullValue; |
| @@ -55,5 +60,13 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* conte · 8 unmodified lines | |||
| 55 | } | 60 | } |
| 56 | 61 | ||
| 57 | float HMDScriptingInterface::getIPD() const { | 62 | float HMDScriptingInterface::getIPD() const { |
| 58 | return Application::getInstance()->getActiveDisplayPlugin()->getIPD(); | 63 | return qApp->getActiveDisplayPlugin()->getIPD(); |
| 64 | } | ||
| 65 | |||
| 66 | void HMDScriptingInterface::toggleMagnifier() { | ||
| 67 | qApp->getApplicationCompositor().toggleMagnifier(); | ||
| 68 | } | ||
| 69 | |||
| 70 | bool HMDScriptingInterface::getMagnifier() const { | ||
| 71 | return qApp->getApplicationCompositor().hasMagnifier(); | ||
| 59 | } | 72 | } |