From ba0cecb3561c6b47be665354d082a6918b3df034 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 9 Jun 2015 12:32:37 -0700 Subject: [PATCH] remove attachments from Model - only supported at avatar layer --- libraries/fbx/src/FBXReader.cpp | 28 ------------- libraries/fbx/src/FBXReader.h | 15 +------ libraries/fbx/src/FSTReader.cpp | 4 +- libraries/fbx/src/OBJReader.cpp | 1 - libraries/render-utils/src/Model.cpp | 60 ---------------------------- libraries/render-utils/src/Model.h | 2 - 6 files changed, 4 insertions(+), 106 deletions(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 464deb1059..76108730e8 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -2646,34 +2646,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } } geometry.palmDirection = parseVec3(mapping.value("palmDirection", "0, -1, 0").toString()); - - // process attachments - QVariantHash attachments = mapping.value("attach").toHash(); - for (QVariantHash::const_iterator it = attachments.constBegin(); it != attachments.constEnd(); it++) { - FBXAttachment attachment; - attachment.jointIndex = modelIDs.indexOf(processID(it.key())); - attachment.scale = glm::vec3(1.0f, 1.0f, 1.0f); - - QVariantList properties = it->toList(); - if (properties.isEmpty()) { - attachment.url = it->toString(); - } else { - attachment.url = properties.at(0).toString(); - - if (properties.size() >= 2) { - attachment.translation = parseVec3(properties.at(1).toString()); - - if (properties.size() >= 3) { - attachment.rotation = glm::quat(glm::radians(parseVec3(properties.at(2).toString()))); - - if (properties.size() >= 4) { - attachment.scale = parseVec3(properties.at(3).toString()); - } - } - } - } - geometry.attachments.append(attachment); - } // Add sitting points QVariantHash sittingPoints = mapping.value("sit").toHash(); diff --git a/libraries/fbx/src/FBXReader.h b/libraries/fbx/src/FBXReader.h index 08ac0e308c..200cd4a121 100644 --- a/libraries/fbx/src/FBXReader.h +++ b/libraries/fbx/src/FBXReader.h @@ -189,17 +189,6 @@ public: Q_DECLARE_METATYPE(FBXAnimationFrame) Q_DECLARE_METATYPE(QVector) -/// An attachment to an FBX document. -class FBXAttachment { -public: - - int jointIndex; - QUrl url; - glm::vec3 translation; - glm::quat rotation; - glm::vec3 scale; -}; - /// A point where an avatar can sit class SittingPoint { public: @@ -256,9 +245,7 @@ public: Extents meshExtents; QVector animationFrames; - - QVector attachments; - + int getJointIndex(const QString& name) const { return jointIndices.value(name) - 1; } QStringList getJointNames() const; diff --git a/libraries/fbx/src/FSTReader.cpp b/libraries/fbx/src/FSTReader.cpp index 32be82b392..a62c0fcea2 100644 --- a/libraries/fbx/src/FSTReader.cpp +++ b/libraries/fbx/src/FSTReader.cpp @@ -124,7 +124,9 @@ FSTReader::ModelType FSTReader::getTypeFromName(const QString& name) { _namesToTypes["head"] = HEAD_MODEL ; _namesToTypes["body"] = BODY_ONLY_MODEL; _namesToTypes["body+head"] = HEAD_AND_BODY_MODEL; - _namesToTypes["attachment"] = ATTACHMENT_MODEL; + + // NOTE: this is not yet implemented, but will be used to allow you to attach fully independent models to your avatar + _namesToTypes["attachment"] = ATTACHMENT_MODEL; } return _namesToTypes[name]; } diff --git a/libraries/fbx/src/OBJReader.cpp b/libraries/fbx/src/OBJReader.cpp index 4a8a2fc53d..f0d3ecf517 100644 --- a/libraries/fbx/src/OBJReader.cpp +++ b/libraries/fbx/src/OBJReader.cpp @@ -544,7 +544,6 @@ void fbxDebugDump(const FBXGeometry& fbxgeo) { qCDebug(modelformat) << "---------------- fbxGeometry ----------------"; qCDebug(modelformat) << " hasSkeletonJoints =" << fbxgeo.hasSkeletonJoints; qCDebug(modelformat) << " offset =" << fbxgeo.offset; - qCDebug(modelformat) << " attachments.count() = " << fbxgeo.attachments.count(); qCDebug(modelformat) << " meshes.count() =" << fbxgeo.meshes.count(); foreach (FBXMesh mesh, fbxgeo.meshes) { qCDebug(modelformat) << " vertices.count() =" << mesh.vertices.count(); diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index c578015b9f..824f100d46 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -405,9 +405,6 @@ void Model::reset() { if (_jointStates.isEmpty()) { return; } - foreach (Model* attachment, _attachments) { - attachment->reset(); - } const FBXGeometry& geometry = _geometry->getFBXGeometry(); for (int i = 0; i < _jointStates.size(); i++) { _jointStates[i].setRotationInConstrainedFrame(geometry.joints.at(i).rotation, 0.0f); @@ -419,14 +416,7 @@ void Model::reset() { } bool Model::updateGeometry() { - // NOTE: this is a recursive call that walks all attachments, and their attachments bool needFullUpdate = false; - for (int i = 0; i < _attachments.size(); i++) { - Model* model = _attachments.at(i); - if (model->updateGeometry()) { - needFullUpdate = true; - } - } bool needToRebuild = false; if (_nextGeometry) { @@ -499,12 +489,6 @@ bool Model::updateGeometry() { } _blendedVertexBuffers.push_back(buffer); } - foreach (const FBXAttachment& attachment, fbxGeometry.attachments) { - Model* model = new Model(this); - model->init(); - model->setURL(attachment.url); - _attachments.append(model); - } needFullUpdate = true; } return needFullUpdate; @@ -913,12 +897,6 @@ bool Model::addToScene(std::shared_ptr scene, render::PendingChan bool somethingAdded = false; - // allow the attachments to add to scene - foreach (Model* attachment, _attachments) { - bool attachementSomethingAdded = attachment->addToScene(scene, pendingChanges); - somethingAdded = somethingAdded || attachementSomethingAdded; - } - foreach (auto renderItem, _transparentRenderItems) { auto item = scene->allocateID(); auto renderData = TransparentMeshPart::Pointer(renderItem); @@ -942,11 +920,6 @@ bool Model::addToScene(std::shared_ptr scene, render::PendingChan } void Model::removeFromScene(std::shared_ptr scene, render::PendingChanges& pendingChanges) { - // allow the attachments to remove to scene - foreach (Model* attachment, _attachments) { - attachment->removeFromScene(scene, pendingChanges); - } - foreach (auto item, _renderItems.keys()) { pendingChanges.removeItem(item); } @@ -958,10 +931,6 @@ bool Model::render(RenderArgs* renderArgs, float alpha) { return true; // PROFILE_RANGE(__FUNCTION__); - // render the attachments - foreach (Model* attachment, _attachments) { - attachment->render(renderArgs, alpha); - } if (_meshStates.isEmpty()) { return false; } @@ -1623,7 +1592,6 @@ void Model::simulate(float deltaTime, bool fullUpdate) { } void Model::simulateInternal(float deltaTime) { - // NOTE: this is a recursive call that walks all attachments, and their attachments // update the world space transforms for all joints // update animations @@ -1640,31 +1608,7 @@ void Model::simulateInternal(float deltaTime) { _shapesAreDirty = !_shapes.isEmpty(); - // update the attachment transforms and simulate them const FBXGeometry& geometry = _geometry->getFBXGeometry(); - for (int i = 0; i < _attachments.size(); i++) { - const FBXAttachment& attachment = geometry.attachments.at(i); - Model* model = _attachments.at(i); - - glm::vec3 jointTranslation = _translation; - glm::quat jointRotation = _rotation; - if (_showTrueJointTransforms) { - getJointPositionInWorldFrame(attachment.jointIndex, jointTranslation); - getJointRotationInWorldFrame(attachment.jointIndex, jointRotation); - } else { - getVisibleJointPositionInWorldFrame(attachment.jointIndex, jointTranslation); - getVisibleJointRotationInWorldFrame(attachment.jointIndex, jointRotation); - } - - model->setTranslation(jointTranslation + jointRotation * attachment.translation * _scale); - model->setRotation(jointRotation * attachment.rotation); - model->setScale(_scale * attachment.scale); - - if (model->isActive()) { - model->simulateInternal(deltaTime); - } - } - glm::mat4 modelToWorld = glm::mat4_cast(_rotation); for (int i = 0; i < _meshStates.size(); i++) { MeshState& state = _meshStates[i]; @@ -2002,10 +1946,6 @@ void Model::applyNextGeometry() { } void Model::deleteGeometry() { - foreach (Model* attachment, _attachments) { - delete attachment; - } - _attachments.clear(); _blendedVertexBuffers.clear(); _jointStates.clear(); _meshStates.clear(); diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 6f751a5f8d..043b7e659b 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -350,8 +350,6 @@ private: QVector > > _dilatedTextures; - QVector _attachments; - QSet _animationHandles; QList _runningAnimations;