From 4e9a0bba20f4aa37e46141724178e6f42ab4ed82 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Thu, 21 Jun 2012 17:24:50 +0200 Subject: [PATCH] + add AI_CONFIG_IMPORT_NO_SKELETON_MESHES flag to control skeleton mesh visualization. No need for this in Blender, and difficult to just ignore the geometry created by it. --- code/ASELoader.cpp | 7 ++++++- code/ASELoader.h | 1 + code/BVHLoader.cpp | 13 +++++++++++-- code/BVHLoader.h | 3 +++ code/CSMLoader.cpp | 10 +++++++--- code/CSMLoader.h | 3 +++ code/ColladaLoader.cpp | 12 +++++++++++- code/ColladaLoader.h | 4 ++++ code/LWSLoader.cpp | 5 ++++- code/LWSLoader.h | 2 ++ include/assimp/config.h | 20 ++++++++++++++++---- 11 files changed, 68 insertions(+), 12 deletions(-) diff --git a/code/ASELoader.cpp b/code/ASELoader.cpp index 1f0c49eb9..f84978509 100644 --- a/code/ASELoader.cpp +++ b/code/ASELoader.cpp @@ -74,6 +74,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ASEImporter::ASEImporter() +: noSkeletonMesh() {} // ------------------------------------------------------------------------------------------------ @@ -111,6 +112,8 @@ void ASEImporter::SetupProperties(const Importer* pImp) { configRecomputeNormals = (pImp->GetPropertyInteger( AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS,1) ? true : false); + + noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; } // ------------------------------------------------------------------------------------------------ @@ -244,7 +247,9 @@ void ASEImporter::InternReadFile( const std::string& pFile, // ------------------------------------------------------------------ if (!pScene->mNumMeshes) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; - SkeletonMeshBuilder skeleton(pScene); + if (!noSkeletonMesh) { + SkeletonMeshBuilder skeleton(pScene); + } } } // ------------------------------------------------------------------------------------------------ diff --git a/code/ASELoader.h b/code/ASELoader.h index 796b395b9..82c1e412f 100644 --- a/code/ASELoader.h +++ b/code/ASELoader.h @@ -197,6 +197,7 @@ protected: /** Config options: Recompute the normals in every case - WA for 3DS Max broken ASE normal export */ bool configRecomputeNormals; + bool noSkeletonMesh; }; } // end of namespace Assimp diff --git a/code/BVHLoader.cpp b/code/BVHLoader.cpp index 1464e4d7c..f6f890b19 100644 --- a/code/BVHLoader.cpp +++ b/code/BVHLoader.cpp @@ -65,6 +65,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer BVHLoader::BVHLoader() +: noSkeletonMesh() {} // ------------------------------------------------------------------------------------------------ @@ -89,6 +90,12 @@ bool BVHLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs return false; } +// ------------------------------------------------------------------------------------------------ +void BVHLoader::SetupProperties(const Importer* pImp) +{ + noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; +} + // ------------------------------------------------------------------------------------------------ // Loader meta information const aiImporterDesc* BVHLoader::GetInfo () const @@ -119,8 +126,10 @@ void BVHLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSys mLine = 1; ReadStructure( pScene); - // build a dummy mesh for the skeleton so that we see something at least - SkeletonMeshBuilder meshBuilder( pScene); + if (!noSkeletonMesh) { + // build a dummy mesh for the skeleton so that we see something at least + SkeletonMeshBuilder meshBuilder( pScene); + } // construct an animation from all the motion data we read CreateAnimation( pScene); diff --git a/code/BVHLoader.h b/code/BVHLoader.h index 7e8237970..5fe9c2da9 100644 --- a/code/BVHLoader.h +++ b/code/BVHLoader.h @@ -94,6 +94,7 @@ public: * See BaseImporter::CanRead() for details. */ bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const; + void SetupProperties(const Importer* pImp); const aiImporterDesc* GetInfo () const; protected: @@ -159,6 +160,8 @@ protected: /** basic Animation parameters */ float mAnimTickDuration; unsigned int mAnimNumFrames; + + bool noSkeletonMesh; }; } // end of namespace Assimp diff --git a/code/CSMLoader.cpp b/code/CSMLoader.cpp index ab50762e4..643eb75ed 100644 --- a/code/CSMLoader.cpp +++ b/code/CSMLoader.cpp @@ -71,6 +71,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer CSMImporter::CSMImporter() +: noSkeletonMesh() {} // ------------------------------------------------------------------------------------------------ @@ -104,9 +105,9 @@ const aiImporterDesc* CSMImporter::GetInfo () const // ------------------------------------------------------------------------------------------------ // Setup configuration properties for the loader -void CSMImporter::SetupProperties(const Importer* /*pImp*/) +void CSMImporter::SetupProperties(const Importer* pImp) { - // nothing to be done for the moment + noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; } // ------------------------------------------------------------------------------------------------ @@ -289,7 +290,10 @@ void CSMImporter::InternReadFile( const std::string& pFile, // mark the scene as incomplete and run SkeletonMeshBuilder on it pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; - SkeletonMeshBuilder maker(pScene,pScene->mRootNode,true); + + if (!noSkeletonMesh) { + SkeletonMeshBuilder maker(pScene,pScene->mRootNode,true); + } } #endif // !! ASSIMP_BUILD_NO_CSM_IMPORTER diff --git a/code/CSMLoader.h b/code/CSMLoader.h index 15760845c..d3fae27c1 100644 --- a/code/CSMLoader.h +++ b/code/CSMLoader.h @@ -79,6 +79,9 @@ protected: IOSystem* pIOHandler); private: + + bool noSkeletonMesh; + }; // end of class CSMImporter } // end of namespace Assimp #endif // AI_AC3DIMPORTER_H_INC diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 0cd6cb104..3f5019bb4 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -73,6 +73,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ColladaLoader::ColladaLoader() +: noSkeletonMesh() {} // ------------------------------------------------------------------------------------------------ @@ -103,6 +104,13 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo return false; } +// ------------------------------------------------------------------------------------------------ +void ColladaLoader::SetupProperties(const Importer* pImp) +{ + noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; +} + + // ------------------------------------------------------------------------------------------------ // Get file extension list const aiImporterDesc* ColladaLoader::GetInfo () const @@ -180,7 +188,9 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I // If no meshes have been loaded, it's probably just an animated skeleton. if (!pScene->mNumMeshes) { - SkeletonMeshBuilder hero(pScene); + if (!noSkeletonMesh) { + SkeletonMeshBuilder hero(pScene); + } pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; } } diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index b2b903077..850bce780 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -94,6 +94,8 @@ protected: */ const aiImporterDesc* GetInfo () const; + void SetupProperties(const Importer* pImp); + /** Imports the given file into the given scene structure. * See BaseImporter::InternReadFile() for details */ @@ -230,6 +232,8 @@ protected: /** Accumulated animations for the target scene */ std::vector mAnims; + + bool noSkeletonMesh; }; } // end of namespace Assimp diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index 9058f9169..91c3bc6a3 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -123,6 +123,7 @@ void LWS::Element::Parse (const char*& buffer) // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer LWSImporter::LWSImporter() +: noSkeletonMesh() { // nothing to do here } @@ -177,6 +178,8 @@ void LWSImporter::SetupProperties(const Importer* pImp) if (last < first) { std::swap(last,first); } + + noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; } // ------------------------------------------------------------------------------------------------ @@ -908,7 +911,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, if (!pScene->mNumMeshes || !pScene->mNumMaterials) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; - if (pScene->mNumAnimations) { + if (pScene->mNumAnimations && !noSkeletonMesh) { // construct skeleton mesh SkeletonMeshBuilder builder(pScene); } diff --git a/code/LWSLoader.h b/code/LWSLoader.h index d3a6d2787..7cca75b3a 100644 --- a/code/LWSLoader.h +++ b/code/LWSLoader.h @@ -233,6 +233,8 @@ private: IOSystem* io; double first,last,fps; + + bool noSkeletonMesh; }; } // end of namespace Assimp diff --git a/include/assimp/config.h b/include/assimp/config.h index 9c4fef0f8..6d2aa921a 100644 --- a/include/assimp/config.h +++ b/include/assimp/config.h @@ -77,6 +77,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_GLOB_MEASURE_TIME \ "GLOB_MEASURE_TIME" + +// --------------------------------------------------------------------------- +/** @brief Global setting to disable generation of skeleton dummy meshes + * + * Skeleton dummy meshes are generated as a visualization aid in cases which + * the input data contains no geometry, but only animation data. + * Property data type: bool. Default value: false + */ +// --------------------------------------------------------------------------- +#define AI_CONFIG_IMPORT_NO_SKELETON_MESHES \ + "IMPORT_NO_SKELETON_MESHES" + + + # if 0 // not implemented yet // --------------------------------------------------------------------------- /** @brief Set Assimp's multithreading policy. @@ -158,6 +172,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE \ "PP_GSN_MAX_SMOOTHING_ANGLE" + // --------------------------------------------------------------------------- /** @brief Sets the colormap (= palette) to be used to decode embedded * textures in MDL (Quake or 3DGS) files. @@ -697,9 +712,6 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME "IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME" - - -// --------------------------------------------------------------------------- /** @brief Specifies whether the IFC loader skips over IfcSpace elements. * * IfcSpace elements (and their geometric representations) are used to @@ -735,4 +747,4 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" -#endif // !! AI_CONFIG_H_INC +#endif // !! AI_CONFIG_H_INC \ No newline at end of file