- cleaned up the BVH loading a bit
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@358 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
84e2c82877
commit
04d0a859a5
|
@ -431,32 +431,16 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
|
||||||
poskey->mTime = double( fr);
|
poskey->mTime = double( fr);
|
||||||
|
|
||||||
// Now compute all translations in the right order
|
// Now compute all translations in the right order
|
||||||
switch (node.mChannels[0])
|
for( unsigned int channel = 0; channel < 3; ++channel)
|
||||||
{
|
{
|
||||||
case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + 0];break;
|
switch( node.mChannels[channel])
|
||||||
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;
|
case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + channel]; break;
|
||||||
default: throw new ImportErrorException( "Unexpected animation channel setup at node " + nodeName );
|
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 );
|
||||||
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];
|
|
||||||
++poskey;
|
++poskey;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -484,36 +468,23 @@ void BVHLoader::CreateAnimation( aiScene* pScene)
|
||||||
aiQuatKey* rotkey = nodeAnim->mRotationKeys;
|
aiQuatKey* rotkey = nodeAnim->mRotationKeys;
|
||||||
for( unsigned int fr = 0; fr < mAnimNumFrames; ++fr)
|
for( unsigned int fr = 0; fr < mAnimNumFrames; ++fr)
|
||||||
{
|
{
|
||||||
// translate ZXY euler angels into a quaternion
|
aiMatrix4x4 temp;
|
||||||
const float angle0 = node.mChannelValues[fr * node.mChannels.size() + rotOffset ] * float( AI_MATH_PI) / 180.0f;
|
aiMatrix3x3 rotMatrix;
|
||||||
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;
|
for( unsigned int channel = 0; channel < 3; ++channel)
|
||||||
aiMatrix3x3 rotMatrix;
|
{
|
||||||
|
// 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
|
// Compute rotation transformations in the right order
|
||||||
switch (node.mChannels[rotOffset])
|
switch (node.mChannels[rotOffset+channel])
|
||||||
{
|
{
|
||||||
case Channel_RotationX: aiMatrix4x4::RotationX( angle0, temp); rotMatrix *= aiMatrix3x3( temp); break;
|
case Channel_RotationX: aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); break;
|
||||||
case Channel_RotationY: aiMatrix4x4::RotationY( angle0, temp); rotMatrix *= aiMatrix3x3( temp); break;
|
case Channel_RotationY: aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); break;
|
||||||
case Channel_RotationZ: aiMatrix4x4::RotationZ( angle0, 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 );
|
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
rotkey->mTime = double( fr);
|
rotkey->mTime = double( fr);
|
||||||
rotkey->mValue = aiQuaternion( rotMatrix);
|
rotkey->mValue = aiQuaternion( rotMatrix);
|
||||||
|
|
Loading…
Reference in New Issue