Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10569 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.7 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
[9869]22ObjectListDefinition(Animation);
[3853]23/**
[4836]24 *  creates a new Animation
[4597]25
[3853]26   This also adds the Animation automatically to the AnimationPlayer's list
27*/
[4746]28Animation::Animation()
[4597]29{
[9869]30  this->registerObject(this, Animation::_objectList);
[4597]31
[3784]32  // initialize a beginning KeyFrame, that will be deleted afterwards
[3876]33  this->keyFrameCount = 0;
[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{
[5777]52  AnimationPlayer::getInstance()->removeAnimation(this);
[3784]53}
54
[4597]55
[3853]56/**
[4836]57 *  Sets the infinitymode
58 * @param postInfinity How the Animation should advance after the last Keyframe
[3853]59*/
[3847]60void Animation::setInfinity(ANIM_INFINITY postInfinity)
[3784]61{
62  this->postInfinity = postInfinity;
63}
[3797]64
[3853]65/**
[4836]66 *  handles the Animation if it gets out of boundraries eg. if animation is finished.
[3858]67*/
[4746]68void Animation::handleInfinity()
[3858]69{
70  switch (this->postInfinity)
71    {
72    case ANIM_INF_CONSTANT:
73      this->localTime = 0.0;
74      this->bRunning = false;
75      break;
76    case ANIM_INF_REPLAY:
[3982]77      this->rewind();
78      this->bRunning = true;
[3858]79      break;
[3863]80    case ANIM_INF_REWIND:
81      this->stop();
82      break;
[3858]83    case ANIM_INF_DELETE: // this will possibly never be made
[3860]84      this->bDelete = true;
[3858]85      break;
86    }
87}
88
89/**
[4836]90 *  plays the animation back from the current Time forward
[3853]91*/
[3847]92void Animation::play()
[3797]93{
[3982]94  this->keyFramesToPlay = -1;
[3797]95  this->bRunning = true;
96}
[3833]97
[3853]98/**
[4836]99 *  plays the Next n keyframes
100 * @param n the Count of keyFrames to play.
[3982]101*/
102void Animation::playNextKeyframes(int n)
103{
104  this->keyFramesToPlay = n-1;
105  this->bRunning = true;
106}
107
108/**
[4836]109 *  Stops the animation. eg. pause(); rewind();
[3853]110*/
[3847]111void Animation::stop()
[3797]112{
[3982]113  this->keyFramesToPlay = -1;
[3797]114  this->rewind();
[3798]115  this->bRunning = true;
116  this->tick(0.0);
[3797]117  this->bRunning = false;
118}
[3853]119
120/**
[4836]121 *  Pauses the animation. Stays at the current Time
[3853]122*/
[3847]123void Animation::pause()
[3797]124{
125  this->bRunning = false;
126}
[3853]127
128/**
[4836]129 *  replays the animation, eg. rewind();play();
[3853]130*/
[3847]131void Animation::replay()
[3797]132{
133  this->rewind();
[3982]134  this->play();
[3797]135}
Note: See TracBrowser for help on using the repository browser.