本文整理汇总了C++中ogre::Entity::getAnimationState方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::getAnimationState方法的具体用法?C++ Entity::getAnimationState怎么用?C++ Entity::getAnimationState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::getAnimationState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: heMuertoDelTodo
bool Pacman::heMuertoDelTodo() // :D :D
{
Ogre::Entity* pacmanEnt = static_cast<Ogre::Entity*>( node->getAttachedObject(PACMAN_NODE));
if (pacmanEnt->getAnimationState(PACMAN_DIES)->hasEnded())
{
pacmanEnt->getAnimationState(PACMAN_DIES)->setEnabled(false);
pacmanEnt->getAnimationState(PACMAN_EAT_ANIM)->setEnabled(true);
estoyMuriendo = false;
return true;
}
return false;
}
示例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: setupScene
void Sample::setupScene()
{
mSceneMgr->setSkyBox(true, "spaceSkyBox");
// Set the scene's ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
Ogre::Entity* pEntity = mSceneMgr->createEntity("SinbadInstance", "Sinbad.mesh");
Ogre::SceneNode* pNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
pNode->attachObject(pEntity);
pNode->setScale(Ogre::Vector3(3.0f));
mDance = pEntity->getAnimationState("Dance");
mDance->setEnabled(true);
mDance->setLoop(true);
mDance->setTimePosition(0);
Ogre::Light* pDirLight = mSceneMgr->createLight();
pDirLight->setDirection(Ogre::Vector3(0,-1,0));
pDirLight->setType(Ogre::Light::LT_DIRECTIONAL);
pNode->attachObject(pDirLight);
mCamera->setNearClipDistance(1.0f);
mCamera->setFarClipDistance(100000.0f);
mCamera->setPosition(0,0,30.0f);
mCamera->lookAt(0,0,0);
mCamera->setAutoAspectRatio(true);
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(1,0,0));
}
示例6: MovableEntity
Barrel::Barrel(Ogre::Vector3 position, Ogre::Quaternion orientation,
const std::string& name, Ogre::SceneNode* sceneNode,
Ogre::Real speed, Ogre::Radian turnSpeed,
Ogre::Entity& entityMesh) :
MovableEntity(position, orientation, name, sceneNode, speed, turnSpeed),
selected(false),
node(NULL) {
animation = NULL;
loadAnimation();
for(unsigned int i = 0; i < numModels; ++i) {
modelNodes.push_back(sceneNode);
animationState = entityMesh.getAnimationState("Sneak");
animationState->setEnabled(true);
animationState->setLoop(true);
animationSpeeds.push_back(Ogre::Real(1.5f));
animationStates.push_back(animationState);
}
std::string selectid = Factory::getID() + "." + name + "/selected";
Ogre::Entity* pointerMesh = Game::getScene()->createEntity(selectid, "target.mesh");
pointerMesh->setMaterialName("target");
node = sceneNode->createChildSceneNode();
node->attachObject(pointerMesh);
node->setVisible(selected);
node->setPosition(position);
}
示例7:
void *mesh_get_anim ( void *mesh, const char *name ) {
Ogre::Entity *e = static_cast<Ogre::Entity *> ( mesh );
Ogre::AnimationState *state = e->getAnimationState ( name );
//state->setEnabled(true);
//state->setLoop ( true );
return state;
}
示例8:
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);
}
示例9: 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;
}
示例10: createScene
void OgreAppLogic::createScene(void)
{
// setup some basic lighting for our scene
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
// make a cube to bounce around
Entity *ent1;
SceneNode *boxNode;
ManualObject *cmo = createCubeMesh("manual", "");
cmo->convertToMesh("cube");
ent1 = mSceneMgr->createEntity("Cube", "cube.mesh");
ent1->setCastShadows(true);
boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject(ent1);
boxNode->setScale(Vector3(0.1,0.1,0.1)); // for some reason converttomesh multiplied dimensions by 10
mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
mSceneMgr->createLight()->setPosition(20, 80, 50);
// create a floor mesh resource
MeshManager::getSingleton().createPlane("floor", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Plane(Vector3::UNIT_Y, -30), 1000, 1000, 10, 10, true, 1, 8, 8, Vector3::UNIT_Z);
// create a floor entity, give it a material, and place it at the origin
Entity* floor = mSceneMgr->createEntity("Floor", "floor");
floor->setMaterialName("Examples/BumpyMetal");
mSceneMgr->getRootSceneNode()->attachObject(floor);
mSceneMgr->getRootSceneNode()->attachObject(mSceneMgr->createEntity("Head", "ogrehead.mesh"));
mSceneMgr->setSkyBox(true, "Examples/GridSkyBox");
Ogre::Entity* ent = mSceneMgr->createEntity("Sinbad.mesh"); //1x1_cube.mesh //Sinbad.mesh //axes.mesh
mObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("cube");
mObjectNode->setOrientation(Quaternion(Degree(90.f), Vector3::UNIT_X));
Ogre::Real scale = 22;
mObjectNode->setPosition(10, 10, 10*scale);
mObjectNode->setScale(Ogre::Vector3::UNIT_SCALE*scale);
mObjectNode->attachObject(ent);
mObjectNode->setVisible(true);
// create swords and attach them to sinbad
Ogre::Entity* sword1 = mSceneMgr->createEntity("SinbadSword1", "Sword.mesh");
Ogre::Entity* sword2 = mSceneMgr->createEntity("SinbadSword2", "Sword.mesh");
ent->attachObjectToBone("Sheath.L", sword1);
ent->attachObjectToBone("Sheath.R", sword2);
mAnimState = ent->getAnimationState("Dance");
mAnimState->setLoop(true);
mAnimState->setEnabled(true);
}
示例11: 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;
}
示例12: setNode
Penguin::Penguin(Ogre::SceneManager* sceneMgr, std::string name) {
Ogre::Entity* entPenguin = sceneMgr->createEntity(name, "penguin.mesh");
mAnimationState = entPenguin->getAnimationState("amuse");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
entPenguin->setCastShadows(true);
Ogre::SceneNode* penguinNode = sceneMgr->getRootSceneNode()->createChildSceneNode(name, Ogre::Vector3(0,30,0));
penguinNode->attachObject(entPenguin);
penguinNode->scale(60 / 63.0057, 50 / 47.99059, 50 / 49.27139);
Ogre::Camera* cam = sceneMgr->getCamera("GameCam");
cameraNode = penguinNode->createChildSceneNode("CameraNode");
cameraNode->attachObject(cam);
setNode(penguinNode);
}
示例13: SceneManager
void
Player::stopAnimation(std::string anim)
{
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);
animation->setEnabled(false);
animation->setTimePosition(0);
}
}
}
示例14: createScene
void createScene()
{
// Create the Entity
Ogre::Entity* robot = mSceneMgr->createEntity("Robot", "robot.mesh");
// Attach robot to scene graph
Ogre::SceneNode* RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot");
//RobotNode->setPosition((Ogre::Real)-0.3, (Ogre::Real)0.2, (Ogre::Real)0);
RobotNode->attachObject(robot);
RobotNode->scale((Ogre::Real)0.001,(Ogre::Real)0.001,(Ogre::Real)0.001);
RobotNode->pitch(Ogre::Degree(180));
RobotNode->yaw(Ogre::Degree(-90));
// The animation
// Set the good animation
mAnimationState = robot->getAnimationState( "Idle" );
// Start over when finished
mAnimationState->setLoop( true );
// Animation enabled
mAnimationState->setEnabled( 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;
}