本文整理汇总了C++中ogre::AnimationState::addTime方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationState::addTime方法的具体用法?C++ AnimationState::addTime怎么用?C++ AnimationState::addTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AnimationState
的用法示例。
在下文中一共展示了AnimationState::addTime方法的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: customframeEnded
bool customframeEnded( const Ogre::FrameEvent& evt)
{
// Update animation
// To move, we add it the time since last frame
mAnimationState->addTime( evt.timeSinceLastFrame );
return true;
}
示例4: frameStarted
bool frameStarted(const FrameEvent &evt)
{
mAnimationState->addTime(evt.timeSinceLastFrame);
return true;
}
示例5: 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;
}
示例6: getAnimationState
//-------------------------------------------------------------------------------------
bool
PlayersManager::taking(zappy::Player *p, int i)
{
OPlayer *OPlayer;
OPlayer = this->mOPlayers.at(i);
Ogre::AnimationState *anim = OPlayer->getEntity()->
getAnimationState("Slump");
anim->setEnabled(true);
anim->setLoop(true);
anim->addTime(this->tslf);
if (OPlayer->stateHasChanged())
OPlayer->detachAnim();
return true;
}
示例7: arrancaMuerte
void Pacman::arrancaMuerte(Ogre::Real deltaT)
{
stop();
Ogre::AnimationState *anim;
Ogre::Entity* pacmanEnt = static_cast<Ogre::Entity*>( node->getAttachedObject(PACMAN_NODE));
anim = pacmanEnt->getAnimationState(PACMAN_EAT_ANIM);
anim->setEnabled(false);
anim = pacmanEnt->getAnimationState(PACMAN_DIES);
anim->addTime(deltaT);
anim->setEnabled(true);
anim->setLoop(false);
anim->setTimePosition(0.0);
estoyMuriendo = true;
}
示例8: 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();
}
示例9: destination
//-------------------------------------------------------------------------------------
bool
PlayersManager::moving(zappy::Player *p, int i)
{
OPlayer *OPlayer = this->mOPlayers.at(i);
this->speed = Constants::SquareSize /
((Constants::timeUnit / static_cast<Ogre::Real>(time)));
Ogre::SceneNode *node = OPlayer->getSceneNode();
Ogre::Vector3 &direction = OPlayer->getDirection();
Ogre::Real &distance = OPlayer->getDistance();
Ogre::Real move = this->speed * this->tslf;
Ogre::Vector3 destination(p->getX() * Constants::SquareSize, 0, p->getY() * Constants::SquareSize);
Ogre::AnimationState *anim = OPlayer->getEntity()->
getAnimationState(distance <= 0.0f ? "Idle" : "Walk");
anim->setLoop(true);
anim->setEnabled(true);
if (direction == Ogre::Vector3::ZERO)
{
Ogre::Vector3 src = node->getOrientation() * Ogre::Vector3::UNIT_X;
direction = destination - node->getPosition();
distance = direction.normalise();
if ((1.0f + src.dotProduct(direction)) < 0.0001f)
node->yaw(Ogre::Degree(180));
else
node->rotate(src.getRotationTo(direction));
if (distance > Constants::SquareSize)
distance = 0.0f;
}
else
{
distance -= move;
if (distance <= 0.0f)
{
node->setPosition(destination);
direction = Ogre::Vector3::ZERO;
}
else
node->translate(direction * move);
}
if (OPlayer->stateHasChanged())
OPlayer->detachAnim();
anim->addTime(this->tslf);
return true;
}
示例10: position
//-------------------------------------------------------------------------------------
bool
PlayersManager::dying(zappy::Player *p, int i)
{
OPlayer *OPlayer = this->mOPlayers.at(i);
if (OPlayer->stateHasChanged())
OPlayer->detachAnim();
Ogre::Vector3 position(p->getX() * Constants::SquareSize, 0, p->getY() * Constants::SquareSize);
Ogre::AnimationState *anim = OPlayer->getEntity()->
getAnimationState("Die");
Ogre::SceneNode *node = OPlayer->getSceneNode();
if (position != node->getPosition())
node->setPosition(position);
anim->setEnabled(true);
anim->setLoop(false);
anim->addTime(this->tslf);
return true;
}
示例11: updateAnimation
/**更新动画*/
void Enemy::updateAnimation(float time)
{
m_AniFade-=time;
m_AniFade=std::max(m_AniFade,0.0f);
if (m_pEntity)
{
Ogre::AnimationStateSet* animStateSet = m_pEntity->getAllAnimationStates();
// 更新自身动画
if (animStateSet)
{
Ogre::ConstEnabledAnimationStateIterator animStateItor = animStateSet->getEnabledAnimationStateIterator();
while (animStateItor.hasMoreElements())
{
Ogre::AnimationState* animState = animStateItor.getNext();
animState->addTime(time);
// 当前动画逐渐递增权重
if (animState== m_pAniSate)
{
if (animState->getWeight() < 1.0f)
{
animState->setWeight(1.0f - m_AniFade);
}
}
// 其余动画逐渐递减权重,直到关闭动画
else
{
if (Ogre::Math::RealEqual(animState->getWeight(), 0.0f))
{
animState->setWeight(1.0f);
animState->setEnabled(false);
}
else
{
animState->setWeight(m_AniFade);
}
}
}
}
}
}
示例12: frameStarted
bool frameStarted(const FrameEvent &evt)
{
mAnimationState = mProfessorEntity->getAnimationState("Walk");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
//if (mDirection == Vector3::ZERO)
//{
// if (nextLocation())
// {
// mAnimationState = mProfessorEntity->getAnimationState("Walk");
// mAnimationState->setLoop(true);
// mAnimationState->setEnabled(true);
// }
//}
//else
//{
// Real move = mWalkSpeed * evt.timeSinceLastFrame; // 이동량 계산
// mDistance -= move; // 남은 거리 계산
// if (mDistance <= 0.0f)
// { // 목표 지점에 다 왔으면…
// mProfessorNode->setPosition(mDestination); // 목표 지점에 캐릭터를 위치
// mDirection = Vector3::ZERO; // 정지 상태로 들어간다.
// if (!nextLocation())
// {
// mAnimationState->setEnabled(false);
// mAnimationState = mProfessorEntity->getAnimationState("Idle");
// mAnimationState->setLoop(true);
// mAnimationState->setEnabled(true);
// }
// }
// else
// {
// mProfessorNode->translate(mDirection * move);
// }
//}
mAnimationState->addTime(evt.timeSinceLastFrame);
return true;
}
示例13: SceneManager
/* crouch_idle | crouch_to_stand | crouch_walk | fall_idle | fall_to_roll
* gangname_style | idle0 | idle1 | idle2 | jump | turnLeft | turnLeft90
* turnRight | turnRight90 | run | run_to_stop | samba | strafeLeft
* strafeRight | the_running_man | walkBackward | walkForward
* (Example: playAnimation("jump", time);)
*/
void
Player::playAnimation(std::string anim, float time)
{
disableAnimations();
Ogre::SceneManager::MovableObjectIterator iterator = SceneManager()->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements())
{
Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());
if (e->hasSkeleton())
{
Ogre::AnimationState *animation = e->getAnimationState(anim);
/*if (animation->getAnimationName().compare("jump") == 0)
finishAnimation(animation, time);
*/
animation->setEnabled("true");
animation->addTime(time);
}
}
}
示例14: frameStarted
bool frameStarted(const FrameEvent &evt)
{
// Fill Here --------------------------------------------------------------
if (Vector3::ZERO == mDirection)
{
if (nextLocation())
{
mAnimationState = mProfessorEntity->getAnimationState("Walk");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
}
}
else // Vector3::ZERO != mDirection
{
Real move = mWalkSpeed * evt.timeSinceLastFrame;
mDistance -= move;
if (mDistance <= 0.f)
{ // 목표 지점에 다 왔으면
mProfessorNode->setPosition(mDestination);
mDestination = Vector3::ZERO;
if (!nextLocation())
{
mAnimationState->setEnabled(false);
mAnimationState = mProfessorEntity->getAnimationState("Idle");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
}
}
else
{
mProfessorNode->translate(mDirection * move);
}
}
// -------------------------------------------------------------------------
mAnimationState->addTime(evt.timeSinceLastFrame);
return true;
}
示例15: animate
void OgreCharacterController::animate(Ogre::Real elapsedTime, OGRE_ANIMATION_STATE state)
{
Ogre::Entity * ent = getEntity();
Ogre::AnimationState * animTop = 0;
Ogre::AnimationState * animBase = 0;
if(animTimer > 0) {
if(lastTop != 0)
lastTop->addTime(elapsedTime);
if(lastBase != 0)
lastBase->addTime(elapsedTime);
animTimer -= elapsedTime;
return;
}
switch(state)
{
case IDLE:
animTop = ent->getAnimationState("IdleTop");
animBase = ent->getAnimationState("IdleBase");
break;
case RUN:
animTop = ent->getAnimationState("RunTop");
animBase = ent->getAnimationState("RunBase");
break;
case DRAWSWORDS:
drawSwords(animTop, ent);
animBase = lastBase;
break;
case SLICE:
animTop = lastTop;
if(swordsOut)
slice(animTop, ent);
animBase = lastBase;
break;
}
// Disable last set of animations
if(animTop != lastTop) {
if(lastTop != 0)
lastTop->setEnabled(false);
}
if(animBase != lastBase) {
if(lastBase != 0)
lastBase->setEnabled(false);
}
// Enable next set
if(animTop) {
animTop->setEnabled(true);
animTop->setLoop(true);
animTop->addTime(elapsedTime);
}
if(animBase) {
animBase->setEnabled(true);
animBase->setLoop(true);
animBase->addTime(elapsedTime);
}
// Book keeping
lastTop = animTop;
lastBase = animBase;
}