Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/util/animation/animation.cc @ 4152

Last change on this file since 4152 was 3988, checked in by bensch, 20 years ago

orxonox/trunk: bRunning is false as default

File size: 3.0 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#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
17
18#include "animation.h"
19#include "debug.h"
20#include "animation_player.h"
21
22/**
23   \brief creates a new Animation
24   
25   This also adds the Animation automatically to the AnimationPlayer's list
26*/
27Animation::Animation(void)
28{ 
29  // initialize a beginning KeyFrame, that will be deleted afterwards
30  this->keyFrameCount = 0;
31  this->bHandled = true;
32  this->bDelete = false;
33  this->baseObject = NULL;
34
35  // setting default values
36  this->keyFramesToPlay = -1;
37  this->localTime = 0.0;
38  this->bRunning = false;
39
40  AnimationPlayer::getInstance()->addAnimation(this);
41}
42
43/**
44   \brief destructs the Animation
45   
46   this also takes the animation out of the AnimationPlayer's list (if it is there)
47*/
48Animation::~Animation(void)
49{
50  this->doNotHandle();
51}
52
53/**
54   \brief tells the AnimationPlayer, that we do not wish to  handle this animation
55   automatically.
56   
57   This means that it will not be ticked, and not be deleted with the AnimationPlayer
58*/
59void Animation::doNotHandle(void)
60{
61  if (this->bHandled)
62    AnimationPlayer::getInstance()->removeAnimation(this);
63}
64
65/**
66   \brief Sets the infinitymode
67   \param postInfinity How the Animation should advance after the last Keyframe
68*/
69void Animation::setInfinity(ANIM_INFINITY postInfinity)
70{
71  this->postInfinity = postInfinity;
72}
73
74/**
75   \brief handles the Animation if it gets out of boundraries eg. if animation is finished.
76*/
77void Animation::handleInfinity(void)
78{
79  switch (this->postInfinity)
80    {
81    case ANIM_INF_CONSTANT:
82      this->localTime = 0.0;
83      this->bRunning = false;
84      break;
85    case ANIM_INF_REPLAY:
86      this->rewind();
87      this->bRunning = true;
88      break;
89    case ANIM_INF_REWIND:
90      this->stop();
91      break;
92    case ANIM_INF_DELETE: // this will possibly never be made
93      this->bDelete = true;
94      break;
95    }
96}
97
98/**
99   \brief plays the animation back from the current Time forward
100*/
101void Animation::play()
102{
103  this->keyFramesToPlay = -1;
104  this->bRunning = true;
105}
106
107/**
108   \brief plays the Next n keyframes
109   \param n the Count of keyFrames to play.
110*/
111void Animation::playNextKeyframes(int n)
112{
113  this->keyFramesToPlay = n-1;
114  this->bRunning = true;
115}
116
117/**
118   \brief Stops the animation. eg. pause(); rewind();
119*/
120void Animation::stop()
121{
122  this->keyFramesToPlay = -1;
123  this->rewind();
124  this->bRunning = true;
125  this->tick(0.0);
126  this->bRunning = false;
127}
128
129/**
130   \brief Pauses the animation. Stays at the current Time
131*/
132void Animation::pause()
133{
134  this->bRunning = false;
135}
136
137/**
138   \brief replays the animation, eg. rewind();play();
139*/
140void Animation::replay()
141{
142  this->rewind();
143  this->play();
144}
Note: See TracBrowser for help on using the repository browser.