Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: setClassID implemented in all files

File size: 3.0 KB
RevLine 
[4597]1/*
[3782]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
[4597]24
[3853]25   This also adds the Animation automatically to the AnimationPlayer's list
26*/
[3847]27Animation::Animation(void)
[4597]28{
29  this->setClassID(CL_ANIMATION, "Animation");
30
[3784]31  // initialize a beginning KeyFrame, that will be deleted afterwards
[3876]32  this->keyFrameCount = 0;
[3820]33  this->bHandled = true;
[3860]34  this->bDelete = false;
[3833]35  this->baseObject = NULL;
[3784]36
[3785]37  // setting default values
[3982]38  this->keyFramesToPlay = -1;
[3786]39  this->localTime = 0.0;
[3988]40  this->bRunning = false;
[3812]41
42  AnimationPlayer::getInstance()->addAnimation(this);
[3782]43}
44
[3853]45/**
46   \brief destructs the Animation
[4597]47
[3853]48   this also takes the animation out of the AnimationPlayer's list (if it is there)
49*/
[3847]50Animation::~Animation(void)
[3784]51{
[3820]52  this->doNotHandle();
[3784]53}
54
[3853]55/**
56   \brief tells the AnimationPlayer, that we do not wish to  handle this animation
57   automatically.
[4597]58
[3853]59   This means that it will not be ticked, and not be deleted with the AnimationPlayer
60*/
[3847]61void Animation::doNotHandle(void)
[3820]62{
63  if (this->bHandled)
64    AnimationPlayer::getInstance()->removeAnimation(this);
65}
66
[3853]67/**
68   \brief Sets the infinitymode
69   \param postInfinity How the Animation should advance after the last Keyframe
70*/
[3847]71void Animation::setInfinity(ANIM_INFINITY postInfinity)
[3784]72{
73  this->postInfinity = postInfinity;
74}
[3797]75
[3853]76/**
[3858]77   \brief handles the Animation if it gets out of boundraries eg. if animation is finished.
78*/
79void Animation::handleInfinity(void)
80{
81  switch (this->postInfinity)
82    {
83    case ANIM_INF_CONSTANT:
84      this->localTime = 0.0;
85      this->bRunning = false;
86      break;
87    case ANIM_INF_REPLAY:
[3982]88      this->rewind();
89      this->bRunning = true;
[3858]90      break;
[3863]91    case ANIM_INF_REWIND:
92      this->stop();
93      break;
[3858]94    case ANIM_INF_DELETE: // this will possibly never be made
[3860]95      this->bDelete = true;
[3858]96      break;
97    }
98}
99
100/**
[3853]101   \brief plays the animation back from the current Time forward
102*/
[3847]103void Animation::play()
[3797]104{
[3982]105  this->keyFramesToPlay = -1;
[3797]106  this->bRunning = true;
107}
[3833]108
[3853]109/**
[3982]110   \brief plays the Next n keyframes
111   \param n the Count of keyFrames to play.
112*/
113void Animation::playNextKeyframes(int n)
114{
115  this->keyFramesToPlay = n-1;
116  this->bRunning = true;
117}
118
119/**
[3853]120   \brief Stops the animation. eg. pause(); rewind();
121*/
[3847]122void Animation::stop()
[3797]123{
[3982]124  this->keyFramesToPlay = -1;
[3797]125  this->rewind();
[3798]126  this->bRunning = true;
127  this->tick(0.0);
[3797]128  this->bRunning = false;
129}
[3853]130
131/**
132   \brief Pauses the animation. Stays at the current Time
133*/
[3847]134void Animation::pause()
[3797]135{
136  this->bRunning = false;
137}
[3853]138
139/**
140   \brief replays the animation, eg. rewind();play();
141*/
[3847]142void Animation::replay()
[3797]143{
144  this->rewind();
[3982]145  this->play();
[3797]146}
Note: See TracBrowser for help on using the repository browser.