- 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
pull/1/head
ulfjorensen 2008-11-03 17:59:04 +00:00
parent 6ee05b6238
commit c25e576a01
2 changed files with 15 additions and 19 deletions

View File

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

View File

@ -51,11 +51,11 @@ using namespace Assimp;
// The transformation matrix to convert from DirectX coordinates to OpenGL coordinates. // The transformation matrix to convert from DirectX coordinates to OpenGL coordinates.
const aiMatrix3x3 Assimp::ConvertToLHProcess::sToOGLTransform( 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. // The transformation matrix to convert from OpenGL coordinates to DirectX coordinates.
const aiMatrix3x3 Assimp::ConvertToLHProcess::sToDXTransform( 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
); );
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -193,6 +193,7 @@ void ConvertToLHProcess::ProcessAnimation( aiNodeAnim* pAnim)
for( unsigned int a = 0; a < pAnim->mNumPositionKeys; a++) for( unsigned int a = 0; a < pAnim->mNumPositionKeys; a++)
ConvertToDX( pAnim->mPositionKeys[a].mValue); ConvertToDX( pAnim->mPositionKeys[a].mValue);
return;
// rotation keys // rotation keys
for( unsigned int a = 0; a < pAnim->mNumRotationKeys; a++) for( unsigned int a = 0; a < pAnim->mNumRotationKeys; a++)
{ {
@ -212,13 +213,13 @@ void ConvertToLHProcess::ConvertToOGL( aiVector3D& poVector)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertToLHProcess::ConvertToOGL( aiMatrix3x3& poMatrix) void ConvertToLHProcess::ConvertToOGL( aiMatrix3x3& poMatrix)
{ {
poMatrix *= sToOGLTransform; poMatrix = sToOGLTransform * poMatrix;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertToLHProcess::ConvertToOGL( aiMatrix4x4& 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) void ConvertToLHProcess::ConvertToDX( aiMatrix3x3& poMatrix)
{ {
poMatrix *= sToDXTransform; poMatrix = sToDXTransform * poMatrix;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertToLHProcess::ConvertToDX( aiMatrix4x4& poMatrix) void ConvertToLHProcess::ConvertToDX( aiMatrix4x4& poMatrix)
{ {
aiMatrix4x4 temp(sToDXTransform); poMatrix = aiMatrix4x4(sToDXTransform) * poMatrix;
poMatrix *= temp;
} }