mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
expose position and orientation of HMD to Javascript.
- HMD.orientation - HMD.position
This commit is contained in:
parent
a42bb5f533
commit
8befade007
2 changed files with 22 additions and 0 deletions
|
@ -57,3 +57,17 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* conte
|
||||||
float HMDScriptingInterface::getIPD() const {
|
float HMDScriptingInterface::getIPD() const {
|
||||||
return Application::getInstance()->getActiveDisplayPlugin()->getIPD();
|
return Application::getInstance()->getActiveDisplayPlugin()->getIPD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 HMDScriptingInterface::getPosition() const {
|
||||||
|
if (Application::getInstance()->getActiveDisplayPlugin()->isHmd()) {
|
||||||
|
return glm::vec3(Application::getInstance()->getActiveDisplayPlugin()->getHeadPose()[3]);
|
||||||
|
}
|
||||||
|
return glm::vec3();
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::quat HMDScriptingInterface::getOrientation() const {
|
||||||
|
if (Application::getInstance()->getActiveDisplayPlugin()->isHmd()) {
|
||||||
|
return glm::quat_cast(Application::getInstance()->getActiveDisplayPlugin()->getHeadPose());
|
||||||
|
}
|
||||||
|
return glm::quat();
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ class HMDScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool magnifier READ getMagnifier)
|
Q_PROPERTY(bool magnifier READ getMagnifier)
|
||||||
Q_PROPERTY(bool active READ isHMDMode)
|
Q_PROPERTY(bool active READ isHMDMode)
|
||||||
|
Q_PROPERTY(glm::vec3 position READ getPosition)
|
||||||
|
Q_PROPERTY(glm::quat orientation READ getOrientation)
|
||||||
Q_PROPERTY(float ipd READ getIPD)
|
Q_PROPERTY(float ipd READ getIPD)
|
||||||
public:
|
public:
|
||||||
static HMDScriptingInterface& getInstance();
|
static HMDScriptingInterface& getInstance();
|
||||||
|
@ -36,6 +38,12 @@ private:
|
||||||
bool isHMDMode() const { return Application::getInstance()->isHMDMode(); }
|
bool isHMDMode() const { return Application::getInstance()->isHMDMode(); }
|
||||||
float getIPD() const;
|
float getIPD() const;
|
||||||
|
|
||||||
|
// Get the position of the HMD
|
||||||
|
glm::vec3 getPosition() const;
|
||||||
|
|
||||||
|
// Get the orientation of the HMD
|
||||||
|
glm::quat getOrientation() const;
|
||||||
|
|
||||||
bool getHUDLookAtPosition3D(glm::vec3& result) const;
|
bool getHUDLookAtPosition3D(glm::vec3& result) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue