From 5470f5fb2806377fcd8abefd45cdf7315b7f5e61 Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Sat, 27 Jul 2013 10:34:48 +0900 Subject: [PATCH] add AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION for not transforming position of vertices --- code/ColladaLoader.cpp | 31 ++++++++++++++++--------------- code/ColladaLoader.h | 1 + include/assimp/config.h | 4 +++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 662f31532..a97ea2c6a 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -73,7 +73,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ColladaLoader::ColladaLoader() -: noSkeletonMesh() +: noSkeletonMesh(), ignoreUpDirection(false) {} // ------------------------------------------------------------------------------------------------ @@ -108,6 +108,7 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo void ColladaLoader::SetupProperties(const Importer* pImp) { noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; + ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0; } @@ -160,21 +161,21 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I 0, parser.mUnitSize, 0, 0, 0, 0, parser.mUnitSize, 0, 0, 0, 0, 1); - + if( !ignoreUpDirection ) { // Convert to Y_UP, if different orientation - if( parser.mUpDirection == ColladaParser::UP_X) - pScene->mRootNode->mTransformation *= aiMatrix4x4( - 0, -1, 0, 0, - 1, 0, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - else if( parser.mUpDirection == ColladaParser::UP_Z) - pScene->mRootNode->mTransformation *= aiMatrix4x4( - 1, 0, 0, 0, - 0, 0, 1, 0, - 0, -1, 0, 0, - 0, 0, 0, 1); - + if( parser.mUpDirection == ColladaParser::UP_X) + pScene->mRootNode->mTransformation *= aiMatrix4x4( + 0, -1, 0, 0, + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + else if( parser.mUpDirection == ColladaParser::UP_Z) + pScene->mRootNode->mTransformation *= aiMatrix4x4( + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, -1, 0, 0, + 0, 0, 0, 1); + } // store all meshes StoreSceneMeshes( pScene); diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index 850bce780..953bd20b8 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -234,6 +234,7 @@ protected: std::vector mAnims; bool noSkeletonMesh; + bool ignoreUpDirection; }; } // end of namespace Assimp diff --git a/include/assimp/config.h b/include/assimp/config.h index c1694c94c..8683cc385 100644 --- a/include/assimp/config.h +++ b/include/assimp/config.h @@ -841,4 +841,6 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" -#endif // !! AI_CONFIG_H_INC \ No newline at end of file +#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" + +#endif // !! AI_CONFIG_H_INC