From b6dced4b115fde178eb03eec924c47d35d77e75e Mon Sep 17 00:00:00 2001 From: ethan Date: Wed, 10 Mar 2021 18:06:42 +0900 Subject: [PATCH 1/4] export with rotation --- tools/assimp_cmd/Main.cpp | 21 +++++++++++++++++++++ tools/assimp_cmd/Main.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index 6801100ac..7cb90a7d7 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -325,6 +325,14 @@ bool ExportModel(const aiScene* pOut, PrintHorBar(); } + aiMatrix4x4 rx, ry, rz; + aiMatrix4x4::RotationX(imp.rot.x, rx); + aiMatrix4x4::RotationX(imp.rot.y, ry); + aiMatrix4x4::RotationX(imp.rot.z, rz); + pOut->mRootNode->mTransformation *= rx; + pOut->mRootNode->mTransformation *= ry; + pOut->mRootNode->mTransformation *= rz; + // do the actual export, measure time const clock_t first = clock(); const aiReturn res = globalExporter->Export(pOut,pID,path); @@ -493,6 +501,19 @@ int ProcessStandardArguments( else if (! strcmp( param, "-v") || ! strcmp( param, "--verbose")) { fill.verbose = true; } + else if (!strncmp(params[i], "-rx=", 4) || !strncmp(params[i], "--rotation-x=", 13)) { + printf("%s", params[i]); + std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4)); + fill.rot.x = std::stof(value); + } + else if (!strncmp(params[i], "-ry=", 4) || !strncmp(params[i], "--rotation-y=", 13)) { + std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4)); + fill.rot.y = std::stof(value); + } + else if (!strncmp(params[i], "-rz=", 4) || !strncmp(params[i], "--rotation-z=", 13)) { + std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4)); + fill.rot.z = std::stof(value); + } else if (! strncmp( param, "--log-out=",10) || ! strncmp( param, "-lo",3)) { fill.logFile = std::string(params[i]+(params[i][1] == '-' ? 10 : 3)); if (!fill.logFile.length()) { diff --git a/tools/assimp_cmd/Main.h b/tools/assimp_cmd/Main.h index bcd2e5c0f..e7fbb6c75 100644 --- a/tools/assimp_cmd/Main.h +++ b/tools/assimp_cmd/Main.h @@ -96,6 +96,7 @@ struct ImportData { , showLog (false) , verbose (false) , log (false) + , rot (aiVector3D(0.f, 0.f, 0.f)) {} /// Post-processing flags @@ -112,6 +113,9 @@ struct ImportData { // Need to log? bool log; + + // Export With Rotation + aiVector3D rot; }; /// \enum AssimpCmdError From 16f10a0533df777e8b554efd44d94414d8906412 Mon Sep 17 00:00:00 2001 From: jaefunk Date: Fri, 12 Mar 2021 10:27:33 +0900 Subject: [PATCH 2/4] remove debug log --- tools/assimp_cmd/Main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index 7cb90a7d7..1a8c38021 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -502,7 +502,6 @@ int ProcessStandardArguments( fill.verbose = true; } else if (!strncmp(params[i], "-rx=", 4) || !strncmp(params[i], "--rotation-x=", 13)) { - printf("%s", params[i]); std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4)); fill.rot.x = std::stof(value); } From a812fd1a0ac4366d93393cc1b74fe74a70bf8ad6 Mon Sep 17 00:00:00 2001 From: jaefunk Date: Mon, 15 Mar 2021 10:23:17 +0900 Subject: [PATCH 3/4] can modify the rotation of the model when exporting. --- tools/assimp_cmd/Main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index 1a8c38021..2fb7559bb 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -327,8 +327,8 @@ bool ExportModel(const aiScene* pOut, aiMatrix4x4 rx, ry, rz; aiMatrix4x4::RotationX(imp.rot.x, rx); - aiMatrix4x4::RotationX(imp.rot.y, ry); - aiMatrix4x4::RotationX(imp.rot.z, rz); + aiMatrix4x4::RotationY(imp.rot.y, ry); + aiMatrix4x4::RotationZ(imp.rot.z, rz); pOut->mRootNode->mTransformation *= rx; pOut->mRootNode->mTransformation *= ry; pOut->mRootNode->mTransformation *= rz; From 3e99385f4487774b3f915f0df3cf9aa6d9942bd3 Mon Sep 17 00:00:00 2001 From: Hill Ma Date: Wed, 17 Mar 2021 15:12:54 -0700 Subject: [PATCH 4/4] Fix a memory leak in glTF2. The destructor of LazyDict uses `delete` but `delete` was not used for objects removed by LazyDict::Remove. --- code/AssetLib/glTF2/glTF2Asset.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 389a05199..a8d4f2d98 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -383,6 +383,7 @@ unsigned int LazyDict::Remove(const char *id) { mAsset.mUsedIds[id] = false; mObjsById.erase(id); mObjsByOIndex.erase(index); + delete mObjs[index]; mObjs.erase(mObjs.begin() + index); //update index of object in mObjs;