Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4597 in orxonox.OLD for orxonox


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
Files:
74 edited

Legend:

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

    r4596 r4597  
    108108
    109109
    110   // WorldEntities (range from 0x00000201 to 0x000005ff)
     110  // WorldEntities (range from 0x00000201 to 0x000004ff)
    111111  CL_CAMERA               =    0x00000201,
    112112  CL_CAMERA_TARGET        =    0x00000202,
     
    122122
    123123
    124   CL_EVENT                =    0x00000a08,
    125   CL_KEY_MAPPER           =    0x00000a09,
     124  // gamePlay (range from 0x00000500 0x000005ff)
     125  CL_EVENT                =    0x00000501,
     126  CL_KEY_MAPPER           =    0x00000502,
     127
     128  CL_WEAPON_MANAGER       =    0x00000503,
     129
     130  // Physics stuff (range from 0x00000600 to 0x000007ff)
     131  CL_PHYSICS_CONNECTION   =    0x00000601,
     132  // Collision
     133  CL_COLLISION            =    0x00000611,
     134  CL_BV_TREE              =    0x00000612,
     135  CL_BV_TREE_NODE         =    0x00000613,
     136  CL_OBB_TREE             =    0x00000614,
     137  CL_OBB_TREE_NODE        =    0x00000615,
     138  CL_BOUNDING_VOLUME      =    0x00000616,
     139  CL_OBB                  =    0x00000617,
     140  CL_BOUNDING_SPHERE      =    0x00000618,
    126141
    127142  // graphical stuff (range from 0x00000800 to 0x000009ff)
    128143  CL_TEXT                 =    0x00000801,
    129   CL_MATERIAL             =    0x00000802,
    130   CL_MODEL                =    0x00000803, //!< \todo make this a SUBCLASS maybe
    131   CL_OBJMODEL             =    0x00000804,
    132   CL_PROMITIVE_MODEL      =    0x00000805,
    133   CL_MD2Model             =    0x00000806,
    134   CL_LIGHT                =    0x00000807,
    135   CL_PARTICLE_EMITTER     =    0x00000808,
    136   CL_PARTICLE_SYSTEM      =    0x00000809,
     144  CL_FONT                 =    0x00000802,
     145  CL_MATERIAL             =    0x00000803,
     146  CL_MODEL                =    0x00000804, //!< \todo make this a SUBCLASS maybe
     147  CL_OBJMODEL             =    0x00000805,
     148  CL_PROMITIVE_MODEL      =    0x00000806,
     149  CL_MD2Model             =    0x00000807,
     150  CL_LIGHT                =    0x00000808,
     151  CL_PARTICLE_EMITTER     =    0x00000809,
     152  CL_PARTICLE_SYSTEM      =    0x0000080a,
     153  CL_ENVIRONMENT          =    0x00000810,
    137154  // GL-menu
    138155  CL_GLMENU_IMAGE_SCREEN  =    0x00000901,
    139156
    140   // Collision
    141   CL_COLLISION,
    142   CL_BV_TREE,
    143   CL_BV_TREE_NODE,
    144   CL_OBB_TREE,
    145   CL_OBB_TREE_NODE,
    146   CL_BOUNDING_VOLUME,
    147   CL_OBB,
    148   CL_BOUNDING_SPHERE,
     157  // sound stuff (range from 0x00000a00 to 0x00000aff)
     158  CL_SOUND_BUFFER         =    0x00000a01,
     159  CL_SOUND_SOURCE         =    0x00000a02,
    149160
    150   // misc: (range from 0x00000a00 to 0x00000bff)
    151   CL_ANIMATION            =    0x00000a01,
    152   //  CL_ANIMATION3D          =    0x00000a02,
    153   CL_FACTORY              =    0x00000a02,
    154   CL_INI_PARSER           =    0x00000a03,
    155   CL_LIST                 =    0x00000a04,
    156   CL_SUBSTRING            =    0x00000a05,
    157   CL_LOAD_PARAM           =    0x00000a06,
    158   CL_CURVE                =    0x00000a07,
    159   CL_VECTOR               =    0x00000a08,
    160   CL_CHARACTER_ATTRIBUTES =    0x00000a09,
    161   CL_NUMBER
     161
     162  // misc: (range from 0x00000b00 to 0x00000cff)
     163  CL_ANIMATION            =    0x00000b01,
     164  //  CL_ANIMATION3D          =    0x00000b02,
     165  CL_QUICK_ANIMATION      =    0x00000b02,
     166  CL_FACTORY              =    0x00000b03,
     167  CL_INI_PARSER           =    0x00000b04,
     168  CL_LIST                 =    0x00000b05,
     169  CL_SUBSTRING            =    0x00000b06,
     170  CL_LOAD_PARAM           =    0x00000b07,
     171  CL_CURVE                =    0x00000b08,
     172  CL_VECTOR               =    0x00000b09,
     173  CL_CHARACTER_ATTRIBUTES =    0x00000b0a,
     174  CL_TRACK_ELEMENT        =    0x00000b0b,
     175  CL_NUMBER               =    0x00000b0c
    162176};
    163177
  • orxonox/trunk/src/glmenu/glmenu_imagescreen.cc

    r4453 r4597  
    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
     
    2828using namespace std;
    2929/**
    30    \brief standard constructor
    31 */
    32 GLMenuImageScreen::GLMenuImageScreen ()
    33 {
    34    this->init();
    35 }
    36 
    37 /**
    3830   \param root The Element to load the GLMenu from
    3931*/
    4032GLMenuImageScreen::GLMenuImageScreen(const TiXmlElement* root)
    4133{
    42   this->init();
    43   this->loadParams(root);
    44 }
    45 
    46 /**
    47    \brief Loads a GLMenu from an inputElement
    48    \param root The Element to load the GLMenu from
    49 */
    50 void GLMenuImageScreen::loadParams(const TiXmlElement* root)
    51 {
    52   LoadParam<GLMenuImageScreen>(root, "BackgroundImage", this, &GLMenuImageScreen::setBackgroundImage)
    53     .describe("sets the image to load onto the loadscreen");
    54 
    55   LoadParam<GLMenuImageScreen>(root, "BackgroundPS", this, &GLMenuImageScreen::setPosScale)
    56     .describe("The Position and Scale of the Background Image in %(0-1.0). PosX, PosY, SizeX, SizeY");
    57 
    58   LoadParam<GLMenuImageScreen>(root, "BarImage", this, &GLMenuImageScreen::setBarImage)
    59     .describe("sets the image of the LoadingBar");
    60  
    61   LoadParam<GLMenuImageScreen>(root, "BarPS", this, &GLMenuImageScreen::setBarPosScale)
    62     .describe("The Position and Scale of the Loading Bar in %(0-1.0). PosX, PosY, SizeX, SizeY");
    63 
    64   LoadParam<GLMenuImageScreen>(root, "ElementCount", this, &GLMenuImageScreen::setMaximum)
    65     .describe("The Count of elements to load into the bar (this is only a maximum value)");
    66 }
    67 
    68 /**
    69    \brief standard deconstructor
    70    \todo this deconstructor is not jet implemented - do it
    71 */
    72 GLMenuImageScreen::~GLMenuImageScreen()
    73 {
    74   delete this->backMat;
    75   delete this->barMat;
    76 }
    77 
    78 /**
    79    \brief function to init the screen
    80 */
    81 void GLMenuImageScreen::init ()
    82 {
    8334  this->setClassID(CL_GLMENU_IMAGE_SCREEN, "GLMenuImageScreen");
    84 
     35  this->setName("GLMenuLoadScreen");
    8536  // Select Our VU Meter Background Texture
    8637  this->backMat = new Material("load_screen");
     
    9243  this->setBarPosScale( .6, .75, .3, .1);
    9344  // End of Background image code.
    94 }
    95 
    96 /**
     45
     46  if (root)
     47    this->loadParams(root);
     48}
     49
     50/**
     51   \brief Loads a GLMenu from an inputElement
     52   \param root The Element to load the GLMenu from
     53*/
     54void GLMenuImageScreen::loadParams(const TiXmlElement* root)
     55{
     56  LoadParam<GLMenuImageScreen>(root, "BackgroundImage", this, &GLMenuImageScreen::setBackgroundImage)
     57    .describe("sets the image to load onto the loadscreen");
     58
     59  LoadParam<GLMenuImageScreen>(root, "BackgroundPS", this, &GLMenuImageScreen::setPosScale)
     60    .describe("The Position and Scale of the Background Image in %(0-1.0). PosX, PosY, SizeX, SizeY");
     61
     62  LoadParam<GLMenuImageScreen>(root, "BarImage", this, &GLMenuImageScreen::setBarImage)
     63    .describe("sets the image of the LoadingBar");
     64
     65  LoadParam<GLMenuImageScreen>(root, "BarPS", this, &GLMenuImageScreen::setBarPosScale)
     66    .describe("The Position and Scale of the Loading Bar in %(0-1.0). PosX, PosY, SizeX, SizeY");
     67
     68  LoadParam<GLMenuImageScreen>(root, "ElementCount", this, &GLMenuImageScreen::setMaximum)
     69    .describe("The Count of elements to load into the bar (this is only a maximum value)");
     70}
     71
     72/**
     73   \brief standard deconstructor
     74   \todo this deconstructor is not jet implemented - do it
     75*/
     76GLMenuImageScreen::~GLMenuImageScreen()
     77{
     78  delete this->backMat;
     79  delete this->barMat;
     80}
     81
     82/**
    9783    \brief sets the background image name
    9884    \param backImageName name of the backgroun-image
     
    191177
    192178
    193 /** 
     179/**
    194180    \brief call this to trigger a progress event
    195    
     181
    196182    this has to redraw the progress bar and the whole image
    197183 */
     
    211197  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    212198
    213   PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n", 
    214             this->currentValue, this->maxValue);
     199  PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n",
     200            this->currentValue, this->maxValue);
    215201
    216202  /* screen size */
    217203  int screenWidth = GraphicsEngine::getInstance()->getResolutionX();
    218204  int screenHeight = GraphicsEngine::getInstance()->getResolutionY();
    219  
     205
    220206  int imageWidth = (int)(screenWidth * this->scaleX);
    221207  int imageHeight = (int)(screenHeight * this->scaleY);
     
    229215  int barW = (int)(this->barW *screenWidth);
    230216  int barH = (int)(this->barH *screenHeight);
    231  
     217
    232218  float val = (float)this->currentValue/(float)this->maxValue;
    233                  
     219
    234220  if( val > barW)
    235221    val = barW;
     
    245231  glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY);
    246232  glEnd();
    247  
     233
    248234  glDisable(GL_TEXTURE_2D);
    249235  /* draw white border */
     
    256242  glColor3f(1.0, 1.0, 1.0);
    257243  glEnd();
    258  
     244
    259245  /* draw the progress bar */
    260246  barMat->select();
     
    275261    glColor3f(1.0, 1.0, 1.0);
    276262    glEnd();
    277    
    278     /* draw black border 
     263
     264    /* draw black border
    279265    glBegin(GL_QUADS);
    280266    glColor3f(0.0, 0.0, 0.0);
     
    285271    glColor3f(1.0, 1.0, 1.0);
    286272    glEnd();
    287    
     273
    288274  */
    289275
    290276  GraphicsEngine::leave2DMode();
    291277
    292   SDL_GL_SwapBuffers();             
    293 }
    294  
    295 
     278  SDL_GL_SwapBuffers();
     279}
     280
     281
  • orxonox/trunk/src/glmenu/glmenu_imagescreen.h

    r4453 r4597  
    1 /*! 
     1/*!
    22    \file glmenu_imagescreen.h
    33    \brief class to display a LoadScreen
     
    1616
    1717 public:
    18   GLMenuImageScreen ();
    19   GLMenuImageScreen (const TiXmlElement* root);
     18  GLMenuImageScreen (const TiXmlElement* root = NULL);
    2019  void loadParams(const TiXmlElement* root);
    2120  virtual ~GLMenuImageScreen ();
    2221
    23   void init ();
     22  void draw ();
    2423
    25   void draw ();
    26  
    2724  void setBackgroundImage(const char* backImageName);
    2825  void setPosition(float offsetX, float offsetY);
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4536 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2929   \todo this constructor is not jet implemented - do it
    3030*/
    31 GraphicsEngine::GraphicsEngine ()
    32 {
     31GraphicsEngine::GraphicsEngine ()
     32{
     33  this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");
     34  this->setName("GraphicsEngine");
    3335  this->bDisplayFPS = false;
    3436  this->minFPS = 9999;
    3537  this->maxFPS = 0;
    36   this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");
    3738
    3839  this->fullscreen = false;
     
    5152   \brief destructs the graphicsEngine.
    5253*/
    53 GraphicsEngine::~GraphicsEngine () 
     54GraphicsEngine::~GraphicsEngine ()
    5455{
    5556  // delete what has to be deleted here
     
    7980  if( videoInfo == NULL)
    8081    {
    81       PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError()); 
     82      PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError());
    8283      SDL_Quit ();
    8384    }
    8485  if( videoInfo->hw_available)
    8586    this->videoFlags |= SDL_HWSURFACE;
    86   else 
     87  else
    8788    this->videoFlags |= SDL_SWSURFACE;
    8889  /*
     
    9394  // setting up the Resolution
    9495  this->setResolution(800, 600, 16);
    95  
     96
    9697  // Set window labeling
    9798  SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
    98  
     99
    99100  // TO DO: Create a cool icon and use it here
    100101  char* loadPic = new char[strlen(ResourceManager::getInstance()->getDataDir())+ 100];
    101102  sprintf(loadPic, "%s%s", ResourceManager::getInstance()->getDataDir(),  "pictures/orxonox-icon32x32.bmp");
    102   SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL); 
     103  SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL);
    103104  delete loadPic;
    104105  // Enable default GL stuff
     
    117118  //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    118119  //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    119  
    120 
    121   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );   
    122   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);   
    123   SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 
     120
     121
     122  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
     123  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
     124  SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0);
    124125  SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
    125126  SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
     
    144145  else
    145146    fullscreenFlag = 0;
    146  
     147
    147148  printf ("ok\n");
    148149  if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags | fullscreenFlag)) == NULL)
     
    195196/**
    196197   \brief entering 2D Mode
    197    
     198
    198199   this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else
    199200*/
     
    202203  GraphicsEngine::storeMatrices();
    203204  SDL_Surface *screen = SDL_GetVideoSurface();
    204  
     205
    205206  /* Note, there may be other things you need to change,
    206207     depending on how you have your OpenGL state set up.
     
    215216  glEnable(GL_BLEND);
    216217  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    217  
     218
    218219  glViewport(0, 0, screen->w, screen->h);
    219  
     220
    220221  glMatrixMode(GL_PROJECTION);
    221222  glPushMatrix();
    222223  glLoadIdentity();
    223  
     224
    224225  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
    225  
     226
    226227  glMatrixMode(GL_MODELVIEW);
    227228  glPushMatrix();
    228229  glLoadIdentity();
    229  
     230
    230231  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    231232}
     
    238239  glMatrixMode(GL_MODELVIEW);
    239240  glPopMatrix();
    240  
     241
    241242  glMatrixMode(GL_PROJECTION);
    242243  glPopMatrix();
    243  
     244
    244245  glPopAttrib();
    245246}
    246247
    247248/**
    248    \brief stores the GL_matrices 
     249   \brief stores the GL_matrices
    249250*/
    250251void GraphicsEngine::storeMatrices(void)
     
    271272  /* Get available fullscreen/hardware modes */
    272273  this->videoModes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
    273  
     274
    274275  /* Check is there are any modes available */
    275276  if(this->videoModes == (SDL_Rect **)0){
     
    277278    exit(-1);
    278279  }
    279  
     280
    280281  /* Check if our resolution is restricted */
    281282  if(this->videoModes == (SDL_Rect **)-1){
     
    301302      if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
    302303      if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
    303      
     304
    304305#ifndef NO_TEXT
    305306      char tmpChar1[20];
     
    315316    }
    316317}
    317  
     318
    318319/**
    319320   \brief displays the Frames per second
     
    335336      this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0);
    336337      this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
    337       this->geTextMinFPS->setPosition(5, 560); 
     338      this->geTextMinFPS->setPosition(5, 560);
    338339#endif /* NO_TEXT */
    339340    }
     
    341342}
    342343
    343  
     344
  • orxonox/trunk/src/lib/graphics/light.cc

    r4519 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    3636{
    3737  this->setClassID(CL_LIGHT, "Light");
    38   char tmpName[7];
    39   sprintf(tmpName, "Light%d", lightNumber);
     38  char tmpName[10];
     39  sprintf(tmpName, "Light[%d]", lightNumber);
    4040  this->setName(tmpName);
    4141
     
    4343  // enable The light
    4444  glEnable(lightsV[lightNumber]); // postSpawn
    45  
     45
    4646  // set values (defaults)
    4747  this->lightNumber = lightNumber;
     
    179179/**
    180180   \brief draws this Light. Being a World-entity the possibility to do this lies at hand.
    181 */ 
     181*/
    182182void Light::draw()
    183183{
     
    195195  PRINT(0)(":: %d ::  -- reference %p\n", this->lightNumber, this);
    196196  PRINT(0)(" GL-state: ");
    197   GLboolean param; 
     197  GLboolean param;
    198198  glGetBooleanv(lightsV[this->lightNumber], &param);
    199199  if (param)
     
    201201  else
    202202    PRINT(0)("OFF\n");
    203  
     203
    204204  PRINT(0)(" Position:      %f/%f/%f\n", this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]);
    205205  PRINT(0)(" DiffuseColor:  %f/%f/%f\n", this->diffuseColor[0], this->diffuseColor[1], this->diffuseColor[2]);
     
    215215   \brief standard constructor for a Light
    216216*/
    217 LightManager::LightManager () 
     217LightManager::LightManager ()
    218218{
    219219  this->setClassID(CL_LIGHT_MANAGER, "LightManager");
     
    229229/**
    230230   \brief standard deconstructor
    231    
     231
    232232   first disables Lighting
    233233
     
    235235   and in the end sets the singleton Reference to zero.
    236236*/
    237 LightManager::~LightManager () 
     237LightManager::~LightManager ()
    238238{
    239239  glDisable(GL_LIGHTING);
    240  
     240
    241241  // this will be done either by worldEntity, or by pNode as each light is one of them
    242242  //  for (int i = 0; i < NUMBEROFLIGHTS; i++)
     
    270270  for (int i = 0; i < NUMBEROFLIGHTS; i++)
    271271    if (!this->lights[i])
    272       return addLight(i); 
     272      return addLight(i);
    273273  PRINTF(1)("no more light slots availiable. All %d already taken\n", NUMBEROFLIGHTS);
    274274  return -1;
     
    302302{
    303303  if (!this->currentLight)
    304     { 
     304    {
    305305      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    306306      return;
     
    316316{
    317317  if (!this->currentLight)
    318     { 
     318    {
    319319      PRINTF(1)("no Light defined yet. So you cannot delete any Light right now.\n");
    320320      return;
     
    392392{
    393393  if (!this->currentLight)
    394     { 
     394    {
    395395      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    396396      return;
     
    409409{
    410410  if (!this->currentLight)
    411     { 
     411    {
    412412      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    413413      return;
     
    426426{
    427427  if (!this->currentLight)
    428     { 
     428    {
    429429      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    430430      return;
     
    443443{
    444444  if (!this->currentLight)
    445     { 
     445    {
    446446      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    447447      return;
     
    458458{
    459459  if (!this->currentLight)
    460     { 
     460    {
    461461      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    462462      return;
     
    473473{
    474474  if (!this->currentLight)
    475     { 
     475    {
    476476      PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");
    477477      return;
     
    488488{
    489489  if (!this->currentLight)
    490     { 
     490    {
    491491      PRINTF(2)("no Light defined yet\n");
    492492      return Vector(.0, .0, .0);
     
    498498
    499499/**
    500    \returns the Position of Light 
     500   \returns the Position of Light
    501501   \param lightNumber lightnumber
    502502*/
     
    539539    if (this->lights[i])
    540540      {
    541         this->lights[i]->debug();
     541        this->lights[i]->debug();
    542542      }
    543543  PRINT(0)("--------------------------------\n");
  • orxonox/trunk/src/lib/graphics/text_engine.cc

    r4537 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1616
    1717   !! IMPORTANT !! When using ttf fonts clear the license issues prior to
    18    adding them to orxonox. This is really important, because we do not 
     18   adding them to orxonox. This is really important, because we do not
    1919   want to offend anyone.
    2020*/
     
    4646   \param type The renderType to display this font in
    4747
    48    this constructor is private, because the user should initialize 
     48   this constructor is private, because the user should initialize
    4949   a text with the TextEngine.
    5050*/
     
    6868/**
    6969   \brief deletes a Text out of memory
    70    
     70
    7171   This also ereases the text from the textList of the TextEngine
    7272*/
     
    117117      char* tmpText = this->text;
    118118      while (*tmpText != '\0')
    119         {
    120           if(glyphArray[*tmpText])
    121             {
    122               width += glyphArray[*tmpText]->width;
    123             }
    124           tmpText++;
    125         }
     119        {
     120          if(glyphArray[*tmpText])
     121            {
     122              width += glyphArray[*tmpText]->width;
     123            }
     124          tmpText++;
     125        }
    126126      this->posSize.w = width;
    127127    }
     
    174174  if (likely(this->font != NULL))
    175175    tmpSurf = TTF_RenderText_Blended(this->font->font,
    176                                      this->text,
    177                                      this->color);
     176                                     this->text,
     177                                     this->color);
    178178  if (tmpSurf)
    179179    this->texture = loadTexture(tmpSurf, &this->texCoord);
     
    208208      pos.z = tmp[2];
    209209    }
    210   else 
     210  else
    211211    {
    212212      pos.x = this->posSize.x;
     
    232232      glEnable(GL_TEXTURE_2D);
    233233      glBegin(GL_QUADS);
    234      
     234
    235235      glTexCoord2f(this->texCoord.minU, this->texCoord.minV);
    236236      glVertex2f(pos.x,   pos.y  );
    237      
     237
    238238      glTexCoord2f(this->texCoord.maxU, this->texCoord.minV);
    239239      glVertex2f(pos.x + this->posSize.w, pos.y  );
    240      
     240
    241241      glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV);
    242242      glVertex2f(pos.x + this->posSize.w, pos.y + this->posSize.h);
    243      
     243
    244244      glTexCoord2f(this->texCoord.minU, this->texCoord.maxV);
    245245      glVertex2f(pos.x, pos.y + this->posSize.h);
    246      
     246
    247247      glEnd();
    248248    }
     
    257257      char* tmpText = this->text;
    258258      while (*tmpText != '\0')
    259         {
    260           if(glyphArray[*tmpText])
    261             {
    262               glCallList(glyphArray[*tmpText]->displayList);
    263               glTranslatef(glyphArray[*tmpText]->width, 0, 0);
    264             }
    265           tmpText++;
    266         }
     259        {
     260          if(glyphArray[*tmpText])
     261            {
     262              glCallList(glyphArray[*tmpText]->displayList);
     263              glTranslatef(glyphArray[*tmpText]->width, 0, 0);
     264            }
     265          tmpText++;
     266        }
    267267    }
    268268  glPopMatrix();
     
    299299  Uint32 saved_flags;
    300300  Uint8  saved_alpha;
    301  
     301
    302302  /* Use the surface width and height expanded to powers of 2 */
    303303  w = powerOfTwo(surface->w);
     
    311311    }
    312312  image = SDL_CreateRGBSurface(SDL_SWSURFACE,
    313                                w, h,
    314                                32,
     313                               w, h,
     314                               32,
    315315#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    316                                0x000000FF,
    317                                0x0000FF00,
    318                                0x00FF0000,
    319                                0xFF000000
     316                               0x000000FF,
     317                               0x0000FF00,
     318                               0x00FF0000,
     319                               0xFF000000
    320320#else
    321                                0xFF000000,
    322                                0x00FF0000,
    323                                0x0000FF00,
    324                                0x000000FF
     321                               0xFF000000,
     322                               0x00FF0000,
     323                               0x0000FF00,
     324                               0x000000FF
    325325#endif
    326                                );
     326                               );
    327327  if ( image == NULL ) {
    328328    return 0;
    329329  }
    330  
     330
    331331  /* Save the alpha blending attributes */
    332332  saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
     
    335335    SDL_SetAlpha(surface, 0, 0);
    336336  }
    337  
     337
    338338  /* Copy the surface into the GL texture image */
    339339  area.x = 0;
     
    342342  area.h = surface->h;
    343343  SDL_BlitSurface(surface, &area, image, &area);
    344  
     344
    345345  /* Restore the alpha blending attributes */
    346346  if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
    347347    SDL_SetAlpha(surface, saved_flags, saved_alpha);
    348348  }
    349  
     349
    350350  /* Create an OpenGL texture for the image */
    351351  glGenTextures(1, &texture);
     
    354354  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    355355  glTexImage2D(GL_TEXTURE_2D,
    356                0,
    357                GL_RGBA,
    358                w, h,
    359                0,
    360                GL_RGBA,
    361                GL_UNSIGNED_BYTE,
    362                image->pixels);
     356               0,
     357               GL_RGBA,
     358               w, h,
     359               0,
     360               GL_RGBA,
     361               GL_UNSIGNED_BYTE,
     362               image->pixels);
    363363  SDL_FreeSurface(image); /* No longer needed */
    364  
     364
    365365  return texture;
    366366}
    367367
    368368/**
    369    \brief Quick utility function for texture creation 
     369   \brief Quick utility function for texture creation
    370370   \param input an integer
    371371   \returns the next bigger 2^n-integer than input
     
    374374{
    375375  int value = 1;
    376  
     376
    377377  while ( value < input ) {
    378378    value <<= 1;
     
    395395Font::Font(const char* fontFile, unsigned int fontSize, Uint8 r, Uint8 g, Uint8 b)
    396396{
     397  this->setClassID(CL_FONT, "Font");
    397398  // setting default values.
    398399  this->font = NULL;
    399400  this->fontFile = NULL;
    400401  this->glyphArray = NULL;
    401   this->fastTextureID = 0; 
    402  
     402  this->fastTextureID = 0;
     403
    403404  this->setSize(fontSize);
    404405
     
    423424    {
    424425      for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
    425         delete this->glyphArray[i];
     426        delete this->glyphArray[i];
    426427      delete []this->glyphArray;
    427428    }
     
    441442  if (!this->fontFile)
    442443    {
     444      this->setName(fontFile);
    443445      this->fontFile = new char[strlen(fontFile)+1];
    444446      strcpy(this->fontFile, fontFile);
    445      
     447
    446448      this->font = TTF_OpenFont(this->fontFile, this->fontSize);
    447449      if(!this->font)
    448         {
    449           PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
    450           return false;
    451         }
     450        {
     451          PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
     452          return false;
     453        }
    452454      else
    453           return true;
     455          return true;
    454456    }
    455457  else
     
    468470{
    469471  this->renderStyle = TTF_STYLE_NORMAL;
    470  
     472
    471473  for (int i = 0; i < strlen(renderStyle); i++)
    472     if (strncmp(renderStyle+i, "b", 1) == 0) 
     474    if (strncmp(renderStyle+i, "b", 1) == 0)
    473475      this->renderStyle |= TTF_STYLE_BOLD;
    474476    else if (strncmp(renderStyle+i, "i", 1) == 0)
    475477      this->renderStyle |= TTF_STYLE_ITALIC;
    476     else if (strncmp(renderStyle+i, "u", 1) == 0) 
     478    else if (strncmp(renderStyle+i, "u", 1) == 0)
    477479      this->renderStyle |= TTF_STYLE_UNDERLINE;
    478480
     
    547549   and MUST be deleted by the user..
    548550
    549    This only works for horizontal fonts. see 
     551   This only works for horizontal fonts. see
    550552   http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
    551553   for more info about vertical Fonts
     
    557559  if (likely (this->font!= NULL))
    558560    TTF_GlyphMetrics(this->font, rg->character,
    559                      &rg->minX, &rg->maxX,
    560                      &rg->minY, &rg->maxY,
    561                      &rg->advance);
     561                     &rg->minX, &rg->maxX,
     562                     &rg->minY, &rg->maxY,
     563                     &rg->advance);
    562564  rg->height = rg->maxY - rg->minY;
    563565  rg->width = rg->maxX - rg->minX;
     
    569571GLuint Font::createFastTexture(void)
    570572{
    571   /* interesting GLYPHS: 
     573  /* interesting GLYPHS:
    572574   *  32: space
    573575   *  33-47: Special Characters.
     
    589591  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
    590592  SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(SDL_SWSURFACE,
    591                                                rectSize, rectSize,
    592                                                32,
     593                                               rectSize, rectSize,
     594                                               32,
    593595#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    594                                                0x000000FF,
    595                                                0x0000FF00,
    596                                                0x00FF0000,
    597                                                0xFF000000
     596                                               0x000000FF,
     597                                               0x0000FF00,
     598                                               0x00FF0000,
     599                                               0xFF000000
    598600#else
    599                                                0xFF000000,
    600                                                0x00FF0000,
    601                                                0x0000FF00,
    602                                                0x000000FF
     601                                               0xFF000000,
     602                                               0x00FF0000,
     603                                               0x0000FF00,
     604                                               0x000000FF
    603605#endif
    604                                                );
     606                                               );
    605607  tmpRect.x = 0; tmpRect.y = 0; tmpRect.w = tmpSurf->w; tmpRect.h = tmpSurf->h;
    606608  SDL_SetClipRect(tmpSurf, &tmpRect);
     
    614616
    615617      if (tmpGlyph = this->glyphArray[i])
    616         {
    617           if (tmpGlyph->height > maxLineHeight)
    618             maxLineHeight = tmpGlyph->height;
    619          
    620           if (tmpRect.x+tmpGlyph->width > tmpSurf->w)
    621             {
    622               tmpRect.x = 0;
    623               tmpRect.y = tmpRect.y + maxLineHeight + 1;
    624               maxLineHeight = 0;
    625             }
    626           if (tmpRect.y + maxLineHeight > tmpSurf->h)
    627             {
    628               PRINTF(1)("Protection, so font cannot write over the boundraries error (this should not heappen\n");
    629               break;
    630             }
    631           // reading in the new Glyph
    632           if (likely(this->font != NULL))
    633             glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor);
    634           if( glyphSurf != NULL )
    635             {
    636 
    637               SDL_SetAlpha(glyphSurf, 0, 0);
    638 
    639               SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
    640               TexCoord tmpTexCoord;
    641               tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
    642               tmpTexCoord.maxU = (float)(tmpRect.x+tmpGlyph->width)/(float)tmpSurf->w;
    643               tmpTexCoord.minV = (float)tmpRect.y/(float)tmpSurf->w;
    644               tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
    645               tmpGlyph->displayList = glGenLists(1);
    646 
    647               glNewList(tmpGlyph->displayList, GL_COMPILE);
    648               glBegin(GL_QUADS);
    649               glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV);
    650               glVertex2d(0, 0);
    651               glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
    652               glVertex2d(0, tmpGlyph->height);
    653               glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
    654               glVertex2d(tmpGlyph->width, tmpGlyph->height);
    655               glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
    656               glVertex2d(tmpGlyph->width, 0);
    657               glEnd();
    658               glEndList();
    659               SDL_FreeSurface(glyphSurf);
    660 
    661               tmpRect.x += tmpGlyph->width + 1;
    662 
    663               // Outputting Glyphs to BMP-files.
    664               /*
    665                 char outname[64];
    666                 if (i < 10)
    667                 sprintf( outname, "glyph-00%d.bmp", i );
    668                 else if (i <100)
    669                 sprintf( outname, "glyph-0%d.bmp", i );
    670                 else
    671                 sprintf( outname, "glyph-%d.bmp", i );
    672                 SDL_SaveBMP(tmpSurf, outname);
    673               */
    674             }
    675         }
     618        {
     619          if (tmpGlyph->height > maxLineHeight)
     620            maxLineHeight = tmpGlyph->height;
     621
     622          if (tmpRect.x+tmpGlyph->width > tmpSurf->w)
     623            {
     624              tmpRect.x = 0;
     625              tmpRect.y = tmpRect.y + maxLineHeight + 1;
     626              maxLineHeight = 0;
     627            }
     628          if (tmpRect.y + maxLineHeight > tmpSurf->h)
     629            {
     630              PRINTF(1)("Protection, so font cannot write over the boundraries error (this should not heappen\n");
     631              break;
     632            }
     633          // reading in the new Glyph
     634          if (likely(this->font != NULL))
     635            glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor);
     636          if( glyphSurf != NULL )
     637            {
     638
     639              SDL_SetAlpha(glyphSurf, 0, 0);
     640
     641              SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
     642              TexCoord tmpTexCoord;
     643              tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
     644              tmpTexCoord.maxU = (float)(tmpRect.x+tmpGlyph->width)/(float)tmpSurf->w;
     645              tmpTexCoord.minV = (float)tmpRect.y/(float)tmpSurf->w;
     646              tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
     647              tmpGlyph->displayList = glGenLists(1);
     648
     649              glNewList(tmpGlyph->displayList, GL_COMPILE);
     650              glBegin(GL_QUADS);
     651              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV);
     652              glVertex2d(0, 0);
     653              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
     654              glVertex2d(0, tmpGlyph->height);
     655              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
     656              glVertex2d(tmpGlyph->width, tmpGlyph->height);
     657              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
     658              glVertex2d(tmpGlyph->width, 0);
     659              glEnd();
     660              glEndList();
     661              SDL_FreeSurface(glyphSurf);
     662
     663              tmpRect.x += tmpGlyph->width + 1;
     664
     665              // Outputting Glyphs to BMP-files.
     666              /*
     667                char outname[64];
     668                if (i < 10)
     669                sprintf( outname, "glyph-00%d.bmp", i );
     670                else if (i <100)
     671                sprintf( outname, "glyph-0%d.bmp", i );
     672                else
     673                sprintf( outname, "glyph-%d.bmp", i );
     674                SDL_SaveBMP(tmpSurf, outname);
     675              */
     676            }
     677        }
    676678    }
    677679
     
    682684  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    683685  glTexImage2D(GL_TEXTURE_2D,
    684                0,
    685                GL_RGBA,
    686                tmpSurf->w, tmpSurf->h,
    687                0,
    688                GL_RGBA,
    689                GL_UNSIGNED_BYTE,
    690                tmpSurf->pixels);
     686               0,
     687               GL_RGBA,
     688               tmpSurf->w, tmpSurf->h,
     689               0,
     690               GL_RGBA,
     691               GL_UNSIGNED_BYTE,
     692               tmpSurf->pixels);
    691693  SDL_FreeSurface(tmpSurf);
    692694  return texture;
     
    707709      this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR];
    708710      for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
    709         this->glyphArray[i] = NULL;
    710     }
    711  
     711        this->glyphArray[i] = NULL;
     712    }
     713
    712714  Uint16 lastGlyph = from + count;
    713  
     715
    714716  for (int i = from; i <= lastGlyph; i++)
    715717    {
     
    723725   \returns the optimal size to use as the texture size
    724726
    725    \todo: this algorithm can be a lot more faster, althought it does 
     727   \todo: this algorithm can be a lot more faster, althought it does
    726728   not really matter within the init-context, and 128 glyphs.
    727729
    728    This function searches for a 2^n sizes texture-size, this is for 
     730   This function searches for a 2^n sizes texture-size, this is for
    729731   openGL-version < 1.2 compatibility ( and because it is realy easy like this :))
    730732*/
     
    743745      maxLineHeight = 0;
    744746      for (i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
    745         {
    746           if(tmpGlyph = this->glyphArray[i])
    747             {
    748               // getting the height of the highest Glyph in the Line.
    749               if (tmpGlyph->height > maxLineHeight)
    750                 maxLineHeight = tmpGlyph->height;
    751 
    752               if (x + tmpGlyph->width > size)
    753                 {
    754                   x = 0;
    755                   y = y + maxLineHeight;
    756                   maxLineHeight = 0;
    757                 }
    758               if (y + maxLineHeight + 1 > size)
    759                 break;
    760               x += tmpGlyph->width + 1;
    761 
    762             }
    763         }
     747        {
     748          if(tmpGlyph = this->glyphArray[i])
     749            {
     750              // getting the height of the highest Glyph in the Line.
     751              if (tmpGlyph->height > maxLineHeight)
     752                maxLineHeight = tmpGlyph->height;
     753
     754              if (x + tmpGlyph->width > size)
     755                {
     756                  x = 0;
     757                  y = y + maxLineHeight;
     758                  maxLineHeight = 0;
     759                }
     760              if (y + maxLineHeight + 1 > size)
     761                break;
     762              x += tmpGlyph->width + 1;
     763
     764            }
     765        }
    764766      if (i == FONT_HIGHEST_KNOWN_CHAR)
    765         sizeOK = true;
     767        sizeOK = true;
    766768      else
    767         size *= 2;
     769        size *= 2;
    768770    }
    769771  return size;
     
    801803   \brief standard constructor
    802804*/
    803 TextEngine::TextEngine () 
     805TextEngine::TextEngine ()
    804806{
    805807   this->setClassID(CL_TEXT_ENGINE, "TextEngine");
     808   this->setName("TextEngine");
    806809   this->enableFonts();
    807810
     
    818821
    819822*/
    820 TextEngine::~TextEngine () 
     823TextEngine::~TextEngine ()
    821824{
    822825  this->disableFonts();
    823  
     826
    824827  delete this->textList;
    825828
     
    835838    {
    836839      if(TTF_Init()==-1)
    837         PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
     840        PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
    838841
    839842      TextEngine::checkVersion();
     
    932935/**
    933936   \brief outputs some nice Debug information
    934    
     937
    935938   \todo there should also be something outputted about Font
    936939*/
     
    941944  PRINT(0)("+-------------------------------+\n");
    942945  PRINT(0)("Reference: %p; Text Counts: %d\n", this, this->textList->getSize());
    943  
     946
    944947  tIterator<Text>* textIterator = textList->getIterator();
    945948  Text* text = textIterator->nextElement();
     
    973976  else
    974977    {
    975       PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n", 
    976                 compile_version.major,
    977                 compile_version.minor,
    978                 compile_version.patch);
    979      
    980       PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n", 
    981                 link_version.major,
    982                 link_version.minor,
    983                 link_version.patch);
     978      PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
     979                compile_version.major,
     980                compile_version.minor,
     981                compile_version.patch);
     982
     983      PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
     984                link_version.major,
     985                link_version.minor,
     986                link_version.patch);
    984987      return false;
    985988    }
  • orxonox/trunk/src/lib/graphics/text_engine.h

    r4536 r4597  
    1 /*! 
     1/*!
    22    \file text_engine.h
    33    \brief Definition of textEngine, the Font and the Text
     
    3030
    3131//! An enumerator for the text alignment.
    32 enum TEXT_ALIGNMENT { TEXT_ALIGN_LEFT,
    33                       TEXT_ALIGN_RIGHT,
    34                       TEXT_ALIGN_CENTER,
    35                       TEXT_ALIGN_SCREEN_CENTER };
     32 enum TEXT_ALIGNMENT
     33{
     34  TEXT_ALIGN_LEFT,
     35  TEXT_ALIGN_RIGHT,
     36  TEXT_ALIGN_CENTER,
     37  TEXT_ALIGN_SCREEN_CENTER
     38};
    3639
    3740/* some default values */
    3841#define FONT_DEFAULT_SIZE       50                   //!< default size of the Text
    39 #define FONT_DEFAULT_TEXT       "orxonox 1234567890" //!< default text to display
     42#define FONT_DEFAULT_TEXT       "orxonox 1234567890" //!< default text to display
    4043#define FONT_DEFAULT_COLOR_R    255                  //!< default red part (color) of the text
    4144#define FONT_DEFAULT_COLOR_G    255                  //!< default red green (color) of the text
     
    8689  int      bearingY;          //!< How much is above the Origin
    8790  int      advance;           //!< How big a Glyph would be in monospace-mode
    88  
     91
    8992  // OpenGL-specific
    9093  //  TexCoord texCoord;      //!< A Texture Coordinate for this glyph.
     
    117120
    118121  void draw(void) const;
    119  
     122
    120123  void debug(void) const;
    121124
    122125 private:
    123126  Text(Font* font, int type = TEXT_DYNAMIC);
    124  
     127
    125128  static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
    126129  static int powerOfTwo(int input);
     
    139142  TexCoord          texCoord;       //!< Texture-coordinates \todo fix this to have a struct
    140143  SDL_Rect          posSize;        //!< An SDL-Rectangle representing the position and size of the Text on the screen.
    141  
     144
    142145  PNode*            bindNode;       //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.)
    143146};
     
    147150////////////
    148151//! A class to handle a Font of a certain ttf-File, Size and Color.
    149 class Font
     152class Font : public BaseObject
    150153{
    151154  friend class Text;
     
    170173  /** \returns the texture to the fast-texture */
    171174  inline GLuint getFastTextureID(void) const {return fastTextureID;}
    172  
     175
    173176 private:
    174177  int getMaxHeight(void);
     
    193196  unsigned int  fontSize;            //!< The size of the font in pixels. each Font has one size.
    194197  int           renderStyle;         //!< The Renderstyle
    195  
     198
    196199  Glyph**       glyphArray;          //!< An Array of all the Glyphs stored in the Array of Glyphs.
    197200  GLuint        fastTextureID;       //!< The fast textureID.
     
    205208///////////////////
    206209//! A singleton Class that operates as a Handler for generating and rendering Text in 2D
    207 class TextEngine : public BaseObject 
     210class TextEngine : public BaseObject
    208211{
    209212 public:
     
    213216
    214217  Text* createText(const char* fontFile,
    215                    unsigned int fontSize = FONT_DEFAULT_SIZE,
    216                    int textType = TEXT_DYNAMIC,
    217                    Uint8 r = FONT_DEFAULT_COLOR_R,
    218                    Uint8 g = FONT_DEFAULT_COLOR_G,
    219                    Uint8 b = FONT_DEFAULT_COLOR_B);
    220  
     218                   unsigned int fontSize = FONT_DEFAULT_SIZE,
     219                   int textType = TEXT_DYNAMIC,
     220                   Uint8 r = FONT_DEFAULT_COLOR_R,
     221                   Uint8 g = FONT_DEFAULT_COLOR_G,
     222                   Uint8 b = FONT_DEFAULT_COLOR_B);
     223
    221224  void deleteText(Text* text);
    222225  void flush(void);
    223226
    224227  void draw(void) const;
    225  
     228
    226229  void debug(void) const;
    227230
  • orxonox/trunk/src/lib/math/curve.h

    r4472 r4597  
    11
    2 /*! 
     2/*!
    33    \file curve.h
    44    \brief A basic 3D curve framework
    5    
     5
    66    Contains classes to handle curves
    7 */ 
     7*/
    88
    99#ifndef _CURVE_H
     
    4949  /** \param t the value on the curve [0-1] \returns quaternion of the rotation */
    5050  virtual Quaternion calcQuat(float t) = 0;
    51  
     51
    5252  // DEBUG
    5353  void debug(void);
     
    8686  virtual Vector calcAcc(float t);
    8787  virtual Quaternion calcQuat(float t);
    88  
    89  
     88
     89
    9090  Vector getPos(void) const;
    9191
  • orxonox/trunk/src/lib/particles/particle_emitter.cc

    r4496 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3131   \brief standard constructor
    3232*/
    33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
    34                   float velocity)
    35 {
     33ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
     34                  float velocity)
     35{
     36  this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter");
    3637  this->type = EMITTER_DOT;
    3738  this->emitterSize = 1.0;
     
    6465   removes the EmitterSystem from the ParticleEngine
    6566*/
    66 ParticleEmitter::~ParticleEmitter () 
     67ParticleEmitter::~ParticleEmitter ()
    6768{
    6869  ParticleEngine::getInstance()->removeEmitter(this);
     
    9192  LoadParam<ParticleEmitter>(root, "emission-velocity", this, &ParticleEmitter::setEmissionVelocity)
    9293    .describe("How fast the particles are emittet (their initial speed)");
    93  
     94
    9495  LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread)
    9596    .describe("The angle the particles are emitted from (angle, deviation)");
     
    224225    float count = (dt+this->saveTime) * this->emissionRate;
    225226    this->saveTime = modff(count, &count) / this->emissionRate;
    226     PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 
    227    
     227    PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime);
     228
    228229    if (likely(count > 0))
    229230      {
    230         Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    231         for (int i = 0; i < count; i++)
    232           // emmits from EMITTER_DOT,
    233           {
    234             Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    235             randDir.normalize();
    236             randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
    237             Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    238 
    239             // this should spread the Particles evenly. if the Emitter is moved around quickly
    240             Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt;
    241             Vector extension; // the Vector for different fields.
    242 
    243             if (this->type & 2)
    244               {
    245                 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5));
    246                 extension = this->getAbsDir().apply(extension);
    247               }
    248             else if (this->type & 8)
    249               {
    250                 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize;
    251               }
    252 
    253             system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV);
    254            
    255           }
     231        Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
     232        for (int i = 0; i < count; i++)
     233          // emmits from EMITTER_DOT,
     234          {
     235            Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
     236            randDir.normalize();
     237            randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
     238            Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
     239
     240            // this should spread the Particles evenly. if the Emitter is moved around quickly
     241            Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt;
     242            Vector extension; // the Vector for different fields.
     243
     244            if (this->type & 2)
     245              {
     246                extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5));
     247                extension = this->getAbsDir().apply(extension);
     248              }
     249            else if (this->type & 8)
     250              {
     251                extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize;
     252              }
     253
     254            system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV);
     255
     256          }
    256257      }
    257258  }
  • orxonox/trunk/src/lib/particles/particle_emitter.h

    r4493 r4597  
    1 /*! 
     1/*!
    22    \file particle_emitter.h
    33    \brief Definition of a ParticleEmitter
     
    99#include "p_node.h"
    1010
    11 // FORWARD DEFINITION 
     11// FORWARD DEFINITION
    1212class ParticleSystem;
    1313class TiXmlElement;
    1414
    1515//! The form of the Emitter to emit from
    16 typedef enum EMITTER_TYPE { EMITTER_DOT   = 1,
    17                             EMITTER_PLANE = 2,
    18                             EMITTER_SPHERE= 4,
    19                             EMITTER_CUBE  = 8 };
     16  typedef enum EMITTER_TYPE
     17{
     18  EMITTER_DOT     = 1,
     19  EMITTER_PLANE   = 2,
     20  EMITTER_SPHERE  = 4,
     21  EMITTER_CUBE    = 8
     22};
    2023
    2124//! A class to handle an Emitter.
     
    2427 public:
    2528  ParticleEmitter(const Vector& direction, float angle = .5,
    26                   float emissionRate = 1.0, float velocity = 1.0);
     29                  float emissionRate = 1.0, float velocity = 1.0);
    2730  ParticleEmitter(const TiXmlElement* root);
    2831  virtual ~ParticleEmitter(void);
    29  
     32
    3033  void loadParams(const TiXmlElement* root);
    3134
  • orxonox/trunk/src/lib/particles/particle_engine.cc

    r4519 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3030   \brief standard constructor
    3131*/
    32 ParticleEngine::ParticleEngine () 
     32ParticleEngine::ParticleEngine ()
    3333{
    3434   this->setClassID(CL_PARTICLE_ENGINE, "ParticleEngine");
     35   this->setName("ParticleEngine");
    3536
    3637   this->systemList = new tList<ParticleSystem>;
     
    4748   \brief deletes all the system, emitters, connections and Lists
    4849*/
    49 ParticleEngine::~ParticleEngine () 
     50ParticleEngine::~ParticleEngine ()
    5051{
    5152  // delete all remaining systems
     
    113114    {
    114115      if (tmpConnection->emitter == emitter && tmpConnection->system == system)
    115         {
    116           PRINTF(2)("Connection between Emitter and System already added\n");
    117           delete tmpConIt;
    118           return;
    119         }
    120      
     116        {
     117          PRINTF(2)("Connection between Emitter and System already added\n");
     118          delete tmpConIt;
     119          return;
     120        }
     121
    121122      tmpConnection = tmpConIt->nextElement();
    122123    }
    123124  delete tmpConIt;
    124  
     125
    125126
    126127
     
    144145    {
    145146      if (tmpConnection->system == system)
    146         this->breakConnection(tmpConnection);
     147        this->breakConnection(tmpConnection);
    147148      tmpConnection = tmpConIt->nextElement();
    148149    }
     
    165166    {
    166167      if (tmpConnection->emitter == emitter)
    167         this->breakConnection(tmpConnection);
     168        this->breakConnection(tmpConnection);
    168169      tmpConnection = tmpConIt->nextElement();
    169170    }
     
    191192    if (tmpConnection->emitter == emitter && tmpConnection->system == system)
    192193      {
    193         this->breakConnection(tmpConnection);
    194         delete tmpConIt;
    195         return true;
     194        this->breakConnection(tmpConnection);
     195        delete tmpConIt;
     196        return true;
    196197      }
    197198    tmpConnection = tmpConIt->nextElement();
     
    268269    {
    269270      if (!strcmp(systemName, tmpSys->getName()))
    270         {
    271           delete tmpIt;
    272           return tmpSys;
    273         }
     271        {
     272          delete tmpIt;
     273          return tmpSys;
     274        }
    274275      tmpSys = tmpIt->nextElement();
    275276    }
     
    291292      count++;
    292293      if ( count == number)
    293         {
    294           delete tmpIt;
    295           return tmpSys;
    296         }
     294        {
     295          delete tmpIt;
     296          return tmpSys;
     297        }
    297298      tmpSys = tmpIt->nextElement();
    298299    }
     
    312313    {
    313314      if (!strcmp(emitterName, tmpEmit->getName()))
    314         {
    315           delete tmpIt;
    316           return tmpEmit;
    317         }
     315        {
     316          delete tmpIt;
     317          return tmpEmit;
     318        }
    318319      tmpEmit = tmpIt->nextElement();
    319320    }
     
    336337      count++;
    337338      if ( count == number)
    338         {
    339           delete tmpIt;
    340           return tmpEmit;
    341         }
     339        {
     340          delete tmpIt;
     341          return tmpEmit;
     342        }
    342343      tmpEmit = tmpIt->nextElement();
    343344    }
     
    356357  PRINT(0)(" Reference: %p\n", ParticleEngine::singletonRef);
    357358  PRINT(0)(" Count: Emitters: %d; Systems: %d, Connections: %d\n",
    358             this->emitterList->getSize(), this->systemList->getSize(), this->connectionList->getSize());
     359            this->emitterList->getSize(), this->systemList->getSize(), this->connectionList->getSize());
    359360  if (this->connectionList->getSize() > 0)
    360361    {
     
    365366      ParticleConnection* tmpConnection = tmpConIt->nextElement();
    366367      while(tmpConnection)
    367         {
    368           PRINT(0)(" Emitter '%s' emitts into System '%s'\n", tmpConnection->emitter->getName(), tmpConnection->system->getName());
    369           tmpConnection = tmpConIt->nextElement();
    370         }
     368        {
     369          PRINT(0)(" Emitter '%s' emitts into System '%s'\n", tmpConnection->emitter->getName(), tmpConnection->system->getName());
     370          tmpConnection = tmpConIt->nextElement();
     371        }
    371372      delete tmpConIt;
    372373    }
     
    376377      ParticleSystem* tmpSys = tmpIt->nextElement();
    377378      while(tmpSys)
    378         {
    379           tmpSys->debug();
    380           tmpSys = tmpIt->nextElement();
    381         }
     379        {
     380          tmpSys->debug();
     381          tmpSys = tmpIt->nextElement();
     382        }
    382383      delete tmpIt;
    383384    }
  • orxonox/trunk/src/lib/particles/particle_system.cc

    r4515 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    4141{
    4242  this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem");
     43
    4344  this->material = NULL;
    4445  this->maxCount = maxCount;
     
    125126/**
    126127   \brief Sets the lifespan of newly created particles
    127 */   
     128*/
    128129void ParticleSystem::setLifeSpan(float lifeSpan, float randomLifeSpan)
    129130{
     
    197198{
    198199  Particle* tickPart = particles;  // the particle to Tick
    199   Particle* prevPart = NULL;       // 
     200  Particle* prevPart = NULL;       //
    200201  while (likely(tickPart != NULL))
    201202    {
    202203      // applying force to the System.
    203204      if (likely (tickPart->mass > 0.0))
    204         tickPart->velocity += tickPart->extForce / tickPart->mass * dt;
     205        tickPart->velocity += tickPart->extForce / tickPart->mass * dt;
    205206
    206207      // rendering new position.
    207208      tickPart->position = tickPart->position + tickPart->velocity * dt;
    208209      tickPart->radius = radiusAnim.getValue(tickPart->lifeCycle)
    209         + randRadiusAnim.getValue(tickPart->lifeCycle) * tickPart->radiusRand;
     210        + randRadiusAnim.getValue(tickPart->lifeCycle) * tickPart->radiusRand;
    210211
    211212      tickPart->mass = massAnim.getValue(tickPart->lifeCycle)
    212         + randMassAnim.getValue(tickPart->lifeCycle) * tickPart->massRand;
    213      
     213        + randMassAnim.getValue(tickPart->lifeCycle) * tickPart->massRand;
     214
    214215      tickPart->extForce = Vector(0,0,0);
    215216
     
    223224
    224225      if (this->conserve < 1.0)
    225         tickPart->velocity = tickPart->velocity * this->conserve;
     226        tickPart->velocity = tickPart->velocity * this->conserve;
    226227      // find out if we have to delete tickPart
    227228      if (unlikely((tickPart->lifeCycle += dt/tickPart->lifeTime) >= 1.0))
    228         {
    229           // remove the particle from the list
    230           if (likely(prevPart != NULL))
    231             {
    232               prevPart->next = tickPart->next;
    233               tickPart->next = this->deadList;
    234               this->deadList = tickPart;
    235               tickPart = prevPart->next;
    236             }
    237           else
    238             {
    239               prevPart = NULL;
    240               this->particles = tickPart->next;
    241               tickPart->next = this->deadList;
    242               this->deadList = tickPart;
    243               tickPart = this->particles;
    244             }
    245           --this->count;
    246         }
     229        {
     230          // remove the particle from the list
     231          if (likely(prevPart != NULL))
     232            {
     233              prevPart->next = tickPart->next;
     234              tickPart->next = this->deadList;
     235              this->deadList = tickPart;
     236              tickPart = prevPart->next;
     237            }
     238          else
     239            {
     240              prevPart = NULL;
     241              this->particles = tickPart->next;
     242              tickPart->next = this->deadList;
     243              this->deadList = tickPart;
     244              tickPart = this->particles;
     245            }
     246          --this->count;
     247        }
    247248      else
    248         {     
    249           prevPart = tickPart;
    250           tickPart = tickPart->next;
    251         }
    252     }
    253 }
    254 
    255 /** 
     249        {
     250          prevPart = tickPart;
     251          tickPart = tickPart->next;
     252        }
     253    }
     254}
     255
     256/**
    256257    \brief applies some force to a Particle.
    257258    \param field the Field to apply.
     
    281282
    282283  Particle* drawPart = particles;
    283      
     284
    284285  switch (this->particleType)
    285286    {
     
    289290      glDepthMask(GL_FALSE);
    290291
    291       material->select(); 
     292      material->select();
    292293      //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    293      
     294
    294295
    295296      while (likely(drawPart != NULL))
    296         {
    297           glColor4fv(drawPart->color);
    298           //! \todo implement a faster code for the look-at Camera algorithm.
    299 
    300           const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
    301           Vector cameraPos = camera->getAbsCoor();
    302           Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor();
    303           Vector view = cameraTargetPos - cameraPos;
    304           Vector up = Vector(0, 1, 0);
    305           up = camera->getAbsDir().apply(up);
    306           Vector h = up.cross(view);
    307           Vector v = h.cross(view);
    308           h.normalize();
    309           v.normalize();
    310           v *= .5 * drawPart->radius;
    311           h *= .5 * drawPart->radius;
    312 
    313           glBegin(GL_TRIANGLE_STRIP);
    314           glTexCoord2i(1, 1);
    315           glVertex3f(drawPart->position.x - h.x - v.x,
    316                      drawPart->position.y - h.y - v.y,
    317                      drawPart->position.z - h.z - v.z);
    318           glTexCoord2i(0, 1);
    319           glVertex3f(drawPart->position.x - h.x + v.x,
    320                      drawPart->position.y - h.y + v.y,
    321                      drawPart->position.z - h.z + v.z);
    322           glTexCoord2i(1, 0);
    323           glVertex3f(drawPart->position.x + h.x - v.x,
    324                      drawPart->position.y + h.y - v.y,
    325                      drawPart->position.z + h.z - v.z);
    326           glTexCoord2i(0, 0);
    327           glVertex3f(drawPart->position.x + h.x + v.x,
    328                      drawPart->position.y + h.y + v.y,
    329                      drawPart->position.z + h.z + v.z);
    330 
    331           glEnd();
    332  
    333           drawPart = drawPart->next;
    334         }
     297        {
     298          glColor4fv(drawPart->color);
     299          //! \todo implement a faster code for the look-at Camera algorithm.
     300
     301          const PNode* camera = State::getInstance()->getCamera();  //!< \todo MUST be different
     302          Vector cameraPos = camera->getAbsCoor();
     303          Vector cameraTargetPos = State::getInstance()->getCameraTarget()->getAbsCoor();
     304          Vector view = cameraTargetPos - cameraPos;
     305          Vector up = Vector(0, 1, 0);
     306          up = camera->getAbsDir().apply(up);
     307          Vector h = up.cross(view);
     308          Vector v = h.cross(view);
     309          h.normalize();
     310          v.normalize();
     311          v *= .5 * drawPart->radius;
     312          h *= .5 * drawPart->radius;
     313
     314          glBegin(GL_TRIANGLE_STRIP);
     315          glTexCoord2i(1, 1);
     316          glVertex3f(drawPart->position.x - h.x - v.x,
     317                     drawPart->position.y - h.y - v.y,
     318                     drawPart->position.z - h.z - v.z);
     319          glTexCoord2i(0, 1);
     320          glVertex3f(drawPart->position.x - h.x + v.x,
     321                     drawPart->position.y - h.y + v.y,
     322                     drawPart->position.z - h.z + v.z);
     323          glTexCoord2i(1, 0);
     324          glVertex3f(drawPart->position.x + h.x - v.x,
     325                     drawPart->position.y + h.y - v.y,
     326                     drawPart->position.z + h.z - v.z);
     327          glTexCoord2i(0, 0);
     328          glVertex3f(drawPart->position.x + h.x + v.x,
     329                     drawPart->position.y + h.y + v.y,
     330                     drawPart->position.z + h.z + v.z);
     331
     332          glEnd();
     333
     334          drawPart = drawPart->next;
     335        }
    335336      glDepthMask(GL_TRUE);
    336337      break;
     
    340341      glBegin(GL_LINES);
    341342      while (likely(drawPart != NULL))
    342         {
    343           glColor4fv(drawPart->color);
    344           glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    345           glVertex3f(drawPart->position.x - drawPart->velocity.x,
    346                      drawPart->position.y - drawPart->velocity.y,
    347                      drawPart->position.z - drawPart->velocity.z);
    348           drawPart = drawPart->next;
    349         }
     343        {
     344          glColor4fv(drawPart->color);
     345          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     346          glVertex3f(drawPart->position.x - drawPart->velocity.x,
     347                     drawPart->position.y - drawPart->velocity.y,
     348                     drawPart->position.z - drawPart->velocity.z);
     349          drawPart = drawPart->next;
     350        }
    350351      glEnd();
    351352      break;
    352      
     353
    353354    case PARTICLE_DOT:
    354355      glBegin(GL_POINTS);
    355356      while (likely(drawPart != NULL))
    356         {
    357           glColor4fv(drawPart->color);
    358 
    359           glLineWidth(drawPart->radius);
    360 
    361           glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
    362           drawPart = drawPart->next;
    363         }
     357        {
     358          glColor4fv(drawPart->color);
     359
     360          glLineWidth(drawPart->radius);
     361
     362          glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z);
     363          drawPart = drawPart->next;
     364        }
    364365      glEnd();
    365366      break;
     
    380381      // if it is the first Particle
    381382      if (unlikely(particles == NULL))
    382         {
    383           if (likely(deadList != NULL))
    384             {
    385               this->particles = this->deadList;
    386               deadList = deadList->next;
    387             }
    388           else
    389             {
    390               PRINTF(5)("Generating new Particle\n");
    391               this->particles = new Particle;
    392             }
    393           this->particles->next = NULL;
    394         }
     383        {
     384          if (likely(deadList != NULL))
     385            {
     386              this->particles = this->deadList;
     387              deadList = deadList->next;
     388            }
     389          else
     390            {
     391              PRINTF(5)("Generating new Particle\n");
     392              this->particles = new Particle;
     393            }
     394          this->particles->next = NULL;
     395        }
    395396      // filling the List from the beginning
    396397      else
    397         {
    398           Particle* tmpPart;
    399           if (likely(deadList != NULL))
    400             {
    401               tmpPart = this->deadList;
    402               deadList = deadList->next;
    403             }
    404           else
    405             {
    406               PRINTF(5)("Generating new Particle\n");
    407               tmpPart = new Particle;
    408             }
    409           tmpPart->next = this->particles;
    410           this->particles = tmpPart;
    411         }
    412      
     398        {
     399          Particle* tmpPart;
     400          if (likely(deadList != NULL))
     401            {
     402              tmpPart = this->deadList;
     403              deadList = deadList->next;
     404            }
     405          else
     406            {
     407              PRINTF(5)("Generating new Particle\n");
     408              tmpPart = new Particle;
     409            }
     410          tmpPart->next = this->particles;
     411          this->particles = tmpPart;
     412        }
     413
    413414      particles->lifeTime = this->lifeSpan + (float)(rand()/RAND_MAX)* this->randomLifeSpan;
    414415      particles->lifeCycle = 0.0;
  • orxonox/trunk/src/lib/particles/particle_system.h

    r4493 r4597  
    1 /*! 
     1/*!
    22    \file particle_system.h
    33
     
    2323
    2424//! An enumerator for the different types of particles.
    25 typedef enum PARTICLE_TYPE { PARTICLE_DOT           =  PARTICLE_DOT_MASK,
    26                              PARTICLE_SPARK         =  PARTICLE_SPARK_MASK,
    27                              PARTICLE_SPRITE        =  PARTICLE_SPRITE_MASK,
    28                              PARTICLE_MULTI_SPRITE  =  PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
    29                              PARTICLE_MODEL         =  PARTICLE_MODEL_MASK,
    30                              PARTICLE_MULTI_MODE    =  PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK };
     25typedef enum PARTICLE_TYPE
     26{
     27  PARTICLE_DOT           =  PARTICLE_DOT_MASK,
     28  PARTICLE_SPARK         =  PARTICLE_SPARK_MASK,
     29  PARTICLE_SPRITE        =  PARTICLE_SPRITE_MASK,
     30  PARTICLE_MULTI_SPRITE  =  PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
     31  PARTICLE_MODEL         =  PARTICLE_MODEL_MASK,
     32  PARTICLE_MULTI_MODE    =  PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK
     33};
    3134
    3235#define PARTICLE_DEFAULT_MAX_COUNT    200               //!< A default count of particles in the system.
     
    5962//! A class to handle ParticleSystems
    6063class ParticleSystem : public WorldEntity, public PhysicsInterface {
    61  
     64
    6265 public:
    6366  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT,
    64                 PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
     67                PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
    6568  virtual ~ParticleSystem();
    6669
     
    116119
    117120  GLuint*           glID;                //!< A List of different gl-List-ID's
    118   GLuint            dialectCount;        //!< How many different types of particles are there in the Particle System 
     121  GLuint            dialectCount;        //!< How many different types of particles are there in the Particle System
    119122
    120123  // per particle attributes
  • orxonox/trunk/src/lib/particles/quick_animation.cc

    r4479 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2727using namespace std;
    2828
    29 
    3029/**
    3130   \brief standard constructor
     
    3332QuickAnimation::QuickAnimation (void)
    3433{
    35    this->setClassName("QuickAnimation");
     34   this->setClassID(CL_QUICK_ANIMATION, "QuickAnimation");
    3635
    3736   this->first = this->current = NULL;
     
    4746  this->current = this->first;
    4847  QuickKeyFrame delKF;
    49  
     48
    5049  while (this->current != NULL)
    5150    {
     
    5453      this->current = this->first;
    5554    }
    56 
    5755}
    5856
     
    7068      // if it is between some keyframes
    7169      if ((!this->current->next && this->current->position < position)
    72           || (this->current->position < position && this->current->next->position > position))
    73         break;
     70          || (this->current->position < position && this->current->next->position > position))
     71        break;
    7472      // if it is the same as an already existing keyframe
    7573      else if (this->current->position == position)
    76         return false;
     74        return false;
    7775      this->current = this->current->next;
    7876    }
     
    9290  newKey->value = value;
    9391  newKey->position = position;
    94  
     92
    9593  this->current = this->first;
    9694
     
    110108    {
    111109      if (this->current->position < position+region && this->current->position > position-region)
    112         {
    113           this->current->value = value;
    114           return true;
    115         }
    116       this->current = this->current->next; 
     110        {
     111          this->current->value = value;
     112          return true;
     113        }
     114      this->current = this->current->next;
    117115    }
    118116  this->current = this->first;
     
    122120/*
    123121  \param position The position where to find the Node to kill
    124  
     122
    125123  bool QuickAnimation::removeEntry(float position)
    126124  {
    127125  this->current = this->first;
    128   QuickKeyFrame* last = 
    129  
     126  QuickKeyFrame* last =
     127
    130128  while (this->current)
    131129  {
    132130  if (this->current->position == position)
    133131  {
    134  
    135  
     132
     133
    136134  }
    137   this->current = this->current->next; 
     135  this->current = this->current->next;
    138136  }
    139137  this->current = this->first;
     
    145143   \param position the position to get the value from :)
    146144*/
    147 float QuickAnimation::getValue(float position) 
     145float QuickAnimation::getValue(float position)
    148146{
    149147  if (unlikely(this->first == NULL))
     
    154152    {
    155153      if (unlikely(position < this->current->position))
    156         {
    157           if (position <= this->first->position)
    158             return this->first->value;
    159           this->current = this->first;
    160         }
     154        {
     155          if (position <= this->first->position)
     156            return this->first->value;
     157          this->current = this->first;
     158        }
    161159      while (likely(this->current->next != NULL && position > this->current->next->position))
    162         this->current = this->current->next;
     160        this->current = this->current->next;
    163161      if (this->current->next == NULL)
    164         return this->current->value;
    165                
     162        return this->current->value;
     163
    166164      return this->current->value + (this->current->next->value - this->current->value)
    167         * ((position-this->current->position) / (this->current->next->position -this->current->position));
     165        * ((position-this->current->position) / (this->current->next->position -this->current->position));
    168166    }
    169167}
  • orxonox/trunk/src/lib/particles/quick_animation.h

    r4479 r4597  
    1 /*! 
     1/*!
    22    \file quick_animation.h
    33    \brief Definition of the QuickAnimation-class
     
    2121   this class is optimized for a raising value. eg. 100 particles sorted
    2222   by age.
     23  \todo speedUP this stuff (especially getValue)
    2324*/
    2425class QuickAnimation : public BaseObject {
  • orxonox/trunk/src/lib/physics/physics_connection.cc

    r4480 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3131PhysicsConnection::PhysicsConnection(PhysicsInterface* subject, Field* field)
    3232{
     33  this->setClassID(CL_PHYSICS_CONNECTION, "PhysicsConnection");
    3334  this->type = PCON_PhysIField;
    3435  this->subject = subject;
     
    4344
    4445*/
    45 PhysicsConnection::~PhysicsConnection () 
     46PhysicsConnection::~PhysicsConnection ()
    4647{
    4748  PhysicsEngine::getInstance()->removeConnection(this);
    4849}
    4950
    50 /** 
     51/**
    5152    \brief applies the Force to some Object.
    5253*/
  • orxonox/trunk/src/lib/physics/physics_connection.h

    r4480 r4597  
    1 /*! 
     1/*!
    22    \file physics_connection.h
    33    \brief Definition of The Physical Connection Class.
    44*/
    55
    6 #ifndef _PHYSICS_CONNECTION_H 
     6#ifndef _PHYSICS_CONNECTION_H
    77#define _PHYSICS_CONNECTION_H
    88
     
    1414
    1515//! An enumerator for different ConnectionTypes
    16 typedef enum PCON_Type { PCON_PhysIPhysI = 0,
    17                          PCON_PhysIField = 1};
     16typedef enum PCON_Type
     17{
     18  PCON_PhysIPhysI = 1,
     19  PCON_PhysIField = 2
     20};
    1821
    1922
     
    3437 private:
    3538  PCON_Type type;                    //!< What kind of connection this is.
    36  
     39
    3740  PhysicsInterface* subject;         //!< The main Subject of this Connection.
    3841  PhysicsInterface* partner2;        //!< The second partner of this Connection.
    39  
     42
    4043  Field* field;                      //!< The field to connect either subject of ParticleSystem to.
    4144};
  • orxonox/trunk/src/lib/physics/physics_engine.cc

    r4558 r4597  
    3030PhysicsEngine::PhysicsEngine()
    3131{
    32    this->setClassName ("PhysicsEngine");
    33 
    34    this->connections = new tList<PhysicsConnection>;
    35    this->interfaces = new tList<PhysicsInterface>;
    36    this->fields = new tList<Field>;
     32  this->setClassID(CL_PHYSICS_ENGINE, "PhysicsEngine");
     33  this->setName("PhysicsEngine");
     34  this->connections = new tList<PhysicsConnection>;
     35  this->interfaces = new tList<PhysicsInterface>;
     36  this->fields = new tList<Field>;
    3737}
    3838
  • orxonox/trunk/src/lib/physics/physics_interface.cc

    r4558 r4597  
    3535/**
    3636   \brief standard constructor
    37 */
     37 */
    3838PhysicsInterface::PhysicsInterface (void* objectPointer)
    3939{
     40  this->setClassID(CL_PHYSICS_INTERFACE, "PhysicsInterface");
    4041  this->objectPointer = objectPointer;
    4142
    42   //   this->setClassName ("PhysicsInterface");
    43    this->mass = 1;
    44    this->massChildren = 0;
    45    this->forceSum = Vector(0, 0, 0);
    46    this->bForceApplied = false;
     43  this->mass = 1;
     44  this->massChildren = 0;
     45  this->forceSum = Vector(0, 0, 0);
     46  this->bForceApplied = false;
    4747
    4848   PhysicsEngine::getInstance()->addPhysicsInterface(this);
  • orxonox/trunk/src/lib/physics/physics_interface.h

    r4558 r4597  
    2828class PhysicsInterface : virtual public BaseObject
    2929{
    30 
    3130 public:
    3231  PhysicsInterface(void* objectPointer);
  • orxonox/trunk/src/lib/sound/sound_engine.cc

    r4519 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    4040SoundBuffer::SoundBuffer(const char* fileName)
    4141{
     42  this->setClassID(CL_SOUND_BUFFER, "SoundBuffer");
     43  this->setName(fileName);
     44
    4245  SoundEngine::getInstance()->addBuffer(this);
    4346
     
    4548  ALvoid* data;
    4649  ALsizei freq;
    47  
     50
    4851  ALenum result;
    4952
     
    5760  if ((result = alGetError()) != AL_NO_ERROR)
    5861    SoundEngine::PrintALErrorString(result);
    59  
     62
    6063  // send the loaded wav data to the buffer
    6164  alBufferData(this->bufferID, format, data, this->size, freq);
     
    8386SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode)
    8487{
     88  this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     89
    8590  ALenum result;
    8691
     
    161166   \brief standard constructor
    162167*/
    163 SoundEngine::SoundEngine ()
    164 {
    165   this->setClassName ("SoundEngine");
    166  
     168SoundEngine::SoundEngine ()
     169{
     170  this->setClassID(CL_SOUND_ENGINE, "SoundEngine");
     171  this->setName("SoundEngine");
     172
    167173  this->listener = NULL;
    168174  this->bufferList = new tList<SoundBuffer>;
     
    179185
    180186*/
    181 SoundEngine::~SoundEngine () 
     187SoundEngine::~SoundEngine ()
    182188{
    183189  SoundEngine::singletonRef = NULL;
     
    262268    {
    263269      if (buffer == enumSource->getBuffer())
    264         delete enumSource;
     270        delete enumSource;
    265271      enumSource = sourceIterator->nextElement();
    266272    }
     
    300306    {
    301307      alListener3f(AL_POSITION,
    302                    this->listener->getAbsCoor().x,
    303                    this->listener->getAbsCoor().y,
    304                    this->listener->getAbsCoor().z);
     308                   this->listener->getAbsCoor().x,
     309                   this->listener->getAbsCoor().y,
     310                   this->listener->getAbsCoor().z);
    305311      alListener3f(AL_VELOCITY,
    306                    this->listener->getVelocity().x,
    307                    this->listener->getVelocity().y,
    308                    this->listener->getVelocity().z);
     312                   this->listener->getVelocity().x,
     313                   this->listener->getVelocity().y,
     314                   this->listener->getVelocity().z);
    309315      Vector absDirV = this->listener->getAbsDirV();
    310316      ALfloat orientation [6] = {1,0,0, absDirV.x, absDirV.y, absDirV.z};
     
    321327      if (likely(enumSource->getNode()!=NULL))
    322328      {
    323         alSource3f(enumSource->getID(), AL_POSITION,
    324                    enumSource->getNode()->getAbsCoor().x,
    325                    enumSource->getNode()->getAbsCoor().y,
    326                    enumSource->getNode()->getAbsCoor().z);
    327         alSource3f(enumSource->getID(), AL_VELOCITY,
    328                    enumSource->getNode()->getVelocity().x,
    329                    enumSource->getNode()->getVelocity().y,
    330                    enumSource->getNode()->getVelocity().z);
     329        alSource3f(enumSource->getID(), AL_POSITION,
     330                   enumSource->getNode()->getAbsCoor().x,
     331                   enumSource->getNode()->getAbsCoor().y,
     332                   enumSource->getNode()->getAbsCoor().z);
     333        alSource3f(enumSource->getID(), AL_VELOCITY,
     334                   enumSource->getNode()->getVelocity().x,
     335                   enumSource->getNode()->getVelocity().y,
     336                   enumSource->getNode()->getVelocity().z);
    331337      }
    332338      enumSource = iterator->nextElement();
     
    347353      SoundSource* enumSource = sourceIterator->nextElement();
    348354      while (enumSource)
    349         {
    350           if (enumBuffer == enumSource->getBuffer())
    351             break;
    352           enumSource = sourceIterator->nextElement();
    353         }
     355        {
     356          if (enumBuffer == enumSource->getBuffer())
     357            break;
     358          enumSource = sourceIterator->nextElement();
     359        }
    354360      delete sourceIterator;
    355361      if (enumSource == NULL)
    356         ResourceManager::getInstance()->unload(enumBuffer);
     362        ResourceManager::getInstance()->unload(enumBuffer);
    357363      enumBuffer = bufferIterator->nextElement();
    358364    }
     
    402408      PRINTF(4)("AL_NO_ERROR\n");
    403409      break;
    404      
     410
    405411    case AL_INVALID_NAME:
    406412      PRINTF(2)("AL_INVALID_NAME\n");
  • orxonox/trunk/src/lib/sound/sound_engine.h

    r4519 r4597  
    1 /*! 
     1/*!
    22    \file sound_engine.h
    3     \brief Definition of the SoundEngine singleton Class 
     3    \brief Definition of the SoundEngine singleton Class
    44*/
    55
     
    2020
    2121//! A class that represents a datastructure to play Sounds.
    22 class SoundBuffer
     22class SoundBuffer : public BaseObject
    2323{
    2424 public:
     
    3737
    3838//! A class that represents a SoundSource
    39 class SoundSource
     39class SoundSource : virtual public BaseObject
    4040{
    4141 public:
    4242  SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL);
    4343  ~SoundSource(void);
    44  
     44
    4545  // user interaction
    4646  void play();
     
    4848  void pause();
    4949  void rewind();
    50  
     50
    5151  // development functions
    5252  /** \returns The ID of this Source */
    5353  inline ALuint getID(void) const { return this->sourceID; }
    5454  /** \returns the SoundBuffer of this Source */
    55   inline SoundBuffer* getBuffer(void) const { return this->buffer; } 
     55  inline SoundBuffer* getBuffer(void) const { return this->buffer; }
    5656  /** \returns the SourceNode of this Source */
    5757  inline PNode* getNode(void) const { return this->sourceNode;}
  • orxonox/trunk/src/lib/util/ini_parser.cc

    r4381 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2828IniParser::IniParser (const char* filename)
    2929{
     30  this->setClassID(CL_INI_PARSER, "IniParser");
     31
    3032  stream = NULL;
    3133  bInSection = false;
     
    5052  char* tmpName = ResourceManager::homeDirCheck(filename);
    5153  if( filename == NULL) return -1;
    52   if( stream != NULL)   fclose (stream);
     54  if( stream != NULL)   fclose (stream);
    5355  if( (stream = fopen (tmpName, "r")) == NULL)
    5456    {
     
    7173  bInSection = false;
    7274  if( stream == NULL) return -1;
    73  
     75
    7476  char linebuffer[PARSELINELENGHT];
    7577  char secbuffer[PARSELINELENGHT];
    7678  char* ptr;
    77  
     79
    7880  rewind (stream);
    7981  while( !feof( stream))
     
    8587      // check for section identifyer
    8688      if( sscanf (linebuffer, "[%s", secbuffer) == 1)
    87         {
    88           if( (ptr = strchr( secbuffer, ']')) != NULL)
    89             {
    90               *ptr = 0;
    91               if( !strcmp( secbuffer, section))
    92                 {
    93                   bInSection = true;
    94                   return 0;
    95                 }
    96             }
    97         }
     89        {
     90          if( (ptr = strchr( secbuffer, ']')) != NULL)
     91            {
     92              *ptr = 0;
     93              if( !strcmp( secbuffer, section))
     94                {
     95                  bInSection = true;
     96                  return 0;
     97                }
     98            }
     99        }
    98100    }
    99101  return -1;
     
    114116    }
    115117  if( !bInSection) return -1;
    116  
     118
    117119  char linebuffer[PARSELINELENGHT];
    118120  char* ptr;
    119  
     121
    120122  while( !feof( stream))
    121123    {
     
    125127      if( (ptr = strchr( linebuffer, '\n')) != NULL) *ptr = 0;
    126128      if( linebuffer[0] == '[')
    127         {
    128           bInSection = false;
    129           return -1;
    130         }
     129        {
     130          bInSection = false;
     131          return -1;
     132        }
    131133      sscanf(linebuffer, "%s = %s", name, value);
    132134      return 0;
    133135      /*
    134         if( (ptr = strchr( tmpBuffer, '=')) != NULL)
    135         {
    136         if( ptr == linebuffer) continue;
    137         strcpy (value, &ptr[1]);
    138         strncpy (name, linebuffer, strlen (linebuffer) - strlen (value) - 1);
    139         printf ("%s, %s\n", value, name);
    140         return 0;
    141         }
     136        if( (ptr = strchr( tmpBuffer, '=')) != NULL)
     137        {
     138        if( ptr == linebuffer) continue;
     139        strcpy (value, &ptr[1]);
     140        strncpy (name, linebuffer, strlen (linebuffer) - strlen (value) - 1);
     141        printf ("%s, %s\n", value, name);
     142        return 0;
     143        }
    142144      */
    143145    }
    144   return -1;   
     146  return -1;
    145147}
    146148
     
    151153   \param defvalue: what should be returned in case the entry cannot be found
    152154   \return a pointer to a buffer conatining the value of the specified entry. This buffer will contain the data specified in defvalue in case the entry wasn't found
    153    
     155
    154156   The returned pointer points to an internal buffer, so do not free it on your own. Do not give a NULL pointer to defvalue, this will certainly
    155157   lead to unwanted behaviour.
     
    159161  strcpy (internbuf, defvalue);
    160162  if( getSection (section) == -1) return internbuf;
    161  
     163
    162164  char namebuf[PARSELINELENGHT];
    163165  char valuebuf[PARSELINELENGHT];
    164  
     166
    165167  while( nextVar (namebuf, valuebuf) != -1)
    166168    {
    167169      if( !strcmp (name, namebuf))
    168         {
    169           strcpy (internbuf, valuebuf);
    170           return internbuf;
    171         }
     170        {
     171          strcpy (internbuf, valuebuf);
     172          return internbuf;
     173        }
    172174    }
    173175  return internbuf;
  • orxonox/trunk/src/lib/util/ini_parser.h

    r4482 r4597  
    22    \file ini_parser.h
    33    \brief A small ini file parser
    4    
     4
    55    Can be used to find a defined [Section] in an ini file and get the VarName=Value entries
    66*/
     
    1212#include <string.h>
    1313#include <stdlib.h>
     14#include "base_object.h"
    1415
    1516#define PARSELINELENGHT     512       //!< how many chars to read at once
     
    1718//! ini-file parser
    1819/**
    19         This class can be used to load an initializer file and parse it's contents for variablename=value pairs.
     20        This class can be used to load an initializer file and parse it's contents for variablename=value pairs.
    2021*/
    21 class IniParser {
     22class IniParser : public BaseObject
     23{
    2224 public:
    2325  IniParser (const char* filename);
    2426  ~IniParser ();
    25  
     27
    2628  char* getVar(const char* name, char* section, char* defvalue);
    2729  int openFile(const char* name);
     
    3335  bool          bInSection;                   //!< if the requested parameter is in the section.
    3436  char          internbuf[PARSELINELENGHT];   //!< a buffer
    35        
     37
    3638
    3739};
  • orxonox/trunk/src/lib/util/substring.cc

    r4220 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1111   ### File Specific:
    1212   main-programmer: Christian Meyer
    13    co-programmer: ...
     13   co-programmer: Benjamin Grauer
     14
     15   2005-06-10: some naming conventions
    1416*/
    1517
     
    2830{
    2931  n = 0;
    30        
     32
    3133  assert( string != NULL);
    32        
     34
    3335  for( int i = 0; i < strlen(string); i++) if( string[i] == ',') n++;
    3436
    3537  n += 1;
    36        
     38
    3739  strings = new char*[n];
    3840
    3941  assert (strings != NULL);
    40        
     42
    4143  int i = 0;
    4244  int l = 0;
    43        
     45
    4446  const char* offset = string;
    4547  char* end = strchr( string, ',');
     
    5759      end = strchr( offset, ',');
    5860    }
    59        
     61
    6062  strings[i] = new char[l + 1];
    6163  l = strlen( offset);
     
    7375      delete strings[i];
    7476    }
    75        
     77
    7678  delete strings;
    7779}
  • orxonox/trunk/src/lib/util/substring.h

    r4482 r4597  
    1 /*! 
     1/*!
    22  \file substring.h
    33  \brief a small class to get the parts of a string separated by commas
     
    1313  SubString(const char* string);
    1414  ~SubString();
    15                
     15
    1616  int getCount();
    1717  const char* getString( int i);
    18                
     18
    1919 private:
    2020  char**     strings;         //!< strings produced from a single string splitted in multiple strings
  • orxonox/trunk/src/orxonox.cc

    r4556 r4597  
    5656{
    5757  this->setClassID(CL_ORXONOX, "Orxonox");
     58  this->setName("orxonox");
    5859
    5960  this->resourceManager = NULL;
  • orxonox/trunk/src/story_entities/campaign.cc

    r4324 r4597  
    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
     
    3232
    3333
    34 Campaign::Campaign ()
    35 {
     34Campaign::Campaign ()
     35{
     36  this->setClassID(CL_CAMPAIGN, "Campaign");
    3637  this->entities = new tList<StoryEntity>();
    3738  this->isInit = false;
    3839}
    3940
    40 Campaign::Campaign ( TiXmlElement* root)
    41 {
     41Campaign::Campaign ( TiXmlElement* root)
     42{
     43  //! \todo loading with load_param....
     44  this->setClassID(CL_CAMPAIGN, "Campaign");
    4245  TiXmlElement* element;
    4346  const char* string;
    4447  int id;
    45  
     48
    4649  PRINTF(3)("Loading Campaign...\n");
    47  
     50
    4851  assert( root != NULL);
    4952  GameLoader* loader = GameLoader::getInstance();
    50  
     53
    5154  this->entities = new tList<StoryEntity>();
    5255  this->isInit = false;
    53  
     56
    5457  // grab all the necessary parameters
    5558  string = grabParameter( root, "identifier");
     
    6063    }
    6164  else this->setStoryID( id);
    62  
     65
    6366  // find WorldList
    6467  element = root->FirstChildElement( "WorldList");
     
    6972  else
    7073    element = element->FirstChildElement();
    71  
     74
    7275  // load Worlds/Subcampaigns/Whatever
    7376  StoryEntity* lastCreated = NULL;
     
    7780      StoryEntity* created = (StoryEntity*) loader->fabricate( element);
    7881      /*
    79       if( lastCreated != NULL) 
    80         created->setNextStoryID( lastCreated->getStoryID());
     82      if( lastCreated != NULL)
     83        created->setNextStoryID( lastCreated->getStoryID());
    8184      else
    82         created->setNextStoryID( WORLD_ID_GAMEEND);
     85        created->setNextStoryID( WORLD_ID_GAMEEND);
    8386      */
    8487      if( created != NULL)
    85         {
    86           this->addEntity( created);   
    87           lastCreated = created;
    88         }
     88        {
     89          this->addEntity( created);
     90          lastCreated = created;
     91        }
    8992      element = element->NextSiblingElement();
    9093    }
    91   //if( lastCreated != NULL) 
     94  //if( lastCreated != NULL)
    9295  //lastCreated->setStoryID( WORLD_ID_GAMEEND);
    9396}
     
    111114{
    112115  ErrorMessage errorCode;
    113   if( !this->isInit) return errorCode; 
     116  if( !this->isInit) return errorCode;
    114117  if( storyID == WORLD_ID_GAMEEND) return errorCode;
    115118  this->running = true;
     
    126129      se->start();
    127130      se->destroy();
    128      
     131
    129132      delete se;
    130133
     
    133136      se = this->getStoryEntity(nextWorldID);
    134137      this->currentEntity = se;
    135       if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) ) 
    136         {
    137           PRINTF(0)("Quitting campaing story loop\n");
    138           if(se != NULL)
    139             delete se;
    140           return errorCode;
    141         }
    142      
     138      if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) )
     139        {
     140          PRINTF(0)("Quitting campaing story loop\n");
     141          if(se != NULL)
     142            delete se;
     143          return errorCode;
     144        }
     145
    143146    }
    144147}
     
    162165{
    163166  this->running = false;
    164   if(this->currentEntity != NULL) 
     167  if(this->currentEntity != NULL)
    165168    {
    166169      this->currentEntity->stop();
     
    182185
    183186
    184 /** 
     187/**
    185188    \brief adds an game stroy entity to the campaign
    186189
     
    206209{
    207210  this->removeEntity(this->getStoryEntity(storyID));
    208  
     211
    209212}
    210213
     
    251254  tList<StoryEntity>* l;
    252255  StoryEntity* entity = NULL;
    253   l = this->entities->getNext(); 
    254   while( l != NULL) 
    255     { 
     256  l = this->entities->getNext();
     257  while( l != NULL)
     258    {
    256259      entity = l->getObject();
    257260      l = l->getNext();
     
    260263      //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
    261264      if(id == storyID)
    262         {
    263           //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
    264           return entity;
    265         }
     265        {
     266          //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
     267          return entity;
     268        }
    266269
    267270    }
     
    271274  tIterator<StoryEntity>* iterator = this->entities->getIterator();
    272275  StoryEntity* entity = iterator->nextElement();
    273   while( entity != NULL) 
    274     { 
     276  while( entity != NULL)
     277    {
    275278      int id = entity->getStoryID();
    276279      //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
    277280      if(id == storyID)
    278         {
    279           //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
    280           return entity;
    281         }
     281        {
     282          //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
     283          return entity;
     284        }
    282285      entity = iterator->nextElement();
    283286    }
  • orxonox/trunk/src/story_entities/campaign.h

    r4261 r4597  
    3232  void removeEntity(int storyID);
    3333  void removeEntity(StoryEntity* se);
    34  
     34
    3535  void nextLevel();
    3636  void previousLevel();
  • orxonox/trunk/src/story_entities/story_def.h

    r3472 r4597  
    2020#define WORLD_ID_GAMEEND 999
    2121
    22 #define MAX_STORY_ENTITIES 99 //!> maximal StoryEntities in a Campaign
     22#define MAX_STORY_ENTITIES 99 //!< maximal StoryEntities in a Campaign
    2323
    2424#endif /* _STORY_DEF_H */
  • orxonox/trunk/src/story_entities/story_entity.cc

    r4592 r4597  
    2626StoryEntity::StoryEntity ()
    2727{
    28   this->setClassID(CL_STORY_ENTITY);
     28  this->setClassID(CL_STORY_ENTITY, "StoryEntity");
    2929}
    3030StoryEntity::~StoryEntity () {}
  • orxonox/trunk/src/story_entities/story_entity.h

    r4261 r4597  
    1 /*! 
     1/*!
    22    \file story_entity.h
    33    \brief holds the base class of everything that is playable - that is part of the story
    4 */ 
     4*/
    55
    66
  • orxonox/trunk/src/story_entities/world.cc

    r4596 r4597  
    769769  //GLMenuImageScreen*
    770770  this->glmis = new GLMenuImageScreen();
    771   this->glmis->init();
    772771  this->glmis->setMaximum(8);
    773   //  this->glmis->draw();
    774772
    775773  PRINTF(3)("World::displayLoadScreen - end\n");
  • 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
  • orxonox/trunk/src/world_entities/environment.cc

    r4490 r4597  
    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
     
    3131Environment::Environment () : WorldEntity()
    3232{
    33 
     33  this->setClassID(CL_ENVIRONMENT, "Environment");
    3434}
    3535
     
    3838   \brief deletes an environment
    3939*/
    40 Environment::~Environment () 
     40Environment::~Environment ()
    4141{
    4242
     
    6767   \brief draws the Environment
    6868*/
    69 void Environment::draw () 
     69void Environment::draw ()
    7070{
    7171  //this->getRelCoor().debug();
     
    7474  glPushMatrix();
    7575  float matrix[4][4];
    76  
     76
    7777  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    7878  //rotate
    7979  this->getAbsDir().matrix (matrix);
    8080  glMultMatrixf((float*)matrix);
    81  
     81
    8282  this->model->draw();
    8383
  • orxonox/trunk/src/world_entities/npc.cc

    r3472 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    2727
    2828
    29 NPC::NPC()
    30   : WorldEntity()
     29NPC::NPC() : WorldEntity()
    3130{
     31  this->setClassID(CL_NPC, "NPC");
    3232  hasDied = 0;
    3333}
     
    4141}
    4242
    43 void NPC::getPosition(float* x, float* y, float* z) 
     43void NPC::getPosition(float* x, float* y, float* z)
    4444{
    45   *x = xCor; 
    46   *y = yCor; 
     45  *x = xCor;
     46  *y = yCor;
    4747  *z = zCor;
    4848}
    4949
    50 void NPC::setCollisionRadius(float r) 
     50void NPC::setCollisionRadius(float r)
    5151{
    5252  collisionRadius = r;
    5353}
    5454
    55 float NPC::getCollisionRadius() 
     55float NPC::getCollisionRadius()
    5656{
    5757  return collisionRadius;
     
    6464void NPC::paint()
    6565{
    66   //cout << "WorldEntity::WorldEntity();" << endl; 
     66  //cout << "WorldEntity::WorldEntity();" << endl;
    6767  /* fix: died flag approach is very stupid, just to show @ convention */
    6868  if( hasDied == 0 ) {
     
    7575}
    7676
    77 void NPC::drawNPC() 
     77void NPC::drawNPC()
    7878{
    7979
  • orxonox/trunk/src/world_entities/player.cc

    r4592 r4597  
    4949  */
    5050  this->setClassID(CL_PLAYER, "Player");
     51
    5152  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    5253  travelSpeed = 15.0;
     
    9091{
    9192  this->setClassID(CL_PLAYER, "Player");
     93
    9294  this->weapons = new tList<Weapon>();
    9395  this->activeWeapon = NULL;
  • orxonox/trunk/src/world_entities/power_up.cc

    r3483 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    2424
    2525
    26 PowerUp::PowerUp () {}
     26PowerUp::PowerUp ()
     27{
     28  this->setClassID(CL_POWER_UP, "PowerUp");
     29}
    2730
    2831
  • orxonox/trunk/src/world_entities/projectile.cc

    r4464 r4597  
    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
     
    3434{
    3535  this->setClassID(CL_PROJECTILE, "Projectile");
     36
    3637  this->weapon = weapon;
    3738  this->flightDirection = NULL;
     
    4546   \brief standard deconstructor
    4647*/
    47 Projectile::~Projectile () 
     48Projectile::~Projectile ()
    4849{
    49   /* 
    50      do not delete the test projectModel, since it is pnode 
    51      and will be cleaned out by world 
     50  /*
     51     do not delete the test projectModel, since it is pnode
     52     and will be cleaned out by world
    5253  */
    5354  //delete this->projectileModel;
     
    110111   \param time since last tick
    111112*/
    112 void Projectile::tick (float time) 
     113void Projectile::tick (float time)
    113114{
    114115  Vector v = this->velocity * (time);
     
    131132   \param place where it is hit
    132133*/
    133 void Projectile::hit (WorldEntity* entity, Vector* place) 
     134void Projectile::hit (WorldEntity* entity, Vector* place)
    134135{}
    135136
     
    138139   \brief the function gets called, when the projectile is destroyed
    139140*/
    140 void Projectile::destroy () 
     141void Projectile::destroy ()
    141142{}
    142143
    143144
    144 void Projectile::draw () 
     145void Projectile::draw ()
    145146{
    146147  glMatrixMode(GL_MODELVIEW);
    147148  glPushMatrix();
    148149
    149   float matrix[4][4]; 
     150  float matrix[4][4];
    150151  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    151152  this->getAbsDir().matrix (matrix);
    152   glMultMatrixf((float*)matrix); 
     153  glMultMatrixf((float*)matrix);
    153154  this->model->draw();
    154155
  • orxonox/trunk/src/world_entities/projectile.h

    r4464 r4597  
    1 /*! 
     1/*!
    22    \projectile.h
    33    \brief a projectile, that is been shooted by a weapon
    44
    55    You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the
    6     shooting funcions work, use the Projectile class. But if you want to implement your own shoots its 
     6    shooting funcions work, use the Projectile class. But if you want to implement your own shoots its
    77    different:<br>
    88    Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions
     
    1010    - void draw()
    1111    - void hit() (only if you have working collision detection)
    12     When you have implemented these functions you have just to add the projectiles to your weapon. You ll want 
    13     to make this by looking into the function 
     12    When you have implemented these functions you have just to add the projectiles to your weapon. You ll want
     13    to make this by looking into the function
    1414    - Weapon::fire()
    1515    there you just change the line:
     
    2727class Weapon;
    2828
    29 class Projectile : public WorldEntity 
     29class Projectile : public WorldEntity
    3030{
    3131  friend class World;
     
    4848 protected:
    4949  //physical attriutes like: force, speed, acceleration etc.
    50   float speed;                         //!< this is the speed of the projectile
    51   float currentLifeTime;               //!< this is the time, the projectile exists in this world (incremented by tick)
    52   float ttl;                           //!< time to life, after this time, the projectile will garbage collect itself
    53   Vector* flightDirection;             //!< direction in which the shoot flights
    54   Weapon* weapon;                      //!< weapon the shoot belongs to
    55  
    56   Vector velocity;                     //!< velocity of the projectile
    57   Vector offsetVel;                    //!< offset velocity TEMP
     50  float          speed;                     //!< this is the speed of the projectile
     51  float          currentLifeTime;           //!< this is the time, the projectile exists in this world (incremented by tick)
     52  float          ttl;                       //!< time to life, after this time, the projectile will garbage collect itself
     53  Vector*        flightDirection;           //!< direction in which the shoot flights
     54  Weapon*        weapon;                    //!< weapon the shoot belongs to
     55
     56  Vector         velocity;                  //!< velocity of the projectile
     57  Vector         offsetVel;                 //!< offset velocity TEMP
    5858};
    5959
  • orxonox/trunk/src/world_entities/satellite.cc

    r4320 r4597  
    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
     
    3232{
    3333  this->setClassID(CL_SATELLITE, "Satellite");
     34
    3435  this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);
    3536  this->speed = speed;
     
    5253   \brief this method is called every frame
    5354   \param time: the time in seconds that has passed since the last tick
    54    
     55
    5556   Handle all stuff that should update with time inside this method (movement, animation, etc.)
    5657*/
    57 void Satellite::tick(float time) 
     58void Satellite::tick(float time)
    5859{
    5960  float w = this->speed * M_PI;
    6061
    61   Quaternion rotation(w * time, *this->axis); 
     62  Quaternion rotation(w * time, *this->axis);
    6263  Quaternion v = this->getRelDir();
    63  
     64
    6465  this->setRelDir(v * rotation);
    6566}
     
    6869/**
    6970   \brief the entity is drawn onto the screen with this function
    70    
     71
    7172   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    7273*/
    73 void Satellite::draw() 
     74void Satellite::draw()
    7475{
    7576  glMatrixMode(GL_MODELVIEW);
    7677  glPushMatrix();
    7778  float matrix[4][4];
    78  
     79
    7980  /* translate */
    80   glTranslatef (this->getAbsCoor ().x, 
    81                 this->getAbsCoor ().y,
    82                 this->getAbsCoor ().z);
     81  glTranslatef (this->getAbsCoor ().x,
     82                this->getAbsCoor ().y,
     83                this->getAbsCoor ().z);
    8384  /* rotate */
    8485  this->getAbsDir ().matrix (matrix);
    8586  glMultMatrixf((float*)matrix);
    86  
     87
    8788  this->model->draw();
    8889  glPopMatrix();
  • orxonox/trunk/src/world_entities/satellite.h

    r3750 r4597  
    1 /*! 
     1/*!
    22    \file world_entity.h
    33    \brief Definition of the basic WorldEntity
     
    1818//! Basic class from which all interactive stuff in the world is derived from
    1919class Satellite : public WorldEntity
    20 {       
     20{
    2121  friend class World;
    2222
     
    2727  virtual void draw ();
    2828  virtual void tick (float time);
    29  
     29
    3030 private:
    31   Vector* axis;
    32   float speed;
    33  
     31  Vector*       axis;
     32  float         speed;
     33
    3434
    3535};
  • orxonox/trunk/src/world_entities/skybox.cc

    r4444 r4597  
    11
    2 /* 
     2/*
    33   orxonox - the future of 3D-vertical-scrollers
    44
     
    6868{
    6969  this->setClassID(CL_SKYBOX, "SkyBox");
     70
    7071  this->skyModel = NULL;
    7172  this->material = new Material*[6];
    72   for (int i = 0; i < 6; i++) 
     73  for (int i = 0; i < 6; i++)
    7374    {
    7475      this->material[i] = new Material();
     
    104105   usage: give this function an argument like
    105106   setTexture("skybox", "jpg");
    106    and it will convert this to 
     107   and it will convert this to
    107108   setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg",
    108109               "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg");
     
    123124  sprintf(front, "%s_front.%s", name, extension);
    124125  sprintf(back, "%s_back.%s", name, extension);
    125  
     126
    126127  this->setTextures(top, bottom, left, right, front, back);
    127128
     
    180181/**
    181182   \brief rebuilds the SkyBox
    182    
     183
    183184   this must be done, when changing the Size of the Skybox (runtime-efficency)
    184185*/
     
    189190  skyModel = new Model();
    190191
    191   this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 
     192  this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size);
    192193  this->skyModel->addVertex (0.5*size, -0.5*size, 0.5*size);
    193194  this->skyModel->addVertex (-0.5*size, 0.5*size, 0.5*size);
     
    222223  this->skyModel->setMaterial(material[5]);
    223224  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
    224  
     225
    225226  this->skyModel->finalize();
    226227}
  • orxonox/trunk/src/world_entities/skybox.h

    r4261 r4597  
    1 /*! 
     1/*!
    22    \file skybox.h
    33    \brief Definition of the SkyBox, that handles the Display of an atmosphere for orxonox.
     
    4343  void rebuild();
    4444
    45   Model* skyModel;        //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.
    46   Material **material;    //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
    47   float size;             //!< Size of the SkyBox. This should match the frustum maximum range.
    48    
     45  Model*          skyModel;        //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.
     46  Material**      material;        //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
     47  float           size;            //!< Size of the SkyBox. This should match the frustum maximum range.
     48
    4949};
    5050
  • orxonox/trunk/src/world_entities/skysphere.cc

    r4444 r4597  
    11
    2 /* 
     2/*
    33   orxonox - the future of 3D-vertical-scrollers
    44
     
    1313   main-programmer: David Gruetter
    1414   co-programmer: Benjamin Grauer
    15    
    16    Created by Dave: this file is actually quite similar to player.cc and so is 
     15
     16   Created by Dave: this file is actually quite similar to player.cc and so is
    1717   skybox.h similar to player.h
    1818   With that said, things should be clear:)
    19    
     19
    2020   Edited:
    2121   Bensch: more constructors, changeability, comments...
     
    4343Skysphere::Skysphere(char* fileName)
    4444{
     45  this->setClassID(CL_SKYSPHERE, "SkySphere");
     46
    4547  if (fileName == NULL)
    4648    this->initialize("pictures/sky-replace.jpg");
     
    9294/**
    9395   \brief draws the Skysphere
    94    
     96
    9597   This part is normally precessed in the "Painting Phase".
    9698*/
     
    105107  //glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
    106108  //glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
    107  
     109
    108110  skyMaterial->select();
    109111  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
  • orxonox/trunk/src/world_entities/skysphere.h

    r3763 r4597  
    1 /*! 
     1/*!
    22    \file skysphere.h
    33    \brief Definition of the Skysphere, that handles the Display of an atmosphere of orxonox.
     
    3434  virtual void draw();
    3535
    36  private:
    37   GLUquadricObj *sphereObj; //!< A Placeholder for the SkySphere.
    38   Material *skyMaterial;    //!< A Material for the SkySphere.
    39   float sphereRadius;       //!< Radius of the SkySphere. This should match the frustum maximum range.
    40    
    41   void initialize(char* fileName); 
     36  private:
     37    void initialize(char* fileName);
     38
     39 private:
     40  GLUquadricObj*    sphereObj;           //!< A Placeholder for the SkySphere.
     41  Material*         skyMaterial;         //!< A Material for the SkySphere.
     42  float             sphereRadius;        //!< Radius of the SkySphere. This should match the frustum maximum range.
    4243};
    4344
  • orxonox/trunk/src/world_entities/terrain.cc

    r4320 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2828
    2929*/
    30 Terrain::Terrain () 
     30Terrain::Terrain ()
    3131{
    3232  this->init();
     
    3636   \brief Constructor for loading a Terrain out of a file
    3737   \param fileName The file to load data from.
    38  
     38
    3939   this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found.
    4040*/
    41 Terrain::Terrain(char* fileName)
     41Terrain::Terrain(const char* fileName)
    4242{
    4343  this->init();
     
    6868
    6969*/
    70 Terrain::~Terrain () 
     70Terrain::~Terrain ()
    7171{
    7272  if (objectList)
     
    7878{
    7979  this->setClassID(CL_TERRAIN, "Terrain");
     80
    8081  this->objectList = 0;
    8182}
     
    8485
    8586void Terrain::draw ()
    86 { 
     87{
    8788  glMatrixMode(GL_MODELVIEW);
    8889  glPushMatrix();
    8990  float matrix[4][4];
    90  
     91
    9192  /* translate */
    92   glTranslatef (this->getAbsCoor ().x, 
    93                 this->getAbsCoor ().y,
    94                 this->getAbsCoor ().z);
     93  glTranslatef (this->getAbsCoor ().x,
     94                this->getAbsCoor ().y,
     95                this->getAbsCoor ().z);
    9596  /* rotate */
    9697  this->getAbsDir ().matrix (matrix);
     
    112113      objectList = glGenLists(1);
    113114      glNewList (objectList, GL_COMPILE);
    114      
     115
    115116      glColor3f(1.0,0,0);
    116      
     117
    117118      int sizeX = 100;
    118119      int sizeZ = 80;
     
    121122      float widthX = float (length /sizeX);
    122123      float widthZ = float (width /sizeZ);
    123      
     124
    124125      float height [sizeX][sizeZ];
    125126      Vector normal_vectors[sizeX][sizeZ];
    126      
    127      
     127
     128
    128129      for ( int i = 0; i<sizeX-1; i+=1)
    129         for (int j = 0; j<sizeZ-1;j+=1)
    130           //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
     130        for (int j = 0; j<sizeZ-1;j+=1)
     131          //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
    131132#ifdef __WIN32__
    132           height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
     133          height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
    133134#else
    134135      height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
    135136#endif
    136      
     137
    137138      //Die Huegel ein wenig glaetten
    138139      for (int h=1; h<2;h++)
    139         for (int i=1;i<sizeX-2 ;i+=1 )
    140           for(int j=1;j<sizeZ-2;j+=1)
    141             height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
    142      
     140        for (int i=1;i<sizeX-2 ;i+=1 )
     141          for(int j=1;j<sizeZ-2;j+=1)
     142            height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
     143
    143144      //Berechnung von normalen Vektoren
    144145      for(int i=1;i<sizeX-2;i+=1)
    145         for(int j=1;j<sizeZ-2 ;j+=1)
    146           {
    147             Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
    148             Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
    149             Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
    150             Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
    151             Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
    152            
    153             Vector c1 = v2 - v1;
    154             Vector c2 = v3 - v1;
    155             Vector c3=  v4 - v1;
    156             Vector c4 = v5 - v1;
    157             Vector zero = Vector (0,0,0);
    158             normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
    159             normal_vectors[i][j].normalize();
    160           }
    161      
     146        for(int j=1;j<sizeZ-2 ;j+=1)
     147          {
     148            Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
     149            Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
     150            Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
     151            Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
     152            Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
     153
     154            Vector c1 = v2 - v1;
     155            Vector c2 = v3 - v1;
     156            Vector c3=  v4 - v1;
     157            Vector c4 = v5 - v1;
     158            Vector zero = Vector (0,0,0);
     159            normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
     160            normal_vectors[i][j].normalize();
     161          }
     162
    162163      glBegin(GL_QUADS);
    163164      int snowheight=3;
    164165      for ( int i = 0; i<sizeX; i+=1)
    165         for (int j = 0; j<sizeZ;j+=1)
    166           {       
    167             Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
    168             Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
    169             Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
    170             Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
    171             float a[3];
    172             if(height[i][j]<snowheight){
    173               a[0]=0;
    174               a[1]=1.0-height[i][j]/10-.3;
    175               a[2]=0;
    176               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    177             }
    178             else{
    179               a[0]=1.0;
    180               a[1]=1.0;
    181               a[2]=1.0;
    182               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    183              
    184             }
    185             glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
    186             glVertex3f(v1.x, v1.y, v1.z);
    187             if(height[i+1][j]<snowheight){
    188               a[0]=0;
    189               a[1] =1.0-height[i+1][j]/10-.3;
    190               a[2]=0;
    191               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    192             }
    193             else{
    194               a[0]=1.0;
    195               a[1]=1.0;
    196               a[2]=1.0;
    197               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    198              
    199             }
    200             glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
    201             glVertex3f(v2.x, v2.y, v2.z);
    202             if(height[i+1][j+1]<snowheight){
    203               a[0]=0;
    204               a[1] =1.0-height[i+1][j+1]/10-.3;
    205               a[2]=0;
    206               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    207             }
    208             else{
    209               a[0]=1.0;
    210               a[1]=1.0;
    211               a[2]=1.0;
    212               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    213              
    214              
    215             }
    216             glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
    217             glVertex3f(v3.x, v3.y, v3.z);
    218             if(height[i][j+1]<snowheight){
    219               a[0]=0;
    220               a[1] =1.0-height[i+1][j+1]/10-.3;
    221               a[2]=0;
    222               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    223             }
    224             else{
    225               a[0]=1.0;
    226               a[1]=1.0;
    227               a[2]=1.0;
    228               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    229             }
    230             glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
    231             glVertex3f(v4.x, v4.y, v4.z);
    232            
    233           }
     166        for (int j = 0; j<sizeZ;j+=1)
     167          {
     168            Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
     169            Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
     170            Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
     171            Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
     172            float a[3];
     173            if(height[i][j]<snowheight){
     174              a[0]=0;
     175              a[1]=1.0-height[i][j]/10-.3;
     176              a[2]=0;
     177              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     178            }
     179            else{
     180              a[0]=1.0;
     181              a[1]=1.0;
     182              a[2]=1.0;
     183              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     184
     185            }
     186            glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
     187            glVertex3f(v1.x, v1.y, v1.z);
     188            if(height[i+1][j]<snowheight){
     189              a[0]=0;
     190              a[1] =1.0-height[i+1][j]/10-.3;
     191              a[2]=0;
     192              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     193            }
     194            else{
     195              a[0]=1.0;
     196              a[1]=1.0;
     197              a[2]=1.0;
     198              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     199
     200            }
     201            glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
     202            glVertex3f(v2.x, v2.y, v2.z);
     203            if(height[i+1][j+1]<snowheight){
     204              a[0]=0;
     205              a[1] =1.0-height[i+1][j+1]/10-.3;
     206              a[2]=0;
     207              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     208            }
     209            else{
     210              a[0]=1.0;
     211              a[1]=1.0;
     212              a[2]=1.0;
     213              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     214
     215
     216            }
     217            glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
     218            glVertex3f(v3.x, v3.y, v3.z);
     219            if(height[i][j+1]<snowheight){
     220              a[0]=0;
     221              a[1] =1.0-height[i+1][j+1]/10-.3;
     222              a[2]=0;
     223              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     224            }
     225            else{
     226              a[0]=1.0;
     227              a[1]=1.0;
     228              a[2]=1.0;
     229              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     230            }
     231            glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
     232            glVertex3f(v4.x, v4.y, v4.z);
     233
     234          }
    234235      glEnd();
    235236      glEndList();
     
    239240    {
    240241      /*
    241         this->model = (OBJModel*) new Model();
     242        this->model = (OBJModel*) new Model();
    242243      this->model->setName("CUBE");
    243244      this->model->addVertex (-0.5, -0.5, 0.5);
     
    249250      this->model->addVertex (-0.5, -0.5, -0.5);
    250251      this->model->addVertex (0.5, -0.5, -0.5);
    251      
     252
    252253      this->model->addVertexTexture (0.0, 0.0);
    253254      this->model->addVertexTexture (1.0, 0.0);
     
    268269      */
    269270    }
    270  
    271 }
     271
     272}
  • orxonox/trunk/src/world_entities/terrain.h

    r3566 r4597  
    1 /*! 
     1/*!
    22    \file terrain.h
    33    \brief Defines and handles the terrain of the World
     
    2020
    2121//! A Class to handle Terrain of orxonox
    22 class Terrain : public WorldEntity 
     22class Terrain : public WorldEntity
    2323{
    2424
    2525 public:
    2626  Terrain();
    27   Terrain(char* fileName);
     27  Terrain(const char* fileName);
    2828  Terrain(DebugTerrain debugTerrain);
    2929  virtual ~Terrain();
    3030  void init();
    31  
     31
    3232  void buildDebugTerrain(DebugTerrain debugTerrain);
    3333  virtual void draw();
  • orxonox/trunk/src/world_entities/test_bullet.cc

    r4593 r4597  
    3434{
    3535  this->setClassID(CL_TEST_BULLET, "TestBullet");
     36
    3637  float modelSize = .5;
    3738  this->model = (Model*)ResourceManager::getInstance()->load("models/Rocket1.obj", OBJ, RP_LEVEL, (void*) &modelSize);
  • orxonox/trunk/src/world_entities/test_gun.cc

    r4592 r4597  
    4343   creates a new weapon
    4444*/
    45 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight)
     45TestGun::TestGun (PNode* parent, const Vector& coordinate,
     46                  const Quaternion& direction, int leftRight)
    4647  :  Weapon (parent, coordinate, direction)
    4748{
    4849  this->setClassID(CL_TEST_GUN, "TestGun");
     50
    4951  this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    5052  this->idleTime = 0.2f;
  • orxonox/trunk/src/world_entities/weapon.cc

    r4000 r4597  
    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
     
    3535   \param number of weapon slots of the model/ship <= 8 (limitied)
    3636*/
    37 WeaponManager::WeaponManager(int nrOfSlots)
    38 {
     37WeaponManager::WeaponManager(int nrOfSlots)
     38{
     39  this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
     40
    3941  for(int i = 0; i < W_MAX_CONFIGS; ++i)
    4042    {
    4143      this->configs[i].bUsed = false;
    4244      for(int j = 0; j < W_MAX_SLOTS; ++j)
    43         this->configs[i].slots[j] = NULL;
     45        this->configs[i].slots[j] = NULL;
    4446    }
    4547  this->nrOfSlots = nrOfSlots;
     
    4850
    4951
    50 WeaponManager::~WeaponManager() 
    51 {
    52   /* 
    53      i dont have to delete the weapons itself, because they are 
     52WeaponManager::~WeaponManager()
     53{
     54  /*
     55     i dont have to delete the weapons itself, because they are
    5456     worldentities and therefore in the entities list of the world.
    5557     world will clean them up for me
     
    5961      this->configs[i].bUsed = false;
    6062      for(int j = 0; j < W_MAX_SLOTS; ++j)
    61         this->configs[i].slots[j] = NULL;
     63        this->configs[i].slots[j] = NULL;
    6264    }
    6365}
     
    7274   if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be
    7375   replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free
    74    slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 
     76   slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be
    7577   a error message.
    7678*/
    77 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 
     79void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    7880{
    7981  if( slotID == W_FREE_SLOT)
     
    8183      int freeSlot = this->getNextFreeSlot( configID);
    8284      if( freeSlot < 0 || freeSlot >= this->nrOfSlots)
    83         {
    84           PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
    85           return;
    86         }
     85        {
     86          PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
     87          return;
     88        }
    8789      PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot);
    8890      this->configs[configID].bUsed = true;
     
    108110   this function will deactivate the weapons first, change the config and reactivate them later
    109111*/
    110 void WeaponManager::nextWeaponConf() 
     112void WeaponManager::nextWeaponConf()
    111113{
    112114  PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID);
     
    116118  for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
    117119  if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0;
    118   else this->currConfID = i; 
    119 
    120  
     120  else this->currConfID = i;
     121
     122
    121123  Weapon *w1, *w2;
    122124  for(int j = 0; j < W_MAX_SLOTS; ++j)
     
    124126      w1 = this->configs[lastConfID].slots[j];
    125127      w2 = this->configs[this->currConfID].slots[j];
    126      
     128
    127129      if( w1 == w2)
    128         {
    129           printf("no need for change\n");
    130         }
     130        {
     131          printf("no need for change\n");
     132        }
    131133      else
    132         {
    133         if( w1 != NULL )
    134           {
    135             w1->deactivate();
    136             printf("deactivating %i,%i\n", j,lastConfID);
    137           }
    138         if( w2 != NULL)
    139           {
    140             w2->activate();
    141             printf("activating %i,%i\n", j, this->currConfID);
    142           }
    143         }
     134        {
     135        if( w1 != NULL )
     136          {
     137            w1->deactivate();
     138            printf("deactivating %i,%i\n", j,lastConfID);
     139          }
     140        if( w2 != NULL)
     141          {
     142            w2->activate();
     143            printf("activating %i,%i\n", j, this->currConfID);
     144          }
     145        }
    144146    }
    145147}
     
    199201    {
    200202      if( this->configs[configID].slots[i] == NULL)
    201         return i;
     203        return i;
    202204    }
    203205  return -1;
     
    214216   creates a new weapon
    215217*/
    216 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 
     218Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction)
    217219  : WorldEntity()
    218220{
     
    236238   \brief standard deconstructor
    237239*/
    238 Weapon::~Weapon () 
     240Weapon::~Weapon ()
    239241{
    240242  // model will be deleted from WorldEntity-destructor
    241243  //this->worldEntities = NULL;
    242  
     244
    243245  /* dont delete objectComponentsX here, they will be killed when the pnodes are cleaned out */
    244246
     
    247249
    248250
    249 /** 
     251/**
    250252    \brief enables the weapon
    251253
    252     a weapon can be enabled/disabled because of various reasons. if a weapon is 
     254    a weapon can be enabled/disabled because of various reasons. if a weapon is
    253255    been enabled, it can interact in a world. elswhere it wont react to any
    254256    action.
     
    260262
    261263
    262 /** 
     264/**
    263265    \brief disables the weapon
    264266
    265     a weapon can be enabled/disabled because of various reasons. if a weapon is 
     267    a weapon can be enabled/disabled because of various reasons. if a weapon is
    266268    been enabled, it can interact in a world. elswhere it wont react to any
    267269    action.
     
    273275
    274276
    275 /** 
     277/**
    276278    \brief checks if the weapon is enabled
    277279    \returns true if enabled
    278280
    279     a weapon can be ebabled/disabled because of various reasons. if a weapon is 
     281    a weapon can be ebabled/disabled because of various reasons. if a weapon is
    280282    been enabled, it can interact in a world. elswhere it wont react to any
    281283    action.
     
    314316   \brief this activates the weapon
    315317
    316    This is needed, since there can be more than one weapon on a ship. the 
    317    activation can be connected with an animation. for example the weapon is 
    318    been armed out. 
     318   This is needed, since there can be more than one weapon on a ship. the
     319   activation can be connected with an animation. for example the weapon is
     320   been armed out.
    319321*/
    320322void Weapon::activate()
     
    325327   \brief this deactivates the weapon
    326328
    327    This is needed, since there can be more than one weapon on a ship. the 
    328    activation can be connected with an animation. for example the weapon is 
     329   This is needed, since there can be more than one weapon on a ship. the
     330   activation can be connected with an animation. for example the weapon is
    329331   been armed out.
    330332*/
     
    352354   can destroy the weapons of enemies or vice versa.
    353355*/
    354 void Weapon::hit (WorldEntity* entity, Vector* position) 
     356void Weapon::hit (WorldEntity* entity, Vector* position)
    355357{}
    356358
     
    362364   hit, it can also be destoryed.
    363365*/
    364 void Weapon::destroy () 
     366void Weapon::destroy ()
    365367{}
    366368
     
    369371   \brief tick signal for time dependent/driven stuff
    370372*/
    371 void Weapon::tick (float time) 
     373void Weapon::tick (float time)
    372374{}
    373375
     
    383385   \brief this will draw the weapon
    384386*/
    385 void Weapon::draw () 
    386 {}
    387 
     387void Weapon::draw ()
     388{}
     389
  • orxonox/trunk/src/world_entities/weapon.h

    r4504 r4597  
    1 /*! 
     1/*!
    22    \file weapon.h
    33    \brief a weapon that a player can use
     
    1212     o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down!
    1313     o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile
    14    
     14
    1515    Furthermore there are some other attributes, that will help to represent a firing
    1616    weapon in this world:
    1717     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
    1818     o shooting animation
    19      
     19
    2020
    2121     a player defines one or more weapon configurations. a player has got one to eight
     
    3131#define _WEAPON_H
    3232
     33#include "base_object.h"
    3334#include "world_entity.h"
    3435
     
    7475//! this is a weapon Configuration: it has up to 8 slots
    7576typedef struct weaponConfig {
    76   bool bUsed;                       //<! is set to true, if this configuration is 
     77  bool bUsed;                       //<! is set to true, if this configuration is
    7778  Weapon* slots[8];
    7879};
    7980
    8081
    81 class WeaponManager {
     82class WeaponManager : public BaseObject {
    8283 public:
    8384  WeaponManager(int nrOfSlots = 2);
    8485  ~WeaponManager();
    85  
     86
    8687  void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT);
    8788  void removeWeapon(Weapon* weapon, int configID = W_CONFIG0);
     
    9697  int currConfID;                       //<! the currently selected config
    9798  weaponConfig configs[4];              //<! a list of four configurations
    98  
     99
    99100  int getNextFreeSlot(int configID);
    100101};
    101102
    102 class Weapon : public WorldEntity 
     103class Weapon : public WorldEntity
    103104{
    104105  friend class World;
     
    107108  Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction);
    108109  virtual ~Weapon ();
    109  
     110
    110111  void enable(void);
    111112  void disable(void);
     
    123124     \brief sets a weapon idle time
    124125     \param idle time in ms
    125      
     126
    126127     a weapon idle time is the time spend after a shoot until the weapon can
    127128     shoot again
     
    131132     \brief gets the weapon idle time
    132133     \returns idle time in ms
    133      
     134
    134135     a weapon idle time is the time spend after a shoot until the weapon can
    135136     shoot again
     
    139140     \brief checks if the idle time is elapsed
    140141     \return true if time is elapsed
    141      
     142
    142143     a weapon idle time is the time spend after a shoot until the weapon can
    143144   shoot again
     
    147148  /**
    148149     \brief fires the weapon
    149      
     150
    150151     this is called from the player.cc, when fire-button is been pushed
    151152  */
     
    153154  virtual void hit (WorldEntity* weapon, Vector* loc);
    154155  virtual void destroy(void);
    155  
     156
    156157  virtual void tick(float time);
    157158  virtual void weaponIdle(void);
  • orxonox/trunk/src/world_entities/world_entity.cc

    r4570 r4597  
    3131{
    3232  this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
     33
    3334  this->model = NULL;
    3435
Note: See TracChangeset for help on using the changeset viewer.