mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge pull request #832 from birarda/assignee
tweaks to assignment server and AvatarData for assignment to iOS
This commit is contained in:
commit
7e5f03a36f
16 changed files with 102 additions and 23 deletions
|
@ -10,13 +10,17 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <UDPSocket.h>
|
#include <UDPSocket.h>
|
||||||
|
|
||||||
const int MAX_PACKET_SIZE_BYTES = 1400;
|
const int MAX_PACKET_SIZE_BYTES = 1400;
|
||||||
|
|
||||||
struct Assignment {};
|
struct Assignment {
|
||||||
|
QString scriptFilename;
|
||||||
|
};
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
|
@ -29,27 +33,46 @@ int main(int argc, const char* argv[]) {
|
||||||
UDPSocket serverSocket(ASSIGNMENT_SERVER_PORT);
|
UDPSocket serverSocket(ASSIGNMENT_SERVER_PORT);
|
||||||
|
|
||||||
int numHeaderBytes = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_SEND_ASSIGNMENT);
|
int numHeaderBytes = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_SEND_ASSIGNMENT);
|
||||||
unsigned char assignmentPacket[numHeaderBytes + sizeof(char)];
|
unsigned char assignmentPacket[MAX_PACKET_SIZE_BYTES];
|
||||||
populateTypeAndVersion(assignmentPacket, PACKET_TYPE_SEND_ASSIGNMENT);
|
populateTypeAndVersion(assignmentPacket, PACKET_TYPE_SEND_ASSIGNMENT);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (serverSocket.receive((sockaddr*) &senderSocket, &senderData, &receivedBytes)) {
|
if (serverSocket.receive((sockaddr*) &senderSocket, &senderData, &receivedBytes)) {
|
||||||
|
|
||||||
// int numHeaderBytes = numBytesForPacketHeader(senderData);
|
int numHeaderBytes = numBytesForPacketHeader(senderData);
|
||||||
|
|
||||||
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
||||||
|
qDebug() << "Assignment request received.\n";
|
||||||
// grab the FI assignment in the queue, if it exists
|
// grab the FI assignment in the queue, if it exists
|
||||||
if (assignmentQueue.size() > 0) {
|
if (assignmentQueue.size() > 0) {
|
||||||
// Assignment firstAssignment = assignmentQueue.front();
|
Assignment firstAssignment = assignmentQueue.front();
|
||||||
assignmentQueue.pop();
|
assignmentQueue.pop();
|
||||||
|
|
||||||
|
QString scriptURL = QString("http://base8-compute.s3.amazonaws.com/%1").arg(firstAssignment.scriptFilename);
|
||||||
|
|
||||||
|
qDebug() << "Sending assignment with URL" << scriptURL << "\n";
|
||||||
|
|
||||||
|
int scriptURLBytes = scriptURL.size();
|
||||||
|
memcpy(assignmentPacket + numHeaderBytes, scriptURL.toLocal8Bit().constData(), scriptURLBytes);
|
||||||
|
|
||||||
// send the assignment
|
// send the assignment
|
||||||
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, sizeof(assignmentPacket));
|
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, numHeaderBytes + scriptURLBytes);
|
||||||
}
|
}
|
||||||
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT) {
|
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT) {
|
||||||
Assignment newAssignment;
|
Assignment newAssignment;
|
||||||
|
|
||||||
|
senderData[receivedBytes] = '\0';
|
||||||
|
newAssignment.scriptFilename = QString((const char*)senderData + numHeaderBytes);
|
||||||
|
|
||||||
|
qDebug() << "Added an assignment with script with filename" << newAssignment.scriptFilename << "\n";
|
||||||
|
|
||||||
// add this assignment to the queue
|
// add this assignment to the queue
|
||||||
|
|
||||||
|
// we're not a queue right now, only keep one assignment
|
||||||
|
if (assignmentQueue.size() > 0) {
|
||||||
|
assignmentQueue.pop();
|
||||||
|
}
|
||||||
|
|
||||||
assignmentQueue.push(newAssignment);
|
assignmentQueue.push(newAssignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,11 @@ Pod::Spec.new do |s|
|
||||||
sp.dependency 'glm'
|
sp.dependency 'glm'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
s.subspec "voxels" do |sp|
|
||||||
|
sp.source_files = 'libraries/voxels/src', 'libraries/voxels/moc_*'
|
||||||
|
sp.dependency 'glm'
|
||||||
|
end
|
||||||
|
|
||||||
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/../../qt5-device/qtbase/include' }
|
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/../../qt5-device/qtbase/include' }
|
||||||
s.libraries = 'libQtCoreCombined', 'libQt5Network', 'libQt5Script'
|
s.libraries = 'libQtCoreCombined', 'libQt5Network', 'libQt5Script'
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ void Agent::run(QUrl scriptURL) {
|
||||||
AvatarData *testAvatarData = new AvatarData;
|
AvatarData *testAvatarData = new AvatarData;
|
||||||
|
|
||||||
QScriptValue avatarDataValue = engine.newQObject(testAvatarData);
|
QScriptValue avatarDataValue = engine.newQObject(testAvatarData);
|
||||||
engine.globalObject().setProperty("AvatarData", avatarDataValue);
|
engine.globalObject().setProperty("Avatar", avatarDataValue);
|
||||||
|
|
||||||
QScriptValue agentValue = engine.newQObject(this);
|
QScriptValue agentValue = engine.newQObject(this);
|
||||||
engine.globalObject().setProperty("Agent", agentValue);
|
engine.globalObject().setProperty("Agent", agentValue);
|
||||||
|
@ -55,7 +55,7 @@ void Agent::run(QUrl scriptURL) {
|
||||||
timeval lastDomainServerCheckIn = {};
|
timeval lastDomainServerCheckIn = {};
|
||||||
int numMicrosecondsSleep = 0;
|
int numMicrosecondsSleep = 0;
|
||||||
|
|
||||||
const float DATA_SEND_INTERVAL_USECS = (1 / 60) * 1000 * 1000;
|
const float DATA_SEND_INTERVAL_USECS = (1 / 60.0f) * 1000 * 1000;
|
||||||
|
|
||||||
sockaddr_in senderAddress;
|
sockaddr_in senderAddress;
|
||||||
unsigned char receivedData[MAX_PACKET_SIZE];
|
unsigned char receivedData[MAX_PACKET_SIZE];
|
||||||
|
|
|
@ -52,6 +52,38 @@ AvatarData::~AvatarData() {
|
||||||
delete _handData;
|
delete _handData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AvatarData::setPositionFromVariantMap(QVariantMap positionMap) {
|
||||||
|
_position = glm::vec3(positionMap.value("x").toFloat(),
|
||||||
|
positionMap.value("y").toFloat(),
|
||||||
|
positionMap.value("z").toFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap AvatarData::getPositionVariantMap() {
|
||||||
|
QVariantMap positionMap;
|
||||||
|
|
||||||
|
positionMap.insert("x", _position.x);
|
||||||
|
positionMap.insert("y", _position.y);
|
||||||
|
positionMap.insert("z", _position.z);
|
||||||
|
|
||||||
|
return positionMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarData::setHandPositionFromVariantMap(QVariantMap handPositionMap) {
|
||||||
|
_handPosition = glm::vec3(handPositionMap.value("x").toFloat(),
|
||||||
|
handPositionMap.value("y").toFloat(),
|
||||||
|
handPositionMap.value("z").toFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap AvatarData::getHandPositionVariantMap() {
|
||||||
|
QVariantMap positionMap;
|
||||||
|
|
||||||
|
positionMap.insert("x", _handPosition.x);
|
||||||
|
positionMap.insert("y", _handPosition.y);
|
||||||
|
positionMap.insert("z", _handPosition.z);
|
||||||
|
|
||||||
|
return positionMap;
|
||||||
|
}
|
||||||
|
|
||||||
void AvatarData::sendData() {
|
void AvatarData::sendData() {
|
||||||
|
|
||||||
// called from Agent visual loop to send data
|
// called from Agent visual loop to send data
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QVariantMap>
|
||||||
|
|
||||||
#include <NodeData.h>
|
#include <NodeData.h>
|
||||||
#include "HeadData.h"
|
#include "HeadData.h"
|
||||||
|
@ -41,7 +42,14 @@ enum KeyState
|
||||||
class JointData;
|
class JointData;
|
||||||
|
|
||||||
class AvatarData : public NodeData {
|
class AvatarData : public NodeData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QVariantMap position READ getPositionVariantMap WRITE setPositionFromVariantMap)
|
||||||
|
Q_PROPERTY(QVariantMap handPosition READ getHandPositionVariantMap WRITE setHandPositionFromVariantMap)
|
||||||
|
Q_PROPERTY(float bodyYaw READ getBodyYaw WRITE setBodyYaw)
|
||||||
|
Q_PROPERTY(float bodyPitch READ getBodyPitch WRITE setBodyPitch)
|
||||||
|
Q_PROPERTY(float bodyRoll READ getBodyRoll WRITE setBodyRoll)
|
||||||
|
Q_PROPERTY(QString chatMessage READ getQStringChatMessage WRITE setChatMessage)
|
||||||
public:
|
public:
|
||||||
AvatarData(Node* owningNode = NULL);
|
AvatarData(Node* owningNode = NULL);
|
||||||
~AvatarData();
|
~AvatarData();
|
||||||
|
@ -51,15 +59,23 @@ public:
|
||||||
void setPosition (const glm::vec3 position ) { _position = position; }
|
void setPosition (const glm::vec3 position ) { _position = position; }
|
||||||
void setHandPosition (const glm::vec3 handPosition ) { _handPosition = handPosition; }
|
void setHandPosition (const glm::vec3 handPosition ) { _handPosition = handPosition; }
|
||||||
|
|
||||||
|
void setPositionFromVariantMap(QVariantMap positionMap);
|
||||||
|
QVariantMap getPositionVariantMap();
|
||||||
|
|
||||||
|
void setHandPositionFromVariantMap(QVariantMap handPositionMap);
|
||||||
|
QVariantMap getHandPositionVariantMap();
|
||||||
|
|
||||||
int getBroadcastData(unsigned char* destinationBuffer);
|
int getBroadcastData(unsigned char* destinationBuffer);
|
||||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||||
|
|
||||||
// Body Rotation
|
// Body Rotation
|
||||||
float getBodyYaw() const { return _bodyYaw; }
|
float getBodyYaw() const { return _bodyYaw; }
|
||||||
|
void setBodyYaw(float bodyYaw) { _bodyYaw = bodyYaw; }
|
||||||
float getBodyPitch() const { return _bodyPitch; }
|
float getBodyPitch() const { return _bodyPitch; }
|
||||||
void setBodyPitch(float bodyPitch) { _bodyPitch = bodyPitch; }
|
void setBodyPitch(float bodyPitch) { _bodyPitch = bodyPitch; }
|
||||||
float getBodyRoll() const {return _bodyRoll; }
|
float getBodyRoll() const {return _bodyRoll; }
|
||||||
void setBodyRoll(float bodyRoll) { _bodyRoll = bodyRoll; }
|
void setBodyRoll(float bodyRoll) { _bodyRoll = bodyRoll; }
|
||||||
|
|
||||||
|
|
||||||
// Hand State
|
// Hand State
|
||||||
void setHandState(char s) { _handState = s; };
|
void setHandState(char s) { _handState = s; };
|
||||||
|
@ -89,7 +105,9 @@ public:
|
||||||
|
|
||||||
// chat message
|
// chat message
|
||||||
void setChatMessage(const std::string& msg) { _chatMessage = msg; }
|
void setChatMessage(const std::string& msg) { _chatMessage = msg; }
|
||||||
const std::string& chatMessage () const { return _chatMessage; }
|
void setChatMessage(const QString& string) { _chatMessage = string.toLocal8Bit().constData(); }
|
||||||
|
const std::string& setChatMessage() const { return _chatMessage; }
|
||||||
|
QString getQStringChatMessage() { return QString(_chatMessage.data()); }
|
||||||
|
|
||||||
// related to Voxel Sending strategies
|
// related to Voxel Sending strategies
|
||||||
bool getWantColor() const { return _wantColor; }
|
bool getWantColor() const { return _wantColor; }
|
||||||
|
@ -107,8 +125,6 @@ public:
|
||||||
void setHandData(HandData* handData) { _handData = handData; }
|
void setHandData(HandData* handData) { _handData = handData; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPosition(float x, float y, float z) { _position = glm::vec3(x, y, z); }
|
|
||||||
void setBodyYaw(float bodyYaw) { _bodyYaw = bodyYaw; }
|
|
||||||
void sendData();
|
void sendData();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -94,6 +94,8 @@ const char* Node::getTypeName() const {
|
||||||
return NODE_TYPE_NAME_AUDIO_INJECTOR;
|
return NODE_TYPE_NAME_AUDIO_INJECTOR;
|
||||||
case NODE_TYPE_ANIMATION_SERVER:
|
case NODE_TYPE_ANIMATION_SERVER:
|
||||||
return NODE_TYPE_NAME_ANIMATION_SERVER;
|
return NODE_TYPE_NAME_ANIMATION_SERVER;
|
||||||
|
case NODE_TYPE_UNASSIGNED:
|
||||||
|
return NODE_TYPE_NAME_UNASSIGNED;
|
||||||
default:
|
default:
|
||||||
return NODE_TYPE_NAME_UNKNOWN;
|
return NODE_TYPE_NAME_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,5 +24,6 @@ const NODE_TYPE NODE_TYPE_AUDIO_MIXER = 'M';
|
||||||
const NODE_TYPE NODE_TYPE_AVATAR_MIXER = 'W';
|
const NODE_TYPE NODE_TYPE_AVATAR_MIXER = 'W';
|
||||||
const NODE_TYPE NODE_TYPE_AUDIO_INJECTOR = 'A';
|
const NODE_TYPE NODE_TYPE_AUDIO_INJECTOR = 'A';
|
||||||
const NODE_TYPE NODE_TYPE_ANIMATION_SERVER = 'a';
|
const NODE_TYPE NODE_TYPE_ANIMATION_SERVER = 'a';
|
||||||
|
const NODE_TYPE NODE_TYPE_UNASSIGNED = 1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QString>
|
#include <QtCore/QString>
|
||||||
#include <QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
#include "JurisdictionMap.h"
|
#include "JurisdictionMap.h"
|
||||||
#include "VoxelNode.h"
|
#include "VoxelNode.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define __hifi__JurisdictionMap__
|
#define __hifi__JurisdictionMap__
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
class JurisdictionMap {
|
class JurisdictionMap {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include <glm/gtx/transform.hpp>
|
#include <glm/gtx/transform.hpp>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include "CoverageMap.h"
|
#include "CoverageMap.h"
|
||||||
#include "GeometryUtil.h"
|
#include "GeometryUtil.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include "GeometryUtil.h"
|
#include "GeometryUtil.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include <glm/gtc/noise.hpp>
|
#include <glm/gtc/noise.hpp>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include "CoverageMap.h"
|
#include "CoverageMap.h"
|
||||||
#include "GeometryUtil.h"
|
#include "GeometryUtil.h"
|
||||||
|
|
Loading…
Reference in a new issue