Extanded FBXService + moved ModelReferential

This commit is contained in:
Atlante45 2014-07-30 16:48:11 -07:00
parent 069f1ed247
commit bc77630c5b
5 changed files with 55 additions and 2 deletions

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <AvatarData.h>
#include "ModelTree.h"
#include "ModelReferential.h"
@ -19,7 +21,7 @@ _modelID(modelID),
_tree(tree)
{
const ModelItem* item = _tree->findModelByID(_modelID);
if (!_isValid || item == NULL || _avatar == NULL) {
if (!_isValid || item == NULL) {
_isValid = false;
return;
}
@ -58,3 +60,34 @@ void ModelReferential::update() {
somethingChanged = true;
}
}
JointReferential::JointReferential(uint32_t jointID, uint32_t modelID, ModelTree* tree, AvatarData* avatar) :
ModelReferential(modelID, tree, avatar),
_jointID(jointID)
{
const Model* model = getModel(_tree->findModelByID(_modelID));
if (!_isValid || model == NULL || model->getJointStateCount() <= jointID) {
_isValid = false;
return;
}
}
void JointReferential::update() {
const ModelItem* item = _tree->findModelByID(_modelID);
if (!_isValid || item == NULL) {
_isValid = false;
return;
}
}
const Model* JointReferential::getModel(const ModelItem* item) {
ModelItemFBXService* fbxService = _tree->getFBXService();
if (item != NULL && fbxService != NULL) {
return fbxService->getModelForModelItem(*item);
}
return NULL;
}

View file

@ -15,6 +15,7 @@
#include <Referential.h>
class ModelTree;
class Model;
class ModelReferential : public Referential {
public:
@ -26,4 +27,15 @@ protected:
ModelTree* _tree;
};
class JointReferential : public ModelReferential {
public:
JointReferential(uint32_t jointID, uint32_t modelID, ModelTree* tree, AvatarData* avatar);
virtual void update();
protected:
const Model* getModel(const ModelItem* item);
uint32_t _jointID;
};
#endif // hifi_ModelReferential_h

View file

@ -76,6 +76,10 @@ const FBXGeometry* ModelTreeRenderer::getGeometryForModel(const ModelItem& model
return result;
}
const Model* ModelTreeRenderer::getModelForModelItem(const ModelItem& modelItem) {
return getModel(modelItem);
}
Model* ModelTreeRenderer::getModel(const ModelItem& modelItem) {
Model* model = NULL;

View file

@ -51,7 +51,7 @@ public:
virtual void render(RenderMode renderMode = DEFAULT_RENDER_MODE);
virtual const FBXGeometry* getGeometryForModel(const ModelItem& modelItem);
virtual const Model* getModelForModelItem(const ModelItem& modelItem);
/// clears the tree
virtual void clear();

View file

@ -15,6 +15,8 @@
#include <Octree.h>
#include "ModelTreeElement.h"
class Model;
class NewlyCreatedModelHook {
public:
virtual void modelCreated(const ModelItem& newModel, const SharedNodePointer& senderNode) = 0;
@ -23,6 +25,7 @@ public:
class ModelItemFBXService {
public:
virtual const FBXGeometry* getGeometryForModel(const ModelItem& modelItem) = 0;
virtual const Model* getModelForModelItem(const ModelItem& modelItem) = 0;
};
class ModelTree : public Octree {
@ -80,6 +83,7 @@ public:
void processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode);
void handleAddModelResponse(const QByteArray& packet);
ModelItemFBXService* getFBXService() const { return _fbxService; }
void setFBXService(ModelItemFBXService* service) { _fbxService = service; }
const FBXGeometry* getGeometryForModel(const ModelItem& modelItem) {
return _fbxService ? _fbxService->getGeometryForModel(modelItem) : NULL;