本文整理汇总了C++中ogre::AnimationState::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationState::getLength方法的具体用法?C++ AnimationState::getLength怎么用?C++ AnimationState::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AnimationState
的用法示例。
在下文中一共展示了AnimationState::getLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEnabled
void Animation::setEnabled(bool enabled)
{
for (AnimationPartSet::const_iterator I = mAnimationParts.begin(); I != mAnimationParts.end(); ++I) {
//we'll get an assert error if we try to enable an animation with zero length
Ogre::AnimationState* state = I->state;
if (state->getLength() != 0) {
if (state->getEnabled() != enabled) {
state->setEnabled(enabled);
state->destroyBlendMask();
if (enabled) {
const std::vector<BoneGroupRef>& boneGroupRefs = I->boneGroupRefs;
for (std::vector<BoneGroupRef>::const_iterator J = boneGroupRefs.begin(); J != boneGroupRefs.end(); ++J) {
const BoneGroupRef& boneGroupRef = *J;
const BoneGroupDefinition& boneGroupDef = *boneGroupRef.boneGroupDefinition;
if (!state->hasBlendMask()) {
state->createBlendMask(mBoneNumber, 0.0f);
}
const std::vector<size_t>& boneIndices = boneGroupDef.Bones;
for (std::vector<size_t>::const_iterator bones_I = boneIndices.begin(); bones_I != boneIndices.end(); ++bones_I) {
state->setBlendMaskEntry(*bones_I, boneGroupRef.weight);
}
}
}
}
}
}
}
示例2: SetAnimationToEnd
void EC_OgreAnimationController::SetAnimationToEnd(const std::string& name)
{
Ogre::Entity* entity = GetEntity();
Ogre::AnimationState* animstate = GetAnimationState(entity, name);
if (!animstate)
return;
if (animstate)
{
SetAnimationTimePosition(name, animstate->getLength());
}
}
示例3: createAnimations
void AnimationSystem::createAnimations()
{
Ogre::AnimationStateSet* animationStates = getAnimationStateSet();
// Although there is an assert for this condition in the constructor, added check for
// safety in a release build.
if ( animationStates == NULL )
{
return;
}
Ogre::AnimationStateIterator it = animationStates->getAnimationStateIterator();
while ( it.hasMoreElements() )
{
Ogre::AnimationState* animationState = it.getNext();
if ( 0 < animationState->getLength() )
{
Animation* animation = new Animation( animationState );
addAnimation( animation );
}
}
}
示例4: update
// update state
void PlayerBombState::update(PlayerUnit *ref)
{
// check if we are putting the bomb
if(isPlantingBomb(ref)){
// wait until the animation finish
if(ref->hasActualAnimEnd()){
// we finish
ref->getFSM().newEvent(PlayerUnit::E_DONE);
}else{
// if the animation time is at half of it's total time
Ogre::AnimationState *anim = ref->getActualAnimation();
ASSERT(anim);
if(anim->getLength()*0.5 < anim->getTimePosition() and ref->getActualBomb()){
doPlantBomb(ref);
}
}
// we continue waiting
return;
}
if(!ref->moveThroughPath()){
ref->changeAnimation(PlayerUnit::ANIM_PLANT_BOMB);
}
}
示例5: Update
void EC_OgreAnimationController::Update(f64 frametime)
{
Ogre::Entity* entity = GetEntity();
if (!entity) return;
std::vector<std::string> erase_list;
// Loop through all animations & update them as necessary
for (AnimationMap::iterator i = animations_.begin(); i != animations_.end(); ++i)
{
Ogre::AnimationState* animstate = GetAnimationState(entity, i->first);
if (!animstate)
continue;
switch(i->second.phase_)
{
case PHASE_FADEIN:
// If period is infinitely fast, skip to full weight & PLAY status
if (i->second.fade_period_ == 0.0f)
{
i->second.weight_ = 1.0f;
i->second.phase_ = PHASE_PLAY;
}
else
{
i->second.weight_ += (1.0f / i->second.fade_period_) * frametime;
if (i->second.weight_ >= 1.0f)
{
i->second.weight_ = 1.0f;
i->second.phase_ = PHASE_PLAY;
}
}
break;
case PHASE_PLAY:
if (i->second.auto_stop_ || i->second.num_repeats_ != 1)
{
if ((i->second.speed_factor_ >= 0.f && animstate->getTimePosition() >= animstate->getLength()) ||
(i->second.speed_factor_ < 0.f && animstate->getTimePosition() <= 0.f))
{
if (i->second.num_repeats_ != 1)
{
if (i->second.num_repeats_ > 1)
i->second.num_repeats_--;
Ogre::Real rewindpos = i->second.speed_factor_ >= 0.f ? (animstate->getTimePosition() - animstate->getLength()) : animstate->getLength();
animstate->setTimePosition(rewindpos);
}
else
{
i->second.phase_ = PHASE_FADEOUT;
}
}
}
break;
case PHASE_FADEOUT:
// If period is infinitely fast, skip to disabled status immediately
if (i->second.fade_period_ == 0.0f)
{
i->second.weight_ = 0.0f;
i->second.phase_ = PHASE_STOP;
}
else
{
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]);
}
//.........这里部分代码省略.........
示例6: HasAnimationFinished
bool EC_OgreAnimationController::HasAnimationFinished(const std::string& name)
{
Ogre::Entity* entity = GetEntity();
Ogre::AnimationState* animstate = GetAnimationState(entity, name);
if (!animstate)
return false;
AnimationMap::iterator i = animations_.find(name);
if (i != animations_.end())
{
if ((!animstate->getLoop()) && ((i->second.speed_factor_ >= 0.f && animstate->getTimePosition() >= animstate->getLength()) ||
(i->second.speed_factor_ < 0.f && animstate->getTimePosition() <= 0.f)))
return true;
else
return false;
}
// Animation not listed, must be finished
return true;
}