mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 07:32:17 +02:00
added new file
This commit is contained in:
parent
8bbdae0e64
commit
55c3e81801
1 changed files with 44 additions and 0 deletions
44
libraries/shared/src/RegisteredMetaTypes.cpp
Normal file
44
libraries/shared/src/RegisteredMetaTypes.cpp
Normal 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();
|
||||
}
|
Loading…
Reference in a new issue