zoukankan      html  css  js  c++  java
  • 添加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);

      }

    }

    。。。

    }

  • 相关阅读:
    18款在线代码片段测试工具
    毫秒必争,前端网页性能最佳实践
    如何判断Javascript对象是否存在
    推荐10款免费的在线UI测试工具
    揭开Socket编程的面纱
    使用 jQuery Ajax 在页面滚动时从服务器加载数据
    对Android开发者有益的40条优化建议
    web api+递归树型结构
    asp.net Lodop实现批量打印
    asp.net lodop单个打印
  • 原文地址:https://www.cnblogs.com/LinuxHunter/p/1884883.html
Copyright © 2011-2022 走看看