Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/animation.h @ 3783

Last change on this file since 3783 was 3783, checked in by bensch, 19 years ago

orxonox/branches/textEngine: more functionality to animation-class

File size: 1.9 KB
RevLine 
[3781]1/*
2   orxonox - the future of 3D-vertical-scrollers
[3329]3
[3781]4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
[3245]14*/
[1853]15
16
[3781]17/*!
18    \file animation.h
19    A Set of functions to animate some floats inside of an Object
20*/
21
22#ifndef _ANIMATION_H
23#define _ANIMATION_H
24
[1853]25
[3782]26// FORWARD DEFINITION
27template<class T> class tList;
28
[3783]29enum ANIM_FUNCTION {ANIM_LINEAR, ANIM_SINE };
30enum ANIM_INFINITY {ANIM_INF_CONSTANT, ANIM_INF_LINEAR, ANIM_INF_PINGPONG, ANIM_INF_REWIND};//, ANIM_DELETE}
[3543]31
[3782]32class Anim
33{
34 protected:
35  Anim();
36
37  static tList<Anim>* animatorList;
[3783]38
39  virtual void tick(float time) = 0;
[3782]40};
41
42
[3781]43//! A Class to handle some animation for single floated values.
[3782]44template<class T> class Animation : public Anim
[3781]45{
46 public:
47  Animation();
48  virtual ~Animation();
[3543]49
[3783]50  void setFuncToAnim(T* object, void (T::*funcToAnim)(float));
51  void setAnimFunc(ANIM_FUNCTION animFunc);
[3781]52  void setValue(float value);
[2036]53
[3783]54  virtual void tick(float time);
[3781]55
56 private:
[3783]57  void (T::*funcToAnim)(float);
58  ANIM_FUNCTION animFunc;
[3781]59  float value;
60  T* object;
61};
62
63
64
[3329]65/**
[3781]66   \brief standard constructor
67
[3329]68*/
[3781]69template<class T>
70Animation<T>::Animation () 
71{
72   this->value = 0.0;
73}
[1853]74
75
[3781]76/**
77   \brief standard deconstructor
[3245]78
[3781]79*/
80template<class T>
81Animation<T>::~Animation () 
82{
83  // delete what has to be deleted here
84}
[3245]85
[1853]86
[3781]87template<class T>
[3783]88void Animation<T>::setFuncToAnim(T* object, void (T::*funcToAnim)(float))
[3781]89{
90  this->object = object;
[3783]91  this->funcToAnim = funcToAnim;
[3781]92}
93
94template<class T>
95void Animation<T>::setValue(float value)
96{
97  this->value = value;
[3783]98  (object->*(funcToAnim))(value);
[3781]99}
100
101template<class T>
102void Animation<T>::tick(float time)
103{
[3783]104  setValue(value - time/1000);
105  if (value < 0)
106    setValue (1.0);
[3781]107}
108
109#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.