mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:29:42 +02:00
get referentials compiling with new Entity ID changes
This commit is contained in:
parent
027b1d58cc
commit
b7767b7971
8 changed files with 56 additions and 48 deletions
|
@ -107,7 +107,7 @@ void Avatar::simulate(float deltaTime) {
|
||||||
// update the avatar's position according to its referential
|
// update the avatar's position according to its referential
|
||||||
if (_referential) {
|
if (_referential) {
|
||||||
if (_referential->hasExtraData()) {
|
if (_referential->hasExtraData()) {
|
||||||
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
EntityTree* tree = Application::getInstance()->getEntities()->getTree();
|
||||||
switch (_referential->type()) {
|
switch (_referential->type()) {
|
||||||
case Referential::MODEL:
|
case Referential::MODEL:
|
||||||
_referential = new ModelReferential(_referential,
|
_referential = new ModelReferential(_referential,
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include <AvatarData.h>
|
#include <AvatarData.h>
|
||||||
|
|
||||||
#include "ModelTree.h"
|
#include <EntityTree.h>
|
||||||
#include "../renderer/Model.h"
|
#include "../renderer/Model.h"
|
||||||
|
|
||||||
#include "ModelReferential.h"
|
#include "ModelReferential.h"
|
||||||
|
|
||||||
ModelReferential::ModelReferential(Referential* referential, ModelTree* tree, AvatarData* avatar) :
|
ModelReferential::ModelReferential(Referential* referential, EntityTree* tree, AvatarData* avatar) :
|
||||||
Referential(MODEL, avatar),
|
Referential(MODEL, avatar),
|
||||||
_tree(tree) {
|
_tree(tree) {
|
||||||
_translation = referential->getTranslation();
|
_translation = referential->getTranslation();
|
||||||
|
@ -30,21 +30,21 @@ ModelReferential::ModelReferential(Referential* referential, ModelTree* tree, Av
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
_refScale = item->getRadius();
|
_refScale = item->getRadius();
|
||||||
_refRotation = item->getModelRotation();
|
_refRotation = item->getRotation();
|
||||||
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
ModelReferential::ModelReferential(const QUuid& entityID, EntityTree* tree, AvatarData* avatar) :
|
||||||
Referential(MODEL, avatar),
|
Referential(MODEL, avatar),
|
||||||
_modelID(modelID),
|
_entityID(entityID),
|
||||||
_tree(tree)
|
_tree(tree)
|
||||||
{
|
{
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||||
if (!isValid() || item == NULL) {
|
if (!isValid() || item == NULL) {
|
||||||
qDebug() << "ModelReferential::constructor(): Not Valid";
|
qDebug() << "ModelReferential::constructor(): Not Valid";
|
||||||
_isValid = false;
|
_isValid = false;
|
||||||
|
@ -52,7 +52,7 @@ ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData
|
||||||
}
|
}
|
||||||
|
|
||||||
_refScale = item->getRadius();
|
_refScale = item->getRadius();
|
||||||
_refRotation = item->getModelRotation();
|
_refRotation = item->getRotation();
|
||||||
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
||||||
|
|
||||||
glm::quat refInvRot = glm::inverse(_refRotation);
|
glm::quat refInvRot = glm::inverse(_refRotation);
|
||||||
|
@ -62,7 +62,7 @@ ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelReferential::update() {
|
void ModelReferential::update() {
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||||
if (!isValid() || item == NULL || _avatar == NULL) {
|
if (!isValid() || item == NULL || _avatar == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ void ModelReferential::update() {
|
||||||
_avatar->setTargetScale(_refScale * _scale, true);
|
_avatar->setTargetScale(_refScale * _scale, true);
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
if (item->getModelRotation() != _refRotation) {
|
if (item->getRotation() != _refRotation) {
|
||||||
_refRotation = item->getModelRotation();
|
_refRotation = item->getRotation();
|
||||||
_avatar->setOrientation(_refRotation * _rotation, true);
|
_avatar->setOrientation(_refRotation * _rotation, true);
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -85,16 +85,18 @@ void ModelReferential::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ModelReferential::packExtraData(unsigned char* destinationBuffer) const {
|
int ModelReferential::packExtraData(unsigned char* destinationBuffer) const {
|
||||||
memcpy(destinationBuffer, &_modelID, sizeof(_modelID));
|
QByteArray encodedEntityID = _entityID.toRfc4122();
|
||||||
return sizeof(_modelID);
|
memcpy(destinationBuffer, encodedEntityID.constData(), encodedEntityID.size());
|
||||||
|
return encodedEntityID.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ModelReferential::unpackExtraData(const unsigned char *sourceBuffer, int size) {
|
int ModelReferential::unpackExtraData(const unsigned char *sourceBuffer, int size) {
|
||||||
memcpy(&_modelID, sourceBuffer, sizeof(_modelID));
|
QByteArray encodedEntityID((const char*)sourceBuffer, NUM_BYTES_RFC4122_UUID);
|
||||||
return sizeof(_modelID);
|
_entityID = QUuid::fromRfc4122(encodedEntityID);
|
||||||
|
return NUM_BYTES_RFC4122_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
JointReferential::JointReferential(Referential* referential, ModelTree* tree, AvatarData* avatar) :
|
JointReferential::JointReferential(Referential* referential, EntityTree* tree, AvatarData* avatar) :
|
||||||
ModelReferential(referential, tree, avatar)
|
ModelReferential(referential, tree, avatar)
|
||||||
{
|
{
|
||||||
_type = JOINT;
|
_type = JOINT;
|
||||||
|
@ -103,7 +105,7 @@ JointReferential::JointReferential(Referential* referential, ModelTree* tree, Av
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||||
const Model* model = getModel(item);
|
const Model* model = getModel(item);
|
||||||
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||||
_refScale = item->getRadius();
|
_refScale = item->getRadius();
|
||||||
|
@ -113,12 +115,12 @@ JointReferential::JointReferential(Referential* referential, ModelTree* tree, Av
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
JointReferential::JointReferential(uint32_t jointIndex, const QUuid& entityID, EntityTree* tree, AvatarData* avatar) :
|
||||||
ModelReferential(modelID, tree, avatar),
|
ModelReferential(entityID, tree, avatar),
|
||||||
_jointIndex(jointIndex)
|
_jointIndex(jointIndex)
|
||||||
{
|
{
|
||||||
_type = JOINT;
|
_type = JOINT;
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||||
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() << "JointReferential::constructor(): Not Valid";
|
qDebug() << "JointReferential::constructor(): Not Valid";
|
||||||
|
@ -137,7 +139,7 @@ JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelT
|
||||||
}
|
}
|
||||||
|
|
||||||
void JointReferential::update() {
|
void JointReferential::update() {
|
||||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||||
const Model* model = getModel(item);
|
const Model* model = getModel(item);
|
||||||
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||||
return;
|
return;
|
||||||
|
@ -149,7 +151,7 @@ void JointReferential::update() {
|
||||||
_avatar->setTargetScale(_refScale * _scale, true);
|
_avatar->setTargetScale(_refScale * _scale, true);
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
if (item->getModelRotation() != _refRotation) {
|
if (item->getRotation() != _refRotation) {
|
||||||
model->getJointRotationInWorldFrame(_jointIndex, _refRotation);
|
model->getJointRotationInWorldFrame(_jointIndex, _refRotation);
|
||||||
_avatar->setOrientation(_refRotation * _rotation, true);
|
_avatar->setOrientation(_refRotation * _rotation, true);
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
|
@ -160,10 +162,10 @@ void JointReferential::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Model* JointReferential::getModel(const ModelItem* item) {
|
const Model* JointReferential::getModel(const EntityItem* item) {
|
||||||
ModelItemFBXService* fbxService = _tree->getFBXService();
|
EntityItemFBXService* fbxService = _tree->getFBXService();
|
||||||
if (item != NULL && fbxService != NULL) {
|
if (item != NULL && fbxService != NULL) {
|
||||||
return fbxService->getModelForModelItem(*item);
|
return fbxService->getModelForEntityItem(item);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,31 +14,31 @@
|
||||||
|
|
||||||
#include <Referential.h>
|
#include <Referential.h>
|
||||||
|
|
||||||
class ModelTree;
|
class EntityTree;
|
||||||
class Model;
|
class Model;
|
||||||
|
|
||||||
class ModelReferential : public Referential {
|
class ModelReferential : public Referential {
|
||||||
public:
|
public:
|
||||||
ModelReferential(Referential* ref, ModelTree* tree, AvatarData* avatar);
|
ModelReferential(Referential* ref, EntityTree* tree, AvatarData* avatar);
|
||||||
ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData* avatar);
|
ModelReferential(const QUuid& entityID, EntityTree* tree, AvatarData* avatar);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
||||||
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
||||||
|
|
||||||
uint32_t _modelID;
|
QUuid _entityID;
|
||||||
ModelTree* _tree;
|
EntityTree* _tree;
|
||||||
};
|
};
|
||||||
|
|
||||||
class JointReferential : public ModelReferential {
|
class JointReferential : public ModelReferential {
|
||||||
public:
|
public:
|
||||||
JointReferential(Referential* ref, ModelTree* tree, AvatarData* avatar);
|
JointReferential(Referential* ref, EntityTree* tree, AvatarData* avatar);
|
||||||
JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar);
|
JointReferential(uint32_t jointIndex, const QUuid& entityID, EntityTree* tree, AvatarData* avatar);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Model* getModel(const ModelItem* item);
|
const Model* getModel(const EntityItem* item);
|
||||||
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
||||||
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
||||||
|
|
||||||
|
|
|
@ -452,8 +452,8 @@ void MyAvatar::clearReferential() {
|
||||||
changeReferential(NULL);
|
changeReferential(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::setModelReferential(int id) {
|
bool MyAvatar::setModelReferential(const QUuid& id) {
|
||||||
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
EntityTree* tree = Application::getInstance()->getEntities()->getTree();
|
||||||
changeReferential(new ModelReferential(id, tree, this));
|
changeReferential(new ModelReferential(id, tree, this));
|
||||||
if (_referential->isValid()) {
|
if (_referential->isValid()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -463,8 +463,8 @@ bool MyAvatar::setModelReferential(int id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::setJointReferential(int id, int jointIndex) {
|
bool MyAvatar::setJointReferential(const QUuid& id, int jointIndex) {
|
||||||
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
EntityTree* tree = Application::getInstance()->getEntities()->getTree();
|
||||||
changeReferential(new JointReferential(jointIndex, id, tree, this));
|
changeReferential(new JointReferential(jointIndex, id, tree, this));
|
||||||
if (!_referential->isValid()) {
|
if (!_referential->isValid()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -152,8 +152,8 @@ public slots:
|
||||||
glm::vec3 getRightPalmPosition();
|
glm::vec3 getRightPalmPosition();
|
||||||
|
|
||||||
void clearReferential();
|
void clearReferential();
|
||||||
bool setModelReferential(int id);
|
bool setModelReferential(const QUuid& id);
|
||||||
bool setJointReferential(int id, int jointIndex);
|
bool setJointReferential(const QUuid& id, int jointIndex);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void transformChanged();
|
void transformChanged();
|
||||||
|
|
|
@ -855,8 +855,7 @@ void EntityTree::findEntities(const AACube& cube, QVector<EntityItem*> foundEnti
|
||||||
foundEntities.swap(args._foundEntities);
|
foundEntities.swap(args._foundEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 ///////////////////////////////////
|
EntityItem* EntityTree::findEntityByID(const QUuid& id) {
|
||||||
EntityItem* EntityTree::findEntityByID(uint32_t id, bool alreadyLocked) /*const*/ {
|
|
||||||
EntityItemID entityID(id);
|
EntityItemID entityID(id);
|
||||||
|
|
||||||
bool wantDebug = false;
|
bool wantDebug = false;
|
||||||
|
@ -869,7 +868,6 @@ EntityItem* EntityTree::findEntityByID(uint32_t id, bool alreadyLocked) /*const
|
||||||
|
|
||||||
return findEntityByEntityItemID(entityID);
|
return findEntityByEntityItemID(entityID);
|
||||||
}
|
}
|
||||||
#endif ////////////////////////////
|
|
||||||
|
|
||||||
EntityItem* EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ {
|
EntityItem* EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ {
|
||||||
EntityItem* foundEntity = NULL;
|
EntityItem* foundEntity = NULL;
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
class EntityItemFBXService {
|
class EntityItemFBXService {
|
||||||
public:
|
public:
|
||||||
virtual const FBXGeometry* getGeometryForEntity(const EntityItem* entityItem) = 0;
|
virtual const FBXGeometry* getGeometryForEntity(const EntityItem* entityItem) = 0;
|
||||||
virtual const Model* getModelForForEntityItem(const EntityItem* entityItem) = 0;
|
virtual const Model* getModelForEntityItem(const EntityItem* entityItem) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ public:
|
||||||
void deleteEntities(QSet<EntityItemID> entityIDs);
|
void deleteEntities(QSet<EntityItemID> entityIDs);
|
||||||
|
|
||||||
const EntityItem* findClosestEntity(glm::vec3 position, float targetRadius);
|
const EntityItem* findClosestEntity(glm::vec3 position, float targetRadius);
|
||||||
EntityItem* findEntityByID(uint32_t id, bool alreadyLocked = false) /*const*/;
|
EntityItem* findEntityByID(const QUuid& id);
|
||||||
EntityItem* findEntityByEntityItemID(const EntityItemID& entityID) /*const*/;
|
EntityItem* findEntityByEntityItemID(const EntityItemID& entityID);
|
||||||
|
|
||||||
EntityItemID assignEntityID(const EntityItemID& entityItemID); /// Assigns a known ID for a creator token ID
|
EntityItemID assignEntityID(const EntityItemID& entityItemID); /// Assigns a known ID for a creator token ID
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,16 @@ Model properties:
|
||||||
DONE -- 22d) void ModelTree::findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels)...
|
DONE -- 22d) void ModelTree::findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels)...
|
||||||
DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels)...
|
DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels)...
|
||||||
|
|
||||||
13) support sitpoints
|
13) support sitpoints and referentials....
|
||||||
|
Q) Referentials????
|
||||||
|
|
||||||
|
For sitting points and referentials you can kill two birds with one stone.
|
||||||
|
Put this model in world: http://highfidelity-public.s3-us-west-1.amazonaws.com/ozan/theater.fst
|
||||||
|
Launch sit.js
|
||||||
|
See sitting points
|
||||||
|
Sit somewhere
|
||||||
|
Move model with another avatar.
|
||||||
|
Observe first avatar moving.
|
||||||
|
|
||||||
K) verify shadows work
|
K) verify shadows work
|
||||||
|
|
||||||
|
@ -67,7 +76,6 @@ Model properties:
|
||||||
12a) make sure server is deleting items??
|
12a) make sure server is deleting items??
|
||||||
12b) Use the delete message instead of shouldDelete property
|
12b) Use the delete message instead of shouldDelete property
|
||||||
|
|
||||||
Q) Referentials????
|
|
||||||
|
|
||||||
R) fix these!!!
|
R) fix these!!!
|
||||||
EntityItem::encodeEntityEditMessageDetails()
|
EntityItem::encodeEntityEditMessageDetails()
|
||||||
|
|
Loading…
Reference in a new issue