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


C++ CAnimation::AddAnimationTack方法代码示例

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


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

示例1: Export

void CFbxExporter::Export( const String& assetFolder, const String& resourceFolder, const String& filePath )
{
	log::Log log(new log::DefaultMessages(), -1);
	FbxConv conv(&log);

	Settings settings;
	settings.flipV = false;
	settings.packColors = false;
	settings.verbose = true;
	settings.maxNodePartBonesCount = 120;
	settings.maxVertexBonesCount = 4;
	settings.maxVertexCount = INT_MAX; //   (1 << 15) - 1;
	settings.maxIndexCount = INT_MAX; // (1 << 15) - 1;
	settings.outType = FILETYPE_AUTO;
	settings.inType = FILETYPE_FBX;
	settings.inFile = std::string( (assetFolder + filePath).c_str() );

	modeldata::Model *model = new modeldata::Model();
	if (!conv.load(&settings, model))
	{
		return;
	}

	conv.info(model);

	CSkeleton* pLastSkeleton = nullptr;

	for (Node* node : model->nodes)
	{
		CSkeleton* pSkeleton = new CSkeleton();
		ParseModelNode( node, *pSkeleton, "" );
		pSkeleton->ComputeGlobalPose(pSkeleton->m_localBindPose, pSkeleton->m_globalBindPose);


		String skeletonPath = resourceFolder + filePath.get_path_base() + filePath.get_path_name() + ".skel";
		gVars->pFileSystem->CreateFileDir( skeletonPath );
		pSkeleton->SaveToFile( skeletonPath );

		if ( pLastSkeleton != nullptr )
		{
			delete pLastSkeleton;
		}

		pLastSkeleton = pSkeleton;
	}


	for (Animation* ani : model->animations)
	{
		CAnimation* pAnimation = new CAnimation();

		for (NodeAnimation* nodeAnim : ani->nodeAnimations)
		{
			int idx = pLastSkeleton->m_boneNameToIndex[nodeAnim->node->id.c_str()];
			if (idx < 0)
				continue;

			const std::vector< Keyframe* >& keyframes = nodeAnim->keyframes;

			Transform* trackKeys = new Transform[ keyframes.size() ];

			for (size_t iKey = 0; iKey < keyframes.size(); ++iKey)
			{
				const Keyframe& k = *(keyframes[ iKey ]);

				Transform transf;
				transf.rotation = Quat(k.rotation[3], k.rotation[0], k.rotation[1], k.rotation[2]);

				if (transf.rotation.w < 0.0f)
				{
					transf.rotation = -1.0f * transf.rotation;
				}

				transf.position = Vec3(k.translation[0], k.translation[1], k.translation[2]);
				transf.scale = Vec3(k.scale[0], k.scale[1], k.scale[2]);

				transf = pLastSkeleton->m_localBindPose.m_boneTransforms[idx].GetInverse() * transf;
				
				if (String(nodeAnim->node->id.c_str()).Contains("twist"))
				{
					transf = Transform();
				}

				trackKeys[ iKey ] = transf;
			}

			pAnimation->AddAnimationTack( new CAnimationTrack( CAnimationTrack::eKFF_Transform, trackKeys, keyframes.size() ), idx );
		}

		String animPath = resourceFolder + filePath.get_path_base() + filePath.get_path_name() + ".anim";
		gVars->pFileSystem->CreateFileDir(animPath);
		pAnimation->SaveToFile(animPath);
		delete pAnimation;
	}

	if (pLastSkeleton != nullptr)
	{
		delete pLastSkeleton;
	}

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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