Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: moved likely to compiler.h in defs
also reset all the UNLIKELY_IF functions to how they should look.

the old approach is still valid, but depricated.

@patrick: i hope this is ok for you, for it is LINUX-standard.
and i think windows is also able to handle likely/unlikely because it is a compiler issue not a system issue

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