本文整理汇总了C++中ogre::Entity::getAllAnimationStates方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::getAllAnimationStates方法的具体用法?C++ Entity::getAllAnimationStates怎么用?C++ Entity::getAllAnimationStates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::getAllAnimationStates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例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: update
void DemoGameLogic::update(void)
{
mLastFrameTime = mCurrentTime;
mCurrentTime = mTime->elapsed();
float timeElapsedInSeconds = (mCurrentTime - mLastFrameTime) / 1000.0f;
for (Ogre::SceneManager::MovableObjectIterator moi = mSceneManager->getMovableObjectIterator("Entity"); moi.hasMoreElements(); moi.moveNext())
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(moi.peekNextValue());
Ogre::AnimationStateSet* animationStateSet = entity->getAllAnimationStates();
if(animationStateSet && animationStateSet->hasAnimationState("Walk"))
{
Ogre::AnimationState* walkAnimationState = animationStateSet->getAnimationState("Walk");
walkAnimationState->addTime(timeElapsedInSeconds);
}
}
float distance = mCameraSpeed * timeElapsedInSeconds;
if(mKeyStates[Qt::Key_W] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() + mCamera->getDirection() * distance);
}
if(mKeyStates[Qt::Key_S] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() - mCamera->getDirection() * distance);
}
if(mKeyStates[Qt::Key_A] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() - mCamera->getRight() * distance);
}
if(mKeyStates[Qt::Key_D] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() + mCamera->getRight() * distance);
}
if(!mIsFirstFrame)
{
QPoint mouseDelta = mCurrentMousePos - mLastFrameMousePos;
mCamera->yaw(Ogre::Radian(-mouseDelta.x() * timeElapsedInSeconds));
mCamera->pitch(Ogre::Radian(-mouseDelta.y() * timeElapsedInSeconds));
int wheelDelta = mCurrentWheelPos - mLastFrameWheelPos;
Ogre::Radian fov = mCamera->getFOVy();
fov += Ogre::Radian(-wheelDelta * 0.001);
fov = (std::min)(fov, Ogre::Radian(2.0f));
fov = (std::max)(fov, Ogre::Radian(0.5f));
mCamera->setFOVy(fov);
}
mLastFrameMousePos = mCurrentMousePos;
mLastFrameWheelPos = mCurrentWheelPos;
mIsFirstFrame = false;
}
示例4: mesh_anim_update
void mesh_anim_update ( void *mesh, int dt ) {
Ogre::Entity *e = static_cast<Ogre::Entity *> ( mesh );
float dt_s = dt * ( 1.0 / 1000.0 );
auto iter = e->getAllAnimationStates()->getEnabledAnimationStateIterator();
while ( iter.hasMoreElements() ) {
iter.getNext()->addTime ( dt_s );
}
}
示例5: mesh_anim_count
int mesh_anim_count ( void *mesh ) {
Ogre::Entity *e = static_cast<Ogre::Entity *> ( mesh );
auto iter = e->getAllAnimationStates()->getAnimationStateIterator();
int c = 0;
while ( iter.hasMoreElements() ) {
iter.getNext();
c++;
}
return c;
}
示例6: 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();
}
示例7: while
const char *mesh_anim_name ( void *mesh, int index ) {
Ogre::Entity *e = static_cast<Ogre::Entity *> ( mesh );
auto iter = e->getAllAnimationStates()->getAnimationStateIterator();
int c = 0;
while ( iter.hasMoreElements() ) {
auto s = iter.getNext();
if ( c == index ) {
return s->getAnimationName().c_str();
}
c++;
}
return "";
}
示例8: ReadEntity
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);
}
}
示例9: updateParts
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
{
if(mTimeToChange <= 0.0f)
{
mTimeToChange = 0.2f;
updateParts();
}
mTimeToChange -= timepassed;
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
const Ogre::SkeletonInstance *skelsrc = mEntityList.mSkelBase->getSkeleton();
for(size_t i = 0;i < sPartListSize;i++)
{
Ogre::Entity *ent = mEntityParts[i].mSkelBase;
if(!ent) continue;
updateSkeletonInstance(skelsrc, ent->getSkeleton());
ent->getAllAnimationStates()->_notifyDirty();
}
return ret;
}
示例10: NPCCharacter
EnemyCharacter::EnemyCharacter(const std::string& name,const std::string& script,Ogre::SceneNode* node,CrowdManager* crowdMgr,DamageInterface* damageInterface)
: NPCCharacter(name,script,node,crowdMgr),
_damageInterface(damageInterface)
{
_name = name;
_scriptName = script;
Ogre::Entity* ent = static_cast<Ogre::Entity*>(getMovableObject());
//this will probably have to change
node->scale(CHARACTER_SCALE_FACTOR,CHARACTER_SCALE_FACTOR,CHARACTER_SCALE_FACTOR);
if(ent != nullptr)
{
std::cout << "EnemyCharacter \'" << name << "\' has an entity attached." << std::endl;
Ogre::AnimationStateSet* animSet = ent->getAllAnimationStates();
if(animSet != nullptr)
{
std::cout << " - has animations" << std::endl;
_animHandler.setEntity(ent);
_animHandler.init("Idle",true);
}
else
{
std::cout << " - doesn't have animations" << std::endl;
_animHandler.setEntity(nullptr);
}
}
//set up the weapon
_currentWeapon.node = nullptr;
_currentWeapon.weapon = nullptr;
_prevBhv = AI::BHV_IDLE;
_prevAct = AI::ACT_IDLE;
_isBhvFinished = true;
_isActFinished = true;
_bhvChange = false;
_actChange = false;
}
示例11: SceneManager
void
Player::disableAnimations()
{
Ogre::SceneManager::MovableObjectIterator iterator = SceneManager()->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements())
{
Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());
if (e->hasSkeleton())
{
Ogre::AnimationStateIterator iter = e->getAllAnimationStates()->getAnimationStateIterator();
while(iter.hasMoreElements())
{
Ogre::AnimationState *animState = iter.getNext();
animState->setEnabled(false);
}
}
}
}
示例12: setAnimationEnabled
void Actor::setAnimationEnabled(const QString& name, bool enabled)
{
assert(mNode);
if(mNode->numAttachedObjects() == 0)
{
qWarning() << "Can't enable animation [" << name
<< "] on actor [" << getName() << "]"
<< " because it doesn't have any attached objects.";
return;
}
Ogre::Entity* entity = dynamic_cast<Ogre::Entity*>(mNode->getAttachedObject(0));
if(!entity)
{
qWarning() << "Can't enable animation [" << name
<< "] on actor [" << getName() << "]"
<< " because its attachment isn't an entity.";
return;
}
Ogre::AnimationStateSet* set = entity->getAllAnimationStates();
if(!set->hasAnimationState(name.toStdString()))
{
qWarning() << "Tried to set the state of an animation named "
<< name << " on actor "
<< QString::fromStdString(mNode->getName())
<< " that doesn't exist. The animation states remain unchanged.";
return;
}
Ogre::AnimationState* state = set->getAnimationState(name.toStdString());
state->setEnabled(enabled);
state->setLoop(true);
}
示例13: BaseEntity
NPCCharacter::NPCCharacter(const std::string& name,const std::string& script,Ogre::SceneNode* node,CrowdManager* crowdMgr)
: BaseEntity(false,LevelData::NPC),
Character(node,crowdMgr,node->getPosition())
{
_name = name;
_scriptName = script;
//check for animations
Ogre::Entity* ent = static_cast<Ogre::Entity*>(getMovableObject());
node->scale(CHARACTER_SCALE_FACTOR,CHARACTER_SCALE_FACTOR,CHARACTER_SCALE_FACTOR);
if(ent != nullptr)
{
std::cout << "NPCCharacter \'" << name << "\' has an entity attached." << std::endl;
Ogre::AnimationStateSet* animSet = ent->getAllAnimationStates();
if(animSet != nullptr)
{
std::cout << " - has animations" << std::endl;
_animHandler.setEntity(ent);
_animHandler.init("Idle",true);
}
else
{
std::cout << " - doesn't have animations" << std::endl;
_animHandler.setEntity(NULL);
}
}
_prevBhv = 0;
_prevAct = 0;
_isBhvFinished = true;
_isActFinished = true;
_bhvChange = false;
_actChange = false;
}
示例14: if
void RoR::GfxCharacter::UpdateCharacterInScene()
{
// Actor coupling
if (xc_simbuf.simbuf_actor_coupling != xc_simbuf_prev.simbuf_actor_coupling)
{
if (xc_simbuf.simbuf_actor_coupling != nullptr)
{
// Entering/switching vehicle
if (xc_movable_text != nullptr)
{
xc_movable_text->setVisible(false);
}
xc_scenenode->getAttachedObject(0)->setCastShadows(false);
xc_scenenode->setVisible(xc_simbuf.simbuf_actor_coupling->GetGfxActor()->HasDriverSeatProp());
}
else if (xc_simbuf_prev.simbuf_actor_coupling != nullptr)
{
// Leaving vehicle
if (xc_movable_text != nullptr)
{
xc_movable_text->setVisible(true);
}
xc_scenenode->getAttachedObject(0)->setCastShadows(true);
xc_scenenode->setVisible(true);
xc_scenenode->resetOrientation();
}
}
// Position + Orientation
if (xc_simbuf.simbuf_actor_coupling != nullptr)
{
if (xc_simbuf.simbuf_actor_coupling->GetGfxActor()->HasDriverSeatProp())
{
Ogre::Vector3 pos;
Ogre::Quaternion rot;
xc_simbuf.simbuf_actor_coupling->GetGfxActor()->CalculateDriverPos(pos, rot);
xc_scenenode->setOrientation(rot);
// hack to position the character right perfect on the default seat (because the mesh has decentered origin)
xc_scenenode->setPosition(pos + (rot * Vector3(0.f, -0.6f, 0.f)));
}
}
else
{
xc_scenenode->resetOrientation();
xc_scenenode->yaw(-xc_simbuf.simbuf_character_rot);
xc_scenenode->setPosition(xc_simbuf.simbuf_character_pos);
}
// Animation
Ogre::Entity* entity = static_cast<Ogre::Entity*>(xc_scenenode->getAttachedObject(0));
if (xc_simbuf.simbuf_anim_name != xc_simbuf_prev.simbuf_anim_name)
{
// 'Classic' method - enable one anim, exterminate the others ~ only_a_ptr, 06/2018
AnimationStateIterator it = entity->getAllAnimationStates()->getAnimationStateIterator();
while (it.hasMoreElements())
{
AnimationState* as = it.getNext();
if (as->getAnimationName() == xc_simbuf.simbuf_anim_name)
{
as->setEnabled(true);
as->setWeight(1);
as->addTime(xc_simbuf.simbuf_anim_time);
}
else
{
as->setEnabled(false);
as->setWeight(0);
}
}
}
else
{
auto* as_cur = entity->getAnimationState(xc_simbuf.simbuf_anim_name);
as_cur->setTimePosition(xc_simbuf.simbuf_anim_time);
}
// SurveyMapEntity
if (xc_survey_map_entity == nullptr)
xc_survey_map_entity = App::GetSimController()->GetGfxScene().GetSurveyMap()->createMapEntity("person");
String caption = (App::mp_state.GetActive() == MpState::CONNECTED) ? xc_simbuf.simbuf_net_username : "";
App::GetSimController()->GetGfxScene().GetSurveyMap()->UpdateMapEntity(xc_survey_map_entity, caption,
xc_simbuf.simbuf_character_pos, xc_simbuf.simbuf_character_rot.valueRadians(),
-static_cast<int>(xc_simbuf.simbuf_is_remote), !xc_simbuf.simbuf_actor_coupling);
// Multiplayer label
#ifdef USE_SOCKETW
if (App::mp_state.GetActive() == MpState::CONNECTED)
{
// From 'updateCharacterNetworkColor()'
const String materialName = "tracks/" + xc_instance_name;
const int textureUnitStateNum = 2;
MaterialPtr mat = MaterialManager::getSingleton().getByName(materialName);
if (!mat.isNull() && mat->getNumTechniques() > 0 && mat->getTechnique(0)->getNumPasses() > 0 && textureUnitStateNum < mat->getTechnique(0)->getPass(0)->getNumTextureUnitStates())
{
auto state = mat->getTechnique(0)->getPass(0)->getTextureUnitState(textureUnitStateNum);
Ogre::ColourValue color = Networking::GetPlayerColor(xc_simbuf.simbuf_color_number);
state->setAlphaOperation(LBX_BLEND_CURRENT_ALPHA, LBS_MANUAL, LBS_CURRENT, 0.8);
//.........这里部分代码省略.........
示例15: while
//!
//! Clones an Ogre::MovableObject.
//!
//! Is needed because OGRE does not provide clone functions for cameras and
//! lights.
//!
//! \param movableObject The object to clone.
//! \param name The name to use for the object.
//! \param sceneManager The scene manager to use for creating the object.
//! \return The cloned object.
//!
Ogre::MovableObject * OgreTools::cloneMovableObject ( Ogre::MovableObject *movableObject, const QString &name, Ogre::SceneManager *sceneManager /* = 0 */ )
{
// make sure the given object is valid
if (!movableObject) {
Log::error("The given movable object is invalid.", "OgreTools::cloneMovableObject");
return 0;
}
// make sure a valid scene manager is available
if (!sceneManager)
sceneManager = movableObject->_getManager();
if (!sceneManager) {
Log::error("No valid scene manager available.", "OgreTools::cloneMovableObject");
return 0;
}
Ogre::MovableObject *result = 0;
Ogre::String typeName = movableObject->getMovableType();
if (typeName == "Entity") {
// clone entity
Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(movableObject);
//movableObjectCopy = entity->clone(name.toStdString());
Ogre::Entity *entityCopy = sceneManager->createEntity(name.toStdString(), entity->getMesh()->getName());
Ogre::AnimationStateSet *animationStateSet = entity->getAllAnimationStates();
Ogre::AnimationStateSet *animationStateSetCopy = entityCopy->getAllAnimationStates();
// set the same blend mode on entity copy
if (entity && entityCopy) {
if (entity->hasSkeleton() && entityCopy->hasSkeleton()) {
Ogre::Skeleton *skeleton = entity->getSkeleton();
Ogre::Skeleton *skeletonCopy = entityCopy->getSkeleton();
skeletonCopy->setBlendMode(skeleton->getBlendMode());
}
}
// copy all animation states
if (animationStateSet && animationStateSetCopy) {
Ogre::AnimationStateIterator animationStateIter = animationStateSet->getAnimationStateIterator();
Ogre::AnimationStateIterator animationStateCopyIter = animationStateSetCopy->getAnimationStateIterator();
while (animationStateIter.hasMoreElements()) {
if (!animationStateCopyIter.hasMoreElements())
break;
Ogre::AnimationState *animationState = animationStateIter.getNext();
Ogre::AnimationState *animationStateCopy = animationStateCopyIter.getNext();
animationStateCopy->setLoop(animationState->getLoop());
//bool enabled = animationState->getEnabled();
//animationStateCopy->setEnabled(animationState->getEnabled());
animationStateCopy->setEnabled(true);
animationStateCopy->setTimePosition(animationState->getTimePosition());
}
}
// create a new container for the cloned entity
OgreContainer *entityCopyContainer = new OgreContainer(entityCopy);
entityCopy->setUserAny(Ogre::Any(entityCopyContainer));
if (!entity->getUserAny().isEmpty()) {
OgreContainer *entityContainer = Ogre::any_cast<OgreContainer *>(entity->getUserAny());
if (entityContainer) {
QObject::connect(entityContainer, SIGNAL(animationStateUpdated(const QString &, double)), entityCopyContainer, SLOT(updateAnimationState(const QString &, double)));
QObject::connect(entityContainer, SIGNAL(boneTransformUpdated(const QString &, double, double, double, double, double, double)), entityCopyContainer, SLOT(updateBoneTransform(const QString &, double, double, double, double, double, double)));
}
}
result = dynamic_cast<Ogre::MovableObject *>(entityCopy);
} else if (typeName == "Light") {
// clone light
Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject);
Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString());
lightCopy->setType(light->getType());
lightCopy->setDiffuseColour(light->getDiffuseColour());
lightCopy->setSpecularColour(light->getSpecularColour());
lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric());
lightCopy->setPosition(light->getPosition());
lightCopy->setDirection(light->getDirection());
if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT)
lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff());
lightCopy->setPowerScale(light->getPowerScale());
lightCopy->setCastShadows(light->getCastShadows());
// create a new container for the cloned light
OgreContainer *lightCopyContainer = new OgreContainer(lightCopy);
lightCopy->setUserAny(Ogre::Any(lightCopyContainer));
if (!light->getUserAny().isEmpty()) {
OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny());
if (lightContainer)
QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight()));
}
result = dynamic_cast<Ogre::MovableObject *>(lightCopy);
} else if (typeName == "Camera") {
// clone camera
Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject);
Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString());
//.........这里部分代码省略.........