Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/animation.cc @ 3859

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

orxonox/trunk: moved the infinity-handling into animation.cc

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