- cleaned up the BVH loading a bit

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@358 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
ulfjorensen 2009-03-07 18:57:04 +00:00
parent 84e2c82877
commit 04d0a859a5
1 changed files with 26 additions and 55 deletions

View File

@ -431,32 +431,16 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
poskey->mTime = double( fr);
// Now compute all translations in the right order
switch (node.mChannels[0])
{
case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + 0];break;
case Channel_PositionY: poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + 0];break;
case Channel_PositionZ: poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + 0];break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
switch (node.mChannels[1])
{
case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + 1];break;
case Channel_PositionY: poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + 1];break;
case Channel_PositionZ: poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + 1];break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
switch (node.mChannels[2])
{
case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + 2];break;
case Channel_PositionY: poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + 2];break;
case Channel_PositionZ: poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + 2];break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + 1];
poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + 2];
for( unsigned int channel = 0; channel < 3; ++channel)
{
switch( node.mChannels[channel])
{
case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + channel]; break;
case Channel_PositionY: poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + channel]; break;
case Channel_PositionZ: poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + channel]; break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
}
++poskey;
}
} else
@ -484,36 +468,23 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
aiQuatKey* rotkey = nodeAnim->mRotationKeys;
for( unsigned int fr = 0; fr < mAnimNumFrames; ++fr)
{
// translate ZXY euler angels into a quaternion
const float angle0 = node.mChannelValues[fr * node.mChannels.size() + rotOffset ] * float( AI_MATH_PI) / 180.0f;
const float angle1 = node.mChannelValues[fr * node.mChannels.size() + rotOffset+1] * float( AI_MATH_PI) / 180.0f;
const float angle2 = node.mChannelValues[fr * node.mChannels.size() + rotOffset+2] * float( AI_MATH_PI) / 180.0f;
aiMatrix4x4 temp;
aiMatrix3x3 rotMatrix;
aiMatrix4x4 temp;
aiMatrix3x3 rotMatrix;
for( unsigned int channel = 0; channel < 3; ++channel)
{
// translate ZXY euler angels into a quaternion
const float angle = node.mChannelValues[fr * node.mChannels.size() + rotOffset + channel] * float( AI_MATH_PI) / 180.0f;
// Compute rotation transformations in the right order
switch (node.mChannels[rotOffset])
{
case Channel_RotationX: aiMatrix4x4::RotationX( angle0, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationY: aiMatrix4x4::RotationY( angle0, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationZ: aiMatrix4x4::RotationZ( angle0, temp); rotMatrix *= aiMatrix3x3( temp); break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
switch (node.mChannels[rotOffset+1])
{
case Channel_RotationX: aiMatrix4x4::RotationX( angle1, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationY: aiMatrix4x4::RotationY( angle1, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationZ: aiMatrix4x4::RotationZ( angle1, temp); rotMatrix *= aiMatrix3x3( temp); break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
switch (node.mChannels[rotOffset+2])
{
case Channel_RotationX: aiMatrix4x4::RotationX( angle2, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationY: aiMatrix4x4::RotationY( angle2, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationZ: aiMatrix4x4::RotationZ( angle2, temp); rotMatrix *= aiMatrix3x3( temp); break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
// Compute rotation transformations in the right order
switch (node.mChannels[rotOffset+channel])
{
case Channel_RotationX: aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationY: aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); break;
case Channel_RotationZ: aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp); break;
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
}
}
rotkey->mTime = double( fr);
rotkey->mValue = aiQuaternion( rotMatrix);