Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/textEngine: some simple animation-template-class implemented, to animate floats
This class will in the Future be able to animate everything one needs to animate

File size: 1.7 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#include "base_object.h"
26
27enum ANIM_FUNCTION {ANIM_LINEAR };
28
29//! A Class to handle some animation for single floated values.
30template<class T> class Animation : public BaseObject
31{
32 public:
33  Animation();
34  virtual ~Animation();
35
36  void setFuncToAnim(T* object, void (T::*animFunc)(float));
37  void setAnimFunc();
38  void setValue(float value);
39
40  void tick(float time);
41
42 private:
43  void (T::*animFunc)(float);
44 
45  float value;
46  T* object;
47};
48
49
50
51/**
52   \brief standard constructor
53
54*/
55template<class T>
56Animation<T>::Animation () 
57{
58   this->setClassName ("Animation");
59   this->value = 0.0;
60}
61
62
63/**
64   \brief standard deconstructor
65
66*/
67template<class T>
68Animation<T>::~Animation () 
69{
70  // delete what has to be deleted here
71}
72
73
74template<class T>
75void Animation<T>::setFuncToAnim(T* object, void (T::*animFunc)(float))
76{
77  this->object = object;
78  this->animFunc = animFunc;
79}
80
81template<class T>
82void Animation<T>::setValue(float value)
83{
84  this->value = value;
85  (object->*(animFunc))(value);
86}
87
88template<class T>
89void Animation<T>::tick(float time)
90{
91  setValue(value+time/1000);
92  if (value >1)
93    setValue (0);
94}
95
96#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.