天龙对skeleton文件做了一点小的改动, 要正确加载需要更改加载skeleton的代码.
对OgreSkeletonSerializer.cpp文件里面的SkeletonSerializer::readAnimationTrack函数进行修改.
void SkeletonSerializer::readAnimationTrack(DataStreamPtr & stream, Animation * anim,
Skeleton * pSkel)
{
// unsigned short boneIndex : Index of bone to apply to
unsigned short boneHandle;
readShorts(stream, & boneHandle, 1 );
// Find bone
Bone * targetBone = pSkel -> getBone(boneHandle);
// Create track
NodeAnimationTrack * pTrack = anim -> createNodeTrack(boneHandle, targetBone);
// Keep looking for nested keyframes
if ( ! stream -> eof())
{
unsigned short streamID = readChunk(stream);
// while(streamID == SKELETON_ANIMATION_TRACK_KEYFRAME && !stream->eof())
while ((streamID == SKELETON_ANIMATION_TRACK_KEYFRAME || streamID == 0x4120 ) && ! stream -> eof())
{
if (streamID == 0x4120 )
{
unsigned short len;
readShorts(stream, & len, 1 );
unsigned short flags;
readShorts(stream, & flags, 1 );
int count = (mCurrentstreamLen - 4 - 4 ) / 4 ;
if (len != count / 8 )
len = len;
float time;
for ( int i = 0 ; i < len; i += 1 )
{
readFloats(stream, & time, 1 );
TransformKeyFrame * kf = pTrack -> createNodeKeyFrame(time);
Quaternion rot = Quaternion::IDENTITY;
if (flags & 1 )
{
readObject(stream, rot);
}
kf -> setRotation(rot);
Vector3 trans = Vector3::ZERO;
if (flags & 2 )
{
readObject(stream, trans);
}
kf -> setTranslate(trans);
}
}
else
readKeyFrame(stream, pTrack, pSkel);
if ( ! stream -> eof())
{
// Get next stream
streamID = readChunk(stream);
}
}
if ( ! stream -> eof())
{
// Backpedal back to start of this stream if we've found a non-keyframe
stream -> skip( - STREAM_OVERHEAD_SIZE);
}
}
}