mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
Beginnings of some metavoxel scriptability, to create some test landscapes.
This commit is contained in:
parent
eab0fa4c27
commit
e32bab5b04
5 changed files with 36 additions and 0 deletions
|
@ -3641,6 +3641,7 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript
|
|||
scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
|
||||
scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector);
|
||||
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QCryptographicHash>
|
||||
#include <QDataStream>
|
||||
#include <QMetaType>
|
||||
#include <QScriptEngine>
|
||||
#include <QScriptValueIterator>
|
||||
#include <QUrl>
|
||||
#include <QtDebug>
|
||||
|
@ -128,6 +129,12 @@ QList<const QMetaObject*> Bitstream::getMetaObjectSubClasses(const QMetaObject*
|
|||
return getMetaObjectSubClasses().values(metaObject);
|
||||
}
|
||||
|
||||
void Bitstream::configureScriptEngine(QScriptEngine* engine) {
|
||||
foreach (const QMetaObject* metaObject, getMetaObjects()) {
|
||||
engine->globalObject().setProperty(metaObject->className(), engine->newQMetaObject(metaObject));
|
||||
}
|
||||
}
|
||||
|
||||
Bitstream::Bitstream(QDataStream& underlying, MetadataType metadataType, GenericsMode genericsMode, QObject* parent) :
|
||||
QObject(parent),
|
||||
_underlying(underlying),
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
class QByteArray;
|
||||
class QColor;
|
||||
class QDataStream;
|
||||
class QScriptEngine;
|
||||
class QScriptValue;
|
||||
class QUrl;
|
||||
|
||||
|
@ -320,6 +321,10 @@ public:
|
|||
/// subclasses.
|
||||
static QList<const QMetaObject*> getMetaObjectSubClasses(const QMetaObject* metaObject);
|
||||
|
||||
/// Configures the supplied script engine with our registered meta-objects, allowing all of them to be instantiated from
|
||||
/// scripts.
|
||||
static void configureScriptEngine(QScriptEngine* engine);
|
||||
|
||||
enum MetadataType { NO_METADATA, HASH_METADATA, FULL_METADATA };
|
||||
|
||||
enum GenericsMode { NO_GENERICS, FALLBACK_GENERICS, ALL_GENERICS };
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QThread>
|
||||
|
||||
#include "MetavoxelClientManager.h"
|
||||
#include "MetavoxelMessages.h"
|
||||
|
||||
|
@ -53,7 +55,24 @@ SharedObjectPointer MetavoxelClientManager::findFirstRaySpannerIntersection(cons
|
|||
return closestSpanner;
|
||||
}
|
||||
|
||||
void MetavoxelClientManager::setSphere(const glm::vec3& center, float radius, QRgb color) {
|
||||
Sphere* sphere = new Sphere();
|
||||
sphere->setTranslation(center);
|
||||
sphere->setScale(radius);
|
||||
sphere->setColor(color);
|
||||
setSpanner(sphere);
|
||||
}
|
||||
|
||||
void MetavoxelClientManager::setSpanner(const SharedObjectPointer& object, bool reliable) {
|
||||
MetavoxelEditMessage edit = { QVariant::fromValue(SetSpannerEdit(object)) };
|
||||
applyEdit(edit, reliable);
|
||||
}
|
||||
|
||||
void MetavoxelClientManager::applyEdit(const MetavoxelEditMessage& edit, bool reliable) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "applyEdit", Q_ARG(const MetavoxelEditMessage&, edit), Q_ARG(bool, reliable));
|
||||
return;
|
||||
}
|
||||
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
||||
if (node->getType() == NodeType::MetavoxelServer) {
|
||||
QMutexLocker locker(&node->getMutex());
|
||||
|
|
|
@ -28,6 +28,10 @@ public:
|
|||
|
||||
SharedObjectPointer findFirstRaySpannerIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
const AttributePointer& attribute, float& distance);
|
||||
|
||||
Q_INVOKABLE void setSphere(const glm::vec3& center, float radius, QRgb color = 0x808080);
|
||||
|
||||
Q_INVOKABLE void setSpanner(const SharedObjectPointer& object, bool reliable = false);
|
||||
|
||||
Q_INVOKABLE void applyEdit(const MetavoxelEditMessage& edit, bool reliable = false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue