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


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

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


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

示例1: readKeyFrame

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

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

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

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

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

示例7: _rebuild

	// 重建整个动画控制器
	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: _mergeSkeletonAnimations


//.........这里部分代码省略.........
            {
                // 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

示例9: getInterpolatedKeyFrame

    //---------------------------------------------------------------------
    void NodeAnimationTrack::getInterpolatedKeyFrame(const TimeIndex& timeIndex, KeyFrame* kf) const
    {
        if (mListener)
        {
            if (mListener->getInterpolatedKeyFrame(this, timeIndex, kf))
                return;
        }

        TransformKeyFrame* kret = static_cast<TransformKeyFrame*>(kf);

        // Keyframe pointers
        KeyFrame *kBase1, *kBase2;
        TransformKeyFrame *k1, *k2;
        unsigned short firstKeyIndex;

        Real t = this->getKeyFramesAtTime(timeIndex, &kBase1, &kBase2, &firstKeyIndex);
        k1 = static_cast<TransformKeyFrame*>(kBase1);
        k2 = static_cast<TransformKeyFrame*>(kBase2);

        if (t == 0.0)
        {
            // Just use k1
            kret->setRotation(k1->getRotation());
            kret->setTranslate(k1->getTranslate());
            kret->setScale(k1->getScale());
        }
        else
        {
            // Interpolate by t
            Animation::InterpolationMode im = mParent->getInterpolationMode();
            Animation::RotationInterpolationMode rim =
                mParent->getRotationInterpolationMode();
            Vector3 base;
            switch(im)
            {
            case Animation::IM_LINEAR:
                // Interpolate linearly
                // Rotation
                // Interpolate to nearest rotation if mUseShortestRotationPath set
                if (rim == Animation::RIM_LINEAR)
                {
                    kret->setRotation( Quaternion::nlerp(t, k1->getRotation(),
                        k2->getRotation(), mUseShortestRotationPath) );
                }
                else //if (rim == Animation::RIM_SPHERICAL)
                {
                    kret->setRotation( Quaternion::Slerp(t, k1->getRotation(),
                        k2->getRotation(), mUseShortestRotationPath) );
                }

                // Translation
                base = k1->getTranslate();
                kret->setTranslate( base + ((k2->getTranslate() - base) * t) );

                // Scale
                base = k1->getScale();
                kret->setScale( base + ((k2->getScale() - base) * t) );
                break;

            case Animation::IM_SPLINE:
                // Spline interpolation

                // Build splines if required
                if (mSplineBuildNeeded)
                {
                    buildInterpolationSplines();
                }

                // Rotation, take mUseShortestRotationPath into account
                kret->setRotation( mSplines->rotationSpline.interpolate(firstKeyIndex, t,
                    mUseShortestRotationPath) );

                // Translation
                kret->setTranslate( mSplines->positionSpline.interpolate(firstKeyIndex, t) );

                // Scale
                kret->setScale( mSplines->scaleSpline.interpolate(firstKeyIndex, t) );

                break;
            }

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

示例10: sampleAllBones

	//-----------------------------------------------------------------------------
	void XsiSkeletonExporter::sampleAllBones(DeformerMap& deformers, 
		std::vector<NodeAnimationTrack*> deformerTracks, double frame, 
		Real time, float fps, AxisAlignedBox& AABBPadding)
	{
		CValueArray args;
		CValue dummy;
		args.Resize(2);
		// set the playcontrol 
		args[0] = L"PlayControl.Key";
		args[1] = frame;
		mXsiApp.ExecuteCommand(L"SetValue", args, dummy);
		args[0] = L"PlayControl.Current";
		mXsiApp.ExecuteCommand(L"SetValue", args, dummy);

		// Refresh
		mXsiApp.ExecuteCommand(L"Refresh", CValueArray(), dummy);
		// Sample all bones
		for (DeformerMap::iterator di = deformers.begin(); di != deformers.end(); ++di)
		{
			DeformerEntry* deformer = di->second;
			NodeAnimationTrack* track = deformerTracks[deformer->boneID];

			double initposx, initposy, initposz;
			deformer->initialXform.GetTranslationValues(initposx, initposy, initposz);
			double initrotx, initroty, initrotz;
			deformer->initialXform.GetRotation().GetXYZAngles(initrotx, initroty, initrotz);
			double initsclx, initscly, initsclz;
			deformer->initialXform.GetScalingValues(initsclx, initscly, initsclz);
			XSI::MATH::CMatrix4 invTrans = deformer->initialXform.GetMatrix4();
			invTrans.InvertInPlace();

			XSI::MATH::CTransformation transformation;
			if (deformer->pBone->getParent() == 0)
			{
				// Based on global
				transformation = 
					deformer->obj.GetKinematics().GetGlobal().GetTransform();
			}
			else
			{
				// Based on local
				transformation = 
					deformer->obj.GetKinematics().GetLocal().GetTransform();
			}

			double posx, posy, posz;
			transformation.GetTranslationValues(posx, posy, posz);
			double sclx, scly, sclz;
			transformation.GetScalingValues(sclx, scly, sclz);

			// Make relative to initial
			XSI::MATH::CMatrix4 transformationMatrix = transformation.GetMatrix4();
			transformationMatrix.MulInPlace(invTrans);
			transformation.SetMatrix4(transformationMatrix);

			// create keyframe
			TransformKeyFrame* kf = track->createNodeKeyFrame(time);
			// not sure why inverted transform doesn't work for position, but it doesn't
			// I thought XSI used same transform order as OGRE
			kf->setTranslate(Vector3(posx - initposx, posy - initposy, posz - initposz));
			kf->setRotation(XSItoOgre(transformation.GetRotationQuaternion()));
			kf->setScale(Vector3(sclx / initsclx, scly / initscly, sclz / initsclz));

			// Derive AABB of bone positions, for padding animated mesh AABB
			XSI::MATH::CVector3 bonePos = 
				deformer->obj.GetKinematics().GetGlobal().GetTransform().GetTranslation();
			AABBPadding.merge(XSItoOgre(bonePos));



		}

	}
开发者ID:albmarvil,项目名称:The-Eternal-Sorrow,代码行数:74,代码来源:OgreXSISkeletonExporter.cpp

示例11: readKeyFrames

	//---------------------------------------------------------------------
	void XMLSkeletonSerializer::readKeyFrames(NodeAnimationTrack* track, TiXmlElement* mKeyfNode) {
		
		TransformKeyFrame* kf ;
		Quaternion q ;

		for (TiXmlElement* keyfElem = mKeyfNode->FirstChildElement("keyframe"); keyfElem != 0; keyfElem = keyfElem->NextSiblingElement())
        {
			Vector3 trans;
			Vector3 axis;
			Radian angle;
			Real time;

            // Get time and create keyframe
			time = StringConverter::parseReal(keyfElem->Attribute("time"));
			kf = track->createNodeKeyFrame(time);
            // Optional translate
			TiXmlElement* transElem = keyfElem->FirstChildElement("translate");
            if (transElem)
            {
			    trans.x = StringConverter::parseReal(transElem->Attribute("x"));
			    trans.y = StringConverter::parseReal(transElem->Attribute("y"));
			    trans.z = StringConverter::parseReal(transElem->Attribute("z"));
			    kf->setTranslate(trans) ;
            }
            // Optional rotate
			TiXmlElement* rotElem = keyfElem->FirstChildElement("rotate");
            if (rotElem)
            {
                TiXmlElement* axisElem = rotElem->FirstChildElement("axis");
                if (!axisElem)
                {
                    OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Missing 'axis' element "
                    "expected under parent 'rotate'", "MXLSkeletonSerializer::readKeyFrames");
                }
			    angle = Radian(StringConverter::parseReal(rotElem->Attribute("angle")));

			    axis.x = StringConverter::parseReal(axisElem->Attribute("x"));
			    axis.y = StringConverter::parseReal(axisElem->Attribute("y"));
			    axis.z = StringConverter::parseReal(axisElem->Attribute("z"));

			    q.FromAngleAxis(angle,axis);
			    kf->setRotation(q) ;

            }
            // Optional scale
			TiXmlElement* scaleElem = keyfElem->FirstChildElement("scale");
            if (scaleElem)
            {
                // Uniform scale or per axis?
				const char* factorAttrib = scaleElem->Attribute("factor");
				if (factorAttrib)
				{
					// Uniform scale
					Real factor = StringConverter::parseReal(factorAttrib);
					kf->setScale(Vector3(factor, factor, factor));
				}
				else
				{
					// axis scale
                    Real xs = 1.0f, ys = 1.0f, zs=1.0f;
                    const char* factorString = scaleElem->Attribute("x");
                    if(factorString)
                    {
                        xs = StringConverter::parseReal(factorString);
                    }
                    factorString = scaleElem->Attribute("y");
                    if(factorString)
                    {
                        ys = StringConverter::parseReal(factorString);
                    }
                    factorString = scaleElem->Attribute("z");
                    if(factorString)
                    {
                        zs = StringConverter::parseReal(factorString);
                    }
					kf->setScale(Vector3(xs, ys, zs));
					
				}
            }

			
			/*
			LogManager::getSingleton().logMessage("Keyframe: translation("
				+ StringConverter::toString(trans.x) + "," + StringConverter::toString(trans.y) + "," + StringConverter::toString(trans.z) + ")"
				+ " - angle: " + StringConverter::toString(angle) +" - axe: "
				+ StringConverter::toString(axis.x) + "," + StringConverter::toString(axis.y) + "," + StringConverter::toString(axis.z) );
			*/
			

		}
	}
开发者ID:redkaras,项目名称:Demi3D,代码行数:92,代码来源:OgreXMLSkeletonSerializer.cpp

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


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