diff --git a/code/MS3DLoader.cpp b/code/MS3DLoader.cpp index 6fad24f41..0b9c7d417 100644 --- a/code/MS3DLoader.cpp +++ b/code/MS3DLoader.cpp @@ -52,6 +52,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "StreamReader.h" using namespace Assimp; +// ASSIMP_BUILD_MS3D_ONE_NODE_PER_MESH +// (enable old code path, which generates extra nodes per mesh while +// the newer code uses aiMesh::mName to express the name of the +// meshes (a.k.a. groups in MS3D)) + // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer MS3DImporter::MS3DImporter() @@ -546,6 +551,8 @@ void MS3DImporter::InternReadFile( const std::string& pFile, // ... add dummy nodes under a single root, each holding a reference to one // mesh. If we didn't do this, we'd loose the group name. aiNode* rt = pScene->mRootNode = new aiNode(""); + +#ifdef ASSIMP_BUILD_MS3D_ONE_NODE_PER_MESH rt->mChildren = new aiNode*[rt->mNumChildren=pScene->mNumMeshes+(joints.size()?1:0)](); for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { @@ -563,9 +570,18 @@ void MS3DImporter::InternReadFile( const std::string& pFile, nd->mMeshes = new unsigned int[nd->mNumMeshes = 1]; nd->mMeshes[0] = i; } +#else + rt->mMeshes = new unsigned int[pScene->mNumMeshes]; + for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { + rt->mMeshes[rt->mNumMeshes++] = i; + } +#endif // convert animations as well if(joints.size()) { +#ifndef ASSIMP_BUILD_MS3D_ONE_NODE_PER_MESH + rt->mChildren = new aiNode*[1](); +#endif aiNode* jt = rt->mChildren[pScene->mNumMeshes] = new aiNode(); jt->mParent = rt; CollectChildJoints(joints,jt); diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index efde1f731..5f23b30d3 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -1147,9 +1147,10 @@ void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd // ----------------------------------------------------------------------------------- int Assimp_Dump (const char* const* params, unsigned int num) { + const char* fail = "assimp dump: Invalid number of arguments. " + "See \'assimp dump --help\'\r\n"; if (num < 1) { - ::printf("assimp dump: Invalid number of arguments. " - "See \'assimp dump --help\'\r\n"); + printf(fail); return 1; } @@ -1161,8 +1162,7 @@ int Assimp_Dump (const char* const* params, unsigned int num) // asssimp dump in out [options] if (num < 1) { - ::printf("assimp dump: Invalid number of arguments. " - "See \'assimp dump --help\'\r\n"); + printf(fail); return 1; } @@ -1206,28 +1206,28 @@ int Assimp_Dump (const char* const* params, unsigned int num) if (out[0] == '-') { // take file name from input file std::string::size_type s = in.find_last_of('.'); - if (s == std::string::npos) + if (s == std::string::npos) { s = in.length(); + } out = in.substr(0,s); out.append((binary ? ".assbin" : ".assxml")); - if (shortened && binary) + if (shortened && binary) { out.append(".regress"); + } } // import the main model const aiScene* scene = ImportModel(import,in); if (!scene) { - ::printf("assimp dump: Unable to load input file %s\n", - in.c_str()); + printf("assimp dump: Unable to load input file %s\n",in.c_str()); return 5; } // open the output file and build the dump FILE* o = ::fopen(out.c_str(),(binary ? "wb" : "wt")); if (!o) { - ::printf("assimp dump: Unable to open output file %s\n", - out.c_str()); + printf("assimp dump: Unable to open output file %s\n",out.c_str()); return 12; } @@ -1235,13 +1235,13 @@ int Assimp_Dump (const char* const* params, unsigned int num) WriteBinaryDump (scene,o,in.c_str(),cmd.c_str(),shortened,compressed,import); } else WriteDump (scene,o,in.c_str(),cmd.c_str(),shortened); - ::fclose(o); + fclose(o); if (compressed && binary) { CompressBinaryDump(out.c_str(),ASSBIN_HEADER_LENGTH); } - ::printf("assimp dump: Wrote output dump %s\n",out.c_str()); + printf("assimp dump: Wrote output dump %s\n",out.c_str()); return 0; }