本文整理汇总了C++中ogre::AnimationState::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationState::setEnabled方法的具体用法?C++ AnimationState::setEnabled怎么用?C++ AnimationState::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AnimationState
的用法示例。
在下文中一共展示了AnimationState::setEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupBody
void CharacterController::setupBody(SceneManager* sceneMgr) {
// create main model
mBodyNode = sceneMgr->getRootSceneNode()->createChildSceneNode(Vector3::UNIT_Y * CHAR_HEIGHT);
mBodyEnt = sceneMgr->createEntity("SinbadBody", "Sinbad.mesh");
mBodyEnt->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
mBodyNode->attachObject(mBodyEnt);
mMove = true;
// scale to fit
mBodyNode->scale(CHAR_SCALE_X, CHAR_SCALE_Y, CHAR_SCALE_Z);
mKeyDirection = Vector3::ZERO;
mVerticalVelocity = 0;
// Get the two halves of the idle animation
Ogre::AnimationState* baseAnim = mBodyEnt->getAnimationState("IdleBase");
Ogre::AnimationState* topAnim = mBodyEnt->getAnimationState("IdleTop");
// Enable both of them and set them to loop.
baseAnim->setLoop(true);
topAnim->setLoop(true);
baseAnim->setEnabled(true);
topAnim->setEnabled(true);
mBodyNode->setVisible(false, true);
}
示例2: createScene
//-------------------------------------------------------------------------------------
void DeltaControl::createScene(void) {
mSceneMgr->setSkyBox(true, "StormySkyBox");
mControlCenter = new ControlCenter(mSceneMgr);
/* *********************************************************
* ENTITIES
* *********************************************************/
// Telephone* phone = new Telephone(mSceneMgr, "phone1");
// phone->init();
// Create entity from mesh and attach it to a scene node.
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Entity* ent = mSceneMgr->createEntity("Sinbad", "Sinbad.mesh");
node->attachObject(ent);
node->setPosition(0,50,0);
node->scale(10,10,10);
// Set animation blend mode to additive / cumulative.
ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
// Get the two halves of the idle animation
Ogre::AnimationState* baseAnim = ent->getAnimationState("IdleBase");
Ogre::AnimationState* topAnim = ent->getAnimationState("IdleTop");
// Enable both of them and set them to loop.
baseAnim->setLoop(true);
topAnim->setLoop(true);
baseAnim->setEnabled(true);
topAnim->setEnabled(true);
}
示例3: 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;
}
示例4: id
void
PlayersManager::createPlayer(zappy::Player *player)
{
Ogre::Entity *ent;
Ogre::SceneNode *node;
Ogre::AnimationState *anim;
std::string id(NumberToString<unsigned int>(player->getId()));
OPlayer *toAdd;
ent = this->mSceneMgr->createEntity("Player" + id, "robot.mesh");
node = this->mSceneMgr->getRootSceneNode()->
createChildSceneNode(PLAYERNODENAME + id,
Ogre::Vector3(player->getX() * Constants::SquareSize,
0,
player->getY() * Constants::SquareSize));
ent->setQueryFlags(Constants::PLAYER_MASK);
anim = ent->getAnimationState("Idle");
anim->setLoop(true);
anim->setEnabled(true);
node->attachObject(ent);
player->setRendered(true);
toAdd = new OPlayer(ent, node);
toAdd->setSpell(this->mSceneMgr->createParticleSystem("Aureola" + id, "Examples/Aureola"));
toAdd->setBroad(this->mSceneMgr->createParticleSystem("Purple" + id, "Examples/PurpleFountain"));
this->mOPlayers.push_back(toAdd);
}
示例5: setAnimationMask
void GfxBody::setAnimationMask (const std::string &name, float v)
{
if (dead) THROW_DEAD(className);
Ogre::AnimationState *state = getAnimState(name);
state->setWeight(v);
state->setEnabled(v > 0.0f);
}
示例6: 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);
}
}
}
}
}
}
}
示例7: insertBoundedPart
NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int group, const std::string &bonename)
{
NifOgre::EntityList entities = NifOgre::Loader::createEntities(mEntityList.mSkelBase, bonename,
mInsert, mesh);
std::vector<Ogre::Entity*> &parts = entities.mEntities;
for(size_t i = 0;i < parts.size();i++)
{
parts[i]->getUserObjectBindings().setUserAny(Ogre::Any(group));
if (mVisibilityFlags != 0)
parts[i]->setVisibilityFlags(mVisibilityFlags);
for(unsigned int j=0; j < parts[i]->getNumSubEntities(); ++j)
{
Ogre::SubEntity* subEnt = parts[i]->getSubEntity(j);
subEnt->setRenderQueueGroup(subEnt->getMaterial()->isTransparent() ? RQG_Alpha : RQG_Main);
}
}
if(entities.mSkelBase)
{
Ogre::AnimationStateSet *aset = entities.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator asiter = aset->getAnimationStateIterator();
while(asiter.hasMoreElements())
{
Ogre::AnimationState *state = asiter.getNext();
state->setEnabled(false);
state->setLoop(false);
}
Ogre::SkeletonInstance *skelinst = entities.mSkelBase->getSkeleton();
Ogre::Skeleton::BoneIterator boneiter = skelinst->getBoneIterator();
while(boneiter.hasMoreElements())
boneiter.getNext()->setManuallyControlled(true);
}
return entities;
}
示例8: position
//-------------------------------------------------------------------------------------
bool
PlayersManager::hidle(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("Idle");
Ogre::SceneNode *node = OPlayer->getSceneNode();
anim->setEnabled(true);
if (position != node->getPosition())
node->setPosition(position);
anim->setLoop(true);
anim->setEnabled(true);
anim->addTime(this->tslf);
return true;
}
示例9:
ProfessorController(Root* root)
{
mProfessorNode = root->getSceneManager("main")->getSceneNode("Professor");
mProfessorEntity = root->getSceneManager("main")->getEntity("Professor");
mWalkSpeed = 80.0f;
mDirection = Vector3::ZERO;
mAnimationState = mProfessorEntity->getAnimationState("Walk");
mAnimationState->setEnabled(true);
mAnimationState->setLoop(true);
}
示例10: stopAnimation
bool CAnimatedEntity::stopAnimation(const std::string &anim)
{
if(!_entity->getAllAnimationStates()->hasAnimationState(anim))
return false;
Ogre::AnimationState *animation = _entity->getAnimationState(anim);
animation->setEnabled(false);
// Si la animación a parar es la animación activa ya no lo estará.
if(animation == _currentAnimation)
_currentAnimation = 0;
return true;
} // stopAnimation
示例11: setAnimation
bool CAnimatedEntity::setAnimation(const std::string &anim, bool loop, int rewind, float fadeTime)
{
if(!_entity->getAllAnimationStates()->hasAnimationState(anim))
return false;
//comprobamos si la animación ya estaba ejecutandose
auto runningAnim = _runningAnimations.find(anim);
if(runningAnim != _runningAnimations.end()) {
if(runningAnim->second.state == FADE_OUT) {
runningAnim->second.state = FADE_IN;
//comprobamos que la animación no estaba justo para
//ser sacada
if(!_deletedAnims.empty()) {
auto delAnim = _deletedAnims.begin();
auto delEnd = _deletedAnims.end();
for(; delAnim!=delEnd; delAnim++) {
if ((*delAnim) == runningAnim->second.animation->getAnimationName()) {
_deletedAnims.erase(delAnim);
runningAnim->second.animation->setEnabled(true);
break;
}
}
}
}
runningAnim->second.direction = rewind;
return true;
}
//cogemos la animacion y la preparamos para ejecutarla
Ogre::AnimationState* animstate = _entity->getAnimationState(anim);
animstate->setEnabled(true);
animstate->setLoop(loop);
animstate->setWeight(0);
//seteamos la animación nueva para que haga fade-in, teniendo
//en cuenta el tiempo de fade que se le ha pasado
Animation animation;
animation.animation = animstate;
animation.state = FADE_IN;
animation.fadeTime = fadeTime;
animation.direction = rewind;
//metemos la animacion en la lista de animaciones ejecutandose
TAnim newAnim (anim,animation);
_runningAnimations.insert(newAnim);
return true;
} // setAnimation
示例12: createCamera
void AssetLoader::createCamera(Ogre::SceneManager* sceneMgr, const aiScene* scene, Ogre::String camName)
{
for (size_t n = 0; n < scene->mNumCameras; n++)
{
// カメラを作成
Ogre::Camera* cam = sceneMgr->createCamera(scene->mCameras[n]->mName.data);
std::cout << "Create Camra " << cam->getName() << " " << scene->mCameras[n]->mHorizontalFOV << std::endl;
cam->setFOVy(Ogre::Radian(scene->mCameras[n]->mHorizontalFOV));
// 視点アニメーション用ノード
Ogre::SceneNode* camNode = sceneMgr->getRootSceneNode()->createChildSceneNode(cam->getName()+"CamNode");
camNode->attachObject(cam);
// アニメーションを走査
for (size_t na = 0; na < scene->mNumAnimations; na++) {
aiAnimation* aiani = scene->mAnimations[na];
for (size_t nc = 0; nc < aiani->mNumChannels; nc++) {
// カメラと同じ名前のチャネルを取得する
if (Ogre::String(scene->mCameras[n]->mName.data) == cam->getName()) {
//アニメーションを付けるトラックを作成しておく
Ogre::Animation* ogani = sceneMgr->createAnimation(cam->getName()+"Animation", aiani->mDuration);
std::cout << "Animation : " << ogani->getName() << std::endl;
Ogre::NodeAnimationTrack* track = ogani->createNodeTrack(0, camNode);
ogani->setInterpolationMode(Ogre::Animation::IM_LINEAR);
// アニメーションチャネルからキーフレームアニメーションを取得
aiNodeAnim* chan = aiani->mChannels[n];
for (size_t np = 0; np < chan->mNumPositionKeys; np++) {
aiVectorKey* vk = &(chan->mPositionKeys[np]);
Ogre::TransformKeyFrame* key = track->createNodeKeyFrame(vk->mTime);
key->setTranslate(Ogre::Vector3(vk->mValue[0], vk->mValue[1], vk->mValue[2]));
aiQuatKey* qk = &(chan->mRotationKeys[np]);
key->setRotation(Ogre::Quaternion(qk->mValue.w, qk->mValue.x, qk->mValue.y, qk->mValue.z));
}
// 管理するアニメーションの名前を付けておく
Ogre::AnimationState* aniState = sceneMgr->createAnimationState(ogani->getName());
aniState->setEnabled(true);
aniState->setLoop(true);
aniState->setTimePosition(0.0);
//ループを抜ける
na = scene->mNumAnimations;
break;
}
}
}
}
}
示例13: 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;
}
示例14: Animation
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
{
mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
std::string mesh = "meshes\\" + ref->mBase->mModel;
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
for(size_t i = 0; i < mEntityList.mEntities.size(); i++)
{
Ogre::Entity *ent = mEntityList.mEntities[i];
ent->setVisibilityFlags(RV_Actors);
bool transparent = false;
for (unsigned int j=0; j < ent->getNumSubEntities() && !transparent; ++j)
{
Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent)
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements() && !transparent)
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setEnabled(true);
state->setLoop(false);
}
}
}
}
示例15: frameStarted
bool frameStarted(const FrameEvent &evt)
{
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;
}