/* 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: ... */ /*! \file animation.h A Set of functions to animate some floats inside of an Object */ #ifndef _ANIMATION_H #define _ANIMATION_H // FORWARD DEFINITION template class tList; enum ANIM_FUNCTION {ANIM_LINEAR, ANIM_SINE }; enum ANIM_INFINITY {ANIM_INF_CONSTANT, ANIM_INF_LINEAR, ANIM_INF_PINGPONG, ANIM_INF_REWIND};//, ANIM_DELETE} class Anim { protected: Anim(); static tList* animatorList; virtual void tick(float time) = 0; }; //! A Class to handle some animation for single floated values. template class Animation : public Anim { public: Animation(); virtual ~Animation(); void setFuncToAnim(T* object, void (T::*funcToAnim)(float)); void setAnimFunc(ANIM_FUNCTION animFunc); void setValue(float value); virtual void tick(float time); private: void (T::*funcToAnim)(float); ANIM_FUNCTION animFunc; float value; T* object; }; /** \brief standard constructor */ template Animation::Animation () { this->value = 0.0; } /** \brief standard deconstructor */ template Animation::~Animation () { // delete what has to be deleted here } template void Animation::setFuncToAnim(T* object, void (T::*funcToAnim)(float)) { this->object = object; this->funcToAnim = funcToAnim; } template void Animation::setValue(float value) { this->value = value; (object->*(funcToAnim))(value); } template void Animation::tick(float time) { setValue(value - time/1000); if (value < 0) setValue (1.0); } #endif /* _ANIMATION_H */