Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

Location:
orxonox/trunk/src/util
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/animation/animation.cc

    r3988 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2222/**
    2323   \brief creates a new Animation
    24    
     24
    2525   This also adds the Animation automatically to the AnimationPlayer's list
    2626*/
    2727Animation::Animation(void)
    28 
     28{
     29  this->setClassID(CL_ANIMATION, "Animation");
     30
    2931  // initialize a beginning KeyFrame, that will be deleted afterwards
    3032  this->keyFrameCount = 0;
     
    4345/**
    4446   \brief destructs the Animation
    45    
     47
    4648   this also takes the animation out of the AnimationPlayer's list (if it is there)
    4749*/
     
    5456   \brief tells the AnimationPlayer, that we do not wish to  handle this animation
    5557   automatically.
    56    
     58
    5759   This means that it will not be ticked, and not be deleted with the AnimationPlayer
    5860*/
  • orxonox/trunk/src/util/animation/animation.h

    r4485 r4597  
    1 /*! 
     1/*!
    22    \file animation.h
    33    A Subclass for all animations in orxonox
     
    3131   deprecated QUADRATIC
    3232*/
    33 typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
    34                             ANIM_LINEAR,
    35                             ANIM_SINE,
    36                             ANIM_COSINE,
    37                             ANIM_EXP,
    38                             ANIM_NEG_EXP,
    39                             ANIM_QUADRATIC,
    40                             ANIM_RANDOM,
    41                             ANIM_NULL};
     33typedef enum ANIM_FUNCTION
     34{
     35  ANIM_CONSTANT,
     36  ANIM_LINEAR,
     37  ANIM_SINE,
     38  ANIM_COSINE,
     39  ANIM_EXP,
     40  ANIM_NEG_EXP,
     41  ANIM_QUADRATIC,
     42  ANIM_RANDOM,
     43  ANIM_NULL
     44};
     45
    4246#define ANIM_DEFAULT_FUNCTION ANIM_LINEAR      //!< A default function to choose from the above set
    4347
     
    4953   ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables
    5054*/
    51 typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
    52                             ANIM_INF_REPLAY,
    53                             ANIM_INF_REWIND,
    54                             ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG;
     55typedef enum ANIM_INFINITY
     56{
     57  ANIM_INF_CONSTANT,
     58  ANIM_INF_REPLAY,
     59  ANIM_INF_REWIND,
     60  ANIM_INF_DELETE
     61}; //, ANIM_INF_LINEAR, ANIM_INF_PINGPONG};
    5562
    5663//! A Superclass for describing an animation (all animations will be derived from this one)
    5764/** implement in subclasses:
    58  * 
     65 *
    5966 * De-/Constructor
    6067 * Animation Functions
     
    6572 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
    6673*/
    67 class Animation
     74class Animation : public BaseObject
    6875{
    6976 public:
  • orxonox/trunk/src/util/animation/animation3d.cc

    r4485 r4597  
    5151/**
    5252   \brief standard deconstructor
    53    
     53
    5454   deletes all the Keyframes
    5555*/
     
    8989*/
    9090void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration,
    91                               ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot)
     91                              ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot)
    9292{
    9393  // some small check
     
    101101
    102102  KeyFrame3D* tmpKeyFrame;
    103    
     103
    104104  // when adding the first frame
    105105  if (this->keyFrameCount == 0)
     
    114114      // when adding the second frame
    115115      if (this->currentKeyFrame == this->nextKeyFrame)
    116         this->nextKeyFrame = tmpKeyFrame;
     116        this->nextKeyFrame = tmpKeyFrame;
    117117      this->keyFrameList->add(tmpKeyFrame);
    118118    }
     
    136136{
    137137  if (this->bRunning)
    138     { 
     138    {
    139139      this->localTime += dt;
    140140      if (localTime >= this->currentKeyFrame->duration)
    141         {
    142           if (likely(this->keyFramesToPlay != 0))
    143             {
    144               if (unlikely(this->keyFramesToPlay > 0))
    145                 --this->keyFramesToPlay;
    146               // switching to the next Key-Frame
    147               this->localTime -= this->currentKeyFrame->duration;
    148               this->currentKeyFrame = this->nextKeyFrame;
    149               // checking, if we should still Play the animation
    150               if (this->currentKeyFrame == this->keyFrameList->lastElement())
    151                 this->handleInfinity();
    152               this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
    153               this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
    154               this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
    155             }
    156           else
    157             this->pause();
    158         }     
     141        {
     142          if (likely(this->keyFramesToPlay != 0))
     143            {
     144              if (unlikely(this->keyFramesToPlay > 0))
     145                --this->keyFramesToPlay;
     146              // switching to the next Key-Frame
     147              this->localTime -= this->currentKeyFrame->duration;
     148              this->currentKeyFrame = this->nextKeyFrame;
     149              // checking, if we should still Play the animation
     150              if (this->currentKeyFrame == this->keyFrameList->lastElement())
     151                this->handleInfinity();
     152              this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     153              this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
     154              this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
     155            }
     156          else
     157            this->pause();
     158        }
    159159      /* now animate it */
    160160      (this->*animFuncMov)(this->localTime);
     
    257257  else
    258258    v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (2.0 + sin( M_PI * (- timePassed /this->currentKeyFrame->duration)) )/ 2.0;
    259  
     259
    260260  this->object->shiftCoor(v - this->currentKeyFrame->lastPosition);
    261261  this->currentKeyFrame->lastPosition = v;
     
    279279  /*
    280280  this->object->setRelCoor( this->nextKeyFrame->position -
    281                             (this->nextKeyFrame->position - this->currentKeyFrame->position) *
    282                             (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0);
     281                            (this->nextKeyFrame->position - this->currentKeyFrame->position) *
     282                            (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0);
    283283  */
    284284}
     
    309309  /*
    310310  this->object->setRelCoor( this->currentKeyFrame->position +
    311                             (this->nextKeyFrame->position - this->currentKeyFrame->position) *
    312                             (1.0 - expf(- timePassed * expFactorMov)) );
     311                            (this->nextKeyFrame->position - this->currentKeyFrame->position) *
     312                            (1.0 - expf(- timePassed * expFactorMov)) );
    313313  */
    314314}
     
    334334{
    335335  /*
    336   this->object->setRelCoor(this->currentKeyFrame->position + 
    337                            (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX);
     336  this->object->setRelCoor(this->currentKeyFrame->position +
     337                           (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX);
    338338  this->object->setRelDir(this->currentKeyFrame->direction +
    339                           (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX);
     339                          (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX);
    340340  */
    341341}
     
    401401void Animation3D::rLinear(float timePassed) const
    402402{
    403   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    404                                      this->currentKeyFrame->direction,
    405                                      timePassed/this->currentKeyFrame->duration) );
     403  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     404                                     this->currentKeyFrame->direction,
     405                                     timePassed/this->currentKeyFrame->duration) );
    406406}
    407407
     
    420420    scale = 1.0 - sin( M_PI * timePassed / this->currentKeyFrame->duration);
    421421
    422   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    423                                      this->currentKeyFrame->direction,
    424                                      scale) );
     422  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     423                                     this->currentKeyFrame->direction,
     424                                     scale) );
    425425}
    426426
     
    435435{
    436436  float scale = cos(M_PI * timePassed / this->currentKeyFrame->duration);
    437   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    438                                      this->currentKeyFrame->direction,
    439                                      scale) );
     437  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     438                                     this->currentKeyFrame->direction,
     439                                     scale) );
    440440}
    441441
     
    458458{
    459459  float scale = (1.0 - expf(- timePassed * expFactorRot));
    460   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    461                                      this->currentKeyFrame->direction,
    462                                      scale) );
     460  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     461                                     this->currentKeyFrame->direction,
     462                                     scale) );
    463463}
    464464
  • orxonox/trunk/src/util/animation/animation3d.h

    r4485 r4597  
    1 /*! 
     1/*!
    22    \file animation3d.h
    33*/
     
    3333  Animation3D(PNode* object);
    3434  virtual ~Animation3D(void);
    35    
     35
    3636  virtual void rewind(void);
    3737
     
    4040
    4141  virtual void tick(float dt);
    42  
     42
    4343 private:
    4444  // animation functions
  • orxonox/trunk/src/util/animation/animation_player.cc

    r4485 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2626   \brief standard constructor
    2727*/
    28 AnimationPlayer::AnimationPlayer () 
     28AnimationPlayer::AnimationPlayer ()
    2929{
    30    this->setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer");
     30  this->setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer");
     31  this->setName("AnimationPlayer");
    3132
    32    this->animationList = new tList<Animation>();
    33    this->play();
     33  this->animationList = new tList<Animation>();
     34  this->play();
    3435}
    3536
     
    4344
    4445   !! DANGER !! when unloading the AnimationPlayer no other Function
    45    should reference any Animations, from the animationList because it 
    46    automatically deletes them. 
     46   should reference any Animations, from the animationList because it
     47   automatically deletes them.
    4748   This usually happens when unloading a World.
    4849*/
    49 AnimationPlayer::~AnimationPlayer () 
     50AnimationPlayer::~AnimationPlayer ()
    5051{
    5152  // deleting the Animation List AND all the elements of the List
     
    6162
    6263   when adding a Animation the Animation will too be deleted when
    63    the AnimationPlayer gets deleted. Consider not adding it, or 
     64   the AnimationPlayer gets deleted. Consider not adding it, or
    6465   unadding it with animation->notHandled();
    6566*/
     
    8081/**
    8182   \brief empties the list AND deletes all the Animations
    82 */ 
     83*/
    8384void AnimationPlayer::flush(void)
    8485{
     
    99100
    100101/**
    101    \brief Ticks all the animations in animationList 
     102   \brief Ticks all the animations in animationList
    102103   \param timePassed the time passed since the last tick.
    103104*/
     
    110111      Animation* anim = animIt->nextElement();
    111112      while( anim != NULL)
    112         {
    113           anim->tick(timePassed);
    114           if(unlikely(anim->ifDelete()))
    115           {
    116             this->animationList->remove(anim);
    117             delete anim;
    118           }
    119           anim = animIt->nextElement();
    120         }
     113        {
     114          anim->tick(timePassed);
     115          if(unlikely(anim->ifDelete()))
     116          {
     117            this->animationList->remove(anim);
     118            delete anim;
     119          }
     120          anim = animIt->nextElement();
     121        }
    121122      delete animIt;
    122123    }
     
    150151    {
    151152      if(anim->getBaseObject() == baseObject)
    152         {
    153           delete animIt;
    154           return anim;
    155         }
     153        {
     154          delete animIt;
     155          return anim;
     156        }
    156157      anim = animIt->nextElement();
    157158    }
  • orxonox/trunk/src/util/animation/animation_player.h

    r4485 r4597  
    1 /*! 
     1/*!
    22    \file animation_player.h
    33*/
     
    1515   <b>AnimationPlayer usage:</b> \n
    1616
    17    <b>Initialisation</b>: AnimationPlayer::getInstance() does the trick this is 
     17   <b>Initialisation</b>: AnimationPlayer::getInstance() does the trick this is
    1818   usually done when initializing a world \n
    1919   <b>Adding Animations</b>: create an Animation the following Way:
     
    2121   \li set some parameters: also see the specific classes for more info
    2222   \n
    23    if you do not want a specific Animation to be handled by the AnimationPlayer, you have to 
     23   if you do not want a specific Animation to be handled by the AnimationPlayer, you have to
    2424   unload it explicitely with animation->doNotHandle();
    2525   \n
  • orxonox/trunk/src/util/animation/t_animation.h

    r3982 r4597  
    1414*/
    1515
    16 /*! 
     16/*!
    1717    \file t_animation.h
    1818*/
     
    8080*/
    8181template<class T>
    82 tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float)) 
     82tAnimation<T>::tAnimation (T* object, void (T::*funcToAnim)(float))
    8383{
    8484  // create a new List
     
    100100/**
    101101   \brief standard deconstructor
    102    
     102
    103103   deletes all the Keyframes
    104104*/
    105105template<class T>
    106 tAnimation<T>::~tAnimation () 
     106tAnimation<T>::~tAnimation ()
    107107{
    108108  // delete all the KeyFrames
     
    158158
    159159  KeyFrameF* tmpKeyFrame;
    160    
     160
    161161  // when adding the first frame
    162162  if (this->keyFrameCount == 0)
     
    170170      // when adding the second frame
    171171      if (this->currentKeyFrame == this->nextKeyFrame)
    172         this->nextKeyFrame = tmpKeyFrame;
     172        this->nextKeyFrame = tmpKeyFrame;
    173173      this->keyFrameList->add(tmpKeyFrame);
    174174    }
     
    191191      this->localTime += dt;
    192192      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      
     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
    214214      (this->object->*(funcToAnim))((this->*animFunc)(this->localTime));
    215215    }
     
    243243    case ANIM_NEG_EXP:
    244244      {
    245         this->animFunc = &tAnimation<T>::negExp;
    246         expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
    247         break;
     245        this->animFunc = &tAnimation<T>::negExp;
     246        expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
     247        break;
    248248      }
    249249    case ANIM_QUADRATIC:
     
    273273*/
    274274template<class T>
    275 float tAnimation<T>::linear(float timePassed) const 
     275float tAnimation<T>::linear(float timePassed) const
    276276{
    277277  return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
     
    287287{
    288288  if (timePassed * 2.0 < this->currentKeyFrame->duration)
    289     return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 
     289    return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
    290290      * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2;
    291   else 
     291  else
    292292    return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    293293      * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2;
     
    350350float tAnimation<T>::random(float timePassed) const
    351351{
    352   return this->currentKeyFrame->value + 
     352  return this->currentKeyFrame->value +
    353353    (this->nextKeyFrame->value - this->currentKeyFrame->value) *
    354354    (float)rand()/(float)RAND_MAX;
  • orxonox/trunk/src/util/garbage_collector.cc

    r4592 r4597  
    3636{
    3737   this->setClassID(CL_GARBAGE_COLLECTOR, "GarbageCollector");
     38   this->setName("GarbageCollector");
     39
    3840   this->time = 0;
    3941   this->delay = 1.5f; /* clean up all 5.0 seconds */
  • orxonox/trunk/src/util/loading/factory.cc

    r4492 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2121
    2222/*  --------------------------------------------------
    23  *              Factory
     23 *              Factory
    2424 *   --------------------------------------------------
    2525 */
     
    2727/**
    2828   \brief constructor
    29    
     29
    3030   set everything to zero and define factoryName
    3131*/
    3232Factory::Factory (const char* factoryName)
    3333{
     34  this->setClassID(CL_FACTORY, "Factory");
     35  this->setName(factoryName);
     36
    3437  this->factoryName = NULL;
    3538  this->setFactoryName(factoryName);
    3639  next = NULL;
    37  
     40
    3841  initialize();
    3942}
     
    4144/**
    4245   \brief destructor
    43    
     46
    4447   clear the Q
    4548*/
  • orxonox/trunk/src/util/loading/factory.h

    r4492 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1414*/
    1515
    16 /*! 
     16/*!
    1717  \file factory.h
    1818  \brief A loadable object handler
     
    2727#include "tinyxml.h"
    2828#include "load_param.h"
     29#include "base_object.h"
    2930#include "debug.h"
    3031
    31 /** 
     32/**
    3233    Creates a factory to a Loadable Class.
    3334    this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
     35  \todo make factoryName a BaseObject-parameter. (else it would be redundant)
    3436*/
    35 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)           
     37#define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
    3638
    3739//! The Factory is a loadable object handler
    38 class Factory {
     40class Factory : public BaseObject {
    3941
    4042 public:
    4143  Factory (const char* factoryName = NULL);
    4244  ~Factory ();
    43  
     45
    4446
    4547  virtual BaseObject* fabricate(const TiXmlElement* root);
     
    5355  /** \returns the next factory */
    5456  Factory* getNext(void) const { return this->next; };
    55        
     57
    5658 protected:
    5759  char*         factoryName;          //!< the name of the factory
     
    6971  tFactory(const char* factoryName);
    7072  virtual ~tFactory();
    71  
     73
    7274  private:
    7375  BaseObject* fabricate(const TiXmlElement* root);
     
    8385  PRINTF(5)("fileName: %s loadable\n", this->factoryName);
    8486}
    85  
     87
    8688
    8789template<class T>
     
    9092
    9193template<class T>
    92 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 
    93 { 
     94BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
     95{
    9496  if(!strcmp(root->Value(), getFactoryName()))
    9597    return new T ( root);
    96   else if( getNext() != NULL) 
     98  else if( getNext() != NULL)
    9799    return getNext()->fabricate( root);
    98   else 
     100  else
    99101    return NULL;
    100102}
  • orxonox/trunk/src/util/loading/game_loader.cc

    r4511 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    3939   \brief simple constructor
    4040*/
    41 GameLoader::GameLoader ()
    42 {
     41GameLoader::GameLoader ()
     42{
     43  this->setClassID(CL_GAME_LOADER, "GameLoader");
     44  this->setName("GameLoader");
    4345  first = NULL;
    4446}
     
    110112  switch(campaignID)
    111113    {
    112       /* 
    113         Debug Level 0: Debug level used to test the base frame work.
    114         As you can see, all storyentity data is allocated before game
    115         start. the storyentity will load themselfs shortly before start
    116         through the StoryEntity::init() funtion.
     114      /*
     115        Debug Level 0: Debug level used to test the base frame work.
     116        As you can see, all storyentity data is allocated before game
     117        start. the storyentity will load themselfs shortly before start
     118        through the StoryEntity::init() funtion.
    117119      */
    118120    case DEBUG_CAMPAIGN_0:
    119121      {
    120         Campaign* debugCampaign = new Campaign();
    121 
    122         World* world0 = new World(DEBUG_WORLD_0);
    123         world0->setNextStoryID(WORLD_ID_1);
    124         debugCampaign->addEntity(world0, WORLD_ID_0);
    125 
    126         World* world1 = new World(DEBUG_WORLD_1);
    127         world1->setNextStoryID(WORLD_ID_2);
    128         debugCampaign->addEntity(world1, WORLD_ID_1);
    129 
    130         World* world2 = new World(DEBUG_WORLD_2);
    131         world2->setNextStoryID(WORLD_ID_GAMEEND);
    132         debugCampaign->addEntity(world2, WORLD_ID_2);
    133 
    134         this->currentCampaign = debugCampaign;
    135         break;
     122        Campaign* debugCampaign = new Campaign();
     123
     124        World* world0 = new World(DEBUG_WORLD_0);
     125        world0->setNextStoryID(WORLD_ID_1);
     126        debugCampaign->addEntity(world0, WORLD_ID_0);
     127
     128        World* world1 = new World(DEBUG_WORLD_1);
     129        world1->setNextStoryID(WORLD_ID_2);
     130        debugCampaign->addEntity(world1, WORLD_ID_1);
     131
     132        World* world2 = new World(DEBUG_WORLD_2);
     133        world2->setNextStoryID(WORLD_ID_GAMEEND);
     134        debugCampaign->addEntity(world2, WORLD_ID_2);
     135
     136        this->currentCampaign = debugCampaign;
     137        break;
    136138      }
    137139    }
     
    139141
    140142
    141 /** 
     143/**
    142144    \brief starts the current entity
    143     \returns error code if this action has caused a error   
     145    \returns error code if this action has caused a error
    144146*/
    145147ErrorMessage GameLoader::start()
     
    150152
    151153
    152 /** 
     154/**
    153155    \brief stops the current entity
    154156    \returns error code if this action has caused a error
     
    168170
    169171
    170 /** 
     172/**
    171173    \brief pause the current entity
    172174    \returns error code if this action has caused a error
     
    182184
    183185
    184 /** 
     186/**
    185187    \brief resumes a pause
    186188    \returns error code if this action has caused a error
     
    218220     can load everything it needs into memory then.
    219221  */
    220  
     222
    221223  if( fileName == NULL)
    222224    {
     
    224226      return NULL;
    225227    }
    226  
     228
    227229  TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);
    228230  // load the campaign document
     
    234236      return NULL;
    235237    }
    236        
     238
    237239  // check basic validity
    238240  TiXmlElement* root = XMLDoc->RootElement();
    239241  assert( root != NULL);
    240        
     242
    241243  if( strcmp( root->Value(), "Campaign"))
    242244    {
     
    246248      return NULL;
    247249    }
    248        
     250
    249251  // construct campaign
    250252  Campaign* c = new Campaign( root);
    251        
     253
    252254  // free the XML data
    253255  delete XMLDoc;
     
    258260
    259261/**
    260    \brief handle keyboard commands 
     262   \brief handle keyboard commands
    261263   \param event the event to handle
    262264*/
     
    265267  if( event.type == KeyMapper::PEV_NEXT_WORLD)
    266268    {
    267       if( likely(event.bPressed)) 
    268         {
    269           this->nextLevel();
    270         }
     269      if( likely(event.bPressed))
     270        {
     271          this->nextLevel();
     272        }
    271273    }
    272274  else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD)
    273275    {
    274276      if( likely(event.bPressed))
    275         {
    276           this->previousLevel();
    277         }
     277        {
     278          this->previousLevel();
     279        }
    278280    }
    279281  else if( event.type == KeyMapper::PEV_PAUSE)
    280282    {
    281283      if( likely(event.bPressed))
    282         {
    283           if(this->isPaused)
    284             this->resume();
    285           else
    286             this->pause();
    287         }
     284        {
     285          if(this->isPaused)
     286            this->resume();
     287          else
     288            this->pause();
     289        }
    288290    }
    289291  else if( event.type == KeyMapper::PEV_QUIT)
     
    322324void GameLoader::registerFactory( Factory* factory)
    323325{
    324         assert( factory != NULL);
    325        
    326         PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName());
    327        
    328         if( first == NULL) first = factory;
    329         else first->registerFactory( factory);
     326        assert( factory != NULL);
     327
     328        PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName());
     329
     330        if( first == NULL) first = factory;
     331        else first->registerFactory( factory);
    330332}
    331333
     
    338340{
    339341  assert( element != NULL);
    340        
     342
    341343  if( first == NULL)
    342344    {
     
    344346      return NULL;
    345347    }
    346        
     348
    347349  if( element->Value() != NULL)
    348350    {
    349351      PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value());
    350352      BaseObject* b = first->fabricate( element);
    351       if( b == NULL) 
    352         PRINTF(2)("Failed to fabricate a '%s'\n", element->Value());
    353       else 
    354         PRINTF(4)("Successfully fabricated a '%s'\n", element->Value());
     353      if( b == NULL)
     354        PRINTF(2)("Failed to fabricate a '%s'\n", element->Value());
     355      else
     356        PRINTF(4)("Successfully fabricated a '%s'\n", element->Value());
    355357      return b;
    356358    }
    357        
     359
    358360  PRINTF(2)("Fabricate failed, TiXmlElement did not contain a value\n");
    359        
     361
    360362  return NULL;
    361363}
  • orxonox/trunk/src/util/loading/load_param.cc

    r4501 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3030*/
    3131BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName,
    32                              int paramCount, bool multi, ...)
    33 {
     32                             int paramCount, bool multi, ...)
     33{
     34  this->setClassID(CL_LOAD_PARAM, "LoadParam");
    3435  this->loadString = NULL;
    3536
     
    3940    {
    4041      if (likely(!multi))
    41         this->loadString = grabParameter(root, paramName);
     42        this->loadString = grabParameter(root, paramName);
    4243      else
    43         {
    44           if (!strcmp(root->Value(), paramName))
    45             {
    46               const TiXmlNode* val = root->FirstChild();
    47               if( val->ToText())
    48                 this->loadString = val->Value();
    49             }
    50         }
     44        {
     45          if (!strcmp(root->Value(), paramName))
     46            {
     47              const TiXmlNode* val = root->FirstChild();
     48              if( val->ToText())
     49                this->loadString = val->Value();
     50            }
     51        }
    5152    }
    5253
     
    6465      va_start (types, multi);
    6566      for(int i = 0; i < paramCount; i++)
    66         {
    67           const char* tmpTypeName = va_arg (types, const char*);
    68           this->paramDesc->types[i] = new char[strlen(tmpTypeName)+1];
    69           strcpy(this->paramDesc->types[i], tmpTypeName);
    70         }
     67        {
     68          const char* tmpTypeName = va_arg (types, const char*);
     69          this->paramDesc->types[i] = new char[strlen(tmpTypeName)+1];
     70          strcpy(this->paramDesc->types[i], tmpTypeName);
     71        }
    7172      va_end(types);
    7273
     
    131132    {
    132133      if (i > 0)
    133         PRINT(3)(",");
     134        PRINT(3)(",");
    134135      PRINT(3)("%s", this->types[i]);
    135136    }
     
    194195    {
    195196      if (!strcmp(enumClassDesc->className, className))
    196         {
    197           delete iterator;
    198           return enumClassDesc;
    199         }
     197        {
     198          delete iterator;
     199          return enumClassDesc;
     200        }
    200201      enumClassDesc = iterator->nextElement();
    201202    }
     
    216217    {
    217218      if (!strcmp(enumParamDesc->paramName, paramName))
    218         {
    219           delete iterator;
    220           return enumParamDesc;
    221         }
     219        {
     220          delete iterator;
     221          return enumParamDesc;
     222        }
    222223      enumParamDesc = iterator->nextElement();
    223224    }
     
    243244      LoadParamDescription* enumParamDesc = paramIT->nextElement();
    244245      while (enumParamDesc)
    245         {
    246           enumParamDesc->print();
    247           enumParamDesc = paramIT->nextElement();
    248         }
     246        {
     247          enumParamDesc->print();
     248          enumParamDesc = paramIT->nextElement();
     249        }
    249250      delete paramIT;
    250251
     
    267268  const TiXmlElement* element;
    268269  const TiXmlNode* node;
    269        
     270
    270271  if (root == NULL)
    271272    return NULL;
    272273  assert( parameterName != NULL);
    273        
     274
    274275  element = root->FirstChildElement( parameterName);
    275276  if( element == NULL) return NULL;
    276        
     277
    277278  node = element->FirstChild();
    278279  while( node != NULL)
  • orxonox/trunk/src/util/loading/load_param.h

    r4592 r4597  
    2222#define _LOAD_PARAM_H
    2323
     24#include "base_object.h"
    2425#include "factory.h"
    2526#include "debug.h"
     
    228229
    229230//! abstract Base class for a Loadable parameter
    230 class BaseLoadParam
     231class BaseLoadParam : public BaseObject
    231232{
    232233 public:
  • orxonox/trunk/src/util/object_manager.cc

    r4592 r4597  
    2929{
    3030  this->setClassID(CL_OBJECT_MANAGER, "ObjectManager");
     31  this->setName("ObjectManager");
    3132
    3233  this->managedObjectList = new tList<BaseObject>*[CL_NUMBER];
  • orxonox/trunk/src/util/resource_manager.cc

    r4534 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    4747   \brief standard constructor
    4848*/
    49 ResourceManager::ResourceManager ()
    50 {
    51    this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager");
    52    this->dataDir = NULL;
    53    this->setDataDir("./");
    54    this->imageDirs = new tList<char>();
    55    this->resourceList = new tList<Resource>();
     49ResourceManager::ResourceManager ()
     50{
     51  this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager");
     52  this->setName("ResourceManager");
     53
     54  this->dataDir = NULL;
     55  this->setDataDir("./");
     56  this->imageDirs = new tList<char>();
     57  this->resourceList = new tList<Resource>();
    5658}
    5759
     
    6264   \brief standard destructor
    6365*/
    64 ResourceManager::~ResourceManager (void) 
     66ResourceManager::~ResourceManager (void)
    6567{
    6668  // deleting the Resources-List
     
    106108
    107109/**
    108    \brief checks for the DataDirectory, by looking if 
     110   \brief checks for the DataDirectory, by looking if
    109111   \param fileInside is inisde??
    110112*/
     
    117119      return false;
    118120    }
    119  
     121
    120122  char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
    121123  sprintf(testFile, "%s%s", this->dataDir, fileInside);
     
    141143      char* tmpDir = tmpImageDirs->nextElement();
    142144      while(tmpDir)
    143         {
    144           if (!strcmp(tmpDir, imageDir))
    145             {
    146               PRINTF(4)("Path %s already loaded\n", imageDir);
    147               delete tmpImageDirs;
    148               return true;
    149             }
    150           tmpDir = tmpImageDirs->nextElement();
    151         }
     145        {
     146          if (!strcmp(tmpDir, imageDir))
     147            {
     148              PRINTF(4)("Path %s already loaded\n", imageDir);
     149              delete tmpImageDirs;
     150              return true;
     151            }
     152          tmpDir = tmpImageDirs->nextElement();
     153        }
    152154      delete tmpImageDirs;
    153155
     
    185187  else if (!strcmp(fileName, "cube") ||
    186188           !strcmp(fileName, "sphere") ||
    187            !strcmp(fileName, "plane") ||
     189           !strcmp(fileName, "plane") ||
    188190           !strcmp(fileName, "cylinder") ||
    189191           !strcmp(fileName, "cone"))
     
    203205#endif /* NO_TEXT */
    204206#ifndef NO_TEXTURES
    205   else 
     207  else
    206208    tmpType = IMAGE;
    207209#endif /* NO_TEXTURES */
     
    221223*/
    222224void* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
    223                             void* param1, void* param2, void* param3)
     225                            void* param1, void* param2, void* param3)
    224226{
    225227  // searching if the resource was loaded before.
     
    230232      tmpResource->count++;
    231233      if(tmpResource->prio < prio)
    232         tmpResource->prio = prio;
     234        tmpResource->prio = prio;
    233235    }
    234236  else
     
    248250      // Checking for the type of resource \see ResourceType
    249251      switch(type)
    250         {
     252        {
    251253#ifndef NO_MODEL
    252         case OBJ:
    253           if (param1)
    254             tmpResource->modelSize = *(float*)param1;
    255           else
    256             tmpResource->modelSize = 1.0;
    257 
    258           if(ResourceManager::isFile(fullName))
    259             tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
    260           else
    261             {
    262               PRINTF(2)("Sorry, %s does not exist. Loading a cube-Model instead\n", fullName);
    263               tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize);
    264             }
    265           break;
    266         case PRIM:
    267           if (param1)
    268             tmpResource->modelSize = *(float*)param1;
    269           else
    270             tmpResource->modelSize = 1.0;
    271 
    272           if (!strcmp(tmpResource->name, "cube"))
    273             tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize);
    274           else if (!strcmp(tmpResource->name, "sphere"))
    275             tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize);
    276           else if (!strcmp(tmpResource->name, "plane"))
    277             tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize);
    278           else if (!strcmp(tmpResource->name, "cylinder"))
    279             tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize);
    280           else if (!strcmp(tmpResource->name, "cone"))
    281             tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize);
    282           break;
    283         case MD2:
    284           if(ResourceManager::isFile(fullName))
    285             {
    286               if (param1)
    287                 {
    288                   tmpResource->skinFileName = new char[strlen((const char*)param1)+1];
    289                   strcpy(tmpResource->skinFileName, (const char*) param1);
    290                 }
    291               else
    292                 tmpResource->skinFileName = NULL;
    293               tmpResource->pointer = new MD2Data(fullName, tmpResource->skinFileName);
    294             }
    295               break;
     254        case OBJ:
     255          if (param1)
     256            tmpResource->modelSize = *(float*)param1;
     257          else
     258            tmpResource->modelSize = 1.0;
     259
     260          if(ResourceManager::isFile(fullName))
     261            tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
     262          else
     263            {
     264              PRINTF(2)("Sorry, %s does not exist. Loading a cube-Model instead\n", fullName);
     265              tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize);
     266            }
     267          break;
     268        case PRIM:
     269          if (param1)
     270            tmpResource->modelSize = *(float*)param1;
     271          else
     272            tmpResource->modelSize = 1.0;
     273
     274          if (!strcmp(tmpResource->name, "cube"))
     275            tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize);
     276          else if (!strcmp(tmpResource->name, "sphere"))
     277            tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize);
     278          else if (!strcmp(tmpResource->name, "plane"))
     279            tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize);
     280          else if (!strcmp(tmpResource->name, "cylinder"))
     281            tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize);
     282          else if (!strcmp(tmpResource->name, "cone"))
     283            tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize);
     284          break;
     285        case MD2:
     286          if(ResourceManager::isFile(fullName))
     287            {
     288              if (param1)
     289                {
     290                  tmpResource->skinFileName = new char[strlen((const char*)param1)+1];
     291                  strcpy(tmpResource->skinFileName, (const char*) param1);
     292                }
     293              else
     294                tmpResource->skinFileName = NULL;
     295              tmpResource->pointer = new MD2Data(fullName, tmpResource->skinFileName);
     296            }
     297              break;
    296298#endif /* NO_MODEL */
    297299#ifndef NO_TEXT
    298         case TTF:
    299             if (param1)
    300               tmpResource->ttfSize = *(int*)param1;
    301             else
    302               tmpResource->ttfSize = FONT_DEFAULT_SIZE;
    303             if (param2)
    304               {
    305                 Vector* tmpVec = (Vector*)param2;
    306                 tmpResource->ttfColorR = (int)tmpVec->x;
    307                 tmpResource->ttfColorG = (int)tmpVec->y;
    308                 tmpResource->ttfColorB = (int)tmpVec->z;
    309               }
    310             else
    311               {
    312                 tmpResource->ttfColorR = FONT_DEFAULT_COLOR_R;
    313                 tmpResource->ttfColorG = FONT_DEFAULT_COLOR_G;
    314                 tmpResource->ttfColorB = FONT_DEFAULT_COLOR_B;
    315               }
    316            
    317           if(isFile(fullName))
    318             tmpResource->pointer = new Font(fullName,
    319                                             tmpResource->ttfSize,
    320                                             tmpResource->ttfColorR,
    321                                             tmpResource->ttfColorG,
    322                                             tmpResource->ttfColorB);
    323           else
    324             PRINTF(2)("Sorry, %s does not exist. Not loading Font\n", fullName);
    325           break;
     300        case TTF:
     301            if (param1)
     302              tmpResource->ttfSize = *(int*)param1;
     303            else
     304              tmpResource->ttfSize = FONT_DEFAULT_SIZE;
     305            if (param2)
     306              {
     307                Vector* tmpVec = (Vector*)param2;
     308                tmpResource->ttfColorR = (int)tmpVec->x;
     309                tmpResource->ttfColorG = (int)tmpVec->y;
     310                tmpResource->ttfColorB = (int)tmpVec->z;
     311              }
     312            else
     313              {
     314                tmpResource->ttfColorR = FONT_DEFAULT_COLOR_R;
     315                tmpResource->ttfColorG = FONT_DEFAULT_COLOR_G;
     316                tmpResource->ttfColorB = FONT_DEFAULT_COLOR_B;
     317              }
     318
     319          if(isFile(fullName))
     320            tmpResource->pointer = new Font(fullName,
     321                                            tmpResource->ttfSize,
     322                                            tmpResource->ttfColorR,
     323                                            tmpResource->ttfColorG,
     324                                            tmpResource->ttfColorB);
     325          else
     326            PRINTF(2)("Sorry, %s does not exist. Not loading Font\n", fullName);
     327          break;
    326328#endif /* NO_TEXT */
    327329#ifndef NO_AUDIO
    328         case WAV:
    329           if(isFile(fullName))
    330             tmpResource->pointer = new SoundBuffer(fullName);
    331           break;
     330        case WAV:
     331          if(isFile(fullName))
     332            tmpResource->pointer = new SoundBuffer(fullName);
     333          break;
    332334#endif /* NO_AUDIO */
    333335#ifndef NO_TEXTURES
    334         case IMAGE:
    335           if(isFile(fullName))
    336             {
    337               PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
    338               tmpResource->pointer = new Texture(fullName);
    339             }
    340           else
    341             {
    342               tIterator<char>* iterator = imageDirs->getIterator();
    343               tmpDir = iterator->nextElement();
    344               //tmpDir = imageDirs->enumerate();
    345               while(tmpDir)
    346                 {
    347                   char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
    348                   sprintf(imgName, "%s%s", tmpDir, fileName);
    349                   if(isFile(imgName))
    350                     {
    351                       PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
    352                       tmpResource->pointer = new Texture(imgName);
    353                       delete []imgName;
    354                       break;
    355                     }
    356                   delete []imgName;
    357                   tmpDir = iterator->nextElement();
    358                 }
    359               delete iterator;
    360             }
    361           if(!tmpResource)
    362              PRINTF(2)("!!Image %s not Found!!\n", fileName);
    363           break;
     336        case IMAGE:
     337          if(isFile(fullName))
     338            {
     339              PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
     340              tmpResource->pointer = new Texture(fullName);
     341            }
     342          else
     343            {
     344              tIterator<char>* iterator = imageDirs->getIterator();
     345              tmpDir = iterator->nextElement();
     346              //tmpDir = imageDirs->enumerate();
     347              while(tmpDir)
     348                {
     349                  char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
     350                  sprintf(imgName, "%s%s", tmpDir, fileName);
     351                  if(isFile(imgName))
     352                    {
     353                      PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
     354                      tmpResource->pointer = new Texture(imgName);
     355                      delete []imgName;
     356                      break;
     357                    }
     358                  delete []imgName;
     359                  tmpDir = iterator->nextElement();
     360                }
     361              delete iterator;
     362            }
     363          if(!tmpResource)
     364             PRINTF(2)("!!Image %s not Found!!\n", fileName);
     365          break;
    364366#endif /* NO_TEXTURES */
    365         default:
    366           tmpResource->pointer = NULL;
    367           PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet.!!\n", tmpResource->name);
    368           break;
    369         }
     367        default:
     368          tmpResource->pointer = NULL;
     369          PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet.!!\n", tmpResource->name);
     370          break;
     371        }
    370372      if (tmpResource->pointer)
    371         this->resourceList->add(tmpResource);
     373        this->resourceList->add(tmpResource);
    372374      delete []fullName;
    373375    }
    374376  if (tmpResource->pointer)
    375377    return tmpResource->pointer;
    376   else 
     378  else
    377379    {
    378380      PRINTF(2)("Resource %s could not be loaded\n", fileName);
     
    413415    {
    414416      if (resource->count <= 0)
    415         {
    416           // deleting the Resource
    417           switch(resource->type)
    418             {
     417        {
     418          // deleting the Resource
     419          switch(resource->type)
     420            {
    419421#ifndef NO_MODEL
    420             case OBJ:
    421             case PRIM:
    422               delete (Model*)resource->pointer;
    423               break;
    424             case MD2:
    425               delete (MD2Data*)resource->pointer;
    426               break;
     422            case OBJ:
     423            case PRIM:
     424              delete (Model*)resource->pointer;
     425              break;
     426            case MD2:
     427              delete (MD2Data*)resource->pointer;
     428              break;
    427429#endif /* NO_MODEL */
    428430#ifndef NO_AUDIO
    429             case WAV:
    430               delete (SoundBuffer*)resource->pointer;
    431               break;
     431            case WAV:
     432              delete (SoundBuffer*)resource->pointer;
     433              break;
    432434#endif /* NO_AUDIO */
    433435#ifndef NO_TEXT
    434             case TTF:
    435               delete (Font*)resource->pointer;
    436               break;
     436            case TTF:
     437              delete (Font*)resource->pointer;
     438              break;
    437439#endif /* NO_TEXT */
    438440#ifndef NO_TEXTURES
    439             case IMAGE:
    440               delete (Texture*)resource->pointer;
    441               break;
     441            case IMAGE:
     442              delete (Texture*)resource->pointer;
     443              break;
    442444#endif /* NO_TEXTURES */
    443             default:
    444               PRINTF(1)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
    445               return false;
    446               break;
    447             }
    448           // deleting the List Entry:
    449           PRINTF(4)("Resource %s safely removed.\n", resource->name);
    450           delete []resource->name;
    451           this->resourceList->remove(resource);
    452         }
     445            default:
     446              PRINTF(1)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
     447              return false;
     448              break;
     449            }
     450          // deleting the List Entry:
     451          PRINTF(4)("Resource %s safely removed.\n", resource->name);
     452          delete []resource->name;
     453          this->resourceList->remove(resource);
     454        }
    453455      else
    454         PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count);
     456        PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count);
    455457    }
    456458  else
     
    471473    {
    472474      if (enumRes->prio <= prio)
    473         if (enumRes->count == 0)
    474           unload(enumRes, prio);
    475         else
    476           PRINTF(2)("unable to unload %s because there are still %d references to it\n",
    477                    enumRes->name, enumRes->count);
     475        if (enumRes->count == 0)
     476          unload(enumRes, prio);
     477        else
     478          PRINTF(2)("unable to unload %s because there are still %d references to it\n",
     479                   enumRes->name, enumRes->count);
    478480      //enumRes = resourceList->nextElement();
    479481      enumRes = iterator->nextElement();
     
    492494*/
    493495Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
    494                                                 void* param1, void* param2, void* param3)
     496                                                void* param1, void* param2, void* param3)
    495497{
    496498  //  Resource* enumRes = resourceList->enumerate();
     
    500502    {
    501503      if (enumRes->type == type && !strcmp(fileName, enumRes->name))
    502         {
    503           bool match = false;
    504           bool subMatch = false;
    505 
    506           switch (type)
    507             {
     504        {
     505          bool match = false;
     506          bool subMatch = false;
     507
     508          switch (type)
     509            {
    508510#ifndef NO_MODEL
    509             case PRIM:
    510             case OBJ:
    511               if (!param1)
    512                 {
    513                   if (enumRes->modelSize == 1.0)
    514                     match = true;
    515                 }
    516               else if (enumRes->modelSize == *(float*)param1)
    517                 match = true;
    518               break;
    519             case MD2:
    520               if (!param1)
    521                 {
    522                   if (enumRes->skinFileName == NULL)
    523                     match = true;
    524                 }
    525               else if (!strcmp(enumRes->skinFileName, (const char*) param1))
    526                 match = true;
    527               break;
     511            case PRIM:
     512            case OBJ:
     513              if (!param1)
     514                {
     515                  if (enumRes->modelSize == 1.0)
     516                    match = true;
     517                }
     518              else if (enumRes->modelSize == *(float*)param1)
     519                match = true;
     520              break;
     521            case MD2:
     522              if (!param1)
     523                {
     524                  if (enumRes->skinFileName == NULL)
     525                    match = true;
     526                }
     527              else if (!strcmp(enumRes->skinFileName, (const char*) param1))
     528                match = true;
     529              break;
    528530#endif /* NO_MODEL */
    529531#ifndef NO_TEXT
    530             case TTF:
    531               if (!param1)
    532                 {
    533                   if (enumRes->ttfSize == FONT_DEFAULT_SIZE)
    534                     subMatch = true;
    535                 }
    536               else if (enumRes->modelSize =- *(int*)param1)
    537                 subMatch = true;
    538               if(subMatch)
    539                 {
    540                   Vector* tmpVec = (Vector*)param2;
    541                   if (!param2)
    542                     {
    543                       if(enumRes->ttfColorR == FONT_DEFAULT_COLOR_R &&
    544                         enumRes->ttfColorG == FONT_DEFAULT_COLOR_G &&
    545                         enumRes->ttfColorB == FONT_DEFAULT_COLOR_B )
    546                         match = true;
    547                     }
    548                   else if (enumRes->ttfColorR == (int)tmpVec->x &&
    549                            enumRes->ttfColorG == (int)tmpVec->y &&
    550                            enumRes->ttfColorB == (int)tmpVec->z )
    551                     match = true;
    552                 }
    553               break;
     532            case TTF:
     533              if (!param1)
     534                {
     535                  if (enumRes->ttfSize == FONT_DEFAULT_SIZE)
     536                    subMatch = true;
     537                }
     538              else if (enumRes->modelSize =- *(int*)param1)
     539                subMatch = true;
     540              if(subMatch)
     541                {
     542                  Vector* tmpVec = (Vector*)param2;
     543                  if (!param2)
     544                    {
     545                      if(enumRes->ttfColorR == FONT_DEFAULT_COLOR_R &&
     546                        enumRes->ttfColorG == FONT_DEFAULT_COLOR_G &&
     547                        enumRes->ttfColorB == FONT_DEFAULT_COLOR_B )
     548                        match = true;
     549                    }
     550                  else if (enumRes->ttfColorR == (int)tmpVec->x &&
     551                           enumRes->ttfColorG == (int)tmpVec->y &&
     552                           enumRes->ttfColorB == (int)tmpVec->z )
     553                    match = true;
     554                }
     555              break;
    554556#endif /* NO_TEXT */
    555             default:
    556               match = true;
    557               break;
    558             }
    559           if (match)
    560             {
    561               delete iterator;
    562               return enumRes;
    563             }
    564         }
     557            default:
     558              match = true;
     559              break;
     560            }
     561          if (match)
     562            {
     563              delete iterator;
     564              return enumRes;
     565            }
     566        }
    565567      enumRes = iterator->nextElement();
    566568    }
     
    582584    {
    583585      if (pointer == enumRes->pointer)
    584         {
    585           delete iterator;
    586           return enumRes;
    587         }
     586        {
     587          delete iterator;
     588          return enumRes;
     589        }
    588590      enumRes = iterator->nextElement();
    589591    }
     
    622624      if (status.st_mode & (S_IFDIR
    623625#ifndef __WIN32__
    624                             | S_IFLNK
     626                            | S_IFLNK
    625627#endif
    626                             ))
    627         {
    628           delete tmpDirName;
    629           return true;
    630         }
     628                            ))
     629        {
     630          delete tmpDirName;
     631          return true;
     632        }
    631633      else
    632         {
    633           delete tmpDirName;
    634           return false;
    635         }
     634        {
     635          delete tmpDirName;
     636          return false;
     637        }
    636638    }
    637639  else
     
    653655  if (!stat(tmpFileName, &status))
    654656    {
    655       if (status.st_mode & (S_IFREG 
     657      if (status.st_mode & (S_IFREG
    656658#ifndef __WIN32__
    657                             | S_IFLNK
     659                            | S_IFLNK
    658660#endif
    659                             ))
    660         {
    661           delete tmpFileName;
    662           return true;
    663         }
     661                            ))
     662        {
     663          delete tmpFileName;
     664          return true;
     665        }
    664666      else
    665         {
    666           delete tmpFileName;
    667           return false;
    668         }
    669     }
    670   else 
     667        {
     668          delete tmpFileName;
     669          return false;
     670        }
     671    }
     672  else
    671673    {
    672674      delete tmpFileName;
     
    691693    }
    692694  fclose(stream);
    693    
    694   delete tmpName; 
     695
     696  delete tmpName;
    695697}
    696698
     
    708710}
    709711
    710 /** 
     712/**
    711713    \param name the Name of the file to check
    712714    \returns The name of the file, including the HomeDir
     
    737739}
    738740
    739 /** 
     741/**
    740742    \param fileName the Name of the File to check
    741743    \returns The full name of the file, including the DataDir, and NULL if the file does not exist
     
    748750
    749751  char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir())
    750                            + strlen(fileName) + 1];
     752                           + strlen(fileName) + 1];
    751753  sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
    752754  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
     
    790792      PRINT(0)("Name: %s; References: %d; Type:", enumRes->name, enumRes->count);
    791793      switch (enumRes->type)
    792         {
    793         case OBJ:
    794           PRINT(0)("ObjectModel\n");
    795           break;
    796         case PRIM:
    797           PRINT(0)("PrimitiveModel\n");
    798           break;
    799         case IMAGE:
    800           PRINT(0)("ImageFile (Texture)\n");
    801           break;
    802         default:
    803           PRINT(0)("SoundFile\n");
    804           break;
    805         }
     794        {
     795        case OBJ:
     796          PRINT(0)("ObjectModel\n");
     797          break;
     798        case PRIM:
     799          PRINT(0)("PrimitiveModel\n");
     800          break;
     801        case IMAGE:
     802          PRINT(0)("ImageFile (Texture)\n");
     803          break;
     804        default:
     805          PRINT(0)("SoundFile\n");
     806          break;
     807        }
    806808      PRINT(0)("gets deleted at ");
    807809      switch(enumRes->prio)
    808         {
    809         default:
    810         case RP_NO:
    811           PRINT(0)("first posibility (0)\n");
    812           break;
    813         case RP_LEVEL:
    814           PRINT(0)("the end of the Level (1)\n");
    815           break;
    816         case RP_CAMPAIGN:
    817           PRINT(0)("the end of the campaign (2)\n");
    818           break;
    819         case RP_GAME:
    820           PRINT(0)("when leaving the game (3)\n");
    821           break;
    822         }
     810        {
     811        default:
     812        case RP_NO:
     813          PRINT(0)("first posibility (0)\n");
     814          break;
     815        case RP_LEVEL:
     816          PRINT(0)("the end of the Level (1)\n");
     817          break;
     818        case RP_CAMPAIGN:
     819          PRINT(0)("the end of the campaign (2)\n");
     820          break;
     821        case RP_GAME:
     822          PRINT(0)("when leaving the game (3)\n");
     823          break;
     824        }
    823825      enumRes = iterator->nextElement();
    824826    }
  • orxonox/trunk/src/util/resource_manager.h

    r4534 r4597  
    1 /*! 
     1/*!
    22    \file resource_manager.h
    33    \brief The Resource Manager checks if a file/resource is loaded.
    44
    5     If a file/resource was already loaded the resourceManager will 
     5    If a file/resource was already loaded the resourceManager will
    66    return a void pointer to the desired resource.
    77    Otherwise it will instruct the coresponding resource-loader to load,
     
    99
    1010    it is possible to compile the resource Manager without some modules by
    11     just adding the compile flag -D.... 
     11    just adding the compile flag -D....
    1212    (NO_MODEL)
    1313    (NO_AUDIO)
     
    2323#include "stdlibincl.h"
    2424
    25 // FORWARD DEFINITION 
     25// FORWARD DEFINITION
    2626template<class T> class tList;
    2727
    2828//! An eumerator for different fileTypes the resourceManager supports
    29 typedef enum ResourceType {
     29typedef enum ResourceType
     30{
    3031#ifndef NO_MODEL
    3132  OBJ,                  //!< loading .obj file
     
    4647};
    4748
    48 //! An enumerator for different UNLOAD-types. 
     49//! An enumerator for different UNLOAD-types.
    4950/**
    5051   RP_NO:        will be unloaded on request
     
    5354   RP_GAME:      will be unloaded at the end of the whole Game (when closing orxonox)
    5455*/
    55 typedef enum ResourcePriority { RP_NO        =   0,
    56                                 RP_LEVEL     =   1,
    57                                 RP_CAMPAIGN  =   2,
    58                                 RP_GAME      =   4 };
     56typedef enum ResourcePriority
     57{
     58  RP_NO        =   0,
     59  RP_LEVEL     =   1,
     60  RP_CAMPAIGN  =   2,
     61  RP_GAME      =   4
     62};
    5963
    6064//! A Struct that keeps track about A resource its name its Type, and so on
     
    6367  void*             pointer;           //!< Pointer to the Resource.
    6468  int               count;             //!< How many times this Resource has been loaded.
    65  
     69
    6670  char*             name;              //!< Name of the Resource.
    6771  ResourceType      type;              //!< ResourceType of this Resource.
     
    8488//! The ResourceManager is a class, that decides if a file/resource should be loaded
    8589/**
    86    If a file/resource was already loaded the resourceManager will 
     90   If a file/resource was already loaded the resourceManager will
    8791   return a void pointer to the desired resource.
    8892   Otherwise it will instruct the corresponding resource-loader to load,
     
    9195   It does it by looking, if a desired file has already been loaded.
    9296*/
    93 class ResourceManager : public BaseObject 
     97class ResourceManager : public BaseObject
    9498{
    9599 public:
     
    105109  bool addImageDir(const char* imageDir);
    106110  void* load(const char* fileName, ResourcePriority prio = RP_NO,
    107              void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
     111             void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
    108112  void* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
    109              void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
     113             void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
    110114  bool unload(void* pointer, ResourcePriority prio = RP_NO);
    111115  bool unload(Resource* resource, ResourcePriority = RP_NO);
    112116  bool unloadAllByPriority(ResourcePriority prio);
    113  
     117
    114118  void debug(void);
    115  
     119
    116120
    117121  // utility functions of this class
     
    127131
    128132  Resource* locateResourceByInfo(const char* fileName, ResourceType type, void* param1, void* param2, void* param3);
    129   Resource* locateResourceByPointer(const void* pointer); 
     133  Resource* locateResourceByPointer(const void* pointer);
    130134
    131135 private:
  • orxonox/trunk/src/util/state.cc

    r4485 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2828   \brief standard constructor
    2929*/
    30 State::State () 
     30State::State ()
    3131{
    32    this->setClassName ("State");
     32   this->setClassID(CL_STATE, "State");
     33   this->setName("State");
    3334
    3435   this->camera = NULL;
     
    4445   \brief standard deconstructor
    4546*/
    46 State::~State () 
     47State::~State ()
    4748{
    4849  State::singletonRef = NULL;
  • orxonox/trunk/src/util/state.h

    r4485 r4597  
    1 /*! 
     1/*!
    22    \file state.h
    33    \brief Definition of the States-singleton Class
  • orxonox/trunk/src/util/track/pilot_node.cc

    r4456 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    2828   \brief standard constructor
    2929*/
    30 PilotNode::PilotNode () 
     30PilotNode::PilotNode ()
    3131{
    3232   this->setClassID(CL_PILOT_PARENT, "PilotNode");
     33   this->setName("PilotNode");
    3334
    3435   travelSpeed = 30.0;
     
    4041   \brief standard deconstructor
    4142*/
    42 PilotNode::~PilotNode () 
     43PilotNode::~PilotNode ()
    4344{
    4445
    4546}
    4647
    47 /** 
     48/**
    4849    \brief ticks the node
    49     \param time the time about whitch to tick                                           \
     50    \param time the time about whitch to tick                                           \
    5051*/
    5152void PilotNode::tick(float time)
     
    7374   direction = q.apply(direction);
    7475
    75    
     76
    7677
    7778   Vector orthDirection(0,0,1);
    7879   orthDirection = q.apply(orthDirection);
    79    
     80
    8081   if( this->bUp)
    8182     accel = accel+(direction*acceleration);
     
    8384     accel = accel -(direction*acceleration);
    8485   if( this->bLeft)
    85      accel = accel - (orthDirection*acceleration); 
     86     accel = accel - (orthDirection*acceleration);
    8687   if( this->bRight)
    8788     accel = accel + (orthDirection*acceleration);
    88    
     89
    8990   Vector move = accel * time;
    9091   this->shiftCoor (move);
    91    
     92
    9293   Quaternion q1(-M_PI/4 * this->roll/40000.0, Vector(0,0,1));
    9394   Quaternion q2(-M_PI/4 * this->pitch/30000.0, Vector(0,1,0));
  • orxonox/trunk/src/util/track/pilot_node.h

    r4456 r4597  
    1 /*! 
     1/*!
    22    \file pilot_node.h
    33    \brief Definition of a PilotNode
  • orxonox/trunk/src/util/track/track_manager.cc

    r4584 r4597  
    4040TrackElement::TrackElement(void)
    4141{
     42  this->setClassID(CL_TRACK_ELEMENT, "TrackElement");
     43
    4244  this->isFresh = true;
    4345  this->isHotPoint = false;
     
    358360{
    359361  this->setClassID(CL_TRACK_MANAGER, "TrackManager");
     362  this->setName("TrackManager");
    360363
    361364  TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager
  • orxonox/trunk/src/util/track/track_node.cc

    r4489 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    2828   \brief standard constructor
    2929*/
    30 TrackNode::TrackNode () 
     30TrackNode::TrackNode ()
    3131{
    3232  this->setClassID(CL_TRACK_NODE, "TrackNode");
    33   this->setName("TrackNode"); /* absolete but still used... */
     33  this->setName("TrackNode");
    3434
    3535  NullParent::getInstance()->addChild(this);
     
    3838}
    3939
    40 
    4140/**
    4241   \brief standard deconstructor
    4342*/
    44 TrackNode::~TrackNode () 
     43TrackNode::~TrackNode ()
    4544{
    4645
Note: See TracChangeset for help on using the changeset viewer.