Merge pull request #3233 from kshepherd2013/master
Fixed rotation order bug in BVH Loaderpull/3241/head
commit
a6d554f645
|
@ -493,37 +493,30 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
|
||||||
for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) {
|
for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) {
|
||||||
aiMatrix4x4 temp;
|
aiMatrix4x4 temp;
|
||||||
aiMatrix3x3 rotMatrix;
|
aiMatrix3x3 rotMatrix;
|
||||||
for (BVHLoader::ChannelType channel = Channel_RotationX; channel <= Channel_RotationZ; channel = (BVHLoader::ChannelType)(channel + 1)) {
|
for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++ channelIdx) {
|
||||||
//Find channel in node
|
switch (node.mChannels[channelIdx]) {
|
||||||
std::map<BVHLoader::ChannelType, int>::iterator mapIter = channelMap.find(channel);
|
|
||||||
|
|
||||||
if (mapIter == channelMap.end())
|
|
||||||
throw DeadlyImportError("Missing rotation channel in node " + nodeName);
|
|
||||||
else {
|
|
||||||
int channelIdx = mapIter->second;
|
|
||||||
// translate ZXY euler angels into a quaternion
|
|
||||||
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
|
|
||||||
|
|
||||||
// Compute rotation transformations in the right order
|
|
||||||
switch (channel) {
|
|
||||||
case Channel_RotationX:
|
case Channel_RotationX:
|
||||||
aiMatrix4x4::RotationX(angle, temp);
|
{
|
||||||
rotMatrix *= aiMatrix3x3(temp);
|
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
|
||||||
|
aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Channel_RotationY:
|
case Channel_RotationY:
|
||||||
aiMatrix4x4::RotationY(angle, temp);
|
{
|
||||||
rotMatrix *= aiMatrix3x3(temp);
|
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
|
||||||
|
aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Channel_RotationZ:
|
case Channel_RotationZ:
|
||||||
aiMatrix4x4::RotationZ(angle, temp);
|
{
|
||||||
rotMatrix *= aiMatrix3x3(temp);
|
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
|
||||||
|
aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rotkey->mTime = double(fr);
|
rotkey->mTime = double(fr);
|
||||||
rotkey->mValue = aiQuaternion(rotMatrix);
|
rotkey->mValue = aiQuaternion(rotMatrix);
|
||||||
++rotkey;
|
++rotkey;
|
||||||
|
|
Loading…
Reference in New Issue