mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:41:20 +02:00
expose the Pose structure to JS
This commit is contained in:
parent
58e5bff9a1
commit
3eedfd369e
3 changed files with 28 additions and 2 deletions
|
@ -6,6 +6,11 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QScriptEngine>
|
||||||
|
#include <QScriptValue>
|
||||||
|
|
||||||
|
#include <RegisteredMetaTypes.h>
|
||||||
|
|
||||||
#include "Pose.h"
|
#include "Pose.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
@ -25,6 +30,20 @@ namespace controller {
|
||||||
velocity == right.getVelocity() && angularVelocity == right.getAngularVelocity();
|
velocity == right.getVelocity() && angularVelocity == right.getAngularVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue Pose::toScriptValue(QScriptEngine* engine, const Pose& pose) {
|
||||||
|
QScriptValue obj = engine->newObject();
|
||||||
|
obj.setProperty("translation", vec3toScriptValue(engine, pose.translation));
|
||||||
|
obj.setProperty("rotation", quatToScriptValue(engine, pose.rotation));
|
||||||
|
obj.setProperty("velocity", vec3toScriptValue(engine, pose.velocity));
|
||||||
|
obj.setProperty("angularVelocity", quatToScriptValue(engine, pose.angularVelocity));
|
||||||
|
obj.setProperty("valid", pose.valid);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pose::fromScriptValue(const QScriptValue& object, Pose& pose) {
|
||||||
|
// nothing for now...
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#ifndef hifi_controllers_Pose_h
|
#ifndef hifi_controllers_Pose_h
|
||||||
#define hifi_controllers_Pose_h
|
#define hifi_controllers_Pose_h
|
||||||
|
|
||||||
|
#include <QScriptValue>
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
@ -35,9 +36,12 @@ namespace controller {
|
||||||
quat getRotation() const { return rotation; }
|
quat getRotation() const { return rotation; }
|
||||||
vec3 getVelocity() const { return velocity; }
|
vec3 getVelocity() const { return velocity; }
|
||||||
quat getAngularVelocity() const { return angularVelocity; }
|
quat getAngularVelocity() const { return angularVelocity; }
|
||||||
|
|
||||||
|
static QScriptValue toScriptValue(QScriptEngine* engine, const Pose& event);
|
||||||
|
static void fromScriptValue(const QScriptValue& object, Pose& event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Q_DECLARE_METATYPE(controller::Pose);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -495,6 +495,7 @@ void UserInputMapper::assignDefaulActionScales() {
|
||||||
static int actionMetaTypeId = qRegisterMetaType<Action>();
|
static int actionMetaTypeId = qRegisterMetaType<Action>();
|
||||||
static int inputMetaTypeId = qRegisterMetaType<Input>();
|
static int inputMetaTypeId = qRegisterMetaType<Input>();
|
||||||
static int inputPairMetaTypeId = qRegisterMetaType<InputPair>();
|
static int inputPairMetaTypeId = qRegisterMetaType<InputPair>();
|
||||||
|
static int poseMetaTypeId = qRegisterMetaType<controller::Pose>("Pose");
|
||||||
|
|
||||||
|
|
||||||
QScriptValue inputToScriptValue(QScriptEngine* engine, const Input& input);
|
QScriptValue inputToScriptValue(QScriptEngine* engine, const Input& input);
|
||||||
|
@ -547,6 +548,8 @@ void UserInputMapper::registerControllerTypes(QScriptEngine* engine) {
|
||||||
qScriptRegisterMetaType(engine, actionToScriptValue, actionFromScriptValue);
|
qScriptRegisterMetaType(engine, actionToScriptValue, actionFromScriptValue);
|
||||||
qScriptRegisterMetaType(engine, inputToScriptValue, inputFromScriptValue);
|
qScriptRegisterMetaType(engine, inputToScriptValue, inputFromScriptValue);
|
||||||
qScriptRegisterMetaType(engine, inputPairToScriptValue, inputPairFromScriptValue);
|
qScriptRegisterMetaType(engine, inputPairToScriptValue, inputPairFromScriptValue);
|
||||||
|
|
||||||
|
qScriptRegisterMetaType(engine, Pose::toScriptValue, Pose::fromScriptValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Input UserInputMapper::makeStandardInput(controller::StandardButtonChannel button) {
|
Input UserInputMapper::makeStandardInput(controller::StandardButtonChannel button) {
|
||||||
|
|
Loading…
Reference in a new issue