Browse Source

- BVH-Loader more or less final now. Reads motion capturing date which plays fine in the viewer, just mirrored ATM.
- Fixed RH->LH conversion, now correctly exchanging Y and Z axis. WARNING: this might propably break face orientations and stuff... I'm to revisit this in the next days.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@227 67173fc5-114c-0410-ac8e-9d2fd5bffc1f

ulfjorensen 17 years ago
parent
commit
c25e576a01
2 changed files with 15 additions and 19 deletions
  1. 7 11
      code/BVHLoader.cpp
  2. 8 8
      code/ConvertToLHProcess.cpp

+ 7 - 11
code/BVHLoader.cpp

@@ -435,20 +435,18 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
 			{
 				poskey->mTime = double( fr);
 				poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + 0];
-				poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + 1];
-				poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + 2];
+				poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + 1];
+				poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + 2];
 				++poskey;
 			}
 		} else
 		{
 			// if no translation part is given, put a default sequence
 			aiVector3D nodePos( node.mNode->mTransformation.a4, node.mNode->mTransformation.b4, node.mNode->mTransformation.c4);
-			nodeAnim->mNumPositionKeys = 2;
-			nodeAnim->mPositionKeys = new aiVectorKey[2];
+			nodeAnim->mNumPositionKeys = 1;
+			nodeAnim->mPositionKeys = new aiVectorKey[1];
 			nodeAnim->mPositionKeys[0].mTime = 0.0;
 			nodeAnim->mPositionKeys[0].mValue = nodePos;
-			nodeAnim->mPositionKeys[1].mTime = anim->mDuration;
-			nodeAnim->mPositionKeys[1].mValue = nodePos;
 		}
 
 		// rotation part. Always present. First find value offsets
@@ -485,9 +483,9 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
 				float angleY = node.mChannelValues[fr * node.mChannels.size() + rotOffset + 2] * float( AI_MATH_PI) / 180.0f;
 				aiMatrix4x4 temp;
 				aiMatrix3x3 rotMatrix;
+				aiMatrix4x4::RotationZ( angleZ, temp); rotMatrix *= aiMatrix3x3( temp);
 				aiMatrix4x4::RotationX( angleX, temp); rotMatrix *= aiMatrix3x3( temp);
 				aiMatrix4x4::RotationY( angleY, temp); rotMatrix *= aiMatrix3x3( temp);
-				aiMatrix4x4::RotationZ( angleZ, temp); rotMatrix *= aiMatrix3x3( temp);
 
 				rotkey->mTime = double( fr);
 				rotkey->mValue = aiQuaternion( rotMatrix);
@@ -497,12 +495,10 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
 
 		// scaling part. Always just a default track
 		{
-			nodeAnim->mNumScalingKeys = 2;
-			nodeAnim->mScalingKeys = new aiVectorKey[2];
+			nodeAnim->mNumScalingKeys = 1;
+			nodeAnim->mScalingKeys = new aiVectorKey[1];
 			nodeAnim->mScalingKeys[0].mTime = 0.0;
 			nodeAnim->mScalingKeys[0].mValue.Set( 1.0f, 1.0f, 1.0f);
-			nodeAnim->mScalingKeys[1].mTime = anim->mDuration;
-			nodeAnim->mScalingKeys[1].mValue.Set( 1.0f, 1.0f, 1.0f);
 		}
 	}
 }

+ 8 - 8
code/ConvertToLHProcess.cpp

@@ -51,11 +51,11 @@ using namespace Assimp;
 
 // The transformation matrix to convert from DirectX coordinates to OpenGL coordinates.
 const aiMatrix3x3 Assimp::ConvertToLHProcess::sToOGLTransform(
-	1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
+	1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f
 	);
 // The transformation matrix to convert from OpenGL coordinates to DirectX coordinates.
 const aiMatrix3x3 Assimp::ConvertToLHProcess::sToDXTransform(
-	1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f
+	1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f
 	);
 
 // ------------------------------------------------------------------------------------------------
@@ -145,7 +145,7 @@ void ConvertToLHProcess::Execute( aiScene* pScene)
 	for( unsigned int a = 0; a < pScene->mNumAnimations; a++)
 	{
 		aiAnimation* anim = pScene->mAnimations[a];
-    for( unsigned int b = 0; b < anim->mNumChannels; b++)
+		for( unsigned int b = 0; b < anim->mNumChannels; b++)
 		{
 			aiNodeAnim* nodeAnim = anim->mChannels[b];
 			if( strcmp( nodeAnim->mNodeName.data, pScene->mRootNode->mName.data) == 0)
@@ -193,6 +193,7 @@ void ConvertToLHProcess::ProcessAnimation( aiNodeAnim* pAnim)
 	for( unsigned int a = 0; a < pAnim->mNumPositionKeys; a++)
 		ConvertToDX( pAnim->mPositionKeys[a].mValue);
 
+	return;
 	// rotation keys
 	for( unsigned int a = 0; a < pAnim->mNumRotationKeys; a++)
 	{
@@ -212,13 +213,13 @@ void ConvertToLHProcess::ConvertToOGL( aiVector3D& poVector)
 // ------------------------------------------------------------------------------------------------
 void ConvertToLHProcess::ConvertToOGL( aiMatrix3x3& poMatrix)
 {
-	poMatrix *= sToOGLTransform;
+	poMatrix = sToOGLTransform * poMatrix;
 }
 
 // ------------------------------------------------------------------------------------------------
 void ConvertToLHProcess::ConvertToOGL( aiMatrix4x4& poMatrix)
 {
-	poMatrix *= aiMatrix4x4( sToOGLTransform);
+	poMatrix = aiMatrix4x4( sToOGLTransform) * poMatrix;
 }
 
 // ------------------------------------------------------------------------------------------------
@@ -231,12 +232,11 @@ void ConvertToLHProcess::ConvertToDX( aiVector3D& poVector)
 // ------------------------------------------------------------------------------------------------
 void ConvertToLHProcess::ConvertToDX( aiMatrix3x3& poMatrix)
 {
-	poMatrix *= sToDXTransform;
+	poMatrix = sToDXTransform * poMatrix;
 }
 
 // ------------------------------------------------------------------------------------------------
 void ConvertToLHProcess::ConvertToDX( aiMatrix4x4& poMatrix)
 {
-	aiMatrix4x4 temp(sToDXTransform);
-	poMatrix *= temp;
+	poMatrix = aiMatrix4x4(sToDXTransform) * poMatrix;
 }