added new file

This commit is contained in:
ZappoMan 2013-12-10 15:51:57 -08:00
parent 8bbdae0e64
commit 55c3e81801

View file

@ -0,0 +1,44 @@
//
// RegisteredMetaTypes.cpp
// hifi
//
// Created by Stephen Birarda on 10/3/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
// Used to register meta-types with Qt so that they can be used as properties for objects exposed to our
// Agent scripting.
#include "RegisteredMetaTypes.h"
void registerMetaTypes(QScriptEngine* engine) {
qScriptRegisterMetaType(engine, vec3toScriptValue, vec3FromScriptValue);
qScriptRegisterMetaType(engine, xColorToScriptValue, xColorFromScriptValue);
}
QScriptValue vec3toScriptValue(QScriptEngine* engine, const glm::vec3 &vec3) {
QScriptValue obj = engine->newObject();
obj.setProperty("x", vec3.x);
obj.setProperty("y", vec3.y);
obj.setProperty("z", vec3.z);
return obj;
}
void vec3FromScriptValue(const QScriptValue &object, glm::vec3 &vec3) {
vec3.x = object.property("x").toVariant().toFloat();
vec3.y = object.property("y").toVariant().toFloat();
vec3.z = object.property("z").toVariant().toFloat();
}
QScriptValue xColorToScriptValue(QScriptEngine *engine, const xColor& color) {
QScriptValue obj = engine->newObject();
obj.setProperty("red", color.red);
obj.setProperty("green", color.green);
obj.setProperty("blue", color.blue);
return obj;
}
void xColorFromScriptValue(const QScriptValue &object, xColor& color) {
color.red = object.property("red").toVariant().toInt();
color.green = object.property("green").toVariant().toInt();
color.blue = object.property("blue").toVariant().toInt();
}