添加TLBB模型动画需要对OGRE添加的代码段

要能正确加载TLBB模型动画在OgreSkeletonSerializer.cpp中readAnimationTrack添加如下代码

void SkeletonSerializer::readAnimationTrack(DataStreamPtr& stream, Animation* anim, Skeleton* pSkel)

{

  (省略)

  。。。

// Keep looking for nested keyframes

if (!stream->eof())

{

  unsigned short streamID = readChunk(stream);

  while( (streamID == SKELETON_ANIMATION_TRACK_KEYFRAME || 

       streamID == 0x4120 ) && !stream->eof() )

  {

    if (streamID == 0x4120 )

    {

      //新增代码

      unsigned short len;

      unsigned short flags;

      readShorts(stream, &len, 1);

      readShorts(stream, &flags, 1);
      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);

                      Vector3 scale = Vector3::UNIT_SCALE;

        if (flags & 4)

        {

          readObject(stream, scale);

        }

        kf->setScale(scale);

      }

    }

    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);

  }

}

。。。

}

你可能感兴趣的:(代码)