mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:44:01 +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 {
|
||||
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_PROPERTY(bool magnifier READ getMagnifier)
|
||||
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)
|
||||
public:
|
||||
static HMDScriptingInterface& getInstance();
|
||||
|
@ -36,6 +38,12 @@ private:
|
|||
bool isHMDMode() const { return Application::getInstance()->isHMDMode(); }
|
||||
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;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue