diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index 1eaa1ab17..007897c93 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -57,7 +57,7 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer PretransformVertices::PretransformVertices() -: configKeepHierarchy (false) +: configKeepHierarchy (false), configNormalize(false), configTransform(false), configTransformation() { } @@ -79,9 +79,13 @@ bool PretransformVertices::IsActive( unsigned int pFlags) const // Setup import configuration void PretransformVertices::SetupProperties(const Importer* pImp) { - // Get the current value of AI_CONFIG_PP_PTV_KEEP_HIERARCHY and AI_CONFIG_PP_PTV_NORMALIZE + // Get the current value of AI_CONFIG_PP_PTV_KEEP_HIERARCHY, AI_CONFIG_PP_PTV_NORMALIZE, + // AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION and AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION configKeepHierarchy = (0 != pImp->GetPropertyInteger(AI_CONFIG_PP_PTV_KEEP_HIERARCHY,0)); configNormalize = (0 != pImp->GetPropertyInteger(AI_CONFIG_PP_PTV_NORMALIZE,0)); + configTransform = (0 != pImp->GetPropertyInteger(AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION,0)); + + configTransformation = pImp->GetPropertyMatrix(AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION, aiMatrix4x4()); } // ------------------------------------------------------------------------------------------------ @@ -439,6 +443,10 @@ void PretransformVertices::Execute( aiScene* pScene) const unsigned int iOldAnimationChannels = pScene->mNumAnimations; const unsigned int iOldNodes = CountNodes(pScene->mRootNode); + if(configTransform) { + pScene->mRootNode->mTransformation = configTransformation; + } + // first compute absolute transformation matrices for all nodes ComputeAbsoluteTransform(pScene->mRootNode); diff --git a/code/PretransformVertices.h b/code/PretransformVertices.h index bfe2c84c8..b1b42c00e 100644 --- a/code/PretransformVertices.h +++ b/code/PretransformVertices.h @@ -152,8 +152,10 @@ private: //! Configuration option: keep scene hierarchy as long as possible - bool configKeepHierarchy, configNormalize; - + bool configKeepHierarchy; + bool configNormalize; + bool configTransform; + aiMatrix4x4 configTransformation; }; } // end of namespace Assimp diff --git a/include/assimp/config.h b/include/assimp/config.h index 8683cc385..034652fa8 100644 --- a/include/assimp/config.h +++ b/include/assimp/config.h @@ -233,6 +233,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_PTV_NORMALIZE \ "PP_PTV_NORMALIZE" +// --------------------------------------------------------------------------- +/** @brief Configures the #aiProcess_PretransformVertices step to use + * a users defined matrix as the scene root node transformation before + * transforming vertices. + * Property type: bool. Default value: false. + */ +#define AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION \ + "PP_PTV_ADD_ROOT_TRANSFORMATION" + +// --------------------------------------------------------------------------- +/** @brief Configures the #aiProcess_PretransformVertices step to use + * a users defined matrix as the scene root node transformation before + * transforming vertices. This property correspond to the 'a1' component + * of the transformation matrix. + * Property type: aiMatrix4x4. + */ +#define AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION \ + "PP_PTV_ROOT_TRANSFORMATION" + // --------------------------------------------------------------------------- /** @brief Configures the #aiProcess_FindDegenerates step to * remove degenerated primitives from the import - immediately.