Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/avi_play/src/util/animation/animation.cc @ 6782

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

orxonox/trunk: stl::list in AnimationPlayer

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