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


C++ SkeletonInstance::getNumBones方法代码示例

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


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

示例1: create_skeleton

bool LIRenAttachmentEntity::create_skeleton ()
{
	Ogre::SkeletonInstance* skeleton = entity->getSkeleton ();
	if (skeleton == NULL)
		return false;

	/* Set the initial bone transformations. */
	/* The mesh may not have set these correctly if it depended on bones
	   in external skeletons. Because of external bones, we need to set
	   the transformations using the pose skeleton of the object. */
	LIRenModelData* model = get_model ();
	if (model != NULL && model->rest_pose_buffer != NULL)
	{
		for (int i = 0 ; i < model->rest_pose_buffer->bones.count ; i++)
		{
			const LIMdlPoseBufferBone* group = model->rest_pose_buffer->bones.array + i;
			if (!group->name)
				continue;
			LIMatTransform t;
			if (!object->get_node_transform (group->name, t))
				continue;
			Ogre::Bone* bone = skeleton->getBone (i);
			bone->setPosition (t.position.x, t.position.y, t.position.z);
			bone->setOrientation (t.rotation.w, t.rotation.x, t.rotation.y, t.rotation.z);
		}
	}

	/* Make all bones manually controlled. */
	for (int i = 0 ; i < skeleton->getNumBones () ; i++)
	{
		Ogre::Bone* bone = skeleton->getBone (i);
		bone->setManuallyControlled (true);
	}

	/* Set the binding pose. */
	skeleton->setBindingPose ();

	return true;
}
开发者ID:bsmr-games,项目名称:lipsofsuna,代码行数:39,代码来源:render-attachment-entity.cpp

示例2: Update


//.........这里部分代码省略.........
                    i->second.weight_ -= (1.0f / i->second.fade_period_) * frametime;
                    if (i->second.weight_ <= 0.0f)
                    {
                        i->second.weight_ = 0.0f;
                        i->second.phase_ = PHASE_STOP;
                    }
                }
                break;
            }

            // Set weight & step the animation forward
            if (i->second.phase_ != PHASE_STOP)
            {
                Ogre::Real advance = i->second.speed_factor_ * frametime;
                Ogre::Real new_weight = i->second.weight_ * i->second.weight_factor_;
                
                if (new_weight != animstate->getWeight())
                    animstate->setWeight((Ogre::Real)i->second.weight_ * i->second.weight_factor_);
                if (advance != 0.0f)
                    animstate->addTime((Ogre::Real)(i->second.speed_factor_ * frametime));
                if (!animstate->getEnabled())
                    animstate->setEnabled(true);
            }
            else
            {
                // If stopped, disable & remove this animation from list
                animstate->setEnabled(false);
                erase_list.push_back(i->first);
            }
        }
        
        for (uint i = 0; i < erase_list.size(); ++i)
        {
            animations_.erase(erase_list[i]);
        }
        
        // High-priority/low-priority blending code
        if (entity->hasSkeleton())
        {
            Ogre::SkeletonInstance* skel = entity->getSkeleton();
            if (!skel)
                return;
                
		    if (highpriority_mask_.size() != skel->getNumBones())
			    highpriority_mask_.resize(skel->getNumBones());
		    if (lowpriority_mask_.size() != skel->getNumBones())
			    lowpriority_mask_.resize(skel->getNumBones());

            for (uint i = 0; i < skel->getNumBones(); ++i)
            {
                highpriority_mask_[i] = 1.0;
                lowpriority_mask_[i] = 1.0;
            }

		    // Loop through all high priority animations & update the lowpriority-blendmask based on their active tracks
            for (AnimationMap::iterator i = animations_.begin(); i != animations_.end(); ++i)
	        {
                Ogre::AnimationState* animstate = GetAnimationState(entity, i->first);
                if (!animstate)
                    continue;	        
                // Create blend mask if animstate doesn't have it yet
                if (!animstate->hasBlendMask())
                    animstate->createBlendMask(skel->getNumBones());

                if ((i->second.high_priority_) && (i->second.weight_ > 0.0))
                {
				    // High-priority animations get the full weight blend mask
                    animstate->_setBlendMaskData(&highpriority_mask_[0]);
                    if (!skel->hasAnimation(animstate->getAnimationName()))
                        continue;
                        
                    Ogre::Animation* anim = skel->getAnimation(animstate->getAnimationName());
                    
                    Ogre::Animation::NodeTrackIterator it = anim->getNodeTrackIterator();
                    while (it.hasMoreElements())
                    {
					    Ogre::NodeAnimationTrack* track = it.getNext();
					    unsigned id = track->getHandle();
					    // For each active track, reduce corresponding bone weight in lowpriority-blendmask 
					    // by this animation's weight
					    if (id < lowpriority_mask_.size())
					    {
						    lowpriority_mask_[id] -= i->second.weight_;
						    if (lowpriority_mask_[id] < 0.0) lowpriority_mask_[id] = 0.0;
					    }
			        }
                }
            }

		    // Now set the calculated blendmask on low-priority animations
            for (AnimationMap::iterator i = animations_.begin(); i != animations_.end(); ++i)
	        {
                Ogre::AnimationState* animstate = GetAnimationState(entity, i->first);
                if (!animstate)
                    continue;	
                if (i->second.high_priority_ == false)	        
                    animstate->_setBlendMaskData(&lowpriority_mask_[0]);			    			   
		    }
        }
    }
开发者ID:caocao,项目名称:naali,代码行数:101,代码来源:EC_OgreAnimationController.cpp


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