• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
LinuxHunter
原创+技巧=无坚不摧
博客园    首页    新随笔    联系   管理    订阅  订阅
添加TLBB模型动画需要对OGRE添加的代码段
如何用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);

  }

}

。。。

}

posted on 2010-11-22 22:51  LinuxHunter  阅读(432)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3