mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 20:58:28 +02:00
PR cleanup + JS API
This commit is contained in:
parent
39a74cbc28
commit
b360b6c55d
14 changed files with 139 additions and 67 deletions
|
@ -89,7 +89,12 @@ var sittingDownAnimation = function(deltaTime) {
|
||||||
|
|
||||||
var pos = { x: startPosition.x - 0.3 * factor, y: startPosition.y - 0.5 * factor, z: startPosition.z};
|
var pos = { x: startPosition.x - 0.3 * factor, y: startPosition.y - 0.5 * factor, z: startPosition.z};
|
||||||
MyAvatar.position = pos;
|
MyAvatar.position = pos;
|
||||||
}
|
} else {
|
||||||
|
Script.update.disconnect(sittingDownAnimation);
|
||||||
|
if (seat.model) {
|
||||||
|
MyAvatar.setModelReferential(seat.model.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var standingUpAnimation = function(deltaTime) {
|
var standingUpAnimation = function(deltaTime) {
|
||||||
|
@ -103,7 +108,10 @@ var standingUpAnimation = function(deltaTime) {
|
||||||
|
|
||||||
var pos = { x: startPosition.x + 0.3 * (passedTime/animationLenght), y: startPosition.y + 0.5 * (passedTime/animationLenght), z: startPosition.z};
|
var pos = { x: startPosition.x + 0.3 * (passedTime/animationLenght), y: startPosition.y + 0.5 * (passedTime/animationLenght), z: startPosition.z};
|
||||||
MyAvatar.position = pos;
|
MyAvatar.position = pos;
|
||||||
}
|
} else {
|
||||||
|
Script.update.disconnect(standingUpAnimation);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var goToSeatAnimation = function(deltaTime) {
|
var goToSeatAnimation = function(deltaTime) {
|
||||||
|
@ -147,7 +155,8 @@ function standUp() {
|
||||||
print("standUp sitting status: " + Settings.getValue(sittingSettingsHandle, false));
|
print("standUp sitting status: " + Settings.getValue(sittingSettingsHandle, false));
|
||||||
passedTime = 0.0;
|
passedTime = 0.0;
|
||||||
startPosition = MyAvatar.position;
|
startPosition = MyAvatar.position;
|
||||||
try{
|
MyAvatar.clearReferential();
|
||||||
|
try{
|
||||||
Script.update.disconnect(sittingDownAnimation);
|
Script.update.disconnect(sittingDownAnimation);
|
||||||
} catch (e){}
|
} catch (e){}
|
||||||
Script.update.connect(standingUpAnimation);
|
Script.update.connect(standingUpAnimation);
|
||||||
|
@ -197,8 +206,10 @@ Controller.mousePressEvent.connect(function(event) {
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||||
|
|
||||||
if (clickedOverlay == sitDownButton) {
|
if (clickedOverlay == sitDownButton) {
|
||||||
|
seat.model = null;
|
||||||
sitDown();
|
sitDown();
|
||||||
} else if (clickedOverlay == standUpButton) {
|
} else if (clickedOverlay == standUpButton) {
|
||||||
|
seat.model = null;
|
||||||
standUp();
|
standUp();
|
||||||
} else {
|
} else {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
@ -214,6 +225,7 @@ Controller.mousePressEvent.connect(function(event) {
|
||||||
model.properties.sittingPoints[i].indicator.position,
|
model.properties.sittingPoints[i].indicator.position,
|
||||||
model.properties.sittingPoints[i].indicator.scale / 2)) {
|
model.properties.sittingPoints[i].indicator.scale / 2)) {
|
||||||
clickedOnSeat = true;
|
clickedOnSeat = true;
|
||||||
|
seat.model = model;
|
||||||
seat.position = model.properties.sittingPoints[i].indicator.position;
|
seat.position = model.properties.sittingPoints[i].indicator.position;
|
||||||
seat.rotation = model.properties.sittingPoints[i].indicator.orientation;
|
seat.rotation = model.properties.sittingPoints[i].indicator.orientation;
|
||||||
}
|
}
|
||||||
|
@ -355,6 +367,7 @@ Script.update.connect(update);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function() {
|
||||||
|
MyAvatar.clearReferential();
|
||||||
for (var i = 0; i < pose.length; i++){
|
for (var i = 0; i < pose.length; i++){
|
||||||
MyAvatar.clearJointData(pose[i].joint);
|
MyAvatar.clearJointData(pose[i].joint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2176,7 +2176,7 @@ void Application::update(float deltaTime) {
|
||||||
|
|
||||||
// Update _viewFrustum with latest camera and view frustum data...
|
// Update _viewFrustum with latest camera and view frustum data...
|
||||||
// NOTE: we get this from the view frustum, to make it simpler, since the
|
// NOTE: we get this from the view frustum, to make it simpler, since the
|
||||||
// loadViewFrumstum() methodill get the correct details from the camera
|
// loadViewFrumstum() method will get the correct details from the camera
|
||||||
// We could optimize this to not actually load the viewFrustum, since we don't
|
// We could optimize this to not actually load the viewFrustum, since we don't
|
||||||
// actually need to calculate the view frustum planes to send these details
|
// actually need to calculate the view frustum planes to send these details
|
||||||
// to the server.
|
// to the server.
|
||||||
|
|
|
@ -182,15 +182,20 @@ void Avatar::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
if (_referential) {
|
if (_referential) {
|
||||||
if (_referential->hasExtraData()) {
|
if (_referential->hasExtraData()) {
|
||||||
qDebug() << "Has extra data";
|
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
||||||
switch (_referential->type()) {
|
switch (_referential->type()) {
|
||||||
case Referential::MODEL:
|
case Referential::MODEL:
|
||||||
qDebug() << "[DEBUG] Switching to the right referential";
|
|
||||||
_referential = new ModelReferential(_referential,
|
_referential = new ModelReferential(_referential,
|
||||||
Application::getInstance()->getModels()->getTree(), this);
|
tree,
|
||||||
|
this);
|
||||||
|
break;
|
||||||
|
case Referential::JOINT:
|
||||||
|
_referential = new JointReferential(_referential,
|
||||||
|
tree,
|
||||||
|
this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "Non handled referential type";
|
qDebug() << "[WARNING] Avatar::simulate(): Unknown referential type.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ protected:
|
||||||
virtual void renderAttachments(RenderMode renderMode);
|
virtual void renderAttachments(RenderMode renderMode);
|
||||||
|
|
||||||
virtual void updateJointMappings();
|
virtual void updateJointMappings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool _initialized;
|
bool _initialized;
|
||||||
|
|
|
@ -22,20 +22,18 @@ ModelReferential::ModelReferential(Referential* referential, ModelTree* tree, Av
|
||||||
unpackExtraData(reinterpret_cast<unsigned char*>(referential->getExtraData().data()),
|
unpackExtraData(reinterpret_cast<unsigned char*>(referential->getExtraData().data()),
|
||||||
referential->getExtraData().size());
|
referential->getExtraData().size());
|
||||||
if (!isValid()) {
|
if (!isValid()) {
|
||||||
qDebug() << "ModelReferential::copyConstructo(): Not Valid";
|
qDebug() << "ModelReferential::copyConstructor(): Not Valid";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const ModelItem* item = _tr
|
||||||
|
ree->findModelByID(_modelID);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
_refScale = item->getRadius();
|
_refScale = item->getRadius();
|
||||||
_refRotation = item->getModelRotation();
|
_refRotation = item->getModelRotation();
|
||||||
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
||||||
}
|
}
|
||||||
|
update();
|
||||||
_scale = referential->getScale();
|
|
||||||
_rotation = referential->getRotation();
|
|
||||||
_translation = referential->getTranslation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
||||||
|
@ -63,7 +61,6 @@ _tree(tree)
|
||||||
void ModelReferential::update() {
|
void ModelReferential::update() {
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||||
if (!isValid() || item == NULL || _avatar == NULL) {
|
if (!isValid() || item == NULL || _avatar == NULL) {
|
||||||
//qDebug() << "ModelReferential::update(): Not Valid";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +92,25 @@ int ModelReferential::unpackExtraData(const unsigned char *sourceBuffer, int siz
|
||||||
return sizeof(_modelID);
|
return sizeof(_modelID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JointReferential::JointReferential(Referential* referential, ModelTree* tree, AvatarData* avatar) :
|
||||||
|
ModelReferential(referential, tree, avatar)
|
||||||
|
{
|
||||||
|
_type = JOINT;
|
||||||
|
if (!isValid()) {
|
||||||
|
qDebug() << "JointReferential::copyConstructor(): Not Valid";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||||
|
const Model* model = getModel(item);
|
||||||
|
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||||
|
_refScale = item->getRadius();
|
||||||
|
model->getJointRotationInWorldFrame(_jointIndex, _refRotation);
|
||||||
|
model->getJointPositionInWorldFrame(_jointIndex, _refPosition);
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
||||||
ModelReferential(modelID, tree, avatar),
|
ModelReferential(modelID, tree, avatar),
|
||||||
_jointIndex(jointIndex)
|
_jointIndex(jointIndex)
|
||||||
|
@ -102,8 +118,8 @@ JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelT
|
||||||
_type = JOINT;
|
_type = JOINT;
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||||
const Model* model = getModel(item);
|
const Model* model = getModel(item);
|
||||||
if (!_isValid || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||||
qDebug() << "Not Valid";
|
qDebug() << "JointReferential::constructor(): Not Valid";
|
||||||
_isValid = false;
|
_isValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -121,9 +137,7 @@ JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelT
|
||||||
void JointReferential::update() {
|
void JointReferential::update() {
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||||
const Model* model = getModel(item);
|
const Model* model = getModel(item);
|
||||||
if (model == NULL || _jointIndex >= model->getJointStateCount()) {
|
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||||
qDebug() << "Not Valid";
|
|
||||||
_isValid = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +164,25 @@ const Model* JointReferential::getModel(const ModelItem* item) {
|
||||||
if (item != NULL && fbxService != NULL) {
|
if (item != NULL && fbxService != NULL) {
|
||||||
return fbxService->getModelForModelItem(*item);
|
return fbxService->getModelForModelItem(*item);
|
||||||
}
|
}
|
||||||
qDebug() << "No Model";
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JointReferential::packExtraData(unsigned char* destinationBuffer) const {
|
||||||
|
unsigned char* startPosition = destinationBuffer;
|
||||||
|
destinationBuffer += ModelReferential::packExtraData(destinationBuffer);
|
||||||
|
|
||||||
|
memcpy(destinationBuffer, &_jointIndex, sizeof(_jointIndex));
|
||||||
|
destinationBuffer += sizeof(_jointIndex);
|
||||||
|
|
||||||
|
return destinationBuffer - startPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JointReferential::unpackExtraData(const unsigned char *sourceBuffer, int size) {
|
||||||
|
const unsigned char* startPosition = sourceBuffer;
|
||||||
|
sourceBuffer += ModelReferential::unpackExtraData(sourceBuffer, size);
|
||||||
|
|
||||||
|
memcpy(&_jointIndex, sourceBuffer, sizeof(_jointIndex));
|
||||||
|
sourceBuffer += sizeof(_jointIndex);
|
||||||
|
|
||||||
|
return sourceBuffer - startPosition;
|
||||||
|
}
|
|
@ -33,12 +33,14 @@ protected:
|
||||||
|
|
||||||
class JointReferential : public ModelReferential {
|
class JointReferential : public ModelReferential {
|
||||||
public:
|
public:
|
||||||
JointReferential(Referential* ref);
|
JointReferential(Referential* ref, ModelTree* tree, AvatarData* avatar);
|
||||||
JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar);
|
JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Model* getModel(const ModelItem* item);
|
const Model* getModel(const ModelItem* item);
|
||||||
|
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
||||||
|
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
||||||
|
|
||||||
uint32_t _jointIndex;
|
uint32_t _jointIndex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,6 +109,10 @@ void MyAvatar::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::update(float deltaTime) {
|
void MyAvatar::update(float deltaTime) {
|
||||||
|
if (_referential) {
|
||||||
|
_referential->update();
|
||||||
|
}
|
||||||
|
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
head->relaxLean(deltaTime);
|
head->relaxLean(deltaTime);
|
||||||
updateFromTrackers(deltaTime);
|
updateFromTrackers(deltaTime);
|
||||||
|
@ -127,22 +131,6 @@ void MyAvatar::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
simulate(deltaTime);
|
simulate(deltaTime);
|
||||||
|
|
||||||
bool WANT_REFERENTIAL = false;
|
|
||||||
if (WANT_REFERENTIAL) {
|
|
||||||
int id = 12340;
|
|
||||||
const ModelItem* item = Application::getInstance()->getModels()->getTree()->findModelByID(id);
|
|
||||||
if (_referential) {
|
|
||||||
PerformanceTimer perfTimer("Referential");
|
|
||||||
_referential->update();
|
|
||||||
} else if (item != NULL) {
|
|
||||||
const Model* model = Application::getInstance()->getModels()->getModelForModelItem(*item);
|
|
||||||
if (model != NULL) {
|
|
||||||
_referential = new ModelReferential(id,
|
|
||||||
Application::getInstance()->getModels()->getTree(), this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::simulate(float deltaTime) {
|
void MyAvatar::simulate(float deltaTime) {
|
||||||
|
@ -461,9 +449,30 @@ glm::vec3 MyAvatar::getRightPalmPosition() {
|
||||||
return rightHandPosition;
|
return rightHandPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::changeReferential(Referential *ref) {
|
void MyAvatar::clearReferential() {
|
||||||
delete _referential;
|
changeReferential(NULL);
|
||||||
_referential = ref;
|
}
|
||||||
|
|
||||||
|
bool MyAvatar::setModelReferential(int id) {
|
||||||
|
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
||||||
|
changeReferential(new ModelReferential(id, tree, this));
|
||||||
|
if (_referential->isValid()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
changeReferential(NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyAvatar::setJointReferential(int id, int jointIndex) {
|
||||||
|
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
||||||
|
changeReferential(new JointReferential(jointIndex, id, tree, this));
|
||||||
|
if (!_referential->isValid()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
changeReferential(NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setLocalGravity(glm::vec3 gravity) {
|
void MyAvatar::setLocalGravity(glm::vec3 gravity) {
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
|
|
||||||
|
class ModelItemID;
|
||||||
|
|
||||||
enum AvatarHandState
|
enum AvatarHandState
|
||||||
{
|
{
|
||||||
HAND_STATE_NULL = 0,
|
HAND_STATE_NULL = 0,
|
||||||
|
@ -149,7 +151,9 @@ public slots:
|
||||||
glm::vec3 getLeftPalmPosition();
|
glm::vec3 getLeftPalmPosition();
|
||||||
glm::vec3 getRightPalmPosition();
|
glm::vec3 getRightPalmPosition();
|
||||||
|
|
||||||
void changeReferential(Referential* ref);
|
void clearReferential();
|
||||||
|
bool setModelReferential(int id);
|
||||||
|
bool setJointReferential(int id, int jointIndex);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void transformChanged();
|
void transformChanged();
|
||||||
|
|
|
@ -425,29 +425,19 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
|
|
||||||
// Referential
|
// Referential
|
||||||
if (hasReferential) {
|
if (hasReferential) {
|
||||||
const unsigned char* start = sourceBuffer;
|
Referential* ref = new Referential(sourceBuffer, this);
|
||||||
if (_referential == NULL) {
|
if (_referential == NULL ||
|
||||||
qDebug() << "New referential";
|
ref->createdAt() > _referential->createdAt()) {
|
||||||
_referential = new Referential(sourceBuffer, this);
|
changeReferential(ref);
|
||||||
} else {
|
} else {
|
||||||
Referential* ref = new Referential(sourceBuffer, this);
|
delete ref;
|
||||||
if (ref->createdAt() > _referential->createdAt()) {
|
|
||||||
qDebug() << "Replacing referential";
|
|
||||||
delete _referential;
|
|
||||||
_referential = ref;
|
|
||||||
} else {
|
|
||||||
delete ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//qDebug() << "Read " << sourceBuffer - start << " bytes.";
|
|
||||||
_referential->update();
|
_referential->update();
|
||||||
} else if (_referential != NULL) {
|
} else if (_referential != NULL) {
|
||||||
qDebug() << "Erasing referencial";
|
changeReferential(NULL);
|
||||||
delete _referential;
|
|
||||||
_referential = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_headData->_isFaceshiftConnected) {
|
if (_headData->_isFaceshiftConnected) {
|
||||||
float leftEyeBlink, rightEyeBlink, averageLoudness, browAudioLift;
|
float leftEyeBlink, rightEyeBlink, averageLoudness, browAudioLift;
|
||||||
minPossibleSize += sizeof(leftEyeBlink) + sizeof(rightEyeBlink) + sizeof(averageLoudness) + sizeof(browAudioLift);
|
minPossibleSize += sizeof(leftEyeBlink) + sizeof(rightEyeBlink) + sizeof(averageLoudness) + sizeof(browAudioLift);
|
||||||
|
@ -569,6 +559,15 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
return sourceBuffer - startPosition;
|
return sourceBuffer - startPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AvatarData::hasReferential() {
|
||||||
|
return _referential != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarData::changeReferential(Referential *ref) {
|
||||||
|
delete _referential;
|
||||||
|
_referential = ref;
|
||||||
|
}
|
||||||
|
|
||||||
void AvatarData::setJointData(int index, const glm::quat& rotation) {
|
void AvatarData::setJointData(int index, const glm::quat& rotation) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -289,6 +289,8 @@ public slots:
|
||||||
void setBillboardFromNetworkReply();
|
void setBillboardFromNetworkReply();
|
||||||
void setJointMappingsFromNetworkReply();
|
void setJointMappingsFromNetworkReply();
|
||||||
void setSessionUUID(const QUuid& id) { _sessionUUID = id; }
|
void setSessionUUID(const QUuid& id) { _sessionUUID = id; }
|
||||||
|
bool hasReferential();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUuid _sessionUUID;
|
QUuid _sessionUUID;
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
|
@ -344,6 +346,7 @@ protected:
|
||||||
|
|
||||||
/// Loads the joint indices, names from the FST file (if any)
|
/// Loads the joint indices, names from the FST file (if any)
|
||||||
virtual void updateJointMappings();
|
virtual void updateJointMappings();
|
||||||
|
void changeReferential(Referential* ref);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// privatize the copy constructor and assignment operator so they cannot be called
|
// privatize the copy constructor and assignment operator so they cannot be called
|
||||||
|
|
|
@ -23,14 +23,17 @@ Referential::Referential(Type type, AvatarData* avatar) :
|
||||||
_isValid = false;
|
_isValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "[DEBUG] New Referential";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Referential::Referential(const unsigned char*& sourceBuffer, AvatarData* avatar) :
|
Referential::Referential(const unsigned char*& sourceBuffer, AvatarData* avatar) :
|
||||||
_isValid(false),
|
_isValid(false),
|
||||||
_avatar(avatar)
|
_avatar(avatar)
|
||||||
{
|
{
|
||||||
|
// Since we can't return how many byte have been read
|
||||||
|
// We take a reference to the pointer as argument and increment the pointer ouself.
|
||||||
sourceBuffer += unpackReferential(sourceBuffer);
|
sourceBuffer += unpackReferential(sourceBuffer);
|
||||||
|
// The actual unpacking to the right referential type happens in Avatar::simulate()
|
||||||
|
// If subclassed, make sure to add a case there to unpack the new referential type correctly
|
||||||
}
|
}
|
||||||
|
|
||||||
Referential::~Referential() {
|
Referential::~Referential() {
|
||||||
|
@ -40,9 +43,9 @@ int Referential::packReferential(unsigned char* destinationBuffer) const {
|
||||||
const unsigned char* startPosition = destinationBuffer;
|
const unsigned char* startPosition = destinationBuffer;
|
||||||
destinationBuffer += pack(destinationBuffer);
|
destinationBuffer += pack(destinationBuffer);
|
||||||
|
|
||||||
unsigned char* sizePosition = destinationBuffer++;
|
unsigned char* sizePosition = destinationBuffer++; // Save a spot for the extra data size
|
||||||
char size = packExtraData(destinationBuffer);
|
char size = packExtraData(destinationBuffer);
|
||||||
*sizePosition = size;
|
*sizePosition = size; // write extra data size in saved spot here
|
||||||
destinationBuffer += size;
|
destinationBuffer += size;
|
||||||
|
|
||||||
return destinationBuffer - startPosition;
|
return destinationBuffer - startPosition;
|
||||||
|
@ -56,6 +59,7 @@ int Referential::unpackReferential(const unsigned char* sourceBuffer) {
|
||||||
char bytesRead = unpackExtraData(sourceBuffer, expectedSize);
|
char bytesRead = unpackExtraData(sourceBuffer, expectedSize);
|
||||||
_isValid = (bytesRead == expectedSize);
|
_isValid = (bytesRead == expectedSize);
|
||||||
if (!_isValid) {
|
if (!_isValid) {
|
||||||
|
// Will occur if the new instance unpacking is of the wrong type
|
||||||
qDebug() << "[ERROR] Referential extra data overflow";
|
qDebug() << "[ERROR] Referential extra data overflow";
|
||||||
}
|
}
|
||||||
sourceBuffer += expectedSize;
|
sourceBuffer += expectedSize;
|
||||||
|
@ -88,10 +92,12 @@ int Referential::unpack(const unsigned char* sourceBuffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Referential::packExtraData(unsigned char *destinationBuffer) const {
|
int Referential::packExtraData(unsigned char *destinationBuffer) const {
|
||||||
|
// Since we can't interpret that data, just store it in a buffer for later use.
|
||||||
memcpy(destinationBuffer, _extraDataBuffer.data(), _extraDataBuffer.size());
|
memcpy(destinationBuffer, _extraDataBuffer.data(), _extraDataBuffer.size());
|
||||||
return _extraDataBuffer.size();
|
return _extraDataBuffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Referential::unpackExtraData(const unsigned char* sourceBuffer, int size) {
|
int Referential::unpackExtraData(const unsigned char* sourceBuffer, int size) {
|
||||||
_extraDataBuffer.clear();
|
_extraDataBuffer.clear();
|
||||||
_extraDataBuffer.setRawData(reinterpret_cast<const char*>(sourceBuffer), size);
|
_extraDataBuffer.setRawData(reinterpret_cast<const char*>(sourceBuffer), size);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
class AvatarData;
|
class AvatarData;
|
||||||
|
|
||||||
|
/// Stores and enforce the relative position of an avatar to a given referential (ie. model, joint, ...)
|
||||||
class Referential {
|
class Referential {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
|
|
|
@ -23,7 +23,6 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||||
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}")
|
||||||
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}")
|
||||||
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}")
|
||||||
link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}")
|
|
||||||
|
|
||||||
# for streamable
|
# for streamable
|
||||||
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||||
|
|
|
@ -179,7 +179,6 @@ void ModelItemIDfromScriptValue(const QScriptValue &object, ModelItemID& propert
|
||||||
|
|
||||||
/// ModelItem class - this is the actual model item class.
|
/// ModelItem class - this is the actual model item class.
|
||||||
class ModelItem {
|
class ModelItem {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModelItem();
|
ModelItem();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue