当前位置: 首页>>代码示例>>C++>>正文


C++ SkeletonAnimation::Update方法代码示例

本文整理汇总了C++中SkeletonAnimation::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonAnimation::Update方法的具体用法?C++ SkeletonAnimation::Update怎么用?C++ SkeletonAnimation::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkeletonAnimation的用法示例。


在下文中一共展示了SkeletonAnimation::Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

	bool AnimationController::Update(Mesh * mesh, float elapsedTime)
	{
		float lastPosition = mPosition;

		mPosition += elapsedTime * mBlendInfo.Speed;

		if (!IsBlendOut())
		{
			if (mWeightBlendInDelta == 0)
			{
				mWeight = 1;
			}
			else
			{
				mWeight += elapsedTime * mWeightBlendInDelta;

				if (mWeight >= 1)
				{
					mWeight = 1;
					mWeightBlendInDelta = 0;
				}
			}
		}
		else
		{
			if (mWeight == 0)
				return false;

			if (mWeightBlendOutDelta > 0)
			{
				mWeight -= elapsedTime * mWeightBlendOutDelta;
				mWeight = Max(0.0f, mWeight);
			}
		}
		
		//
		if (mCatchedAnim == NULL && mesh->GetSource() != NULL)
		{
			mCatchedAnim = mesh->GetSource()->GetAnimation(mName.c_str());
			if (mCatchedAnim == NULL)
				return true;

			mSkelAnimLastKeys.Resize(mCatchedAnim->GetSkeletonAnimationCount());
			for (int i = 0; i < mSkelAnimLastKeys.Size(); ++i)
				mSkelAnimLastKeys[i] = -1;
		}

		if (mCatchedAnim != NULL)
		{
			float length = mCatchedAnim->GetLength();

			if (mPosition >= length)
			{
				if (mBlendInfo.Looped)
				{
					while (mPosition > length)
						mPosition -= length;

					for (int i = 0; i < mSkelAnimLastKeys.Size(); ++i)
						mSkelAnimLastKeys[i] = -1;
				}
				else
				{
					mPosition = length;
					return false;
				}
			}

			for (int i = 0; i < mCatchedAnim->GetEventCount(); ++i)
			{
				Animation::Event * e = mCatchedAnim->GetEvent(i);
				if (e->time > lastPosition && e->time <= mPosition)
					E_Event(e);
			}

			Skeleton * skel = mesh->GetSkeleton().c_ptr();
			if (skel != NULL && !mesh->IsSkeletonShared())
			{
				for (int i = 0; i < mCatchedAnim->GetSkeletonAnimationCount(); ++i)
				{
					SkeletonAnimation * skelAnim = mCatchedAnim->GetSkeletonAnimation(i);

					skelAnim->Update(skel, this, mSkelAnimLastKeys[i]);
				}
			}
		}

		return true;
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:89,代码来源:MAnimationController.cpp


注:本文中的SkeletonAnimation::Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。