本文整理汇总了C++中ogre::AnimationState::setTimePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationState::setTimePosition方法的具体用法?C++ AnimationState::setTimePosition怎么用?C++ AnimationState::setTimePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::AnimationState
的用法示例。
在下文中一共展示了AnimationState::setTimePosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnableAnimation
bool EC_OgreAnimationController::EnableAnimation(const std::string& name, bool looped, Real fadein, bool high_priority)
{
Ogre::Entity* entity = GetEntity();
Ogre::AnimationState* animstate = GetAnimationState(entity, name);
if (!animstate)
return false;
animstate->setLoop(looped);
// See if we already have this animation
AnimationMap::iterator i = animations_.find(name);
if (i != animations_.end())
{
i->second.phase_ = PHASE_FADEIN;
i->second.num_repeats_ = (looped ? 0: 1);
i->second.fade_period_ = fadein;
i->second.high_priority_ = high_priority;
return true;
}
// Start new animation from zero weight & speed factor 1, also reset time position
animstate->setTimePosition(0.0f);
Animation newanim;
newanim.phase_ = PHASE_FADEIN;
newanim.num_repeats_ = (looped ? 0: 1); // if looped, repeat 0 times (loop indefinetly) otherwise repeat one time.
newanim.fade_period_ = fadein;
newanim.high_priority_ = high_priority;
animations_[name] = newanim;
return true;
}
示例2: 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;
}
}
}
}
}
示例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: 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);
}
}
}
示例5: SetAnimationTimePosition
bool EC_OgreAnimationController::SetAnimationTimePosition(const std::string& name, Real newPosition)
{
Ogre::Entity* entity = GetEntity();
Ogre::AnimationState* animstate = GetAnimationState(entity, name);
if (!animstate)
return false;
// See if we find this animation in the list of active animations
AnimationMap::iterator i = animations_.find(name);
if (i != animations_.end())
{
animstate->setTimePosition(newPosition);
return true;
}
// Animation not active
return false;
}
示例6: 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());
//.........这里部分代码省略.........
示例7: receiveAnimationTaskMessage
void AnimationTask::receiveAnimationTaskMessage(const Poco::AutoPtr<AnimationTaskMessage>& message)
{
AnimationMapEntry entry;
AnimationMapIterator iter;
AnimationMapValueEntry valueEntry;
Ogre::AnimationState *animation;
memUInt animationAddress;
FunctorBase *pFunctor;
if (message.get() == NULL)
{
LOG(EngineLog::LM_WARNING, "AnimationTask::receiveAnimationTaskMessage(): message is NULL.");
return;
}
Poco::ScopedRWLock lock(mRWLockActiveAnimations, true);
animation = message->getAnimation();
animationAddress = reinterpret_cast<memUInt>(animation);
if (animation != NULL)
{
iter = activeAnimations.find(animationAddress);
}
switch (message->getMessageType())
{
case AnimationTaskMessage::AM_ENABLE:
// If the playCounter flag is true, increment the playCounter if the animation is active, other just start
// playing the animation if the counter is one.
if ((message->isPlayCounter()) && (iter != activeAnimations.end()))
{
valueEntry = iter->second;
valueEntry.second++;
}
else
{
// Set the loop, restart and enabled values for the animation
animation->setLoop(message->isLoop());
if (message->isRestart())
{
animation->setTimePosition(0.0f);
}
animation->setEnabled(true);
valueEntry.first = animation;
valueEntry.second = 1;
}
// Add this animations start and stop callbacks to the callback maps
pFunctor = message->getStartCallback();
if (pFunctor != NULL)
{
Poco::ScopedRWLock lock(mRWLockCallbacks, true);
mStartCallbacks[animationAddress] = pFunctor;
}
pFunctor = message->getStopCallback();
if (pFunctor != NULL)
{
Poco::ScopedRWLock lock(mRWLockCallbacks, true);
mStopCallbacks[animationAddress] = pFunctor;
}
// Add it to the list of active animations
activeAnimations[animationAddress] = valueEntry;
// Add it to the set of starting animations
mStartingAnimations.insert(animationAddress);
break;
case AnimationTaskMessage::AM_DISABLE:
if (iter != activeAnimations.end())
{
// If the playCounter flag is true, decrement the playCounter if the animation is active, otherwise just stop
// playing the animation if the counter <= 0.
if (message->isPlayCounter())
{
valueEntry = iter->second;
valueEntry.second--;
if (valueEntry.second == 0)
{
// Mark animation as disabled and remove it from the list
// of active animations
animation->setEnabled(false);
activeAnimations.erase(animationAddress);
// Remove any callbacks associated with this animation
{
Poco::ScopedRWLock lock(mRWLockCallbacks, true);
mStartCallbacks.erase(animationAddress);
mStopCallbacks.erase(animationAddress);
}
}
else
{
activeAnimations[animationAddress] = valueEntry;
}
}
else
{
// Mark animation as disabled and remove it from the list
//.........这里部分代码省略.........
示例8: Update
void EC_OgreAnimationController::Update(f64 frametime)
{
Ogre::Entity* entity = GetEntity();
if (!entity) return;
std::vector<std::string> erase_list;
// Loop through all animations & update them as necessary
for (AnimationMap::iterator i = animations_.begin(); i != animations_.end(); ++i)
{
Ogre::AnimationState* animstate = GetAnimationState(entity, i->first);
if (!animstate)
continue;
switch(i->second.phase_)
{
case PHASE_FADEIN:
// If period is infinitely fast, skip to full weight & PLAY status
if (i->second.fade_period_ == 0.0f)
{
i->second.weight_ = 1.0f;
i->second.phase_ = PHASE_PLAY;
}
else
{
i->second.weight_ += (1.0f / i->second.fade_period_) * frametime;
if (i->second.weight_ >= 1.0f)
{
i->second.weight_ = 1.0f;
i->second.phase_ = PHASE_PLAY;
}
}
break;
case PHASE_PLAY:
if (i->second.auto_stop_ || i->second.num_repeats_ != 1)
{
if ((i->second.speed_factor_ >= 0.f && animstate->getTimePosition() >= animstate->getLength()) ||
(i->second.speed_factor_ < 0.f && animstate->getTimePosition() <= 0.f))
{
if (i->second.num_repeats_ != 1)
{
if (i->second.num_repeats_ > 1)
i->second.num_repeats_--;
Ogre::Real rewindpos = i->second.speed_factor_ >= 0.f ? (animstate->getTimePosition() - animstate->getLength()) : animstate->getLength();
animstate->setTimePosition(rewindpos);
}
else
{
i->second.phase_ = PHASE_FADEOUT;
}
}
}
break;
case PHASE_FADEOUT:
// If period is infinitely fast, skip to disabled status immediately
if (i->second.fade_period_ == 0.0f)
{
i->second.weight_ = 0.0f;
i->second.phase_ = PHASE_STOP;
}
else
{
i->second.weight_ -= (1.0f / i->second.fade_period_) * frametime;
if (i->second.weight_ <= 0.0f)
{
i->second.weight_ = 0.0f;
i->second.phase_ = PHASE_STOP;
}
}
break;
}
// Set weight & step the animation forward
if (i->second.phase_ != PHASE_STOP)
{
Ogre::Real advance = i->second.speed_factor_ * frametime;
Ogre::Real new_weight = i->second.weight_ * i->second.weight_factor_;
if (new_weight != animstate->getWeight())
animstate->setWeight((Ogre::Real)i->second.weight_ * i->second.weight_factor_);
if (advance != 0.0f)
animstate->addTime((Ogre::Real)(i->second.speed_factor_ * frametime));
if (!animstate->getEnabled())
animstate->setEnabled(true);
}
else
{
// If stopped, disable & remove this animation from list
animstate->setEnabled(false);
erase_list.push_back(i->first);
}
}
for (uint i = 0; i < erase_list.size(); ++i)
{
animations_.erase(erase_list[i]);
}
//.........这里部分代码省略.........
示例9: vt
bool
PlayState::frameStarted
(const Ogre::FrameEvent& evt)
{
std::cout << "frameStarted PLAY" << std::endl;
Ogre::Vector3 vt(0,0,0); Ogre::Real tSpeed = 20.0;
_deltaT = evt.timeSinceLastFrame;
_world->stepSimulation(_deltaT); // Actualizar simulacion Bullet
_timeLastObject -= _deltaT;
_camera->moveRelative(vt * _deltaT * tSpeed);
if (_camera->getPosition().length() < 10.0) {
_camera->moveRelative(-vt * _deltaT * tSpeed);
}
_camera->yaw(Degree(CAM_ROTATION_SPEED * _deltaT * _mouseRotation.x)); //, Node::TS_PARENT
_camera->pitch(Degree(CAM_ROTATION_SPEED * _deltaT * _mouseRotation.y)); //, Node::TS_LOCAL
_mouseRotation = Vector2::ZERO;
//CONTROLAR LA DIRECCION DE LA CAMARA DEL PROYECTIL
_projectileCamera->lookAt(_camera->getDerivedDirection());
if(_trackedBody){
_projectileCamera->setPosition(_trackedBody->getCenterOfMassPosition());
Ogre::Vector3 trackedBodyPosition = _trackedBody->getCenterOfMassPosition();
Ogre::Vector3 projectileLookAt(trackedBodyPosition.x - _camera->getPosition().x, trackedBodyPosition.y - _camera->getPosition().y, trackedBodyPosition.z - _camera->getPosition().z);
//_projectileCamera->lookAt(_camera->getDerivedDirection());
_projectileCamera->lookAt(trackedBodyPosition + projectileLookAt);
}
std::cout << "CAMERAS" << std::endl;
if(_shootKeyDown){
_keyDownTime = _keyDownTime + _deltaT;
}
if(_keyDownTime * THROW_FORCE > 100){
_forcePercent = 100;
}
else{
_forcePercent = _keyDownTime * THROW_FORCE;
}
//_points++;
_sPF->updatePower(_forcePercent);
_sPF->updatePoints(_points);
//std::cout<<_sPF->getSheet()->getChild("PowerWindow")->getUpdateMode() <<std::endl;
//_sPF->getSheet()->getChild("PowerWindow")->update(_deltaT);
//CEGUI::System::getSingleton().injectTimePulse(_deltaT);
//DetectCollisionPig();
std::cout << "points power" << std::endl;
_physicsController->detectCollision(); //Este es el bueno. Hay que cambiarlo para que compruebe colisiones sobre todo
std::cout << "pisis" << std::endl;
_movementController->moveAll();
std::cout << "collision moveall" << std::endl;
if(_finalGame){
pushState(FinalState::getSingletonPtr());
}
lifeWolf();
std::cout << "wolf" << std::endl;
if (_lanzaranimationPig){
for (int i = 0; i < 3; ++i){
std::ostringstream os;
os << "pigA" <<i;
Ogre::AnimationState* animStatePig = _sceneMgr->getEntity(os.str())-> getAnimationState("SaltoR");
animStatePig->setTimePosition(0.0);
animStatePig->setEnabled(true);
animStatePig->setLoop(true);
_vector_anims_pig -> push_back(animStatePig);
}
_lanzaranimationPig = false;
}
for (int i = 0; i < 3; ++i){
Ogre::AnimationState* animStatePig = _vector_anims_pig->at(i);
if (animStatePig != NULL){
if (animStatePig->hasEnded()){
animStatePig->setTimePosition(0.0);
animStatePig->setEnabled(false);
}else{
animStatePig->addTime(_deltaT);
}
}
}
std::cout << "animation" << std::endl;
//RecorreVectorTAOAnadirMovimientoConstante();
//std::cout << "Hasta aqui todo bien 1" << std::endl;
return true;
}