Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4592 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jun 10, 2005, 7:17:22 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: derivations work.
now the only thing to do is specify all the classes, and DO it CLEAN.

@patrick: is it ok, how i treated your ObjectManager??

Location:
orxonox/trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/class_list.h

    r4591 r4592  
    2727
    2828
     29#define ClassDefinition(CLASS_DEFINITION, CLASS_VALUE, CLASS_NAME) \
     30                  CLASS_DEFINITION
     31
    2932//! list of all classes to be loadable in via the ObjectManager
    3033/**
     
    4548  CL_MASK_SUPERCLASS      =    0xff000000,
    4649  CL_BASE_OBJECT          =    0x01000000,
     50
    4751  CL_PARENT_NODE          =    0x02000000,
    4852  CL_WORLD_ENTITY         =    0x04000000,
     53
    4954  CL_STORY_ENTITY         =    0x08000000,
    5055
     56  CL_PHYSICS_INTERFACE    =    0x10000000,
     57
     58  CL_EVENT_LISTENER       =    0x20000000,
     59
    5160  // subsuper-classes
     61  CL_MASK_SUBCLASS        =    0x00fff000,
    5262  CL_PLAYER               =    0x00001000,
    5363  CL_NPC                  =    0x00002000,
     
    5767  CL_WEAPON               =    0x00020000,
    5868
    59 
     69  // lowest level classes
     70  CL_MASK_LOWLEVEL_CLASS  =    0x00000fff,
    6071  // singleton classes (range from 0x00000001 to 0x000000ff)
    6172  CL_MASK_SINGLETON       =    0x0000003f,
     
    118129
    119130  CL_EVENT,
    120   CL_EVENT_LISTENER,
    121131  CL_KEY_MAPPER,
    122132
  • orxonox/trunk/src/lib/coord/p_node.cc

    r4575 r4592  
    101101void PNode::init(PNode* parent)
    102102{
     103  this->setClassID(CL_PARENT_NODE);
    103104  this->children = new tList<PNode>();
    104105  this->bRelCoorChanged = true;
  • orxonox/trunk/src/lib/lang/base_object.cc

    r4591 r4592  
    7878void BaseObject::setClassID (long classID)
    7979{
    80   this->classID = classID;
     80  this->classID |= classID;
    8181}
    8282
     
    9191}
    9292
    93 
    94 /*
    95    \brief sets the class identifiers
    96    \param a number for the class from class_list.h enumeration
    97    \param the class name
    98 
    99 bool BaseObject::isA (char* className)
    100 {
    101   if( this->className == className)
    102     return false;
    103   return true;
    104 }
    105 */
    106 
    10793/**
    10894  \brief set the name of the Object
    10995 */
    110 void BaseObject::setName (const char* objectName)
     96             void BaseObject::setName (const char* objectName)
    11197{
    11298  if (this->objectName)
    11399    delete []this->objectName;
    114100  if (objectName)
    115     {
    116       this->objectName = new char[strlen(objectName)+1];
    117       strcpy(this->objectName, objectName);
    118     }
     101  {
     102    this->objectName = new char[strlen(objectName)+1];
     103    strcpy(this->objectName, objectName);
     104  }
    119105  else
    120106    this->objectName = NULL;
    121107}
     108
     109
     110/**
     111   \brief checks if the class is a classID
     112   \param classID the Identifier to check for
     113   \returns true if it is, false otherwise
     114*/
     115bool BaseObject::isA (ClassID classID)
     116{
     117  if( this->classID & classID)
     118    return true;
     119  return false;
     120}
     121
     122/**
     123 * @brief displays everything this class is
     124 */
     125void BaseObject::whatIs(void) const
     126{
     127  PRINT(0)("object %s: ", this->getName() );
     128  if (this->classID & CL_MASK_SUPERCLASS)
     129  {
     130    PRINT(0)("is a derived Class from: \n");
     131    if (this->classID & CL_BASE_OBJECT)
     132      PRINT(0)("BaseObject, ");
     133    if (this->classID & CL_PARENT_NODE)
     134      PRINT(0)("ParentNode, ");
     135    if (this->classID & CL_WORLD_ENTITY)
     136      PRINT(0)("WorldEntity, ");
     137    if (this->classID & CL_PHYSICS_INTERFACE)
     138      PRINT(0)("PhysicsInterface, ");
     139    if (this->classID & CL_EVENT_LISTENER)
     140      PRINT(0)("EventListener, ");
     141    if (this->classID & CL_STORY_ENTITY)
     142      PRINT(0)("StoryEntity, ");
     143  }
     144  printf("\n");
     145}
  • orxonox/trunk/src/lib/lang/base_object.h

    r4591 r4592  
    3737  inline int getClassID(void) const { return this->classID; }
    3838
    39   //  bool isA (char* className);
     39  bool isA (ClassID classID);
     40  void whatIs(void) const;
    4041
    4142  /** \returns if the object is finalized */
  • orxonox/trunk/src/story_entities/story_entity.cc

    r3629 r4592  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616*/
    1717
     
    2424
    2525
    26 StoryEntity::StoryEntity () {}
     26StoryEntity::StoryEntity ()
     27{
     28  this->setClassID(CL_STORY_ENTITY);
     29}
    2730StoryEntity::~StoryEntity () {}
    2831
    2932
    30 /** 
     33/**
    3134    \brief sets the story ID
    3235
    33     sets the story id of the current entity, this enables it to be identified in a 
     36    sets the story id of the current entity, this enables it to be identified in a
    3437    global context.
    3538*/
     
    4043
    4144
    42 /** 
     45/**
    4346    \brief this reads the story id of the current entity
    4447    \returns the story entity id
     
    5053
    5154
    52 /** 
     55/**
    5356    \brief sets the id of the next story entity
    54    
     57
    5558    StoryEntities can choose their following entity themselfs. the entity id defined here
    5659    will be startet after this entity ends. this can be convenient if you want to have a
     
    6265}
    6366
    64 /** 
     67/**
    6568    \brief gets the story id of the current entity
    6669    \returns story id
     
    8184{}
    8285
    83 /** 
     86/**
    8487    \brief loads the current entity
    8588
     
    9295
    9396
    94 /** 
    95     \brief initialize the entity before use. 
     97/**
     98    \brief initialize the entity before use.
    9699    \returns an error code if not able to apply.
    97100
    98     After execution of this function, the Entity is ready to be played/executed, 
     101    After execution of this function, the Entity is ready to be played/executed,
    99102    this shifts the initialisation work before the execution - very important...
    100103    init() is exec shortly before start()
     
    104107
    105108
    106 /** 
     109/**
    107110    \brief starts the entity with the choosen id. only for entities with lists.
    108111    \param story id
     
    118121
    119122
    120 /** 
     123/**
    121124    \brief starts the current entity
    122     \returns error code if this action has caused a error   
     125    \returns error code if this action has caused a error
    123126*/
    124127ErrorMessage StoryEntity::start()
     
    126129
    127130
    128 /** 
     131/**
    129132    \brief pause the current entity
    130133    \returns error code if this action has caused a error
     
    136139
    137140
    138 /** 
     141/**
    139142    \brief resumes a pause
    140143    \returns error code if this action has caused a error
     
    146149
    147150
    148 /** 
     151/**
    149152    \brief stops the current entity
    150153    \returns error code if this action has caused a error
     
    160163
    161164
    162 /** 
    163     \brief destroys and cleans up the current entity. 
     165/**
     166    \brief destroys and cleans up the current entity.
    164167
    165     this cleans up ressources before the deconstructor is called. for terminating 
     168    this cleans up ressources before the deconstructor is called. for terminating
    166169    the entity please use the stop() function.
    167170*/
     
    170173
    171174
    172 /** 
     175/**
    173176    \brief this displays the load screen
    174177
    175     it will need some time to load maps or things like that. to inform the user about 
     178    it will need some time to load maps or things like that. to inform the user about
    176179    progress and to just show him/her something for the eyes, put here this stuff
    177180*/
     
    180183
    181184
    182 /** 
     185/**
    183186    \brief undisplay the load screen
    184187
  • orxonox/trunk/src/story_entities/world.cc

    r4574 r4592  
    520520  new PhysicsConnection(testEntity, gravity);
    521521
    522 
     522  // printing out some debug stuff
    523523  NullParent::getInstance()->debug(0);
     524  this->localPlayer->whatIs();
     525  this->whatIs();
    524526}
    525527
  • orxonox/trunk/src/util/garbage_collector.cc

    r4519 r4592  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3333   \brief standard constructor
    3434*/
    35 GarbageCollector::GarbageCollector () 
     35GarbageCollector::GarbageCollector ()
    3636{
    3737   this->setClassID(CL_GARBAGE_COLLECTOR, "GarbageCollector");
     
    4444   \brief standard deconstructor
    4545*/
    46 GarbageCollector::~GarbageCollector () 
     46GarbageCollector::~GarbageCollector ()
    4747{
    4848  // delete what has to be deleted here
     
    5252   \brief this sets the collection delay
    5353   \param delay: the delay
    54    
     54
    5555   after this delay, the garbage collector starts its work and begins to collect unused object
    5656   to delete them afterwards. only objects in the worldentity list from the world object are lookded
    57    at. 
     57   at.
    5858*/
    5959void GarbageCollector::setCollectionDelay(float delay)
     
    107107  tIterator<WorldEntity>* iterator = list->getIterator();
    108108  WorldEntity* entity = iterator->nextElement();
    109   while( entity != NULL) 
    110     { 
     109  while( entity != NULL)
     110    {
    111111      if( entity->isFinalized())
    112         {
    113           PRINTF(4)("= finalizing object\n");
    114           ++counter;
    115          
    116           /* first remove out of entity list */
    117           list->remove(entity);
    118           /* second remove out of pnode tree */
    119           entity->remove();
    120           /* then finaly delete reference */
    121           //delete entity;
    122           ObjectManager::getInstance()->addToDeadList(entity->getClassID(), entity);
    123         }
     112        {
     113          PRINTF(4)("= finalizing object\n");
     114          ++counter;
     115
     116          /* first remove out of entity list */
     117          list->remove(entity);
     118          /* second remove out of pnode tree */
     119          entity->remove();
     120          /* then finaly delete reference */
     121          //delete entity;
     122          ObjectManager::getInstance()->addToDeadList(entity->getClassID() & CL_MASK_LOWLEVEL_CLASS, entity);
     123        }
    124124      entity = iterator->nextElement();
    125125    }
  • orxonox/trunk/src/util/loading/load_param.h

    r4501 r4592  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1414*/
    1515
    16 /*! 
     16/*!
    1717    \file load_param.h
    1818    \brief A Class and macro-functions, that makes our lives easy to load-in parameters
     
    7474#define LoadParam1(type1) \
    7575 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), bool multi = false) \
    76    : BaseLoadParam(root, pt2Object, paramName, 1, multi, type1##_NAME)          \
    77     { \
    78       if (loadString != NULL && root != NULL) \
    79         (*pt2Object.*function)(type1##_FUNC(loadString)); \
    80       else \
    81         PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     76   : BaseLoadParam(root, pt2Object, paramName, 1, multi, type1##_NAME)          \
     77    { \
     78      if (loadString != NULL && root != NULL) \
     79        (*pt2Object.*function)(type1##_FUNC(loadString)); \
     80      else \
     81        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
    8282    }
    8383
     
    9494    { \
    9595      if (loadString != NULL && root != NULL) \
    96         { \
    97           SubString subLoads(loadString); \
    98           if (subLoads.getCount() == 2) \
    99             (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1))); \
    100           else \
    101             PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
    102                       paramName, pt2Object->getClassName(), 2, subLoads.getCount()); \
    103         } \
    104       else \
    105         PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     96        { \
     97          SubString subLoads(loadString); \
     98          if (subLoads.getCount() == 2) \
     99            (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1))); \
     100          else \
     101            PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
     102                      paramName, pt2Object->getClassName(), 2, subLoads.getCount()); \
     103        } \
     104      else \
     105        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
    106106    }
    107107
     
    119119    { \
    120120      if (loadString != NULL && root != NULL) \
    121         { \
    122           SubString subLoads(loadString); \
    123           if (subLoads.getCount() == 3) \
    124             (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2))); \
    125           else \
    126             PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
    127                       paramName, pt2Object->getClassName(), 3, subLoads.getCount()); \
    128         } \
    129       else \
    130         PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     121        { \
     122          SubString subLoads(loadString); \
     123          if (subLoads.getCount() == 3) \
     124            (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2))); \
     125          else \
     126            PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
     127                      paramName, pt2Object->getClassName(), 3, subLoads.getCount()); \
     128        } \
     129      else \
     130        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
    131131    }
    132132
     
    145145    { \
    146146      if (loadString != NULL && root != NULL) \
    147         { \
    148           SubString subLoads(loadString); \
    149           if (subLoads.getCount() == 4) \
    150             (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3))); \
    151           else \
    152             PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
    153                       paramName, pt2Object->getClassName(), 4, subLoads.getCount()); \
    154         } \
    155       else \
    156         PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     147        { \
     148          SubString subLoads(loadString); \
     149          if (subLoads.getCount() == 4) \
     150            (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3))); \
     151          else \
     152            PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
     153                      paramName, pt2Object->getClassName(), 4, subLoads.getCount()); \
     154        } \
     155      else \
     156        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
    157157    }
    158158
     
    172172    { \
    173173      if (loadString != NULL && root != NULL) \
    174         { \
    175           SubString subLoads(loadString); \
    176           if (subLoads.getCount() == 5) \
    177             (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3)), type5##_FUNC(subLoads.getString(4))); \
    178           else \
    179             PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
    180                       paramName, pt2Object->getClassName(), 5, subLoads.getCount()); \
    181         } \
    182       else \
    183         PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     174        { \
     175          SubString subLoads(loadString); \
     176          if (subLoads.getCount() == 5) \
     177            (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3)), type5##_FUNC(subLoads.getString(4))); \
     178          else \
     179            PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
     180                      paramName, pt2Object->getClassName(), 5, subLoads.getCount()); \
     181        } \
     182      else \
     183        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
    184184    }
    185185
     
    216216  static LoadClassDescription* addClass(const char* className);
    217217  LoadParamDescription* addParam(const char* paramName);
    218  
     218
    219219
    220220  static void printAll(const char* fileName = NULL);
     
    249249  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false)
    250250    : BaseLoadParam(root, pt2Object, paramName, 0, multi, "")
    251     { 
     251    {
    252252      if (loadString != NULL && root != NULL)
    253         (*pt2Object.*function)();
    254       else 
    255         PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName());
     253        (*pt2Object.*function)();
     254      else
     255        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName());
    256256    }
    257257
  • orxonox/trunk/src/util/object_manager.cc

    r4519 r4592  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2626   \brief standard constructor
    2727*/
    28 ObjectManager::ObjectManager () 
     28ObjectManager::ObjectManager ()
    2929{
    3030  this->setClassID(CL_OBJECT_MANAGER, "ObjectManager");
    31  
     31
    3232  this->managedObjectList = new tList<BaseObject>*[CL_NUMBER];
    3333  for(int i = 0; i < CL_NUMBER; ++i)
     
    4848   \brief standard deconstructor
    4949*/
    50 ObjectManager::~ObjectManager () 
     50ObjectManager::~ObjectManager ()
    5151{
    5252  ObjectManager::singletonRef = NULL;
     
    8080      this->managedObjectList[index]->remove(obj);
    8181      if( unlikely(obj == NULL))
    82         {
    83           PRINTF(0)("Critical: there was no object anymore in the dead list! This could result in Segfaults\n");
    84         }
     82        {
     83          PRINTF(0)("Critical: there was no object anymore in the dead list! This could result in Segfaults\n");
     84        }
    8585      return obj;
    8686    }
     
    9696{
    9797  PRINT(0)("\n==========================| ObjectManager::debug() |===\n");
    98   PRINT(0)("=  Number of registerable classes: %i\n", CL_NUMBER ); 
     98  PRINT(0)("=  Number of registerable classes: %i\n", CL_NUMBER );
    9999  PRINT(0)("=  Currently cached objects: \n");
    100100  for(int i = 0; i < CL_NUMBER; ++i)
    101101    {
    102102      if( this->managedObjectList[i] != NULL)
    103         PRINT(0)("=   o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize());
     103        PRINT(0)("=   o Class Nr. %i has cached %i object(s)\n", i, this->managedObjectList[i]->getSize());
    104104      else
    105         PRINT(0)("=   o Class Nr. %i has cached 0 object(s)\n", i);
     105        PRINT(0)("=   o Class Nr. %i has cached 0 object(s)\n", i);
    106106    }
    107107  PRINT(0)("=======================================================\n");
  • orxonox/trunk/src/world_entities/camera.h

    r4490 r4592  
    1 /*! 
     1/*!
    22    \file camera.h
    33    \brief Viewpoint controlling class definitions
    4 */ 
     4*/
    55
    66#ifndef _CAMERA_H
     
    1616
    1717//! an enumerator for different types of view
    18 typedef enum ViewMode{ VIEW_NORMAL,
    19                        VIEW_BEHIND,
    20                        VIEW_FRONT,
    21                        VIEW_LEFT,
    22                        VIEW_RIGHT,
    23                        VIEW_TOP };
     18typedef enum ViewMode
     19{
     20  VIEW_NORMAL,
     21  VIEW_BEHIND,
     22  VIEW_FRONT,
     23  VIEW_LEFT,
     24  VIEW_RIGHT,
     25  VIEW_TOP
     26};
    2427
    2528//! Camera
     
    5962
    6063//! A CameraTarget is where the Camera is looking at.
    61 class CameraTarget : public PNode 
     64class CameraTarget : public PNode
    6265{
    6366  friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
    64  
     67
    6568 private:
    6669  CameraTarget(void);
    67  
     70
    6871 public:
    6972  virtual ~CameraTarget(void);
  • orxonox/trunk/src/world_entities/player.cc

    r4414 r4592  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    4848     the player.cc for debug also
    4949  */
    50   this->setClassName("Player");
     50  this->setClassID(CL_PLAYER, "Player");
    5151  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    5252  travelSpeed = 15.0;
     
    6060  Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
    6161  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
    62  
     62
    6363  this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
    6464  this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
     
    8484   \brief creates a new Player from Xml Data
    8585   \param root the xml element containing player data
    86    
     86
    8787   \todo add more parameters to load
    8888*/
    8989Player::Player(const TiXmlElement* root) : WorldEntity(root), PhysicsInterface(this)
    9090{
    91   this->setClassName("Player");
     91  this->setClassID(CL_PLAYER, "Player");
    9292  this->weapons = new tList<Weapon>();
    9393  this->activeWeapon = NULL;
     
    107107  Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);
    108108  Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
    109  
     109
    110110  this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0);
    111111  this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1);
     
    162162
    163163
    164 /** 
     164/**
    165165    \brief Collision with another Entity has this effect
    166166    \param other the other colider
     
    177177*/
    178178void Player::draw ()
    179 { 
     179{
    180180  glMatrixMode(GL_MODELVIEW);
    181181  glPushMatrix();
    182182  float matrix[4][4];
    183  
     183
    184184  /* translate */
    185   glTranslatef (this->getAbsCoor ().x, 
    186                 this->getAbsCoor ().y,
    187                 this->getAbsCoor ().z);
     185  glTranslatef (this->getAbsCoor ().x,
     186                this->getAbsCoor ().y,
     187                this->getAbsCoor ().z);
    188188  /* rotate */
    189189  this->getAbsDir ().matrix (matrix);
    190190  glMultMatrixf((float*)matrix);
    191  
     191
    192192  this->model->draw();
    193193  glPopMatrix();
     
    205205  //printf("%p\n", this);
    206206  //this->getRelCoor().debug();
    207  
     207
    208208  /* link tick to weapon */
    209209  //this->activeWeapon->tick(time);
     
    236236    accel = accel -(direction*acceleration);
    237237  if( this->bLeft &&  TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)
    238     accel = accel - (orthDirection*acceleration); 
     238    accel = accel - (orthDirection*acceleration);
    239239  if( this->bRight &&  TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
    240240    accel = accel + (orthDirection*acceleration);
  • orxonox/trunk/src/world_entities/test_gun.cc

    r4504 r4592  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616
    1717
     
    4343   creates a new weapon
    4444*/
    45 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight) 
    46   :  Weapon (parent, coordinate, direction) 
     45TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight)
     46  :  Weapon (parent, coordinate, direction)
    4747{
    4848  this->setClassID(CL_TEST_GUN, "TestGun");
     
    6565      this->projectileOffset = Vector(1.0, 0.0, -0.35);
    6666
    67       this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 
     67      this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    6868      this->animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    6969      this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    7070
    71       this->animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 
     71      this->animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    7272      this->animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    7373
    7474      this->animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    75       this->animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 
     75      this->animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    7676    }
    7777  else if( this->leftRight == W_RIGHT)
     
    8080
    8181      this->objectComponent1->setRelCoor(Vector(0,0,0.35));
    82       this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 
     82      this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    8383      this->animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    8484      this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT);
    8585
    86       this->animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 
     86      this->animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    8787      this->animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    8888
    8989      this->animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    90       this->animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 
     90      this->animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT);
    9191    }
    92  
     92
    9393  this->fireSound = (SoundBuffer*)ResourceManager::getInstance()->load("sound/shot1.wav", WAV);
    9494  this->weaponSource = new SoundSource(this->fireSound, this);
     
    103103   \brief standard deconstructor
    104104*/
    105 TestGun::~TestGun () 
     105TestGun::~TestGun ()
    106106{
    107107  // model will be deleted from WorldEntity-destructor
     
    112112   \brief this activates the weapon
    113113
    114    This is needed, since there can be more than one weapon on a ship. the 
    115    activation can be connected with an animation. for example the weapon is 
    116    been armed out. 
     114   This is needed, since there can be more than one weapon on a ship. the
     115   activation can be connected with an animation. for example the weapon is
     116   been armed out.
    117117*/
    118118void TestGun::activate()
     
    125125   \brief this deactivates the weapon
    126126
    127    This is needed, since there can be more than one weapon on a ship. the 
    128    activation can be connected with an animation. for example the weapon is 
     127   This is needed, since there can be more than one weapon on a ship. the
     128   activation can be connected with an animation. for example the weapon is
    129129   been armed out.
    130130*/
     
    137137/**
    138138   \brief fires the weapon
    139    
     139
    140140   this is called from the player.cc, when fire-button is been pushed
    141141   \todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
     
    149149    }
    150150
    151   Projectile* pj = dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET));
     151  Projectile* pj = dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));
    152152  weaponSource->play();
    153153
     
    157157  this->worldEntities->add(pj);
    158158  this->localTime = 0;
    159  
     159
    160160  this->animation1->replay();
    161161}
     
    170170   can destroy the weapons of enemies or vice versa.
    171171*/
    172 void TestGun::hit (WorldEntity* entity, Vector* position) 
     172void TestGun::hit (WorldEntity* entity, Vector* position)
    173173{}
    174174
     
    180180   hit, it can also be destoryed.
    181181*/
    182 void TestGun::destroy () 
     182void TestGun::destroy ()
    183183{}
    184184
     
    187187   \brief tick signal for time dependent/driven stuff
    188188*/
    189 void TestGun::tick (float time) 
     189void TestGun::tick (float time)
    190190{
    191191  this->localTime += time;
     
    203203   \brief this will draw the weapon
    204204*/
    205 void TestGun::draw () 
     205void TestGun::draw ()
    206206{
    207207  /* draw gun body */
     
    209209  glPushMatrix();
    210210  float matrix[4][4];
    211   glTranslatef (this->getAbsCoor ().x, 
    212                 this->getAbsCoor ().y,
    213                 this->getAbsCoor ().z); 
     211  glTranslatef (this->getAbsCoor ().x,
     212                this->getAbsCoor ().y,
     213                this->getAbsCoor ().z);
    214214  this->getAbsDir ().matrix (matrix);
    215215  glMultMatrixf((float*)matrix);
     
    222222  glMatrixMode(GL_MODELVIEW);
    223223  glPushMatrix();
    224   glTranslatef (this->objectComponent1->getAbsCoor ().x, 
    225                 this->objectComponent1->getAbsCoor ().y,
    226                 this->objectComponent1->getAbsCoor ().z);
     224  glTranslatef (this->objectComponent1->getAbsCoor ().x,
     225                this->objectComponent1->getAbsCoor ().y,
     226                this->objectComponent1->getAbsCoor ().z);
    227227  this->objectComponent1->getAbsDir ().matrix (matrix);
    228228  glMultMatrixf((float*)matrix);
Note: See TracChangeset for help on using the changeset viewer.