Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/animation.cc @ 3784

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

orxonox/branches/textEngine: some better implementation for the Animation Class. it now sends around some FunctionPointers

File size: 2.1 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#include "animation.h"
18#include "debug.h"
19#include "list.h"
20
21
22Anim::Anim(void)
23{
24  // create a new List
25  this->keyFrameList = new tList<AnimKeyFrame>();
26 
27  // initialize a beginning KeyFrame, that will be deleted afterwards
28  this->bHasKeys = false;
29
30
31  this->animFunc = &Anim::random;
32}
33
34
35Anim::~Anim(void)
36{
37  // delete all the KeyFrames
38  tIterator<AnimKeyFrame>* itKF = keyFrameList->getIterator();
39  AnimKeyFrame*  enumKF = itKF->nextElement();
40  while (enumKF)
41    {
42      delete enumKF;
43      enumKF = itKF->nextElement();
44    }
45  delete itKF;
46  delete this->keyFrameList;
47}
48
49tList<Anim>* Anim::animatorList = NULL;
50
51
52void Anim::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc)
53{
54  if (!bHasKeys)
55    {
56      this->keyFrameList->remove(this->keyFrameList->firstElement());
57      bHasKeys = true;
58    }
59  AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame;
60  tmpKeyFrame->value = value;
61  tmpKeyFrame->duration = duration;
62  tmpKeyFrame->animFunc = animFunc;
63 
64  this->keyFrameList->add(tmpKeyFrame);
65}
66
67void Anim::setInfinity(ANIM_INFINITY preInfinity, ANIM_INFINITY postInfinity)
68{
69  this->preInfinity = preInfinity;
70  this->postInfinity = postInfinity;
71}
72
73void Anim::setAnimFunc(ANIM_FUNCTION animFunc)
74{
75  switch (animFunc)
76    {
77    default:
78    case ANIM_CONSTANT:
79      this->animFunc = &Anim::constant;
80      break;
81    case ANIM_LINEAR:
82      this->animFunc = &Anim::linear;
83      break;
84    case ANIM_RANDOM:
85      this->animFunc = &Anim::random;
86      break;
87    case ANIM_SINE:
88      this->animFunc = &Anim::sine;
89      break;
90
91    }
92}
93
94
95// animation functions
96float Anim::random(float time)
97{
98  return (float)rand()/(float)RAND_MAX;
99}
100
101float Anim::constant(float time)
102{
103
104}
105
106float Anim::linear(float time)
107{
108
109}
110
111float Anim::sine(float time)
112{
113
114}
Note: See TracBrowser for help on using the repository browser.