本文整理汇总了C++中ogre::AnimationState::getEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationState::getEnabled方法的具体用法?C++ AnimationState::getEnabled怎么用?C++ AnimationState::getEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AnimationState
的用法示例。
在下文中一共展示了AnimationState::getEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAnimationMask
float GfxBody::getAnimationMask (const std::string &name)
{
if (dead) THROW_DEAD(className);
Ogre::AnimationState *state = getAnimState(name);
if (!state->getEnabled()) return 0.0f;
return state->getWeight();
}
示例2: update
void Actor::update(float deltaTime)
{
assert(mNode);
if(mNode->numAttachedObjects() == 0)
{
return;
}
Ogre::Entity* entity = dynamic_cast<Ogre::Entity*>(mNode->getAttachedObject(0));
if(!entity)
{
return;
}
Ogre::AnimationStateSet* set = entity->getAllAnimationStates();
if(!set)
{
return;
}
Ogre::AnimationStateIterator it = set->getAnimationStateIterator();
while(it.hasMoreElements())
{
Ogre::AnimationState* state = it.getNext();
if(state->getEnabled())
{
state->addTime(deltaTime);
}
}
}
示例3: paintGL
/**
* @brief render a frame
* @author Kito Berg-Taylor
*/
void THIS::paintGL()
{
if (!initialised)
initializeOgre();
for (Ogre::SceneManager::MovableObjectIterator mit = mSceneMgr->getMovableObjectIterator("Entity");mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (entity->hasSkeleton() )
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator(); animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
animState->addTime(mWindow->getBestFPS()/10000);
}
}
}
}
//Ogre::WindowEventUtilities::messagePump();
mRoot->renderOneFrame();
}
示例4: 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);
}
}
}
}
}
}
}
示例5: updateOGRE
void MainWindow::updateOGRE()
{
QMutexLocker locker(&mutex);
static bool updateGUI=true;
Ogre::Root* mRoot = Ogre::Root::getSingletonPtr();
mRoot->_fireFrameStarted();
// loop through ogre widgets and update animation
QList<OgreWidget*> rendlist = this->findChildren<OgreWidget*>();
foreach (OgreWidget* w, rendlist)
{
// update animation for OgreWidget's sceneManager
if (w->mRenderWindow && w->updatesEnabled())
{
// update OgreWidget
w->update();
//emit w->paintEvent(new QPaintEvent(w->rect()));
for (Ogre::SceneManager::MovableObjectIterator mit = w->getSceneManager()->getMovableObjectIterator("Entity");
mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (updateGUI) {
updateGUI = false;
}
// check has skeleton to avoid crash for non animable entities
if (entity->hasSkeleton())
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator();
animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
//std::cout << entity->getName() << " ZZZZZZZZZZZ " << animState->getAnimationName();
animState->addTime(w->getRenderWindow()->getBestFPS()/10000);
}
}
}
}
}
}
mRoot->_fireFrameRenderingQueued();
mRoot->_fireFrameEnded();
}
示例6: execute
void AnimationTask::execute(unsigned long timeDelta)
{
double deltaSec;
std::list<memUInt> finishedAnimations;
std::list<memUInt>::iterator finishedAnimationsIter;
AnimationMapIterator iter;
Value val;
if (getState() != TS_RUNNING)
{
setState(TS_RUNNING);
}
// Dispatch all waiting messages of this task
NotificationManager::getSingleton().dispatchQueuedNotifications((memUInt) this);
deltaSec = ((double) timeDelta) / MICROSECONDS_IN_SECOND;
{
Poco::ScopedRWLock lock(mRWLockActiveAnimations, false);
// Update animations
for (iter = activeAnimations.begin(); iter != activeAnimations.end(); ++iter)
{
AnimationMapValueEntry entry = iter->second;
Ogre::AnimationState *animationState = entry.first;
// Check if the animation has ended, and add it to a list of animations to be removed from the active list
if ((animationState->hasEnded()) || (!animationState->getEnabled()))
{
finishedAnimations.push_back(iter->first);
animationState->setEnabled(false);
// If the animation has a stop callback, call it
callCallback(animationState, &mStopCallbacks);
}
else
{
// Add the time since the last update to the animation
animationState->addTime(deltaSec);
// Check if this animation is just starting, if it is call its start callback
if (mStartingAnimations.erase(reinterpret_cast<memUInt>(animationState)) == 1)
{
callCallback(animationState, &mStartCallbacks);
}
}
}
}
mStartingAnimations.clear();
{
Poco::ScopedRWLock lock(mRWLockActiveAnimations, true);
Poco::ScopedRWLock lockCallbacks(mRWLockCallbacks, true);
// Remove the animations that have ended from the list of active animations
for (finishedAnimationsIter = finishedAnimations.begin(); finishedAnimationsIter != finishedAnimations.end(); ++finishedAnimationsIter)
{
memUInt animationAddress = *finishedAnimationsIter;
activeAnimations.erase(animationAddress);
// Remove any callbacks associated with this animation
mStartCallbacks.erase(animationAddress);
mStopCallbacks.erase(animationAddress);
}
}
}
示例7: 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]);
}
//.........这里部分代码省略.........