Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/util/animation/animation.cc @ 10611

Last change on this file since 10611 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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