瀏覽代碼

Added custom root transformation for pre-transform vertices post-process step

Léo Terziman 11 年之前
父節點
當前提交
f54c85d4e6
共有 3 個文件被更改,包括 33 次插入4 次删除
  1. 10 2
      code/PretransformVertices.cpp
  2. 4 2
      code/PretransformVertices.h
  3. 19 0
      include/assimp/config.h

+ 10 - 2
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);
 

+ 4 - 2
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

+ 19 - 0
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.