mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 21:18:54 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into authentication
This commit is contained in:
commit
c1b45d7eaa
7 changed files with 209 additions and 49 deletions
|
@ -689,42 +689,47 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
// this is a script upload - ask the HTTPConnection to parse the form data
|
// this is a script upload - ask the HTTPConnection to parse the form data
|
||||||
QList<FormData> formData = connection->parseFormData();
|
QList<FormData> formData = connection->parseFormData();
|
||||||
|
|
||||||
// create an assignment for this saved script
|
|
||||||
Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType);
|
|
||||||
|
|
||||||
// check how many instances of this assignment the user wants by checking the ASSIGNMENT-INSTANCES header
|
// check how many instances of this assignment the user wants by checking the ASSIGNMENT-INSTANCES header
|
||||||
const QString ASSIGNMENT_INSTANCES_HEADER = "ASSIGNMENT-INSTANCES";
|
const QString ASSIGNMENT_INSTANCES_HEADER = "ASSIGNMENT-INSTANCES";
|
||||||
|
|
||||||
QByteArray assignmentInstancesValue = connection->requestHeaders().value(ASSIGNMENT_INSTANCES_HEADER.toLocal8Bit());
|
QByteArray assignmentInstancesValue = connection->requestHeaders().value(ASSIGNMENT_INSTANCES_HEADER.toLocal8Bit());
|
||||||
|
|
||||||
|
int numInstances = 1;
|
||||||
|
|
||||||
if (!assignmentInstancesValue.isEmpty()) {
|
if (!assignmentInstancesValue.isEmpty()) {
|
||||||
// the user has requested a specific number of instances
|
// the user has requested a specific number of instances
|
||||||
// so set that on the created assignment
|
// so set that on the created assignment
|
||||||
int numInstances = assignmentInstancesValue.toInt();
|
|
||||||
if (numInstances > 0) {
|
numInstances = assignmentInstancesValue.toInt();
|
||||||
qDebug() << numInstances;
|
|
||||||
scriptAssignment->setNumberOfInstances(numInstances);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment";
|
const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment";
|
||||||
|
|
||||||
QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION);
|
for (int i = 0; i < numInstances; i++) {
|
||||||
newPath += "/";
|
|
||||||
// append the UUID for this script as the new filename, remove the curly braces
|
|
||||||
newPath += uuidStringWithoutCurlyBraces(scriptAssignment->getUUID());
|
|
||||||
|
|
||||||
// create a file with the GUID of the assignment in the script host locaiton
|
// create an assignment for this saved script
|
||||||
QFile scriptFile(newPath);
|
Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType);
|
||||||
scriptFile.open(QIODevice::WriteOnly);
|
|
||||||
scriptFile.write(formData[0].second);
|
|
||||||
|
|
||||||
qDebug("Saved a script for assignment at %s", qPrintable(newPath));
|
QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION);
|
||||||
|
newPath += "/";
|
||||||
|
// append the UUID for this script as the new filename, remove the curly braces
|
||||||
|
newPath += uuidStringWithoutCurlyBraces(scriptAssignment->getUUID());
|
||||||
|
|
||||||
|
// create a file with the GUID of the assignment in the script host locaiton
|
||||||
|
QFile scriptFile(newPath);
|
||||||
|
scriptFile.open(QIODevice::WriteOnly);
|
||||||
|
scriptFile.write(formData[0].second);
|
||||||
|
|
||||||
|
qDebug("Saved a script for assignment at %s", qPrintable(newPath));
|
||||||
|
|
||||||
|
// add the script assigment to the assignment queue
|
||||||
|
_assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment));
|
||||||
|
}
|
||||||
|
|
||||||
// respond with a 200 code for successful upload
|
// respond with a 200 code for successful upload
|
||||||
connection->respond(HTTPConnection::StatusCode200);
|
connection->respond(HTTPConnection::StatusCode200);
|
||||||
|
|
||||||
// add the script assigment to the assignment queue
|
|
||||||
_assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment));
|
|
||||||
}
|
}
|
||||||
} else if (connection->requestOperation() == QNetworkAccessManager::DeleteOperation) {
|
} else if (connection->requestOperation() == QNetworkAccessManager::DeleteOperation) {
|
||||||
if (path.startsWith(URI_NODE)) {
|
if (path.startsWith(URI_NODE)) {
|
||||||
|
@ -834,14 +839,7 @@ SharedAssignmentPointer DomainServer::deployableAssignmentForRequest(const Assig
|
||||||
|
|
||||||
if (assignment->getType() == Assignment::AgentType) {
|
if (assignment->getType() == Assignment::AgentType) {
|
||||||
// if there is more than one instance to send out, simply decrease the number of instances
|
// if there is more than one instance to send out, simply decrease the number of instances
|
||||||
|
return _assignmentQueue.takeAt(sharedAssignment - _assignmentQueue.begin());
|
||||||
if (assignment->getNumberOfInstances() == 1) {
|
|
||||||
return _assignmentQueue.takeAt(sharedAssignment - _assignmentQueue.begin());
|
|
||||||
} else {
|
|
||||||
assignment->decrementNumberOfInstances();
|
|
||||||
return *sharedAssignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// remove the assignment from the queue
|
// remove the assignment from the queue
|
||||||
SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment
|
SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment
|
||||||
|
|
|
@ -18,8 +18,8 @@ function getRandomInt (min, max) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// choose a random x and y in the range of 0 to 50
|
// choose a random x and y in the range of 0 to 50
|
||||||
positionX = getRandomFloat(0, 50);
|
positionX = getRandomFloat(0, 18);
|
||||||
positionZ = getRandomFloat(0, 50);
|
positionZ = getRandomFloat(0, 18);
|
||||||
|
|
||||||
// change the avatar's position to the random one
|
// change the avatar's position to the random one
|
||||||
Avatar.position = {x: positionX, y: 0, z: positionZ};
|
Avatar.position = {x: positionX, y: 0, z: positionZ};
|
||||||
|
@ -49,6 +49,6 @@ if (botNumber <= 20) {
|
||||||
// set the face model fst using the bot number
|
// set the face model fst using the bot number
|
||||||
// there is no need to change the body model - we're using the default
|
// there is no need to change the body model - we're using the default
|
||||||
Avatar.faceModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/meshes/" + newFaceFilePrefix + ".fst";
|
Avatar.faceModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/meshes/" + newFaceFilePrefix + ".fst";
|
||||||
Avatar.bodyModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/meshes/" + newBodyFilePrefix + ".fst";
|
Avatar.skeletonModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/meshes/" + newBodyFilePrefix + ".fst";
|
||||||
|
|
||||||
Agent.isAvatar = true;
|
Agent.isAvatar = true;
|
173
examples/ribbon.js
Normal file
173
examples/ribbon.js
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
//
|
||||||
|
// ribbon.js
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 2/24/14.
|
||||||
|
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
function vectorMultiply(vector, scalar) {
|
||||||
|
return [ vector[0] * scalar, vector[1] * scalar, vector[2] * scalar ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorAdd(firstVector, secondVector) {
|
||||||
|
return [ firstVector[0] + secondVector[0], firstVector[1] + secondVector[1], firstVector[2] + secondVector[2] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorSubtract(firstVector, secondVector) {
|
||||||
|
return [ firstVector[0] - secondVector[0], firstVector[1] - secondVector[1], firstVector[2] - secondVector[2] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorCross(firstVector, secondVector) {
|
||||||
|
return [ firstVector[1] * secondVector[2] - firstVector[2] * secondVector[1],
|
||||||
|
firstVector[2] * secondVector[0] - firstVector[0] * secondVector[2],
|
||||||
|
firstVector[0] * secondVector[1] - firstVector[1] * secondVector[0] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorLength(vector) {
|
||||||
|
return Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1] + vector[2] * vector[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorNormalize(vector) {
|
||||||
|
return vectorMultiply(vector, 1.0 / vectorLength(vector));
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorClone(vector) {
|
||||||
|
return [ vector[0], vector[1], vector[2] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function mix(first, second, amount) {
|
||||||
|
return first + (second - first) * amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vectorMix(firstVector, secondVector, amount) {
|
||||||
|
return vectorAdd(firstVector, vectorMultiply(vectorSubtract(secondVector, firstVector), amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomVector(minVector, maxVector) {
|
||||||
|
return [ mix(minVector[0], maxVector[0], Math.random()), mix(minVector[1], maxVector[1], Math.random()),
|
||||||
|
mix(minVector[2], maxVector[2], Math.random()) ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyToLine(start, end, granularity, fn) {
|
||||||
|
// determine the number of steps from the maximum length
|
||||||
|
var steps = Math.max(
|
||||||
|
Math.abs(Math.floor(start[0] / granularity) - Math.floor(end[0] / granularity)),
|
||||||
|
Math.abs(Math.floor(start[1] / granularity) - Math.floor(end[1] / granularity)),
|
||||||
|
Math.abs(Math.floor(start[2] / granularity) - Math.floor(end[2] / granularity)));
|
||||||
|
var position = vectorClone(start);
|
||||||
|
var increment = vectorMultiply(vectorSubtract(end, start), 1.0 / steps);
|
||||||
|
for (var i = 0; i <= steps; i++) {
|
||||||
|
fn(granularity * Math.floor(position[0] / granularity),
|
||||||
|
granularity * Math.floor(position[1] / granularity),
|
||||||
|
granularity * Math.floor(position[2] / granularity),
|
||||||
|
granularity);
|
||||||
|
position = vectorAdd(position, increment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLine(start, end, color, granularity) {
|
||||||
|
applyToLine(start, end, granularity, function(x, y, z, scale) {
|
||||||
|
Voxels.setVoxel(x, y, z, scale, color[0], color[1], color[2]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function eraseLine(start, end, granularity) {
|
||||||
|
applyToLine(start, end, granularity, function(x, y, z, scale) {
|
||||||
|
Voxels.eraseVoxel(x, y, z, scale);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHueColor(hue) {
|
||||||
|
// see http://en.wikipedia.org/wiki/HSL_and_HSV
|
||||||
|
var hPrime = hue / 60.0;
|
||||||
|
var x = Math.floor(255.0 * (1.0 - Math.abs(hPrime % 2.0 - 1.0)));
|
||||||
|
if (hPrime < 1) {
|
||||||
|
return [255, x, 0];
|
||||||
|
|
||||||
|
} else if (hPrime < 2) {
|
||||||
|
return [x, 255, 0];
|
||||||
|
|
||||||
|
} else if (hPrime < 3) {
|
||||||
|
return [0, 255, x];
|
||||||
|
|
||||||
|
} else if (hPrime < 4) {
|
||||||
|
return [0, x, 255];
|
||||||
|
|
||||||
|
} else if (hPrime < 5) {
|
||||||
|
return [x, 0, 255];
|
||||||
|
|
||||||
|
} else { // hPrime < 6
|
||||||
|
return [255, 0, x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var UNIT_MIN = [-1.0, -1.0, -1.0];
|
||||||
|
var UNIT_MAX = [1.0, 1.0, 1.0];
|
||||||
|
|
||||||
|
var EPSILON = 0.00001;
|
||||||
|
|
||||||
|
var BOUNDS_MIN = [5.0, 0.0, 5.0];
|
||||||
|
var BOUNDS_MAX = [15.0, 10.0, 15.0];
|
||||||
|
|
||||||
|
var GRANULARITY = 1.0 / 16.0;
|
||||||
|
|
||||||
|
var WIDTH = 0.5;
|
||||||
|
|
||||||
|
var HISTORY_LENGTH = 300;
|
||||||
|
|
||||||
|
var stateHistory = [];
|
||||||
|
var position;
|
||||||
|
var velocity;
|
||||||
|
var hueAngle = 0;
|
||||||
|
var smoothedOffset;
|
||||||
|
|
||||||
|
function step() {
|
||||||
|
if (stateHistory.length === 0) {
|
||||||
|
// start at a random position within the bounds, with a random velocity
|
||||||
|
position = randomVector(BOUNDS_MIN, BOUNDS_MAX);
|
||||||
|
do {
|
||||||
|
velocity = randomVector(UNIT_MIN, UNIT_MAX);
|
||||||
|
} while (vectorLength(velocity) < EPSILON);
|
||||||
|
velocity = vectorMultiply(velocity, GRANULARITY * 0.5 / vectorLength(velocity));
|
||||||
|
smoothedOffset = [0.0, 0.0, 0.0];
|
||||||
|
}
|
||||||
|
|
||||||
|
var right = vectorCross(velocity, [0.0, 1.0, 0.0]);
|
||||||
|
if (vectorLength(right) < EPSILON) {
|
||||||
|
right = [1.0, 0.0, 0.0];
|
||||||
|
} else {
|
||||||
|
right = vectorNormalize(right);
|
||||||
|
}
|
||||||
|
var up = vectorNormalize(vectorCross(right, velocity));
|
||||||
|
var ANGULAR_SPEED = 2.0;
|
||||||
|
var radians = hueAngle * Math.PI * ANGULAR_SPEED / 180.0;
|
||||||
|
var offset = vectorAdd(vectorMultiply(right, WIDTH * Math.cos(radians)), vectorMultiply(up, WIDTH * Math.sin(radians)));
|
||||||
|
var OFFSET_SMOOTHING = 0.9;
|
||||||
|
smoothedOffset = vectorMix(offset, smoothedOffset, OFFSET_SMOOTHING);
|
||||||
|
|
||||||
|
var state = { start: vectorAdd(position, smoothedOffset), end: vectorSubtract(position, smoothedOffset) };
|
||||||
|
drawLine(state.start, state.end, getHueColor(hueAngle), GRANULARITY);
|
||||||
|
stateHistory.push(state);
|
||||||
|
if (stateHistory.length > HISTORY_LENGTH) {
|
||||||
|
var last = stateHistory.shift();
|
||||||
|
eraseLine(last.start, last.end, GRANULARITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update position, check against bounds
|
||||||
|
position = vectorAdd(position, velocity);
|
||||||
|
for (var i = 0; i < 3; i++) {
|
||||||
|
if (position[i] < BOUNDS_MIN[i]) {
|
||||||
|
velocity[i] = -velocity[i];
|
||||||
|
position[i] += 2.0 * (BOUNDS_MIN[i] - position[i]);
|
||||||
|
|
||||||
|
} else if (position[i] > BOUNDS_MAX[i]) {
|
||||||
|
velocity[i] = -velocity[i];
|
||||||
|
position[i] += 2.0 * (BOUNDS_MAX[i] - position[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var MAX_HUE_ANGLE = 360;
|
||||||
|
hueAngle = (hueAngle + 1) % MAX_HUE_ANGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.willSendVisualDataCallback.connect(step);
|
|
@ -171,6 +171,8 @@ protected:
|
||||||
float getPelvisFloatingHeight() const;
|
float getPelvisFloatingHeight() const;
|
||||||
float getPelvisToHeadLength() const;
|
float getPelvisToHeadLength() const;
|
||||||
|
|
||||||
|
void renderDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool _initialized;
|
bool _initialized;
|
||||||
|
@ -178,8 +180,6 @@ private:
|
||||||
|
|
||||||
void renderBody();
|
void renderBody();
|
||||||
void renderBillboard();
|
void renderBillboard();
|
||||||
|
|
||||||
void renderDisplayName();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -463,8 +463,8 @@ void MyAvatar::render(bool forceRenderHead) {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
|
||||||
renderBody(forceRenderHead);
|
renderBody(forceRenderHead);
|
||||||
}
|
}
|
||||||
|
setShowDisplayName(true);
|
||||||
//renderDebugBodyPoints();
|
renderDisplayName();
|
||||||
|
|
||||||
if (!_chatMessage.empty()) {
|
if (!_chatMessage.empty()) {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
|
@ -45,7 +45,6 @@ Assignment::Assignment() :
|
||||||
_type(Assignment::AllTypes),
|
_type(Assignment::AllTypes),
|
||||||
_pool(),
|
_pool(),
|
||||||
_location(Assignment::LocalLocation),
|
_location(Assignment::LocalLocation),
|
||||||
_numberOfInstances(1),
|
|
||||||
_payload()
|
_payload()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
|
||||||
_type(type),
|
_type(type),
|
||||||
_pool(pool),
|
_pool(pool),
|
||||||
_location(location),
|
_location(location),
|
||||||
_numberOfInstances(1),
|
|
||||||
_payload()
|
_payload()
|
||||||
{
|
{
|
||||||
if (_command == Assignment::CreateCommand) {
|
if (_command == Assignment::CreateCommand) {
|
||||||
|
@ -69,7 +67,6 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
|
||||||
Assignment::Assignment(const QByteArray& packet) :
|
Assignment::Assignment(const QByteArray& packet) :
|
||||||
_pool(),
|
_pool(),
|
||||||
_location(GlobalLocation),
|
_location(GlobalLocation),
|
||||||
_numberOfInstances(1),
|
|
||||||
_payload()
|
_payload()
|
||||||
{
|
{
|
||||||
PacketType packetType = packetTypeForPacket(packet);
|
PacketType packetType = packetTypeForPacket(packet);
|
||||||
|
@ -99,7 +96,6 @@ Assignment::Assignment(const Assignment& otherAssignment) {
|
||||||
_type = otherAssignment._type;
|
_type = otherAssignment._type;
|
||||||
_location = otherAssignment._location;
|
_location = otherAssignment._location;
|
||||||
_pool = otherAssignment._pool;
|
_pool = otherAssignment._pool;
|
||||||
_numberOfInstances = otherAssignment._numberOfInstances;
|
|
||||||
_payload = otherAssignment._payload;
|
_payload = otherAssignment._payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +113,6 @@ void Assignment::swap(Assignment& otherAssignment) {
|
||||||
swap(_type, otherAssignment._type);
|
swap(_type, otherAssignment._type);
|
||||||
swap(_location, otherAssignment._location);
|
swap(_location, otherAssignment._location);
|
||||||
swap(_pool, otherAssignment._pool);
|
swap(_pool, otherAssignment._pool);
|
||||||
|
|
||||||
swap(_numberOfInstances, otherAssignment._numberOfInstances);
|
|
||||||
swap(_payload, otherAssignment._payload);
|
swap(_payload, otherAssignment._payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,10 +80,6 @@ public:
|
||||||
void setPool(const QString& pool) { _pool = pool; };
|
void setPool(const QString& pool) { _pool = pool; };
|
||||||
const QString& getPool() const { return _pool; }
|
const QString& getPool() const { return _pool; }
|
||||||
|
|
||||||
int getNumberOfInstances() const { return _numberOfInstances; }
|
|
||||||
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
|
||||||
void decrementNumberOfInstances() { --_numberOfInstances; }
|
|
||||||
|
|
||||||
const char* getTypeName() const;
|
const char* getTypeName() const;
|
||||||
|
|
||||||
// implement parseData to return 0 so we can be a subclass of NodeData
|
// implement parseData to return 0 so we can be a subclass of NodeData
|
||||||
|
@ -99,7 +95,6 @@ protected:
|
||||||
Assignment::Type _type; /// the type of the assignment, defines what the assignee will do
|
Assignment::Type _type; /// the type of the assignment, defines what the assignee will do
|
||||||
QString _pool; /// the destination pool for this assignment
|
QString _pool; /// the destination pool for this assignment
|
||||||
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
|
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
|
||||||
int _numberOfInstances; /// the number of instances of this assignment
|
|
||||||
QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed
|
QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue