void MeshObject::stopAllAnimations( ) { AnimationStateSet* animStates = getEntity()->getAllAnimationStates(); if (animStates != NULL) { AnimationStateIterator iter = animStates->getAnimationStateIterator(); while(iter.hasMoreElements()) { AnimationState* state = iter.getNext(); stopAnimation( state->getAnimationName() ); } } }
/** * Construit la scène animée. */ void AnimApp::buildScene() { Entity * ent = scMgr->createEntity("AnimatedMesh", "Sinbad.mesh"); scMgr->getRootSceneNode()->attachObject(ent); camera->setPosition(0, 2, 12); AnimationStateSet * set = ent->getAllAnimationStates(); AnimationStateIterator iter = set->getAnimationStateIterator(); vector<string> animSetNames; while (iter.hasMoreElements()) { animSetNames.push_back(iter.getNext()->getAnimationName()); } animState = ent->getAnimationState(animSetNames.at(0)); animState->setEnabled(true); animState->setLoop(true); }
void FvXMLAnimationModelSerializerImpl::ReadEntity( FvXMLSectionPtr spSection, Ogre::SceneNode* pkNode, FvAnimationModel* pkDest ) { Ogre::SceneManager *pkSceneManager = Ogre::Root::getSingleton(). _getCurrentSceneManager(); FV_ASSERT(pkSceneManager); FvString kMeshIdentifier = spSection->ReadString("identifier"); FvString kMeshFile = spSection->ReadString("mesh"); Ogre::Entity *pkEntity = pkSceneManager->createEntity( pkNode->getName() + "_" + kMeshIdentifier,kMeshFile); FV_ASSERT(pkEntity); pkEntity->setCastShadows(pkDest->m_bCastShadows); pkNode->attachObject(pkEntity); pkDest->m_akNodes[pkDest->m_u32CurrentLodLevel].m_kEntityList.push_back(pkEntity); pkEntity->setRenderQueueGroup(RENDER_QUEUE_MAX); AnimationStateSet *pkAnimations = pkEntity->getAllAnimationStates(); if(pkAnimations) { AnimationStateIterator kIt = pkAnimations->getAnimationStateIterator(); while (kIt.hasMoreElements()) { AnimationState *pkAnim= kIt.getNext(); if(pkDest->GetAnimation(pkAnim->getAnimationName()) == NULL) pkDest->m_kModelAnimations.insert(std::make_pair(pkAnim->getAnimationName(),pkAnim)); } } std::vector<FvXMLSectionPtr> kSubentities; spSection->OpenSections("subentities/subentity",kSubentities); std::vector<FvXMLSectionPtr>::iterator kSubIt = kSubentities.begin(); for(; kSubIt != kSubentities.end(); ++kSubIt) { int iIndex = (*kSubIt)->ReadInt("index",-1); FvString kMaterialName = (*kSubIt)->ReadString("materialName"); Ogre::SubEntity *pkSubEntity = pkEntity->getSubEntity(iIndex); if(pkSubEntity && !kMaterialName.empty()) pkSubEntity->setMaterialName(kMaterialName); } }
void AnimationBlender::init(const String &animation, bool l, Game::Actor* _owner) { this->Owner = _owner; if (!mEntity->hasSkeleton()) return; AnimationStateSet *set = mEntity->getAllAnimationStates(); AnimationStateIterator it = set->getAnimationStateIterator(); while(it.hasMoreElements()) { AnimationState *anim = it.getNext(); anim->setEnabled(false); anim->setWeight(0); anim->setTimePosition(0); std::string name = anim->getAnimationName(); if (_owner->entity->hasSkeleton()) { Animation* an = _owner->entity->getSkeleton()->getAnimation(name); an->setRotationInterpolationMode(Ogre::Animation::RotationInterpolationMode::RIM_LINEAR); an->setInterpolationMode(Ogre::Animation::InterpolationMode::IM_LINEAR); } //GameFramework::getSingletonPtr()->sceneManager->getAnimation(); } //Ogre::Animation::setDefaultInterpolationMode(InterpolationMode:: //_owner->entity->getAnimationState("")-> mSource = mEntity->getAnimationState( animation ); mSource->setEnabled(true); //////CALLBACK///// this->Owner->onAnimationStarted(mSource->getAnimationName()); mSource->setWeight(1); mTimeleft = 0; mDuration = 1; mTarget = 0; complete = false; loop = l; this->isInitialized = true; this->isBlending = false; }
void AnimationBlender::init(const string& animation, bool looping) { AnimationStateSet* set = mEntity->getAllAnimationStates(); if (set == nullptr) throw string("AnimationBlender::init:That mesh does not have any animations!"); for (auto animPair : set->getAnimationStateIterator()) { animPair.second->setEnabled(false); animPair.second->setWeight(0); animPair.second->setTimePosition(0); } mCurrentAnim = animation; mSource = mEntity->getAnimationState(animation); mSource->setEnabled(true); mSource->setWeight(1); mTimeleft = 0; mDuration = 1; mTarget = nullptr; mComplete = true; mLoop = looping; }
void AnimationBlender2::init(const String &animation, bool loop, Game::Actor* _owner) { this->Owner = _owner; if (!mEntity->hasSkeleton()) return; AnimationStateSet *set = mEntity->getAllAnimationStates(); AnimationStateIterator it = set->getAnimationStateIterator(); while(it.hasMoreElements()) { AnimationState *anim = it.getNext(); std::string name = anim->getAnimationName(); if (_owner->entity->hasSkeleton()) { Animation* an = _owner->entity->getSkeleton()->getAnimation(name); if (an->getRotationInterpolationMode() != Animation::RotationInterpolationMode::RIM_LINEAR) an->setRotationInterpolationMode(Ogre::Animation::RotationInterpolationMode::RIM_LINEAR); if (an->getInterpolationMode() != Ogre::Animation::InterpolationMode::IM_LINEAR) an->setInterpolationMode(Ogre::Animation::InterpolationMode::IM_LINEAR); } } this->currentAnimation = AnimationBlendData(mEntity->getAnimationState( animation )); this->currentAnimation.animationState->setEnabled(true); this->currentAnimation.animationState->setWeight(1); this->currentAnimation.animationState->setTimePosition(0); this->currentAnimation.animationState->setLoop(loop); this->animationFadingIn.exist = false; this->animationsFadingOut->clear(); this->isInitialized = true; }