Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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/lib
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.