本文整理汇总了C++中ogre::AnimationState::getAnimationName方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationState::getAnimationName方法的具体用法?C++ AnimationState::getAnimationName怎么用?C++ AnimationState::getAnimationName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AnimationState
的用法示例。
在下文中一共展示了AnimationState::getAnimationName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
if(argc <= 1 || argc > 2)
{
std::cout << "Invalid argument, it sould be : ./ogre_show_animationstate /path/name.mesh !\n";
return -1;
}
std::string nameMesh(argv[1]);
std::string pathMesh;
int index = nameMesh.size();
while(nameMesh[index] != '/')
{
index--;
if(index == 0)
{
pathMesh = "./";
break;
}
}
if(index != 0)
{
pathMesh = nameMesh.substr(0, index);
}
// Init
Ogre::Root* mRoot = new Ogre::Root();
new Ogre::DefaultHardwareBufferManager();
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("./", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(pathMesh, "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// load mesh
Ogre::MeshPtr mesh =
Ogre::MeshManager::getSingleton().load(nameMesh, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// create & load a SkeletonInstance
Ogre::SkeletonInstance* skelInst = new Ogre::SkeletonInstance(mesh->getSkeleton());
skelInst->load();
// create & load an AnimationStateSet
Ogre::AnimationStateSet* animStateSet = new Ogre::AnimationStateSet();
mesh->_initAnimationState(animStateSet);
// show animation state
std::cout << "Animation states : \n";
Ogre::AnimationStateIterator iter = animStateSet->getAnimationStateIterator();
while(iter.hasMoreElements())
{
Ogre::AnimationState* animationState = iter.getNext();
std::cout << "\t- " << animationState->getAnimationName() << "\n";
}
return 0;
}
示例2: _behaviorMove
void NPCCharacter::_behaviorMove(const Ogre::Vector3& target)
{
//Check for duplicate move calls and update lua function call with that info
//std::cout << target << std::endl;
if(_destination.squaredDistance(target) >= 5)
{
updateDestination(target,false);
_destination = target;
}
if(destinationReached())
{
_isBhvFinished = true;
}
else
{
_isBhvFinished = false;
}
//point the character in the direction it's traveling
Ogre::Vector3 vel = getVelocity();
float speed = vel.length();
vel.y = 0;
vel.normalise();
if(speed > .2f)
{
Ogre::Vector3 src = _node->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z;
src.y = 0;
//moving sufficiently fast, change to moving animation and point character
Utility::rotateToTarget(_node,vel,true);
//change animation if needed.
if(_animHandler.getSource() != nullptr)
{
Ogre::AnimationState* target = _animHandler.getTarget();
//this relies on the properties of the '&&' construct used by C++(if the first is false,
//then the if-statement is false. It DOESN'T check both fields.
if((target == nullptr && _animHandler.getSource()->getAnimationName() != "Walk") ||
(target != nullptr && target->getAnimationName() != "Walk"))
{
_animHandler.blend("Walk",AnimationBlender::BlendWhileAnimating,.2f,true);
}
}
}
//also have to reset the head, since I'm manually controlling it.
Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton();
Ogre::Bone* headBone = skel->getBone("Bip01_Head");
//not sure how to do this.
}
示例3: AnimState
CharacterAnimation::CharacterAnimation(Ogre::Entity* ent)
{
Ogre::AnimationStateSet * anims = ent->getAllAnimationStates();
Ogre::AnimationStateIterator it = anims->getAnimationStateIterator();
while(it.hasMoreElements())
{
Ogre::AnimationState * as = it.getNext();
as->setWeight(0);
Animations.insert(std::make_pair(as->getAnimationName(), AnimState(as, 0, 5, 5, 1)));
}
ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
示例4: moveBone
void CAnimatedEntity::moveBone(const std::string &bone, float pitch) {
Ogre::Bone * entityBone = _entity->getSkeleton()->getBone(bone);
entityBone->reset();
Ogre::Skeleton * skel = _entity->getSkeleton();
//entityBone->setManuallyControlled(true);
unsigned short boneHandle = entityBone->getHandle();
Ogre::AnimationStateIterator animStateIt = _entity->getAllAnimationStates()->getAnimationStateIterator();
while( animStateIt.hasMoreElements() )
{
Ogre::AnimationState *pAnimState = animStateIt.getNext();
// ignore disabled animations
skel->getAnimation(pAnimState->getAnimationName())->destroyNodeTrack(boneHandle);
}
entityBone->pitch(Ogre::Radian(pitch));
}
示例5: setAnimationState
void MeshPersonVisual::setAnimationState(const std::string& nameOfAnimationState) {
Ogre::AnimationStateSet *animationStates = entity_->getAllAnimationStates();
if(animationStates != NULL)
{
Ogre::AnimationStateIterator animationsIterator = animationStates->getAnimationStateIterator();
while (animationsIterator.hasMoreElements())
{
Ogre::AnimationState *animationState = animationsIterator.getNext();
if(animationState->getAnimationName() == nameOfAnimationState || nameOfAnimationState.empty()) {
animationState->setLoop(true);
animationState->setEnabled(true);
m_animationState = animationState;
return;
}
}
// Not found. Set first animation state then.
ROS_WARN_STREAM_ONCE("Person mesh animation state " << nameOfAnimationState << " does not exist in mesh!");
setAnimationState("");
}
}
示例6: 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]);
}
}
}