/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #include "animation.h" #include "debug.h" #include "animation_player.h" /** \brief creates a new Animation This also adds the Animation automatically to the AnimationPlayer's list */ Animation::Animation(void) { // initialize a beginning KeyFrame, that will be deleted afterwards this->bHasKeys = false; this->bHandled = true; this->bDelete = false; this->baseObject = NULL; // setting default values this->localTime = 0.0; this->bRunning = true; AnimationPlayer::getInstance()->addAnimation(this); } /** \brief destructs the Animation this also takes the animation out of the AnimationPlayer's list (if it is there) */ Animation::~Animation(void) { this->doNotHandle(); } /** \brief tells the AnimationPlayer, that we do not wish to handle this animation automatically. This means that it will not be ticked, and not be deleted with the AnimationPlayer */ void Animation::doNotHandle(void) { if (this->bHandled) AnimationPlayer::getInstance()->removeAnimation(this); } /** \brief Sets the infinitymode \param postInfinity How the Animation should advance after the last Keyframe */ void Animation::setInfinity(ANIM_INFINITY postInfinity) { this->postInfinity = postInfinity; } /** \brief handles the Animation if it gets out of boundraries eg. if animation is finished. */ void Animation::handleInfinity(void) { switch (this->postInfinity) { case ANIM_INF_CONSTANT: this->localTime = 0.0; this->bRunning = false; break; case ANIM_INF_REPLAY: this->replay(); break; case ANIM_INF_DELETE: // this will possibly never be made this->bDelete = true; break; } } /** \brief plays the animation back from the current Time forward */ void Animation::play() { this->bRunning = true; } /** \brief Stops the animation. eg. pause(); rewind(); */ void Animation::stop() { this->rewind(); this->bRunning = true; this->tick(0.0); this->bRunning = false; } /** \brief Pauses the animation. Stays at the current Time */ void Animation::pause() { this->bRunning = false; } /** \brief replays the animation, eg. rewind();play(); */ void Animation::replay() { this->rewind(); this->bRunning = true; }