From b6dced4b115fde178eb03eec924c47d35d77e75e Mon Sep 17 00:00:00 2001 From: ethan Date: Wed, 10 Mar 2021 18:06:42 +0900 Subject: [PATCH] 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