Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: renamed all the \param → @param and so on in Doxygen tags.
Thanks a lot to the kDevelop team. this took since the last commit :)

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/**
[4836]23 *  creates a new Animation
[4597]24
[3853]25   This also adds the Animation automatically to the AnimationPlayer's list
26*/
[4746]27Animation::Animation()
[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/**
[4836]46 *  destructs the Animation
[4597]47
[3853]48   this also takes the animation out of the AnimationPlayer's list (if it is there)
49*/
[4746]50Animation::~Animation()
[3784]51{
[3820]52  this->doNotHandle();
[3784]53}
54
[3853]55/**
[4836]56 *  tells the AnimationPlayer, that we do not wish to  handle this animation
[3853]57   automatically.
[4597]58
[3853]59   This means that it will not be ticked, and not be deleted with the AnimationPlayer
60*/
[4746]61void Animation::doNotHandle()
[3820]62{
63  if (this->bHandled)
64    AnimationPlayer::getInstance()->removeAnimation(this);
65}
66
[3853]67/**
[4836]68 *  Sets the infinitymode
69 * @param postInfinity How the Animation should advance after the last Keyframe
[3853]70*/
[3847]71void Animation::setInfinity(ANIM_INFINITY postInfinity)
[3784]72{
73  this->postInfinity = postInfinity;
74}
[3797]75
[3853]76/**
[4836]77 *  handles the Animation if it gets out of boundraries eg. if animation is finished.
[3858]78*/
[4746]79void Animation::handleInfinity()
[3858]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/**
[4836]101 *  plays the animation back from the current Time forward
[3853]102*/
[3847]103void Animation::play()
[3797]104{
[3982]105  this->keyFramesToPlay = -1;
[3797]106  this->bRunning = true;
107}
[3833]108
[3853]109/**
[4836]110 *  plays the Next n keyframes
111 * @param n the Count of keyFrames to play.
[3982]112*/
113void Animation::playNextKeyframes(int n)
114{
115  this->keyFramesToPlay = n-1;
116  this->bRunning = true;
117}
118
119/**
[4836]120 *  Stops the animation. eg. pause(); rewind();
[3853]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/**
[4836]132 *  Pauses the animation. Stays at the current Time
[3853]133*/
[3847]134void Animation::pause()
[3797]135{
136  this->bRunning = false;
137}
[3853]138
139/**
[4836]140 *  replays the animation, eg. rewind();play();
[3853]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.