diff --git a/VoxelScriptingInterface.cpp b/VoxelScriptingInterface.cpp new file mode 100644 index 0000000000..901bb06750 --- /dev/null +++ b/VoxelScriptingInterface.cpp @@ -0,0 +1,9 @@ +// +// VoxelScriptingInterface.cpp +// hifi +// +// Created by Stephen Birarda on 9/17/13. +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// + +#include "VoxelScriptingInterface.h" diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 1315b0ce84..f1a8566af3 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -23,4 +23,5 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR}) \ No newline at end of file +link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_library(voxels ${TARGET_NAME} ${ROOT_DIR}) \ No newline at end of file diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 3b56a6b0b7..147314ab9d 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -9,11 +9,11 @@ #include #include +#include #include -#include "AvatarData.h" - #include "Agent.h" +#include "VoxelScriptingInterface.h" Agent::Agent() : _shouldStop(false) @@ -39,14 +39,13 @@ void Agent::run(QUrl scriptURL) { QScriptEngine engine; - AvatarData *testAvatarData = new AvatarData; - - QScriptValue avatarDataValue = engine.newQObject(testAvatarData); - engine.globalObject().setProperty("Avatar", avatarDataValue); - QScriptValue agentValue = engine.newQObject(this); engine.globalObject().setProperty("Agent", agentValue); + VoxelScriptingInterface voxelScripter; + QScriptValue voxelScripterValue = engine.newQObject(&voxelScripter); + engine.globalObject().setProperty("Voxels", voxelScripterValue); + qDebug() << "Downloaded script:" << scriptString << "\n"; qDebug() << "Evaluated script:" << engine.evaluate(scriptString).toString() << "\n"; @@ -75,9 +74,10 @@ void Agent::run(QUrl scriptURL) { NodeList::getInstance()->sendDomainServerCheckIn(); } + // allow the scripter's call back to setup visual data emit preSendCallback(); - - testAvatarData->sendData(); + // flush the voxel packet queue + voxelScripter.getVoxelPacketSender()->flushQueue(); if (NodeList::getInstance()->getNodeSocket()->receive((sockaddr*) &senderAddress, receivedData, &receivedBytes)) { NodeList::getInstance()->processNodeData((sockaddr*) &senderAddress, receivedData, receivedBytes); diff --git a/assignment-client/src/VoxelScriptingInterface.cpp b/assignment-client/src/VoxelScriptingInterface.cpp new file mode 100644 index 0000000000..9dce6a7c11 --- /dev/null +++ b/assignment-client/src/VoxelScriptingInterface.cpp @@ -0,0 +1,15 @@ +// +// VoxelScriptingInterface.cpp +// hifi +// +// Created by Stephen Birarda on 9/17/13. +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// + +#include "VoxelScriptingInterface.h" + +void VoxelScriptingInterface::queueVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue) { + // setup a VoxelDetail struct with the data + VoxelDetail addVoxelDetail = {x, y, z, scale, red, green, blue}; + _voxelPacketSender.queueVoxelEditMessages(PACKET_TYPE_SET_VOXEL, 1, &addVoxelDetail); +} diff --git a/assignment-client/src/VoxelScriptingInterface.h b/assignment-client/src/VoxelScriptingInterface.h new file mode 100644 index 0000000000..e78dce5ff1 --- /dev/null +++ b/assignment-client/src/VoxelScriptingInterface.h @@ -0,0 +1,26 @@ +// +// VoxelScriptingInterface.h +// hifi +// +// Created by Stephen Birarda on 9/17/13. +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. +// + +#ifndef __hifi__VoxelScriptingInterface__ +#define __hifi__VoxelScriptingInterface__ + +#include + +#include + +class VoxelScriptingInterface : public QObject { + Q_OBJECT +public: + VoxelEditPacketSender* getVoxelPacketSender() { return &_voxelPacketSender; } +public slots: + void queueVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue); +private: + VoxelEditPacketSender _voxelPacketSender; +}; + +#endif /* defined(__hifi__VoxelScriptingInterface__) */