mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 20:13:09 +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
|
||||
if (_referential) {
|
||||
if (_referential->hasExtraData()) {
|
||||
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
||||
EntityTree* tree = Application::getInstance()->getEntities()->getTree();
|
||||
switch (_referential->type()) {
|
||||
case Referential::MODEL:
|
||||
_referential = new ModelReferential(_referential,
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
#include <AvatarData.h>
|
||||
|
||||
#include "ModelTree.h"
|
||||
#include <EntityTree.h>
|
||||
#include "../renderer/Model.h"
|
||||
|
||||
#include "ModelReferential.h"
|
||||
|
||||
ModelReferential::ModelReferential(Referential* referential, ModelTree* tree, AvatarData* avatar) :
|
||||
ModelReferential::ModelReferential(Referential* referential, EntityTree* tree, AvatarData* avatar) :
|
||||
Referential(MODEL, avatar),
|
||||
_tree(tree) {
|
||||
_translation = referential->getTranslation();
|
||||
|
@ -30,21 +30,21 @@ ModelReferential::ModelReferential(Referential* referential, ModelTree* tree, Av
|
|||
return;
|
||||
}
|
||||
|
||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||
if (item != NULL) {
|
||||
_refScale = item->getRadius();
|
||||
_refRotation = item->getModelRotation();
|
||||
_refRotation = item->getRotation();
|
||||
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
||||
ModelReferential::ModelReferential(const QUuid& entityID, EntityTree* tree, AvatarData* avatar) :
|
||||
Referential(MODEL, avatar),
|
||||
_modelID(modelID),
|
||||
_entityID(entityID),
|
||||
_tree(tree)
|
||||
{
|
||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||
if (!isValid() || item == NULL) {
|
||||
qDebug() << "ModelReferential::constructor(): Not Valid";
|
||||
_isValid = false;
|
||||
|
@ -52,7 +52,7 @@ ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData
|
|||
}
|
||||
|
||||
_refScale = item->getRadius();
|
||||
_refRotation = item->getModelRotation();
|
||||
_refRotation = item->getRotation();
|
||||
_refPosition = item->getPosition() * (float)TREE_SCALE;
|
||||
|
||||
glm::quat refInvRot = glm::inverse(_refRotation);
|
||||
|
@ -62,7 +62,7 @@ ModelReferential::ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData
|
|||
}
|
||||
|
||||
void ModelReferential::update() {
|
||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||
if (!isValid() || item == NULL || _avatar == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ void ModelReferential::update() {
|
|||
_avatar->setTargetScale(_refScale * _scale, true);
|
||||
somethingChanged = true;
|
||||
}
|
||||
if (item->getModelRotation() != _refRotation) {
|
||||
_refRotation = item->getModelRotation();
|
||||
if (item->getRotation() != _refRotation) {
|
||||
_refRotation = item->getRotation();
|
||||
_avatar->setOrientation(_refRotation * _rotation, true);
|
||||
somethingChanged = true;
|
||||
}
|
||||
|
@ -85,16 +85,18 @@ void ModelReferential::update() {
|
|||
}
|
||||
|
||||
int ModelReferential::packExtraData(unsigned char* destinationBuffer) const {
|
||||
memcpy(destinationBuffer, &_modelID, sizeof(_modelID));
|
||||
return sizeof(_modelID);
|
||||
QByteArray encodedEntityID = _entityID.toRfc4122();
|
||||
memcpy(destinationBuffer, encodedEntityID.constData(), encodedEntityID.size());
|
||||
return encodedEntityID.size();
|
||||
}
|
||||
|
||||
int ModelReferential::unpackExtraData(const unsigned char *sourceBuffer, int size) {
|
||||
memcpy(&_modelID, sourceBuffer, sizeof(_modelID));
|
||||
return sizeof(_modelID);
|
||||
QByteArray encodedEntityID((const char*)sourceBuffer, NUM_BYTES_RFC4122_UUID);
|
||||
_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)
|
||||
{
|
||||
_type = JOINT;
|
||||
|
@ -103,7 +105,7 @@ JointReferential::JointReferential(Referential* referential, ModelTree* tree, Av
|
|||
return;
|
||||
}
|
||||
|
||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||
const Model* model = getModel(item);
|
||||
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||
_refScale = item->getRadius();
|
||||
|
@ -113,12 +115,12 @@ JointReferential::JointReferential(Referential* referential, ModelTree* tree, Av
|
|||
update();
|
||||
}
|
||||
|
||||
JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
|
||||
ModelReferential(modelID, tree, avatar),
|
||||
JointReferential::JointReferential(uint32_t jointIndex, const QUuid& entityID, EntityTree* tree, AvatarData* avatar) :
|
||||
ModelReferential(entityID, tree, avatar),
|
||||
_jointIndex(jointIndex)
|
||||
{
|
||||
_type = JOINT;
|
||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||
const Model* model = getModel(item);
|
||||
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||
qDebug() << "JointReferential::constructor(): Not Valid";
|
||||
|
@ -137,7 +139,7 @@ JointReferential::JointReferential(uint32_t jointIndex, uint32_t modelID, ModelT
|
|||
}
|
||||
|
||||
void JointReferential::update() {
|
||||
const ModelItem* item = _tree->findModelByID(_modelID);
|
||||
const EntityItem* item = _tree->findEntityByID(_entityID);
|
||||
const Model* model = getModel(item);
|
||||
if (!isValid() || model == NULL || _jointIndex >= model->getJointStateCount()) {
|
||||
return;
|
||||
|
@ -149,7 +151,7 @@ void JointReferential::update() {
|
|||
_avatar->setTargetScale(_refScale * _scale, true);
|
||||
somethingChanged = true;
|
||||
}
|
||||
if (item->getModelRotation() != _refRotation) {
|
||||
if (item->getRotation() != _refRotation) {
|
||||
model->getJointRotationInWorldFrame(_jointIndex, _refRotation);
|
||||
_avatar->setOrientation(_refRotation * _rotation, true);
|
||||
somethingChanged = true;
|
||||
|
@ -160,10 +162,10 @@ void JointReferential::update() {
|
|||
}
|
||||
}
|
||||
|
||||
const Model* JointReferential::getModel(const ModelItem* item) {
|
||||
ModelItemFBXService* fbxService = _tree->getFBXService();
|
||||
const Model* JointReferential::getModel(const EntityItem* item) {
|
||||
EntityItemFBXService* fbxService = _tree->getFBXService();
|
||||
if (item != NULL && fbxService != NULL) {
|
||||
return fbxService->getModelForModelItem(*item);
|
||||
return fbxService->getModelForEntityItem(item);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -14,31 +14,31 @@
|
|||
|
||||
#include <Referential.h>
|
||||
|
||||
class ModelTree;
|
||||
class EntityTree;
|
||||
class Model;
|
||||
|
||||
class ModelReferential : public Referential {
|
||||
public:
|
||||
ModelReferential(Referential* ref, ModelTree* tree, AvatarData* avatar);
|
||||
ModelReferential(uint32_t modelID, ModelTree* tree, AvatarData* avatar);
|
||||
ModelReferential(Referential* ref, EntityTree* tree, AvatarData* avatar);
|
||||
ModelReferential(const QUuid& entityID, EntityTree* tree, AvatarData* avatar);
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
||||
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
||||
|
||||
uint32_t _modelID;
|
||||
ModelTree* _tree;
|
||||
QUuid _entityID;
|
||||
EntityTree* _tree;
|
||||
};
|
||||
|
||||
class JointReferential : public ModelReferential {
|
||||
public:
|
||||
JointReferential(Referential* ref, ModelTree* tree, AvatarData* avatar);
|
||||
JointReferential(uint32_t jointIndex, uint32_t modelID, ModelTree* tree, AvatarData* avatar);
|
||||
JointReferential(Referential* ref, EntityTree* tree, AvatarData* avatar);
|
||||
JointReferential(uint32_t jointIndex, const QUuid& entityID, EntityTree* tree, AvatarData* avatar);
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
const Model* getModel(const ModelItem* item);
|
||||
const Model* getModel(const EntityItem* item);
|
||||
virtual int packExtraData(unsigned char* destinationBuffer) const;
|
||||
virtual int unpackExtraData(const unsigned char* sourceBuffer, int size);
|
||||
|
||||
|
|
|
@ -452,8 +452,8 @@ void MyAvatar::clearReferential() {
|
|||
changeReferential(NULL);
|
||||
}
|
||||
|
||||
bool MyAvatar::setModelReferential(int id) {
|
||||
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
||||
bool MyAvatar::setModelReferential(const QUuid& id) {
|
||||
EntityTree* tree = Application::getInstance()->getEntities()->getTree();
|
||||
changeReferential(new ModelReferential(id, tree, this));
|
||||
if (_referential->isValid()) {
|
||||
return true;
|
||||
|
@ -463,8 +463,8 @@ bool MyAvatar::setModelReferential(int id) {
|
|||
}
|
||||
}
|
||||
|
||||
bool MyAvatar::setJointReferential(int id, int jointIndex) {
|
||||
ModelTree* tree = Application::getInstance()->getModels()->getTree();
|
||||
bool MyAvatar::setJointReferential(const QUuid& id, int jointIndex) {
|
||||
EntityTree* tree = Application::getInstance()->getEntities()->getTree();
|
||||
changeReferential(new JointReferential(jointIndex, id, tree, this));
|
||||
if (!_referential->isValid()) {
|
||||
return true;
|
||||
|
|
|
@ -152,8 +152,8 @@ public slots:
|
|||
glm::vec3 getRightPalmPosition();
|
||||
|
||||
void clearReferential();
|
||||
bool setModelReferential(int id);
|
||||
bool setJointReferential(int id, int jointIndex);
|
||||
bool setModelReferential(const QUuid& id);
|
||||
bool setJointReferential(const QUuid& id, int jointIndex);
|
||||
|
||||
signals:
|
||||
void transformChanged();
|
||||
|
|
|
@ -855,8 +855,7 @@ void EntityTree::findEntities(const AACube& cube, QVector<EntityItem*> foundEnti
|
|||
foundEntities.swap(args._foundEntities);
|
||||
}
|
||||
|
||||
#if 0 ///////////////////////////////////
|
||||
EntityItem* EntityTree::findEntityByID(uint32_t id, bool alreadyLocked) /*const*/ {
|
||||
EntityItem* EntityTree::findEntityByID(const QUuid& id) {
|
||||
EntityItemID entityID(id);
|
||||
|
||||
bool wantDebug = false;
|
||||
|
@ -869,7 +868,6 @@ EntityItem* EntityTree::findEntityByID(uint32_t id, bool alreadyLocked) /*const
|
|||
|
||||
return findEntityByEntityItemID(entityID);
|
||||
}
|
||||
#endif ////////////////////////////
|
||||
|
||||
EntityItem* EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ {
|
||||
EntityItem* foundEntity = NULL;
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
class EntityItemFBXService {
|
||||
public:
|
||||
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);
|
||||
|
||||
const EntityItem* findClosestEntity(glm::vec3 position, float targetRadius);
|
||||
EntityItem* findEntityByID(uint32_t id, bool alreadyLocked = false) /*const*/;
|
||||
EntityItem* findEntityByEntityItemID(const EntityItemID& entityID) /*const*/;
|
||||
EntityItem* findEntityByID(const QUuid& id);
|
||||
EntityItem* findEntityByEntityItemID(const EntityItemID& entityID);
|
||||
|
||||
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 -- 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
|
||||
|
||||
|
@ -67,7 +76,6 @@ Model properties:
|
|||
12a) make sure server is deleting items??
|
||||
12b) Use the delete message instead of shouldDelete property
|
||||
|
||||
Q) Referentials????
|
||||
|
||||
R) fix these!!!
|
||||
EntityItem::encodeEntityEditMessageDetails()
|
||||
|
|
Loading…
Reference in a new issue