• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ VertexAnimationTrack类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VertexAnimationTrack的典型用法代码示例。如果您正苦于以下问题:C++ VertexAnimationTrack类的具体用法?C++ VertexAnimationTrack怎么用?C++ VertexAnimationTrack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: optimiseVertexTracks

	//-----------------------------------------------------------------------
	void Animation::optimiseVertexTracks(void)
	{
		// Iterate over the node tracks and identify those with no useful keyframes
		std::list<unsigned short> tracksToDestroy;
		VertexTrackList::iterator i;
		for (i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
		{
			VertexAnimationTrack* track = i->second;
			if (!track->hasNonZeroKeyFrames())
			{
				// mark the entire track for destruction
				tracksToDestroy.push_back(i->first);
			}
			else
			{
				track->optimise();
			}

		}

		// Now destroy the tracks we marked for death
		for(std::list<unsigned short>::iterator h = tracksToDestroy.begin();
			h != tracksToDestroy.end(); ++h)
		{
			destroyVertexTrack(*h);
		}

	}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:29,代码来源:OgreAnimation.cpp


示例2: createVertexTrack

	//---------------------------------------------------------------------
	VertexAnimationTrack* Animation::createVertexTrack(unsigned short handle, 
		VertexData* data, VertexAnimationType animType)
	{
		VertexAnimationTrack* ret = createVertexTrack(handle, animType);

		ret->setAssociatedVertexData(data);

		return ret;
	}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:10,代码来源:OgreAnimation.cpp


示例3: _applyBaseKeyFrame

	//---------------------------------------------------------------------
	void Animation::apply(Entity* entity, Real timePos, Real weight, 
		bool software, bool hardware)
	{
		_applyBaseKeyFrame();

        // Calculate time index for fast keyframe search
        TimeIndex timeIndex = _getTimeIndex(timePos);

		VertexTrackList::iterator i;
		for (i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
		{
			unsigned short handle = i->first;
			VertexAnimationTrack* track = i->second;

			VertexData* swVertexData;
			VertexData* hwVertexData;
			if (handle == 0)
			{
				// shared vertex data
				swVertexData = entity->_getSoftwareVertexAnimVertexData();
				hwVertexData = entity->_getHardwareVertexAnimVertexData();
				entity->_markBuffersUsedForAnimation();
			}
			else
			{
				// sub entity vertex data (-1)
				SubEntity* s = entity->getSubEntity(handle - 1);
				// Skip this track if subentity is not visible
				if (!s->isVisible())
					continue;
				swVertexData = s->_getSoftwareVertexAnimVertexData();
				hwVertexData = s->_getHardwareVertexAnimVertexData();
				s->_markBuffersUsedForAnimation();
			}
			// Apply to both hardware and software, if requested
			if (software)
			{
				track->setTargetMode(VertexAnimationTrack::TM_SOFTWARE);
				track->applyToVertexData(swVertexData, timeIndex, weight, 
					&(entity->getMesh()->getPoseList()));
			}
			if (hardware)
			{
				track->setTargetMode(VertexAnimationTrack::TM_HARDWARE);
				track->applyToVertexData(hwVertexData, timeIndex, weight, 
					&(entity->getMesh()->getPoseList()));
			}
		}

	}
开发者ID:JangoOs,项目名称:kbengine_ogre_demo,代码行数:51,代码来源:OgreAnimation.cpp


示例4: kf

    //-----------------------------------------------------------------------
	void Animation::_applyBaseKeyFrame()
	{
		if (mUseBaseKeyFrame)
		{
			Animation* baseAnim = this;
			if (mBaseKeyFrameAnimationName != StringUtil::BLANK && mContainer)
				baseAnim = mContainer->getAnimation(mBaseKeyFrameAnimationName);
			
			if (baseAnim)
			{
				for (NodeTrackList::iterator i = mNodeTrackList.begin(); i != mNodeTrackList.end(); ++i)
				{
					NodeAnimationTrack* track = i->second;
					
					NodeAnimationTrack* baseTrack;
					if (baseAnim == this)
						baseTrack = track;
					else
						baseTrack = baseAnim->getNodeTrack(track->getHandle());
					
					TransformKeyFrame kf(baseTrack, mBaseKeyFrameTime);
					baseTrack->getInterpolatedKeyFrame(baseAnim->_getTimeIndex(mBaseKeyFrameTime), &kf);
					track->_applyBaseKeyFrame(&kf);
				}
				
				for (VertexTrackList::iterator i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
				{
					VertexAnimationTrack* track = i->second;
					
					if (track->getAnimationType() == VAT_POSE)
					{
						VertexAnimationTrack* baseTrack;
						if (baseAnim == this)
							baseTrack = track;
						else
							baseTrack = baseAnim->getVertexTrack(track->getHandle());
						
						VertexPoseKeyFrame kf(baseTrack, mBaseKeyFrameTime);
						baseTrack->getInterpolatedKeyFrame(baseAnim->_getTimeIndex(mBaseKeyFrameTime), &kf);
						track->_applyBaseKeyFrame(&kf);
						
					}
				}
				
			}
			
			// Re-base has been done, this is a one-way translation
			mUseBaseKeyFrame = false;
		}
		
	}
开发者ID:JangoOs,项目名称:kbengine_ogre_demo,代码行数:52,代码来源:OgreAnimation.cpp


示例5: _getTimeIndex

	//---------------------------------------------------------------------
	void Animation::apply(Entity* entity, Real timePos, Real weight, 
		bool software, bool hardware)
	{
        // Calculate time index for fast keyframe search
        TimeIndex timeIndex = _getTimeIndex(timePos);

		VertexTrackList::iterator i;
		for (i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
		{
			unsigned short handle = i->first;
			VertexAnimationTrack* track = i->second;

			VertexData* swVertexData;
			VertexData* hwVertexData;
			VertexData* origVertexData;
			bool firstAnim = false;
			if (handle == 0)
			{
				// shared vertex data
				firstAnim = !entity->_getBuffersMarkedForAnimation();
				swVertexData = entity->_getSoftwareVertexAnimVertexData();
				hwVertexData = entity->_getHardwareVertexAnimVertexData();
				origVertexData = entity->getMesh()->sharedVertexData;
				entity->_markBuffersUsedForAnimation();
			}
			else
			{
				// sub entity vertex data (-1)
				SubEntity* s = entity->getSubEntity(handle - 1);
				// Skip this track if subentity is not visible
				if (!s->isVisible())
					continue;
				firstAnim = !s->_getBuffersMarkedForAnimation();
				swVertexData = s->_getSoftwareVertexAnimVertexData();
				hwVertexData = s->_getHardwareVertexAnimVertexData();
				origVertexData = s->getSubMesh()->vertexData;
				s->_markBuffersUsedForAnimation();
			}
			// Apply to both hardware and software, if requested
			if (software)
			{
				if (firstAnim && track->getAnimationType() == VAT_POSE)
				{
					// First time through for a piece of pose animated vertex data
					// We need to copy the original position values to the temp accumulator
					const VertexElement* origelem = 
						origVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
					const VertexElement* destelem = 
						swVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
					HardwareVertexBufferSharedPtr origBuffer = 
						origVertexData->vertexBufferBinding->getBuffer(origelem->getSource());
					HardwareVertexBufferSharedPtr destBuffer = 
						swVertexData->vertexBufferBinding->getBuffer(destelem->getSource());
					destBuffer->copyData(*origBuffer.get(), 0, 0, destBuffer->getSizeInBytes(), true);
				}
				track->setTargetMode(VertexAnimationTrack::TM_SOFTWARE);
				track->applyToVertexData(swVertexData, timeIndex, weight, 
					&(entity->getMesh()->getPoseList()));
			}
			if (hardware)
			{
				track->setTargetMode(VertexAnimationTrack::TM_HARDWARE);
				track->applyToVertexData(hwVertexData, timeIndex, weight, 
					&(entity->getMesh()->getPoseList()));
			}
		}

	}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:69,代码来源:OgreAnimation.cpp


示例6: dir

//---------------------------------------------------------------------
void PlayPen_testPoseAnimationWithoutNormals::setupContent()
{
	mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
	Vector3 dir(-1, -1, 0.5);
	dir.normalise();
	Light* l = mSceneMgr->createLight("light1");
	l->setType(Light::LT_DIRECTIONAL);
	l->setDirection(dir);

	MeshPtr mesh = MeshManager::getSingleton().load("cube.mesh", 
		ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		
	String newName = "testposenonormals.mesh";
	mesh = mesh->clone(newName);


	SubMesh* sm = mesh->getSubMesh(0);
	// Re-organise geometry since this mesh has no animation and all 
	// vertex elements are packed into one buffer
	VertexDeclaration* newDecl = 
		sm->vertexData->vertexDeclaration->getAutoOrganisedDeclaration(false, true, false);
	sm->vertexData->reorganiseBuffers(newDecl);

	// create 2 poses
	Pose* pose = mesh->createPose(1, "pose1");
	// Pose1 moves vertices 0, 1, 2 and 3 upward 
	Vector3 offset1(0, 50, 0);
	pose->addVertex(0, offset1);
	pose->addVertex(1, offset1);
	pose->addVertex(2, offset1);
	pose->addVertex(3, offset1);

	pose = mesh->createPose(1, "pose2");
	// Pose2 moves vertices 3, 4, and 5 to the right
	// Note 3 gets affected by both
	Vector3 offset2(100, 0, 0);
	pose->addVertex(3, offset2);
	pose->addVertex(4, offset2);
	pose->addVertex(5, offset2);


	Animation* anim = mesh->createAnimation("poseanim", 20.0f);
	VertexAnimationTrack* vt = anim->createVertexTrack(1, sm->vertexData, VAT_POSE);
	
	// Frame 0 - no effect 
	VertexPoseKeyFrame* kf = vt->createVertexPoseKeyFrame(0);

	// Frame 1 - bring in pose 1 (index 0)
	kf = vt->createVertexPoseKeyFrame(3);
	kf->addPoseReference(0, 1.0f);

	// Frame 2 - remove all 
	kf = vt->createVertexPoseKeyFrame(6);

	// Frame 3 - bring in pose 2 (index 1)
	kf = vt->createVertexPoseKeyFrame(9);
	kf->addPoseReference(1, 1.0f);

	// Frame 4 - remove all
	kf = vt->createVertexPoseKeyFrame(12);


	// Frame 5 - bring in pose 1 at 50%, pose 2 at 100% 
	kf = vt->createVertexPoseKeyFrame(15);
	kf->addPoseReference(0, 0.5f);
	kf->addPoseReference(1, 1.0f);

	// Frame 6 - bring in pose 1 at 100%, pose 2 at 50% 
	kf = vt->createVertexPoseKeyFrame(18);
	kf->addPoseReference(0, 1.0f);
	kf->addPoseReference(1, 0.5f);

	// Frame 7 - reset
	kf = vt->createVertexPoseKeyFrame(20);

	// Export the mesh
	DataStreamPtr stream = Root::getSingleton().createFileStream(newName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
	MeshSerializer ser;
	ser.exportMesh(mesh.get(), stream);
	stream->close();

	// Unload old mesh to force reload
	MeshManager::getSingleton().remove(mesh->getHandle());
	mesh->unload();
	mesh.setNull();

	Entity*  e;
	AnimationState* animState;
	// software pose
	e = mSceneMgr->createEntity("test2", newName);
	mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(150,0,0))->attachObject(e);
	animState = e->getAnimationState("poseanim");
	animState->setEnabled(true);
	animState->setWeight(1.0f);
	mAnimStateList.push_back(animState);
	
	// test hardware pose
	e = mSceneMgr->createEntity("test", newName);
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(e);
//.........这里部分代码省略.........
开发者ID:Anti-Mage,项目名称:ogre,代码行数:101,代码来源:PlayPenSamples.cpp


示例7: print

	MeshPtr MeshMergeTool::merge(const Ogre::String& name, const Ogre::String& resourceGroupName)
	{
		print("Baking: New Mesh started", V_HIGH);

		MeshPtr mp = MeshManager::getSingleton().createManual(name, resourceGroupName);

		if (!mBaseSkeleton.isNull())
		{
			mp->setSkeletonName(mBaseSkeleton->getName());
		}

		AxisAlignedBox totalBounds = AxisAlignedBox();
		for (std::vector<Ogre::MeshPtr>::iterator it = mMeshes.begin(); it != mMeshes.end(); ++it)
		{
			print("Baking: adding submeshes for " + (*it)->getName(), V_HIGH);

			// insert all submeshes
			for (Ogre::ushort sid = 0; sid < (*it)->getNumSubMeshes(); ++sid)
			{
				SubMesh* sub = (*it)->getSubMesh(sid);
				const String name = findSubmeshName((*it), sid);

				// create submesh with correct name
				SubMesh* newsub;
				if (name.length() == 0)
				{
					newsub = mp->createSubMesh();
				}
				else
				{
					/// @todo check if a submesh with this name has been created before
					newsub = mp->createSubMesh(name);
				}

				newsub->useSharedVertices = sub->useSharedVertices;

				// add index
				newsub->indexData = sub->indexData->clone();

				// add geometry
				if (!newsub->useSharedVertices)
				{
					newsub->vertexData = sub->vertexData->clone();

					if (!mBaseSkeleton.isNull())
					{
						// build bone assignments
						SubMesh::BoneAssignmentIterator bit = sub->getBoneAssignmentIterator();
						while (bit.hasMoreElements())
						{
							VertexBoneAssignment vba = bit.getNext();
							newsub->addBoneAssignment(vba);
						}
					}
				}

				newsub->setMaterialName(sub->getMaterialName());

				// Add vertex animations for this submesh
				Animation *anim = 0;
				for (unsigned short i = 0; i < (*it)->getNumAnimations(); ++i)
				{
					anim = (*it)->getAnimation(i);

					// get or create the animation for the new mesh
					Animation *newanim;
					if (mp->hasAnimation(anim->getName()))
					{
						newanim = mp->getAnimation(anim->getName());
					}
					else
					{
						newanim = mp->createAnimation(anim->getName(), anim->getLength());
					}

					print("Baking: adding vertex animation "
						+ anim->getName() + " for " + (*it)->getName(), V_HIGH);

					Animation::VertexTrackIterator vti=anim->getVertexTrackIterator();
					while (vti.hasMoreElements())
					{
						VertexAnimationTrack *vt = vti.getNext();

						// handle=0 targets the main mesh, handle i (where i>0) targets submesh i-1.
						// In this case there are only submeshes so index 0 will not be used.
						unsigned short handle = mp->getNumSubMeshes();
						VertexAnimationTrack* newvt = newanim->createVertexTrack(
								handle,
								vt->getAssociatedVertexData()->clone(),
								vt->getAnimationType());
						for (int keyFrameIndex = 0; keyFrameIndex < vt->getNumKeyFrames();
							++keyFrameIndex)
						{
							switch (vt->getAnimationType())
							{
								case VAT_MORPH:
								{
									// copy the keyframe vertex buffer
									VertexMorphKeyFrame *kf =
										vt->getVertexMorphKeyFrame(keyFrameIndex);
//.........这里部分代码省略.........
开发者ID:EternalWind,项目名称:Ogitor-Facade,代码行数:101,代码来源:MmMeshMergeTool.cpp


示例8: while


//.........这里部分代码省略.........

            MeshCombiner::getSingleton().log( 
                "Baking: adding animations for " + (*it)->getName() );

            // insert all animations
            for (unsigned short a=0; a < (*it)->getNumAnimations(); ++a )
            {
                Animation* anim = (*it)->getAnimation( a );
                Animation* newanim = sp->createAnimation( anim->getName(), anim->getLength() );

                if( anim->getNumNodeTracks() > 0 )
                    MeshCombiner::getSingleton().log( 
                        "Baking: adding node tracks" );
                for( unsigned short na=0; na < anim->getNumNodeTracks(); ++na )
                {
                    if( anim->hasNodeTrack( na ) )
                    {
                        NodeAnimationTrack* nat = anim->getNodeTrack( na );
                        NodeAnimationTrack* newnat = newanim->createNodeTrack( na );
                        // all key frames
                        for( unsigned short nf=0; nf < nat->getNumKeyFrames(); ++nf )
                        {
                            TransformKeyFrame* tkf = nat->getNodeKeyFrame( nf );
                            TransformKeyFrame* newtkf = newnat->createNodeKeyFrame( tkf->getTime() );
                            newtkf->setRotation( tkf->getRotation() );
                            newtkf->setTranslate( tkf->getTranslate() );
                            newtkf->setScale( tkf->getScale() );
                        }

                        newnat->setAssociatedNode( sp->getBone( nat->getHandle() ) );
                    }
                }

                if( anim->getNumNumericTracks() > 0 )
                    MeshCombiner::getSingleton().log( 
                        "Baking: adding numeric tracks" );
                for( unsigned short na=0; na < anim->getNumNumericTracks(); ++na )
                {
                    if( anim->hasNumericTrack( na ) )
                    {
                        NumericAnimationTrack* nat = anim->getNumericTrack( na );
                        NumericAnimationTrack* newnat = newanim->createNumericTrack( na );

                        // all key frames
                        for( unsigned short nf=0; nf < nat->getNumKeyFrames(); ++nf )
                        {
                            NumericKeyFrame* nkf = nat->getNumericKeyFrame( nf );
                            NumericKeyFrame* newnkf = newnat->createNumericKeyFrame( nkf->getTime() );
                            newnkf->setValue( nkf->getValue() );
                        }
                    }
                }

                if( anim->getNumVertexTracks() > 0 )
                    MeshCombiner::getSingleton().log( 
                        "Baking: adding vertex tracks" );
                for( unsigned short va=0; va < anim->getNumVertexTracks(); ++va )
                {
                    if( anim->hasVertexTrack( va ) )
                    {
                        VertexAnimationTrack* vat = anim->getVertexTrack( va );
                        VertexAnimationTrack* newvat = newanim->createVertexTrack( va, vat->getAnimationType() );

                        // all key frames
                        for( unsigned short nf=0; nf < vat->getNumKeyFrames(); ++nf )
                        {
                            // all morphs
                            VertexMorphKeyFrame* vmkf = vat->getVertexMorphKeyFrame( nf );
                            if( vmkf != NULL )
                            {
                                VertexMorphKeyFrame* newvmkf = newvat->createVertexMorphKeyFrame( vmkf->getTime() );
                                // @todo vertex buffer copying correct??
                                HardwareVertexBufferSharedPtr buf = vmkf->getVertexBuffer();
                                HardwareVertexBufferSharedPtr newbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
                                    buf->getVertexSize(), buf->getNumVertices(), buf->getUsage(), buf->hasShadowBuffer() );
                                newbuf->copyData( *buf.getPointer(), 0, 0, buf->getSizeInBytes() );
                            }

                            // all poses
                            VertexPoseKeyFrame* vpkf = vat->getVertexPoseKeyFrame( nf );
                            if( vpkf != NULL )
                            {
                                VertexPoseKeyFrame* newvpkf = newvat->createVertexPoseKeyFrame( vpkf->getTime() );
                                
                                VertexPoseKeyFrame::PoseRefIterator pit = vpkf->getPoseReferenceIterator();
                                while( pit.hasMoreElements() )
                                {
                                    VertexPoseKeyFrame::PoseRef pr = pit.getNext();
                                    newvpkf->addPoseReference( pr.poseIndex, pr.influence );
                                }
                            }

                        }
                    }
                }
            }
        }           

        return sp;
	}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:101,代码来源:MergeSkeleton.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VertexArray类代码示例发布时间:2022-05-31
下一篇:
C++ halfedge::Vertex类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap