Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: bRunning is false as default

File size: 3.0 KB
RevLine 
[3782]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
[3863]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
[3782]17
18#include "animation.h"
19#include "debug.h"
[3812]20#include "animation_player.h"
[3782]21
[3853]22/**
23   \brief creates a new Animation
24   
25   This also adds the Animation automatically to the AnimationPlayer's list
26*/
[3847]27Animation::Animation(void)
[3795]28{ 
[3784]29  // initialize a beginning KeyFrame, that will be deleted afterwards
[3876]30  this->keyFrameCount = 0;
[3820]31  this->bHandled = true;
[3860]32  this->bDelete = false;
[3833]33  this->baseObject = NULL;
[3784]34
[3785]35  // setting default values
[3982]36  this->keyFramesToPlay = -1;
[3786]37  this->localTime = 0.0;
[3988]38  this->bRunning = false;
[3812]39
40  AnimationPlayer::getInstance()->addAnimation(this);
[3782]41}
42
[3853]43/**
44   \brief destructs the Animation
45   
46   this also takes the animation out of the AnimationPlayer's list (if it is there)
47*/
[3847]48Animation::~Animation(void)
[3784]49{
[3820]50  this->doNotHandle();
[3784]51}
52
[3853]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*/
[3847]59void Animation::doNotHandle(void)
[3820]60{
61  if (this->bHandled)
62    AnimationPlayer::getInstance()->removeAnimation(this);
63}
64
[3853]65/**
66   \brief Sets the infinitymode
67   \param postInfinity How the Animation should advance after the last Keyframe
68*/
[3847]69void Animation::setInfinity(ANIM_INFINITY postInfinity)
[3784]70{
71  this->postInfinity = postInfinity;
72}
[3797]73
[3853]74/**
[3858]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:
[3982]86      this->rewind();
87      this->bRunning = true;
[3858]88      break;
[3863]89    case ANIM_INF_REWIND:
90      this->stop();
91      break;
[3858]92    case ANIM_INF_DELETE: // this will possibly never be made
[3860]93      this->bDelete = true;
[3858]94      break;
95    }
96}
97
98/**
[3853]99   \brief plays the animation back from the current Time forward
100*/
[3847]101void Animation::play()
[3797]102{
[3982]103  this->keyFramesToPlay = -1;
[3797]104  this->bRunning = true;
105}
[3833]106
[3853]107/**
[3982]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/**
[3853]118   \brief Stops the animation. eg. pause(); rewind();
119*/
[3847]120void Animation::stop()
[3797]121{
[3982]122  this->keyFramesToPlay = -1;
[3797]123  this->rewind();
[3798]124  this->bRunning = true;
125  this->tick(0.0);
[3797]126  this->bRunning = false;
127}
[3853]128
129/**
130   \brief Pauses the animation. Stays at the current Time
131*/
[3847]132void Animation::pause()
[3797]133{
134  this->bRunning = false;
135}
[3853]136
137/**
138   \brief replays the animation, eg. rewind();play();
139*/
[3847]140void Animation::replay()
[3797]141{
142  this->rewind();
[3982]143  this->play();
[3797]144}
Note: See TracBrowser for help on using the repository browser.