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


C++ TransformKeyFrame类代码示例

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


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

示例1: saveBlendFrame

void Recording::saveBlendFrame( float time
                              , const Recording& base
                              , const Recording& layer
                              , const BoneMask& boneMask/*=default_bone_mask */
                              , const ELayerMappingMode& mappingMode/*=ELayerMappingMode::MAP_ADDITIVE*/ )
{
	const Animation *baseAnim  = base.getAnimation();
	const Animation *layerAnim = layer.getAnimation();

	BoneAnimationTrack *baseTrack  = nullptr;
	BoneAnimationTrack *layerTrack = nullptr;
	BoneAnimationTrack *blendTrack = nullptr;

	for (auto boneID = 0; boneID < EBoneID::COUNT; ++boneID) {
		// Get this bone's animation track for the base, layer, and blend (i.e. this) animations
		baseTrack  = baseAnim->getBoneTrack(boneID);
		layerTrack = layerAnim->getBoneTrack(boneID);
		blendTrack = animation->getBoneTrack(boneID);
		if (nullptr == baseTrack || nullptr == layerTrack || nullptr == blendTrack) continue;

		// Create a new keyframe in this blended recording
		TransformKeyFrame *blendTKF = static_cast<TransformKeyFrame*>(blendTrack->createKeyFrame(time));
		if (nullptr == blendTKF) continue;

		// If this boneID is not in boneMask, save the base keyframe for this bone
		if (end(boneMask) == boneMask.find((EBoneID) boneID)) {
			baseTrack->getInterpolatedKeyFrame(time, blendTKF);
			continue;
		}
		// else this boneID is in boneMask, so save a blended keyframe
		layerTrack->getInterpolatedKeyFrame(time, blendTKF);
		blendTKF->setRotation(glm::normalize(blendTKF->getRotation()));
		blendTKF->setScale(glm::vec3(1)); // scale is ignored
	}
}
开发者ID:bploeckelman,项目名称:KinectedActing,代码行数:35,代码来源:Recording.cpp

示例2: saveKeyFrame

size_t Recording::saveKeyFrame(float now)
{
	if (nullptr == animation) return 0;

	// Get the Kinect skeleton data if there is any
	const auto& skeletonFrame    = kinect.getSkeletonFrame();
	const auto *skeletonData     = kinect.getFirstTrackedSkeletonData(skeletonFrame);
	const auto *boneOrientations = kinect.getOrientations();
	if (nullptr == skeletonData) return 0;

	// Update all bone tracks with a new keyframe
	BoneAnimationTrack *track   = nullptr;
	TransformKeyFrame *keyFrame = nullptr;
	size_t numKeyFrames = 0;
	for (auto boneID = 0; boneID < EBoneID::COUNT; ++boneID) {
		track = animation->getBoneTrack(boneID);
		if (nullptr == track) continue;

		keyFrame = static_cast<TransformKeyFrame*>(track->createKeyFrame(now));
		if (nullptr == keyFrame) continue;

		const Vector4& p = skeletonData->SkeletonPositions[boneID];
		const Vector4& q = boneOrientations[boneID].hierarchicalRotation.rotationQuaternion;
		const Vector4& a = boneOrientations[boneID].absoluteRotation.rotationQuaternion;
		keyFrame->setTranslation(glm::vec3(p.x, p.y, p.z));
		keyFrame->setRotation(glm::normalize(glm::quat(q.w, q.x, q.y, q.z)));
		keyFrame->setAbsRotation(glm::normalize(glm::quat(a.w, a.x, a.y, a.z)));
		keyFrame->setScale(glm::vec3(1));

		numKeyFrames += track->getNumKeyFrames();
	}

	return numKeyFrames;
}
开发者ID:bploeckelman,项目名称:KinectedActing,代码行数:34,代码来源:Recording.cpp

示例3: readFloats

    //---------------------------------------------------------------------
    void SkeletonSerializer::readKeyFrame(DataStreamPtr& stream, NodeAnimationTrack* track, 
        Skeleton* pSkel)
    {
        // float time                    : The time position (seconds)
        float time;
        readFloats(stream, &time, 1);

        TransformKeyFrame *kf = track->createNodeKeyFrame(time);

        // Quaternion rotate            : Rotation to apply at this keyframe
        Quaternion rot;
        readObject(stream, rot);
        kf->setRotation(rot);
        // Vector3 translate            : Translation to apply at this keyframe
        Vector3 trans;
        readObject(stream, trans);
        kf->setTranslate(trans);
        // Do we have scale?
        if (mCurrentstreamLen > calcKeyFrameSizeWithoutScale(pSkel, kf))
        {
            Vector3 scale;
            readObject(stream, scale);
            kf->setScale(scale);
        }
    }
开发者ID:MrLobo,项目名称:El-Rayo-de-Zeus,代码行数:26,代码来源:OgreSkeletonSerializer.cpp

示例4: hasNonZeroKeyFrames

    //---------------------------------------------------------------------
    bool NodeAnimationTrack::hasNonZeroKeyFrames(void) const
    {
        KeyFrameList::const_iterator i = mKeyFrames.begin();
        for (; i != mKeyFrames.end(); ++i)
        {
            // look for keyframes which have any component which is non-zero
            // Since exporters can be a little inaccurate sometimes we use a
            // tolerance value rather than looking for nothing
            TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
            Vector3 trans = kf->getTranslate();
            Vector3 scale = kf->getScale();
            Vector3 axis;
            Radian angle;
            kf->getRotation().ToAngleAxis(angle, axis);
            Real tolerance = 1e-3f;
            if (!trans.positionEquals(Vector3::ZERO, tolerance) ||
                !scale.positionEquals(Vector3::UNIT_SCALE, tolerance) ||
                !Math::RealEqual(angle.valueRadians(), 0.0f, tolerance))
            {
                return true;
            }

        }

        return false;
    }
开发者ID:yiliu1203,项目名称:OGRE,代码行数:27,代码来源:OgreAnimationTrack.cpp

示例5: quatTolerance

    //---------------------------------------------------------------------
    void NodeAnimationTrack::optimise(void)
    {
        // Eliminate duplicate keyframes from 2nd to penultimate keyframe
        // NB only eliminate middle keys from sequences of 5+ identical keyframes
        // since we need to preserve the boundary keys in place, and we need
        // 2 at each end to preserve tangents for spline interpolation
        Vector3 lasttrans = Vector3::ZERO;
        Vector3 lastscale = Vector3::ZERO;
        Quaternion lastorientation;
        KeyFrameList::iterator i = mKeyFrames.begin();
        Radian quatTolerance(1e-3f);
        std::list<unsigned short> removeList;
        unsigned short k = 0;
        ushort dupKfCount = 0;
        for (; i != mKeyFrames.end(); ++i, ++k)
        {
            TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
            Vector3 newtrans = kf->getTranslate();
            Vector3 newscale = kf->getScale();
            Quaternion neworientation = kf->getRotation();
            // Ignore first keyframe; now include the last keyframe as we eliminate
            // only k-2 in a group of 5 to ensure we only eliminate middle keys
            if (i != mKeyFrames.begin() &&
                newtrans.positionEquals(lasttrans) &&
                newscale.positionEquals(lastscale) &&
                neworientation.equals(lastorientation, quatTolerance))
            {
                ++dupKfCount;

                // 4 indicates this is the 5th duplicate keyframe
                if (dupKfCount == 4)
                {
                    // remove the 'middle' keyframe
                    removeList.push_back(k-2);
                    --dupKfCount;
                }
            }
            else
            {
                // reset
                dupKfCount = 0;
                lasttrans = newtrans;
                lastscale = newscale;
                lastorientation = neworientation;
            }
        }

        // Now remove keyframes, in reverse order to avoid index revocation
        std::list<unsigned short>::reverse_iterator r = removeList.rbegin();
        for (; r!= removeList.rend(); ++r)
        {
            removeKeyFrame(*r);
        }


    }
开发者ID:yiliu1203,项目名称:OGRE,代码行数:57,代码来源:OgreAnimationTrack.cpp

示例6: _getCurrentSceneManager

void FvXMLAnimationModelSerializerImpl::ReadAnimation( 
	FvXMLSectionPtr spSection, Ogre::SceneNode* pkNode, FvAnimationModel* pkDest )
{
	Ogre::SceneManager *pkSceneManager = Ogre::Root::getSingleton().
		_getCurrentSceneManager();
	FV_ASSERT(pkSceneManager);

	FvString kAnimationName = spSection->ReadString("name");
	bool bEnable = spSection->ReadBool("enable");
	bool bLoop = spSection->ReadBool("loop");
	FvString kIterpolationMode = spSection->ReadString("interpolationMode");
	FvString kRotationIterpolationMode = spSection->ReadString("rotationInterpolationMode");
	float fLength = spSection->ReadFloat("length");

	if(!pkSceneManager->hasAnimation(pkNode->getName() + kAnimationName))
	{
		std::vector<FvXMLSectionPtr> kKeyFrames;
		spSection->OpenSections("keyframe",kKeyFrames);

		Animation *pkAnimation = pkSceneManager->createAnimation(pkNode->getName() + kAnimationName, fLength);
		if(strcmp(kIterpolationMode.c_str(),"spline") == 0)
			pkAnimation->setInterpolationMode(Animation::IM_SPLINE);
		else
			pkAnimation->setInterpolationMode(Animation::IM_LINEAR);

		if(strcmp(kRotationIterpolationMode.c_str(),"spherical") == 0)
			pkAnimation->setRotationInterpolationMode(Animation::RIM_SPHERICAL);
		else
			pkAnimation->setRotationInterpolationMode(Animation::RIM_LINEAR);

		NodeAnimationTrack *pkAnimationTrack = pkAnimation->createNodeTrack(
			pkAnimation->getNumNodeTracks() + 1, pkNode);

		for (size_t stKeyframeIndex = 0; stKeyframeIndex < kKeyFrames.size(); stKeyframeIndex++)
		{
			float fTime = kKeyFrames[stKeyframeIndex]->ReadFloat("time");
			FvVector3 kPosition = kKeyFrames[stKeyframeIndex]->ReadVector3("translation");
			FvVector3 kScale = kKeyFrames[stKeyframeIndex]->ReadVector3("scale");
			FvQuaternion kQuaternion = kKeyFrames[stKeyframeIndex]->ReadQuaternion("rotation");
			TransformKeyFrame *pkKeyFrame = pkAnimationTrack->createNodeKeyFrame(fTime);
			pkKeyFrame->setTranslate(Vector3(kPosition.x,kPosition.y,kPosition.z));
			pkKeyFrame->setRotation(Quaternion(kQuaternion.w,kQuaternion.x,kQuaternion.y,kQuaternion.z));
			pkKeyFrame->setScale(Vector3(kScale.x,kScale.y,kScale.z));
		}

		AnimationState *pkAnimationState = pkSceneManager->createAnimationState(pkNode->getName() + kAnimationName);
		pkAnimationState->setEnabled(bEnable);
		pkAnimationState->setLoop(bLoop);
		pkDest->m_kModelAnimations.insert(std::make_pair(kAnimationName,pkAnimationState));
	}
}
开发者ID:Kiddinglife,项目名称:geco-game-engine,代码行数:51,代码来源:FvAnimationModelSerializer.cpp

示例7: destroy

	// 重建整个动画控制器
	void AnimationTrackController::_rebuild()
	{
		if(!m_needRebuild)
			return;
		destroy();

		// 计算动画长度
		m_length = 0.0f;
		{
			AnimationTrackObject::ConstKeyFrameIterator iterator = m_animationTrackObject->getConstKeyFrameIterator();
			while(iterator.hasMoreElements())
			{
				const AnimationTrackObject::KeyFrame& keyFrame = iterator.getNext();
				m_length += keyFrame.m_length;
			}
		}
		// 创建动画
		m_animation = m_sceneMgr->createAnimation(m_animationTrackObject->getFullName() + "_" + m_trackObject->getScene()->getName() + m_trackObject->getName()
			, m_length
			);
		// 使用样条动画
		m_animation->setInterpolationMode((Animation::InterpolationMode)m_interpolationMode);
		m_animation->setRotationInterpolationMode((Animation::RotationInterpolationMode)m_rotationInterpolationMode);
		// 创建节点轨迹动画
		m_animationTrack = m_animation->createNodeTrack(0 , m_trackObject->getOgreSceneNode());
		// 创建所有关键帧
		{
			float timePos = 0.0f;
			AnimationTrackObject::ConstKeyFrameIterator iterator = m_animationTrackObject->getConstKeyFrameIterator();
			while(iterator.hasMoreElements())
			{
				const AnimationTrackObject::KeyFrame& keyFrame = iterator.getNext();
				timePos += keyFrame.m_length;
				TransformKeyFrame *frame = m_animationTrack->createNodeKeyFrame(timePos);
				frame->setTranslate(keyFrame.m_translate);
				frame->setScale(keyFrame.m_scale);
				frame->setRotation(keyFrame.m_rotate);
			}
		}
		// 创建动画状态
		m_animationState = m_sceneMgr->createAnimationState(m_animation->getName());
		// 总是不使用循环系统
		m_animationState->setLoop(false);
		
		// 重建完毕
		m_needRebuild = false;
	}
开发者ID:duzhi5368,项目名称:FKOgreWorldEdit,代码行数:48,代码来源:AnimationTrackController.cpp

示例8: OGRE_NEW_T

    //---------------------------------------------------------------------
    void NodeAnimationTrack::buildInterpolationSplines(void) const
    {
        // Allocate splines if not exists
        if (!mSplines)
        {
            mSplines = OGRE_NEW_T(Splines, MEMCATEGORY_ANIMATION);
        }

        // Cache to register for optimisation
        Splines* splines = mSplines;

        // Don't calc automatically, do it on request at the end
        splines->positionSpline.setAutoCalculate(false);
        splines->rotationSpline.setAutoCalculate(false);
        splines->scaleSpline.setAutoCalculate(false);

        splines->positionSpline.clear();
        splines->rotationSpline.clear();
        splines->scaleSpline.clear();

        KeyFrameList::const_iterator i, iend;
        iend = mKeyFrames.end(); // precall to avoid overhead
        for (i = mKeyFrames.begin(); i != iend; ++i)
        {
            TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
            splines->positionSpline.addPoint(kf->getTranslate());
            splines->rotationSpline.addPoint(kf->getRotation());
            splines->scaleSpline.addPoint(kf->getScale());
        }

        splines->positionSpline.recalcTangents();
        splines->rotationSpline.recalcTangents();
        splines->scaleSpline.recalcTangents();


        mSplineBuildNeeded = false;
    }
开发者ID:yiliu1203,项目名称:OGRE,代码行数:38,代码来源:OgreAnimationTrack.cpp

示例9: _applyBaseKeyFrame

 //--------------------------------------------------------------------------
 void NodeAnimationTrack::_applyBaseKeyFrame(const KeyFrame* b)
 {
     const TransformKeyFrame* base = static_cast<const TransformKeyFrame*>(b);
     
     for (KeyFrameList::iterator i = mKeyFrames.begin(); i != mKeyFrames.end(); ++i)
     {
         TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
         kf->setTranslate(kf->getTranslate() - base->getTranslate());
         kf->setRotation(base->getRotation().Inverse() * kf->getRotation());
         kf->setScale(kf->getScale() * (Vector3::UNIT_SCALE / base->getScale()));
     }
         
 }
开发者ID:yiliu1203,项目名称:OGRE,代码行数:14,代码来源:OgreAnimationTrack.cpp

示例10: createScene

// Just override the mandatory create scene method
    void createScene(void)
    {
		sceneMgr = mSceneMgr ;
        // Set ambient light
        mSceneMgr->setAmbientLight(ColourValue(0.75, 0.75, 0.75));

        // Create a light
        Light* l = mSceneMgr->createLight("MainLight");
        // Accept default settings: point light, white diffuse, just set position
        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
        //  other objects, but I don't
        l->setPosition(200,300,100);

		// Create water mesh and entity
		waterMesh = new WaterMesh(MESH_NAME, PLANE_SIZE, COMPLEXITY);
		waterEntity = mSceneMgr->createEntity(ENTITY_NAME,
			MESH_NAME);
		//~ waterEntity->setMaterialName(MATERIAL_NAME);
		SceneNode *waterNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		waterNode->attachObject(waterEntity);

        // Add a head, give it it's own node
        headNode = waterNode->createChildSceneNode();
        Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
        headNode->attachObject(ent);

		// Make sure the camera track this node
        //~ mCamera->setAutoTracking(true, headNode);

		// Create the camera node, set its position & attach camera
        SceneNode* camNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		camNode->translate(0, 500, PLANE_SIZE);
		camNode->yaw(Degree(-45));
        camNode->attachObject(mCamera);

		// Create light node
        SceneNode* lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		lightNode->attachObject(l);

        // set up spline animation of light node
        Animation* anim = mSceneMgr->createAnimation("WaterLight", 20);
		NodeAnimationTrack *track ;
        TransformKeyFrame *key ;
		// create a random spline for light
		track = anim->createNodeTrack(0, lightNode);
		key = track->createNodeKeyFrame(0);
		for(int ff=1;ff<=19;ff++) {
			key = track->createNodeKeyFrame(ff);
			Vector3 lpos (
				rand()%(int)PLANE_SIZE , //- PLANE_SIZE/2,
				rand()%300+100,
				rand()%(int)PLANE_SIZE //- PLANE_SIZE/2
				);
			key->setTranslate(lpos);
		}
		key = track->createNodeKeyFrame(20);

        // Create a new animation state to track this
        mAnimState = mSceneMgr->createAnimationState("WaterLight");
        mAnimState->setEnabled(true);

        // Put in a bit of fog for the hell of it
        //mSceneMgr->setFog(FOG_EXP, ColourValue::White, 0.0002);

		// show overlay
		waterOverlay = OverlayManager::getSingleton().getByName("Example/WaterOverlay");
		waterOverlay->show();

        // Let there be rain
        particleSystem = mSceneMgr->createParticleSystem("rain",
            "Examples/Water/Rain");
		particleEmitter = particleSystem->getEmitter(0);
        SceneNode* rNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
        rNode->translate(PLANE_SIZE/2.0f, 3000, PLANE_SIZE/2.0f);
        rNode->attachObject(particleSystem);
        // Fast-forward the rain so it looks more natural
        particleSystem->fastForward(20);
		// It can't be set in .particle file, and we need it ;)
		static_cast<BillboardParticleRenderer*>(particleSystem->getRenderer())->setBillboardOrigin(BBO_BOTTOM_CENTER);

		prepareCircleMaterial();
	}
开发者ID:Argos86,项目名称:dt2370,代码行数:83,代码来源:Water.cpp

示例11: while

    SkeletonPtr MergeSkeleton::bake()
    {    
        MeshCombiner::getSingleton().log( 
             "Baking: New Skeleton started" );

        SkeletonPtr sp = SkeletonManager::getSingleton().create( "mergeSkeleton", 
             ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true );
        
        for( std::vector< Ogre::SkeletonPtr >::iterator it = m_Skeletons.begin();
             it != m_Skeletons.end(); ++it )
        {   
            if(  it == m_Skeletons.begin() )
            {
                MeshCombiner::getSingleton().log( 
                    "Baking: using " + (*it)->getName() + " as the base skeleton"   );

                MeshCombiner::getSingleton().log( 
                    "Baking: adding bones"   );
                Skeleton::BoneIterator bit = (*it)->getBoneIterator();
                while( bit.hasMoreElements() )
                {
                    Bone* bone = bit.getNext();
                    Bone* newbone = sp->createBone( bone->getName(), bone->getHandle() );
                    newbone->setScale( bone->getScale() );
                    newbone->setOrientation( bone->getOrientation() );
                    newbone->setPosition( bone->getPosition() );
                }
                MeshCombiner::getSingleton().log( 
                    "Baking: building bone hierarchy"   );
                // bone hierarchy
                bit = (*it)->getBoneIterator();
                while( bit.hasMoreElements() )
                {
                    Bone* bone = bit.getNext();
                    Node* pnode = bone->getParent();
                    if( pnode != NULL )
                    {
                        Bone* pbone = static_cast<Bone*>( pnode );
                        sp->getBone( pbone->getHandle() )->addChild( sp->getBone( bone->getHandle() ) );
                    }
                }
            }   

            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 )
                {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:101,代码来源:MergeSkeleton.cpp

示例12: OGRE_EXCEPT


//.........这里部分代码省略.........
            {
                // New bone, the delta-transform is identity

                deltaTransform.translate = Vector3::ZERO;
                deltaTransform.rotate = Quaternion::IDENTITY;
                deltaTransform.scale = Vector3::UNIT_SCALE;
                deltaTransform.isIdentity = true;
            }
        }

        // Now copy animations

        ushort numAnimations;
        if (animations.empty())
            numAnimations = src->getNumAnimations();
        else
            numAnimations = static_cast<ushort>(animations.size());
        for (ushort i = 0; i < numAnimations; ++i)
        {
            const Animation* srcAnimation;
            if (animations.empty())
            {
                // Get animation of source skeleton by the given index
                srcAnimation = src->getAnimation(i);
            }
            else
            {
                // Get animation of source skeleton by the given name
                const LinkedSkeletonAnimationSource* linker;
                srcAnimation = src->_getAnimationImpl(animations[i], &linker);
                if (!srcAnimation || linker)
                {
                    OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
                        "No animation entry found named " + animations[i],
                        "Skeleton::_mergeSkeletonAnimations");
                }
            }

            // Create target animation
            Animation* dstAnimation = this->createAnimation(srcAnimation->getName(), srcAnimation->getLength());

            // Copy interpolation modes
            dstAnimation->setInterpolationMode(srcAnimation->getInterpolationMode());
            dstAnimation->setRotationInterpolationMode(srcAnimation->getRotationInterpolationMode());

            // Copy track for each bone
            for (handle = 0; handle < numSrcBones; ++handle)
            {
                const DeltaTransform& deltaTransform = deltaTransforms[handle];
                ushort dstHandle = boneHandleMap[handle];

                if (srcAnimation->hasNodeTrack(handle))
                {
                    // Clone track from source animation

                    const NodeAnimationTrack* srcTrack = srcAnimation->getNodeTrack(handle);
                    NodeAnimationTrack* dstTrack = dstAnimation->createNodeTrack(dstHandle, this->getBone(dstHandle));
                    dstTrack->setUseShortestRotationPath(srcTrack->getUseShortestRotationPath());

                    ushort numKeyFrames = srcTrack->getNumKeyFrames();
                    for (ushort k = 0; k < numKeyFrames; ++k)
                    {
                        const TransformKeyFrame* srcKeyFrame = srcTrack->getNodeKeyFrame(k);
                        TransformKeyFrame* dstKeyFrame = dstTrack->createNodeKeyFrame(srcKeyFrame->getTime());

                        // Adjust keyframes to match target binding pose
                        if (deltaTransform.isIdentity)
                        {
                            dstKeyFrame->setTranslate(srcKeyFrame->getTranslate());
                            dstKeyFrame->setRotation(srcKeyFrame->getRotation());
                            dstKeyFrame->setScale(srcKeyFrame->getScale());
                        }
                        else
                        {
                            dstKeyFrame->setTranslate(deltaTransform.translate + srcKeyFrame->getTranslate());
                            dstKeyFrame->setRotation(deltaTransform.rotate * srcKeyFrame->getRotation());
                            dstKeyFrame->setScale(deltaTransform.scale * srcKeyFrame->getScale());
                        }
                    }
                }
                else if (!deltaTransform.isIdentity)
                {
                    // Create 'static' track for this bone

                    NodeAnimationTrack* dstTrack = dstAnimation->createNodeTrack(dstHandle, this->getBone(dstHandle));
                    TransformKeyFrame* dstKeyFrame;

                    dstKeyFrame = dstTrack->createNodeKeyFrame(0);
                    dstKeyFrame->setTranslate(deltaTransform.translate);
                    dstKeyFrame->setRotation(deltaTransform.rotate);
                    dstKeyFrame->setScale(deltaTransform.scale);

                    dstKeyFrame = dstTrack->createNodeKeyFrame(dstAnimation->getLength());
                    dstKeyFrame->setTranslate(deltaTransform.translate);
                    dstKeyFrame->setRotation(deltaTransform.rotate);
                    dstKeyFrame->setScale(deltaTransform.scale);
                }
            }
        }
    }
开发者ID:Strongc,项目名称:game-ui-solution,代码行数:101,代码来源:OgreSkeleton.cpp

示例13: _dumpContents

    //---------------------------------------------------------------------
    void Skeleton::_dumpContents(const String& filename)
    {
        std::ofstream of;

        Quaternion q;
        Radian angle;
        Vector3 axis;
        of.open(filename.c_str());

        of << "-= Debug output of skeleton " << mName << " =-" << std::endl << std::endl;
        of << "== Bones ==" << std::endl;
        of << "Number of bones: " << (unsigned int)mBoneList.size() << std::endl;
        
        BoneList::iterator bi;
        for (bi = mBoneList.begin(); bi != mBoneList.end(); ++bi)
        {
            Bone* bone = *bi;

            of << "-- Bone " << bone->getHandle() << " --" << std::endl;
            of << "Position: " << bone->getPosition();
            q = bone->getOrientation();
            of << "Rotation: " << q;
            q.ToAngleAxis(angle, axis);
            of << " = " << angle.valueRadians() << " radians around axis " << axis << std::endl << std::endl;
        }

        of << "== Animations ==" << std::endl;
        of << "Number of animations: " << (unsigned int)mAnimationsList.size() << std::endl;

        AnimationList::iterator ai;
        for (ai = mAnimationsList.begin(); ai != mAnimationsList.end(); ++ai)
        {
            Animation* anim = ai->second;

            of << "-- Animation '" << anim->getName() << "' (length " << anim->getLength() << ") --" << std::endl;
            of << "Number of tracks: " << anim->getNumNodeTracks() << std::endl;

            for (unsigned short ti = 0; ti < anim->getNumNodeTracks(); ++ti)
            {
                NodeAnimationTrack* track = anim->getNodeTrack(ti);
                of << "  -- AnimationTrack " << ti << " --" << std::endl;
                of << "  Affects bone: " << ((Bone*)track->getAssociatedNode())->getHandle() << std::endl;
                of << "  Number of keyframes: " << track->getNumKeyFrames() << std::endl;

                for (unsigned short ki = 0; ki < track->getNumKeyFrames(); ++ki)
                {
                    TransformKeyFrame* key = track->getNodeKeyFrame(ki);
                    of << "    -- KeyFrame " << ki << " --" << std::endl;
                    of << "    Time index: " << key->getTime(); 
                    of << "    Translation: " << key->getTranslate() << std::endl;
                    q = key->getRotation();
                    of << "    Rotation: " << q;
                    q.ToAngleAxis(angle, axis);
                    of << " = " << angle.valueRadians() << " radians around axis " << axis << std::endl;
                }

            }



        }

    }
开发者ID:Strongc,项目名称:game-ui-solution,代码行数:64,代码来源:OgreSkeleton.cpp

示例14: createSampleLights


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

		MLight *d = mSystem->createMLight();
		SceneNode *dn = parentNode->createChildSceneNode();
		dn->attachObject(d);
		d->setAttenuation(1.0f, 0.002f, 0.002f);
		dn->setPosition(-25,0,0);
		d->setDiffuseColour(1,0,1);
		d->setSpecularColour(0.0,0,0.0);
		lights.push_back(d);
		nodes.push_back(dn);

		MLight *e = mSystem->createMLight();
		SceneNode *en = parentNode->createChildSceneNode();
		en->attachObject(e);
		e->setAttenuation(1.0f, 0.002f, 0.0025f);
		en->setPosition(25,0,25);
		e->setDiffuseColour(0,0,1);
		e->setSpecularColour(0,0,0);
		lights.push_back(e);
		nodes.push_back(en);
		
		MLight *f = mSystem->createMLight();
		SceneNode *fn = parentNode->createChildSceneNode();
		fn->attachObject(f);
		f->setAttenuation(1.0f, 0.0015f, 0.0021f);
		fn->setPosition(-25,0,-25);
		f->setDiffuseColour(0,1,0);
		f->setSpecularColour(0,0.0,0.0);
		lights.push_back(f);
		nodes.push_back(fn);

		// Create marker meshes to show user where the lights are
		Entity *ent;
		GeomUtils::createSphere("PointLightMesh", 1.0f, 5, 5, true, true);
		for(std::vector<MLight*>::iterator i=lights.begin(); i!=lights.end(); ++i)
		{
			MLight* light = *i;
			ent = mSceneMgr->createEntity(light->getName()+"v", "PointLightMesh");
			String matname = light->getName()+"m";
			// Create coloured material
			MaterialPtr mat = MaterialManager::getSingleton().create(matname,
                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
            Pass* pass = mat->getTechnique(0)->getPass(0);
            pass->setDiffuse(0.0f,0.0f,0.0f,1.0f);
			pass->setAmbient(0.0f,0.0f,0.0f);
			pass->setSelfIllumination(light->getDiffuseColour());

			ent->setMaterialName(matname);
			ent->setRenderQueueGroup(light->getRenderQueueGroup());
			static_cast<SceneNode*>(light->getParentNode())->attachObject(ent);
		}		

		// Store nodes for hiding/showing
		SharedData::getSingleton().mLightNodes = nodes;

		// Do some animation for node a-f
		// Generate helix structure
		float seconds_per_station = 1.0f;
		float r=35;
		//Vector3 base(0,-30,0);
		Vector3 base(-100, -30, 85);

		float h=120;
		const size_t s_to_top = 16;
		const size_t stations = s_to_top*2-1;
		float ascend = h/((float)s_to_top);
		float stations_per_revolution = 3.5f;
		size_t skip = 2; // stations between lights
		Vector3 station_pos[stations];
		for(int x=0; x<s_to_top; ++x)
		{
			float theta = ((float)x/stations_per_revolution)*2.0f*Math::PI;
			station_pos[x] = base+Vector3(Math::Sin(theta)*r, ascend*x, Math::Cos(theta)*r);
		}
		for(int x=s_to_top; x<stations; ++x)
		{
			float theta = ((float)x/stations_per_revolution)*2.0f*Math::PI;
			station_pos[x] = base+Vector3(Math::Sin(theta)*r, h-ascend*(x-s_to_top), Math::Cos(theta)*r);
		}
		// Create a track for the light swarm
		Animation* anim = mSceneMgr->createAnimation("LightSwarmTrack", stations*seconds_per_station);
		// Spline it for nice curves
		anim->setInterpolationMode(Animation::IM_SPLINE);
		for(unsigned int x=0; x<nodes.size(); ++x)
		{
			// Create a track to animate the camera's node
			NodeAnimationTrack* track = anim->createNodeTrack(x, nodes[x]);
			for(int y=0; y<=stations; ++y)
			{
				// Setup keyframes
				TransformKeyFrame* key = track->createNodeKeyFrame(y*seconds_per_station); // A start position
				key->setTranslate(station_pos[(x*skip+y)%stations]);
				// Make sure size of light doesn't change
				key->setScale(nodes[x]->getScale());
			}
		}
		// Create a new animation state to track this
		SharedData::getSingleton().mMLAnimState = mSceneMgr->createAnimationState("LightSwarmTrack");
		SharedData::getSingleton().mMLAnimState->setEnabled(true);
	}
开发者ID:Argos86,项目名称:dt2370,代码行数:101,代码来源:DeferredShadingDemo.cpp

示例15: createScene


//.........这里部分代码省略.........
			2000, 2000, -1000,
			20, 20, 
			true, 1, 10, 10, Vector3::UNIT_Z);
		mPlaneEnt = mSceneMgr->createEntity( "Plane", "ReflectionPlane" );
		mPlaneNode = rootNode->createChildSceneNode();
		mPlaneNode->attachObject(mPlaneEnt);
		mPlaneNode->translate(-5, -30, 0);
		//mPlaneNode->roll(Degree(5));
		mPlaneEnt->setMaterialName("DeferredDemo/Ground");

		// Create an entity from a model (will be loaded automatically)
		Entity* knotEnt = mSceneMgr->createEntity("Knot", "knot.mesh");
		knotEnt->setMaterialName("DeferredDemo/RockWall");
		knotEnt->setMeshLodBias(0.25f);

		// Create an entity from a model (will be loaded automatically)
		Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
		ogreHead->getSubEntity(0)->setMaterialName("DeferredDemo/Ogre/Eyes");// eyes
		ogreHead->getSubEntity(1)->setMaterialName("DeferredDemo/Ogre/Skin"); 
		ogreHead->getSubEntity(2)->setMaterialName("DeferredDemo/Ogre/EarRing"); // earrings
		ogreHead->getSubEntity(3)->setMaterialName("DeferredDemo/Ogre/Tusks"); // tusks
		rootNode->createChildSceneNode( "Head" )->attachObject( ogreHead );

		// Add a whole bunch of extra entities to fill the scene a bit
		Entity *cloneEnt;
		int N=4;
		for (int n = 0; n < N; ++n)
		{
			float theta = 2.0f*Math::PI*(float)n/(float)N;
			// Create a new node under the root
			SceneNode* node = mSceneMgr->createSceneNode();
			// Random translate
			Vector3 nodePos;
			nodePos.x = Math::SymmetricRandom() * 40.0 + Math::Sin(theta) * 500.0;
			nodePos.y = Math::SymmetricRandom() * 20.0 - 40.0;
			nodePos.z = Math::SymmetricRandom() * 40.0 + Math::Cos(theta) * 500.0;
			node->setPosition(nodePos);
			Quaternion orientation(Math::SymmetricRandom(),Math::SymmetricRandom(),Math::SymmetricRandom(),Math::SymmetricRandom());
			orientation.normalise();
			node->setOrientation(orientation);
			rootNode->addChild(node);
			// Clone knot
			char cloneName[12];
			sprintf(cloneName, "Knot%d", n);
			cloneEnt = knotEnt->clone(cloneName);
			// Attach to new node
			node->attachObject(cloneEnt);

		}

        mCamera->setPosition(-50, 100, 500);
        mCamera->lookAt(0,0,0);

		// show overlay
		Overlay* overlay = OverlayManager::getSingleton().getByName("Example/ShadowsOverlay");    
		overlay->show();

		mSystem = new DeferredShadingSystem(mWindow->getViewport(0), mSceneMgr, mCamera);

		// Create main, moving light
		MLight* l1 = mSystem->createMLight();//"MainLight");
        l1->setDiffuseColour(0.75f, 0.7f, 0.8f);
		l1->setSpecularColour(0.85f, 0.9f, 1.0f);
		
		SceneNode *lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		lightNode->attachObject(l1);

		// Create a track for the light
        Animation* anim = mSceneMgr->createAnimation("LightTrack", 16);
        // Spline it for nice curves
        anim->setInterpolationMode(Animation::IM_SPLINE);
        // Create a track to animate the camera's node
        NodeAnimationTrack* track = anim->createNodeTrack(0, lightNode);
        // Setup keyframes
        TransformKeyFrame* key = track->createNodeKeyFrame(0); // A start position
        key->setTranslate(Vector3(300,300,-300));
        key = track->createNodeKeyFrame(4);//B
        key->setTranslate(Vector3(300,300,300));
        key = track->createNodeKeyFrame(8);//C
        key->setTranslate(Vector3(-300,300,300));
        key = track->createNodeKeyFrame(12);//D
        key->setTranslate(Vector3(-300,300,-300));
		key = track->createNodeKeyFrame(16);//D
        key->setTranslate(Vector3(300,300,-300));
        // Create a new animation state to track this
        SharedData::getSingleton().mAnimState = mSceneMgr->createAnimationState("LightTrack");
        SharedData::getSingleton().mAnimState->setEnabled(true);

		// Create some happy little lights
		createSampleLights();

		// safely setup application's (not postfilter!) shared data
		SharedData::getSingleton().iCamera = mCamera;
		SharedData::getSingleton().iRoot = mRoot;
		SharedData::getSingleton().iWindow = mWindow;
		SharedData::getSingleton().iActivate = true;
		SharedData::getSingleton().iGlobalActivate = true;
		SharedData::getSingleton().iSystem = mSystem;
		SharedData::getSingleton().iMainLight = l1;
	}
开发者ID:Argos86,项目名称:dt2370,代码行数:101,代码来源:DeferredShadingDemo.cpp


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