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


C++ TransformKeyFrame::getRotation方法代码示例

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


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

示例1: 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

示例2: 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

示例3: optimise

    //---------------------------------------------------------------------
    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

示例4: _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

示例5: oldKf

void OgreSample19App::tweakSneakAnim()
{
	SkeletonPtr skel = SkeletonManager::getSingleton().load("jaiqua.skeleton",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	Animation * anim = skel->getAnimation("Sneak");
	Animation::NodeTrackIterator tracks = anim->getNodeTrackIterator();
	
	while(tracks.hasMoreElements())
	{
		NodeAnimationTrack * track = tracks.getNext();
		TransformKeyFrame oldKf(0,0);
		track->getInterpolatedKeyFrame(ANIM_CHOP,&oldKf);
		while (track->getKeyFrame(track->getNumKeyFrames()-1)->getTime() >= ANIM_CHOP - 0.3f)
		{
			track->removeKeyFrame(track->getNumKeyFrames()-1);
		}

		TransformKeyFrame * newKf = track->createNodeKeyFrame(ANIM_CHOP);
		TransformKeyFrame * startKf = track->getNodeKeyFrame(0);

		Bone * bone = skel->getBone(track->getHandle());

		if (bone->getName() == "Spineroot")
		{
			mSneakStartPos = startKf->getTranslate() + bone->getInitialPosition();
			mSneakEndPos = oldKf.getTranslate() + bone->getInitialPosition();
			mSneakStartPos.y = mSneakEndPos.y;
			newKf->setTranslate(oldKf.getTranslate());
			newKf->setRotation(oldKf.getRotation());
			newKf->setScale(oldKf.getScale());
		}
		else
		{
			newKf->setTranslate(startKf->getTranslate());
			newKf->setRotation(startKf->getRotation());
			newKf->setScale(startKf->getScale());
		}
	}
}
开发者ID:harr999y,项目名称:OgreFramework,代码行数:38,代码来源:OgreSample19.cpp

示例6: buildInterpolationSplines

    //---------------------------------------------------------------------
    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

示例7: _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

示例8: bake

    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

示例9: ExportSkeleton

void ModelConverter::ExportSkeleton( const Ogre::Skeleton* pSkeleton, const Ogre::String& filename )
{
	LogManager::getSingleton().logMessage("Populating DOM...");

	// Write main skeleton data
	LogManager::getSingleton().logMessage("Exporting bones..");

	DiMotionPtr mt = Demi::DiAssetManager::GetInstancePtr(
		)->CreateOrReplaceAsset<DiMotion>(pSkeleton->getName().c_str());
	DiSkeleton* skeleton = mt->CreateSkeleton();
	
	// save bones
	WriteSkeleton(pSkeleton,skeleton);

	LogManager::getSingleton().logMessage("Bones exported.");

	unsigned short numAnims = pSkeleton->getNumAnimations();
	String msg = "Exporting animations, count=" + StringConverter::toString(numAnims);
	LogManager::getSingleton().logMessage(msg);

	// save animations
	for (unsigned short i = 0; i < numAnims; ++i)
	{
		Animation* pAnim = pSkeleton->getAnimation(i);
		msg = "Exporting animation: " + pAnim->getName();
		LogManager::getSingleton().logMessage(msg);

		Demi::DiAnimation* anim = mt->CreateAnimation(
			pAnim->getName().c_str(), pAnim->getLength());

		// save tracks
		Animation::NodeTrackIterator trackIt = pAnim->getNodeTrackIterator();
		size_t count = 0;
		while (trackIt.hasMoreElements())
		{
			NodeAnimationTrack* track = trackIt.getNext();

			Bone* bone = (Bone*)track->getAssociatedNode();
			Demi::DiNodeClip* clip = anim->CreateNodeClip(count++,skeleton->GetBone(bone->getHandle()));
			
			// save key frames
			for (unsigned short i = 0; i < track->getNumKeyFrames(); ++i)
			{
				TransformKeyFrame* kf = track->getNodeKeyFrame(i);

				Demi::DiTransformKeyFrame* pKeyframe = clip->CreateNodeKeyFrame(kf->getTime());

				pKeyframe->SetTranslate(Demi::DiVec3(kf->getTranslate().x,
										kf->getTranslate().y,kf->getTranslate().z));
				pKeyframe->SetRotation(Demi::DiQuat(kf->getRotation().w,
										kf->getRotation().x,kf->getRotation().y,kf->getRotation().z));
				pKeyframe->SetScale(Demi::DiVec3(kf->getScale().x,
										kf->getScale().y,kf->getScale().z));
			}
		}

		LogManager::getSingleton().logMessage("Animation exported.");
	}

	if (mt)
	{
		// save to file
		DiMotionSerializer ms;
		ms.ExportMotion(mt,filename);
	}
}
开发者ID:redkaras,项目名称:Demi3D,代码行数:66,代码来源:ModelConverter.cpp


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