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
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
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: ...
14*/
15
16
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
25
26// FORWARD DEFINITION
27template<class T> class tList;
28
29enum ANIM_FUNCTION {ANIM_LINEAR, ANIM_SINE };
30enum ANIM_INFINITY {ANIM_INF_CONSTANT, ANIM_INF_LINEAR, ANIM_INF_PINGPONG, ANIM_INF_REWIND};//, ANIM_DELETE}
31
32class Anim
33{
34 protected:
35  Anim();
36
37  static tList<Anim>* animatorList;
38
39  virtual void tick(float time) = 0;
40};
41
42
43//! A Class to handle some animation for single floated values.
44template<class T> class Animation : public Anim
45{
46 public:
47  Animation();
48  virtual ~Animation();
49
50  void setFuncToAnim(T* object, void (T::*funcToAnim)(float));
51  void setAnimFunc(ANIM_FUNCTION animFunc);
52  void setValue(float value);
53
54  virtual void tick(float time);
55
56 private:
57  void (T::*funcToAnim)(float);
58  ANIM_FUNCTION animFunc;
59  float value;
60  T* object;
61};
62
63
64
65/**
66   \brief standard constructor
67
68*/
69template<class T>
70Animation<T>::Animation () 
71{
72   this->value = 0.0;
73}
74
75
76/**
77   \brief standard deconstructor
78
79*/
80template<class T>
81Animation<T>::~Animation () 
82{
83  // delete what has to be deleted here
84}
85
86
87template<class T>
88void Animation<T>::setFuncToAnim(T* object, void (T::*funcToAnim)(float))
89{
90  this->object = object;
91  this->funcToAnim = funcToAnim;
92}
93
94template<class T>
95void Animation<T>::setValue(float value)
96{
97  this->value = value;
98  (object->*(funcToAnim))(value);
99}
100
101template<class T>
102void Animation<T>::tick(float time)
103{
104  setValue(value - time/1000);
105  if (value < 0)
106    setValue (1.0);
107}
108
109#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.