Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10618 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Apr 4, 2007, 12:13:53 PM (18 years ago)
Author:
bknecht
Message:

merged cleanup into trunk (only improvements)

Location:
trunk
Files:
6 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1616OrxonoxPlayability.kdevses
        1717OrxonoxPlayability.kdevelop.pcs
         18orxonox.backtrace
         19orxonox.kdevses
         20orxonox.kdevelop.pcs
  • trunk/src/util/Makefile.am

    r10368 r10618  
    2626                        animation/animation_player.cc \
    2727                        \
    28                         track/pilot_node.cc \
    29                         track/track.cc \
    30                         track/track_manager.cc \
    31                         track/track_node.cc
     28                        track/track.cc
    3229
    3330noinst_HEADERS =        \
     
    5249                        animation/t_animation.h \
    5350                        \
    54                         track/pilot_node.h \
    55                         track/track.h \
    56                         track/track_manager.h \
    57                         track/track_node.h
    58 
     51                        track/track.h
  • trunk/src/util/animation/animation.h

    r9869 r10618  
    1010#include "debug.h"
    1111
    12 #include "list.h"
     12#include <list>
    1313// FORWARD DECLARATION
    1414
  • trunk/src/util/animation/animation3d.cc

    r9406 r10618  
    3535
    3636  // create a new List
    37   this->keyFrameList = new tList<KeyFrame3D>();
    38   KeyFrame3D* tmpKeyFrame = new KeyFrame3D;
    39   tmpKeyFrame->position = Vector();
    40   tmpKeyFrame->direction = Quaternion();
    41   keyFrameList->add(tmpKeyFrame);
    42 
    43   this->currentKeyFrame = tmpKeyFrame;
    44   this->nextKeyFrame = tmpKeyFrame;
     37  KeyFrame3D tmpKeyFrame;
     38  keyFrameList.push_back(tmpKeyFrame);
     39
     40  this->currentKeyFrame = keyFrameList.begin();
     41  this->nextKeyFrame = keyFrameList.begin();
    4542
    4643  this->animFuncMov = NULL;//&Animation3D::mLinear;
    4744  this->animFuncRot = NULL;//&Animation3D::rLinear;
    48 
    4945}
    5046
     
    5652Animation3D::~Animation3D()
    5753{
    58   // delete all the KeyFrames
    59   tIterator<KeyFrame3D>* itKF = keyFrameList->getIterator();
    60   KeyFrame3D*  enumKF = itKF->firstElement();
    61   while (enumKF)
    62     {
    63       delete enumKF;
    64       enumKF = itKF->nextElement();
    65     }
    66   delete itKF;
    67   delete this->keyFrameList;
    6854}
    6955
     
    7359void Animation3D::rewind()
    7460{
    75   this->currentKeyFrame = keyFrameList->firstElement();
    76   this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement());
     61  this->currentKeyFrame = keyFrameList.begin();
     62  this->nextKeyFrame = keyFrameList.begin()++;
    7763  this->localTime = 0.0;
    78   this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
    79   this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
     64  this->setAnimFuncMov((*this->currentKeyFrame).animFuncMov);
     65  this->setAnimFuncRot((*this->currentKeyFrame).animFuncRot);
    8066}
    8167
     
    10086//    animFuncRot = animFuncMov;
    10187
    102   KeyFrame3D* tmpKeyFrame;
     88  KeyFrame3D& tmpKeyFrame = keyFrameList.front();
    10389
    10490  // when adding the first frame
    10591  if (this->keyFrameCount == 0)
    10692    {
    107       tmpKeyFrame = this->keyFrameList->firstElement();
    10893      //this->setAnimFuncMov(animFuncMov);
    10994      //this->setAnimFuncRot(animFuncRot);
     
    11196  else
    11297    {
    113       tmpKeyFrame = new KeyFrame3D;
    11498      // when adding the second frame
     99      this->keyFrameList.push_back(KeyFrame3D());
    115100      if (this->currentKeyFrame == this->nextKeyFrame)
    116         this->nextKeyFrame = tmpKeyFrame;
    117       this->keyFrameList->add(tmpKeyFrame);
     101        this->nextKeyFrame = --keyFrameList.end();
    118102    }
    119103
    120   tmpKeyFrame->position = position;
     104  tmpKeyFrame.position = position;
    121105  //tmpKeyFrame->lastPosition = position;
    122   tmpKeyFrame->direction = direction;
    123   tmpKeyFrame->duration = duration;
    124   tmpKeyFrame->animFuncMov = animFuncMov;
    125   tmpKeyFrame->animFuncRot = animFuncRot;
     106  tmpKeyFrame.direction = direction;
     107  tmpKeyFrame.duration = duration;
     108  tmpKeyFrame.animFuncMov = animFuncMov;
     109  tmpKeyFrame.animFuncRot = animFuncRot;
    126110  this->keyFrameCount++;
    127111}
     
    146130              this->currentKeyFrame = this->nextKeyFrame;
    147131              // checking, if we should still Play the animation
    148               if (this->currentKeyFrame == this->keyFrameList->lastElement())
     132              if (this->currentKeyFrame == --this->keyFrameList.end())
    149133                this->handleInfinity();
    150               this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     134              this->nextKeyFrame = this->currentKeyFrame;
     135              this->nextKeyFrame++;
    151136              this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
    152137              this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
  • trunk/src/util/animation/animation3d.h

    r6616 r10618  
    1616   This represents one point with direction of the animation
    1717*/
    18 typedef struct KeyFrame3D {
     18typedef struct KeyFrame3D
     19{
    1920  float             duration;              //!< The duration of this KeyFrame
    2021  Vector            position;              //!< The position of this KeyFrame
     
    3132class Animation3D : public Animation
    3233{
    33  public:
     34public:
    3435  Animation3D(PNode* object);
    3536  virtual ~Animation3D();
     
    4445  virtual void tick(float dt);
    4546
    46  private:
     47private:
    4748  // animation functions
    4849  void setAnimFuncMov(ANIM_FUNCTION animFunc);
     
    6970
    7071
    71  private:
    72   KeyFrame3D*          currentKeyFrame;               //!< The current KeyFrame
    73   KeyFrame3D*          nextKeyFrame;                  //!< The KeyFrame we iterate to
    74   tList<KeyFrame3D>*   keyFrameList;                  //!< The KeyFrameList
     72private:
     73  typedef std::list<KeyFrame3D>  KeyFrameList;        //!< A Type definition for th KeyFrame List
     74  typedef KeyFrameList::iterator KeyFrameIterator;        //!< A Type definition for th KeyFrame List
     75
     76  KeyFrameIterator     currentKeyFrame;               //!< The current KeyFrame
     77  KeyFrameIterator     nextKeyFrame;                  //!< The KeyFrame we iterate to
     78  KeyFrameList         keyFrameList;                  //!< The KeyFrameList
    7579
    7680
  • trunk/src/util/animation/t_animation.h

    r8315 r10618  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3 
     3 
    44   Copyright (C) 2004 orx
    5 
     5 
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10 
     10 
    1111   ### File Specific:
    1212   main-programmer: Benjamin Grauer
     
    3737template<class T> class tAnimation : public Animation
    3838{
    39  public:
     39public:
    4040  tAnimation(T* object = NULL, void (T::*funcToAnim)(float) = NULL);
    41   virtual ~tAnimation();
    4241
    4342  void setFuncToAnim(T* object, void (T::*funcToAnim)(float));
     
    4847  virtual void tick(float dt);
    4948
    50  private:
     49private:
    5150  // animation functions
    5251  void setAnimFunc(ANIM_FUNCTION animFunc);
     
    6160
    6261
     62private:
     63  typedef std::list<KeyFrameF> KeyFrameList;
     64  typedef typename KeyFrameList::iterator KeyFrameIterator;
     65
    6366  //  ANIM_FUNCTION animFunc
    6467  float (tAnimation<T>::*animFunc)(float) const;  //!< A Function for the AnimationType
    6568
    66   KeyFrameF* currentKeyFrame;                     //!< The current KeyFrame
    67   KeyFrameF* nextKeyFrame;                        //!< The KeyFrame we iterate to
    68   tList<KeyFrameF>* keyFrameList;                 //!< The KeyFrameList
     69  KeyFrameIterator  currentKeyFrame;                     //!< The current KeyFrame
     70  KeyFrameIterator  nextKeyFrame;                        //!< The KeyFrame we iterate to
     71  KeyFrameList      keyFrameList;                 //!< The KeyFrameList
    6972
    7073  T* object;                                      //!< The Object from which to Animate something
     
    8386{
    8487  // create a new List
    85   this->keyFrameList = new tList<KeyFrameF>();
    86   KeyFrameF* tmpKeyFrame = new KeyFrameF;
    87   tmpKeyFrame->value = 0.0;
    88   tmpKeyFrame->duration = 1.0;
    89   keyFrameList->add(tmpKeyFrame);
    90 
    91   this->currentKeyFrame = tmpKeyFrame;
    92   this->nextKeyFrame = tmpKeyFrame;
     88  KeyFrameF tmpKeyFrame;
     89  tmpKeyFrame.value = 0.0;
     90  tmpKeyFrame.duration = 1.0;
     91  keyFrameList.push_back(tmpKeyFrame);
     92
     93  this->currentKeyFrame = keyFrameList.begin();
     94  this->nextKeyFrame = keyFrameList.begin();
    9395
    9496  this->animFunc = &tAnimation<T>::linear;
     
    99101
    100102/**
    101  *  standard deconstructor
    102 
    103    deletes all the Keyframes
    104 */
    105 template<class T>
    106 tAnimation<T>::~tAnimation ()
    107 {
    108   // delete all the KeyFrames
    109   tIterator<KeyFrameF>* itKF = keyFrameList->getIterator();
    110   KeyFrameF*  enumKF = itKF->firstElement();
    111   while (enumKF)
    112     {
    113       delete enumKF;
    114       enumKF = itKF->nextElement();
    115     }
    116   delete itKF;
    117   delete this->keyFrameList;
    118 }
    119 
    120 /**
    121103 *  rewinds the Animation to the beginning (first KeyFrame and time == 0)
    122104*/
     
    124106void tAnimation<T>::rewind()
    125107{
    126   this->currentKeyFrame = keyFrameList->firstElement();
    127   this->nextKeyFrame = keyFrameList->nextElement(keyFrameList->firstElement());
     108  this->currentKeyFrame = keyFrameList.begin();
     109  this->nextKeyFrame = ++keyFrameList.begin();
    128110  this->localTime = 0.0;
    129   this->setAnimFunc(this->currentKeyFrame->animFunc);
     111  this->setAnimFunc((*this->currentKeyFrame).animFunc);
    130112}
    131113
     
    157139    animFunc = ANIM_DEFAULT_FUNCTION;
    158140
    159   KeyFrameF* tmpKeyFrame;
     141  KeyFrameF& tmpKeyFrame = keyFrameList.front();
    160142
    161143  // when adding the first frame
    162144  if (this->keyFrameCount == 0)
    163     {
    164       tmpKeyFrame = this->keyFrameList->firstElement();
    165       this->setAnimFunc(animFunc);
    166     }
     145  {
     146    this->setAnimFunc(animFunc);
     147  }
    167148  else
    168     {
    169       tmpKeyFrame = new KeyFrameF;
    170       // when adding the second frame
    171       if (this->currentKeyFrame == this->nextKeyFrame)
    172         this->nextKeyFrame = tmpKeyFrame;
    173       this->keyFrameList->add(tmpKeyFrame);
    174     }
    175 
    176   tmpKeyFrame->value = value;
    177   tmpKeyFrame->duration = duration;
    178   tmpKeyFrame->animFunc = animFunc;
     149  {
     150    this->keyFrameList.push_back(KeyFrameF());
     151    tmpKeyFrame = keyFrameList.back();
     152    // when adding the second frame
     153    if (this->currentKeyFrame == this->nextKeyFrame)
     154      this->nextKeyFrame = --keyFrameList.end();
     155  }
     156
     157  tmpKeyFrame.value = value;
     158  tmpKeyFrame.duration = duration;
     159  tmpKeyFrame.animFunc = animFunc;
    179160  this->keyFrameCount++;
    180161}
     
    188169{
    189170  if (this->bRunning)
     171  {
     172    this->localTime += dt;
     173    if (localTime >= this->currentKeyFrame->duration)
    190174    {
    191       this->localTime += dt;
    192       if (localTime >= this->currentKeyFrame->duration)
    193         {
    194           if (likely(this->keyFramesToPlay != 0))
    195             {
    196               if (unlikely(this->keyFramesToPlay > 0))
    197                 --this->keyFramesToPlay;
    198               // switching to the next Key-Frame
    199               this->localTime -= this->currentKeyFrame->duration;
    200 
    201               this->currentKeyFrame = this->nextKeyFrame;
    202               // checking, if we should still Play the animation
    203               if (this->currentKeyFrame == this->keyFrameList->lastElement())
    204                 this->handleInfinity();
    205               this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
    206 
    207               //printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
    208               this->setAnimFunc(this->currentKeyFrame->animFunc);
    209             }
    210           else
    211             this->pause();
    212         }
    213 
    214       (this->object->*(funcToAnim))((this->*animFunc)(this->localTime));
     175      if (likely(this->keyFramesToPlay != 0))
     176      {
     177        if (unlikely(this->keyFramesToPlay > 0))
     178          --this->keyFramesToPlay;
     179        // switching to the next Key-Frame
     180        this->localTime -= this->currentKeyFrame->duration;
     181
     182        this->currentKeyFrame = this->nextKeyFrame;
     183        // checking, if we should still Play the animation
     184        if (this->currentKeyFrame == --this->keyFrameList.end())
     185          this->handleInfinity();
     186        this->nextKeyFrame = this->currentKeyFrame;
     187        this->nextKeyFrame++;
     188
     189        //printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
     190        this->setAnimFunc(this->currentKeyFrame->animFunc);
     191      }
     192      else
     193        this->pause();
    215194    }
     195
     196    (this->object->*(funcToAnim))((this->*animFunc)(this->localTime));
     197  }
    216198}
    217199
     
    224206{
    225207  switch (animFunc)
    226     {
    227     default:
    228     case ANIM_CONSTANT:
    229       this->animFunc = &tAnimation<T>::constant;
    230       break;
    231     case ANIM_LINEAR:
    232       this->animFunc = &tAnimation<T>::linear;
    233       break;
    234     case ANIM_SINE:
    235       this->animFunc = &tAnimation<T>::sine;
    236       break;
    237     case ANIM_COSINE:
    238       this->animFunc = &tAnimation<T>::cosine;
    239       break;
    240     case ANIM_EXP:
    241       this->animFunc = &tAnimation<T>::exp;
    242       break;
    243     case ANIM_NEG_EXP:
    244         this->animFunc = &tAnimation<T>::negExp;
    245         expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
    246         break;
    247     case ANIM_QUADRATIC:
    248       this->animFunc = &tAnimation<T>::quadratic;
    249       break;
    250     case ANIM_RANDOM:
    251       this->animFunc = &tAnimation<T>::random;
    252       break;
    253     }
     208  {
     209  default:
     210  case ANIM_CONSTANT:
     211    this->animFunc = &tAnimation<T>::constant;
     212    break;
     213  case ANIM_LINEAR:
     214    this->animFunc = &tAnimation<T>::linear;
     215    break;
     216  case ANIM_SINE:
     217    this->animFunc = &tAnimation<T>::sine;
     218    break;
     219  case ANIM_COSINE:
     220    this->animFunc = &tAnimation<T>::cosine;
     221    break;
     222  case ANIM_EXP:
     223    this->animFunc = &tAnimation<T>::exp;
     224    break;
     225  case ANIM_NEG_EXP:
     226    this->animFunc = &tAnimation<T>::negExp;
     227    expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
     228    break;
     229  case ANIM_QUADRATIC:
     230    this->animFunc = &tAnimation<T>::quadratic;
     231    break;
     232  case ANIM_RANDOM:
     233    this->animFunc = &tAnimation<T>::random;
     234    break;
     235  }
    254236}
    255237
     
    274256{
    275257  return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
    276     * (timePassed / this->currentKeyFrame->duration);
     258         * (timePassed / this->currentKeyFrame->duration);
    277259}
    278260
     
    286268  if (timePassed * 2.0 < this->currentKeyFrame->duration)
    287269    return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
    288       * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2;
     270           * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2;
    289271  else
    290272    return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    291       * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2;
     273           * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2;
    292274  /*
    293275  printf("::%f::::%f::\n",timePassed/this->currentKeyFrame->duration,retVal);
     
    304286{
    305287  return ((this->nextKeyFrame->value + this->currentKeyFrame->value) +
    306     (this->currentKeyFrame->value - this->nextKeyFrame->value) *
    307     cos( M_PI * timePassed / this->currentKeyFrame->duration))/2;
     288          (this->currentKeyFrame->value - this->nextKeyFrame->value) *
     289          cos( M_PI * timePassed / this->currentKeyFrame->duration))/2;
    308290}
    309291
     
    348330{
    349331  return this->currentKeyFrame->value +
    350     (this->nextKeyFrame->value - this->currentKeyFrame->value) *
    351     (float)rand()/(float)RAND_MAX;
     332         (this->nextKeyFrame->value - this->currentKeyFrame->value) *
     333         (float)rand()/(float)RAND_MAX;
    352334}
    353335
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r10114 r10618  
    3131
    3232#include "shared_network_data.h"
    33 #include "terrain.h"
     33#include "environments/terrain.h"
    3434#include "space_ships/space_ship.h"
    3535
     
    4444#include "shell_command.h"
    4545
    46 #include "spawning_point.h"
     46#include "tools/spawning_point.h"
    4747
    4848#include "creatures/fps_player.h"
  • trunk/src/util/state.cc

    r10379 r10618  
    1919
    2020
    21 #include "camera.h"
    22 #include "cameraman.h"
     21#include "tools/camera.h"
     22#include "tools/cameraman.h"
    2323
    2424#ifndef NULL
  • trunk/src/util/track/track.cc

    r10512 r10618  
    2525#include "util/loading/load_param.h"
    2626#include "track/track.h"
    27 
     27#include "glincl.h"
    2828#include "p_node.h"
    29 
    30 #include "stdincl.h"
    3129
    3230#include "debug.h"
Note: See TracChangeset for help on using the changeset viewer.