Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7208 in orxonox.OLD


Ignore:
Timestamp:
Mar 10, 2006, 1:56:40 AM (19 years ago)
Author:
bensch
Message:

orxonox/std: less evil

Location:
branches/std/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/graphics/importer/md2Model.cc

    r7207 r7208  
    513513    }
    514514
    515   this->skinFileName =fileName;
     515  this->skinFileName = fileName;
    516516
    517517  this->material.setName("md2ModelMaterial");
  • branches/std/src/lib/graphics/importer/media_container.cc

    r7203 r7208  
    3434 * Default constructor
    3535 */
    36 MediaContainer::MediaContainer(const char* filename)
     36MediaContainer::MediaContainer(const std::string& filename)
    3737{
    3838  // set the class id for the base object
     
    4141  fps = 0;
    4242  mediaLoaded = false;
    43 
    44   this->loadMedia(filename);
     43  if (!filename.empty())
     44    this->loadMedia(filename);
    4545}
    4646
     
    8484}
    8585
    86 bool MediaContainer::loadMedia(const char* filename)
     86bool MediaContainer::loadMedia(const std::string& filename)
    8787{
    8888  this->unloadMedia();
    8989
    90   if(filename == NULL)
     90  if(filename.empty())
    9191    return false;
    9292  // check whether file exists
    9393  if(!ResourceManager::isInDataDir(filename))
    9494  {
    95     PRINTF(1)("Could not find %s\n", filename);
     95    PRINTF(1)("Could not find %s\n", filename.c_str());
    9696    return false;
    9797  }
  • branches/std/src/lib/graphics/importer/media_container.h

    r6981 r7208  
    4444public:
    4545
    46   MediaContainer(const char* filename = NULL);
     46  MediaContainer(const std::string& filename = NULL);
    4747  virtual ~MediaContainer();
    4848
    49   bool loadMedia(const char* filename);
     49  bool loadMedia(const std::string& filename);
    5050  void loadFrames();
    5151
  • branches/std/src/lib/graphics/importer/movie_player.cc

    r7203 r7208  
    4242  mediaLoaded = false;
    4343
    44   this->loadMovie(filename);
    45 
     44  if (!filename.empty())
     45    this->loadMovie(filename);
    4646}
    4747
  • branches/std/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc

    r7193 r7208  
    8787  * @param backImageName name of the backgroun-image
    8888 */
    89 void GLMenuImageScreen::setBackgroundImage (const char* backImageName)
     89void GLMenuImageScreen::setBackgroundImage (const std::string& backImageName)
    9090{
    9191  this->backMat->setDiffuseMap(backImageName);
     
    130130 * @param barImage An image for the Bar
    131131*/
    132 void GLMenuImageScreen::setBarImage(const char* barImage)
     132void GLMenuImageScreen::setBarImage(const std::string& barImage)
    133133{
    134134  this->barMat->setDiffuseMap(barImage);
  • branches/std/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.h

    r6512 r7208  
    1313
    1414//! A class to display a loadScreen
    15 class GLMenuImageScreen : public BaseObject {
     15class GLMenuImageScreen : public BaseObject
     16{
    1617
    17  public:
     18public:
    1819  GLMenuImageScreen (const TiXmlElement* root = NULL);
    1920  virtual void loadParams(const TiXmlElement* root);
     
    2223  void draw();
    2324
    24   void setBackgroundImage(const char* backImageName);
     25  void setBackgroundImage(const std::string& backImageName);
    2526  void setPosition(float offsetX, float offsetY);
    2627  void setScale (float scaleX, float scaleY);
    2728  void setPosScale(float offsetX, float offsetY, float scaleX, float scaleY);
    2829
    29   void setBarImage(const char* barImage);
     30  void setBarImage(const std::string& barImage);
    3031  void setBarPosScale(float barX, float barY, float barW, float barH);
    3132
     
    3940
    4041
    41  private:
     42private:
    4243  // background image
    43   char*         backImageName;       //!< the name of the file of the background image
     44  std::string         backImageName;       //!< the name of the file of the background image
    4445  float         offsetX;             //!< X-offset of the the image from the left
    4546  float         offsetY;             //!< Y-offset of the image from the top
  • branches/std/src/lib/util/loading/resource_manager.cc

    r7207 r7208  
    324324                                  const MultiType& param0, const MultiType& param1, const MultiType& param2)
    325325{
     326
     327  printf("LOADING:::::: %s\n", fileName.c_str());
    326328  // searching if the resource was loaded before.
    327329  Resource* tmpResource;
  • branches/std/src/story_entities/movie_loader.cc

    r7193 r7208  
    3636}
    3737
    38 MovieLoader::~MovieLoader() 
     38MovieLoader::~MovieLoader()
    3939{
    4040  delete this->movie_player;
     
    5656}
    5757
    58 void MovieLoader::loadMovie(const char* filename)
     58void MovieLoader::loadMovie(const std::string& filename)
    5959{
    6060  movie_player->loadMovie(filename);
     
    7878
    7979  this->movie_player->start(0);
    80  
     80
    8181  this->isRunning = true;
    8282  this->run();
     
    139139
    140140  // calculate time difference in milliseconds (Uint32)
    141   this->dt = currentFrame - this->lastFrame; 
     141  this->dt = currentFrame - this->lastFrame;
    142142  // calculate time difference in seconds (float)
    143143  this->dts = (float)this->dt / 1000.0f;
  • branches/std/src/story_entities/movie_loader.h

    r7022 r7208  
    4343
    4444  private:
    45     void loadMovie(const char* filename);
     45    void loadMovie(const std::string& filename);
    4646    void setFPS(float fps);
    4747    void tick();
  • branches/std/src/world_entities/movie_entity.cc

    r7193 r7208  
    7474}
    7575
    76 void MovieEntity::loadMovie(const char* filename)
     76void MovieEntity::loadMovie(const std::string& filename)
    7777{
    7878  if(media_container->loadMedia(filename))
  • branches/std/src/world_entities/movie_entity.h

    r7010 r7208  
    3737    virtual void loadParams(const TiXmlElement* root);
    3838
    39     void loadMovie(const char* filename);
     39    void loadMovie(const std::string& filename);
    4040    void setAxis(float axis);
    4141    void setRotation(float rotation);
  • branches/std/src/world_entities/skybox.cc

    r7193 r7208  
    3838 * @param fileName the file to take as input for the SkyBox
    3939*/
    40 SkyBox::SkyBox(const char* fileName)
     40SkyBox::SkyBox(const std::string& fileName)
    4141{
    4242  this->preInit();
    43   if (fileName)
     43  if (!fileName.empty())
    4444    this->setTextureAndType(fileName, ".jpg");
    4545  this->postInit();
     
    8989  this->setParentMode(PNODE_MOVEMENT);
    9090
    91   this->textureName = NULL;
     91  this->textureName = "";
    9292}
    9393
     
    106106  for (int i = 0; i < 6; i++)
    107107  {
    108     if( this->material[i])
     108    if (this->material[i])
    109109      delete this->material[i];
    110     if( this->cubeTexture[i])
     110    if (this->cubeTexture[i])
    111111      ResourceManager::getInstance()->unload(this->cubeTexture[i]);
    112112  }
    113113}
     114
     115void SkyBox::setTexture(const std::string& name)
     116{
     117  this->textureName = name;
     118  this->setTextureAndType (name, "jpg");
     119};
     120
    114121
    115122/**
     
    122129               "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg");
    123130*/
    124 void SkyBox::setTextureAndType(const char* name, const char* extension)
    125 {
    126   char* top    = new char[strlen(name)+strlen(extension)+ 10];
    127   char* bottom = new char[strlen(name)+strlen(extension)+ 10];
    128   char* left   = new char[strlen(name)+strlen(extension)+ 10];
    129   char* right  = new char[strlen(name)+strlen(extension)+ 10];
    130   char* front  = new char[strlen(name)+strlen(extension)+ 10];
    131   char* back   = new char[strlen(name)+strlen(extension)+ 10];
    132 
    133   sprintf(top, "%s_top.%s", name, extension);
    134   sprintf(bottom, "%s_bottom.%s", name, extension);
    135   sprintf(left, "%s_left.%s", name, extension);
    136   sprintf(right, "%s_right.%s", name, extension);
    137   sprintf(front, "%s_front.%s", name, extension);
    138   sprintf(back, "%s_back.%s", name, extension);
     131void SkyBox::setTextureAndType(const std::string& name, const std::string& extension)
     132{
     133  std::string top = name + "_top." + extension;
     134  std::string bottom = name + "_bottom." + extension;
     135  std::string left = name + "_left." + extension;
     136  std::string right = name + "_right." + extension;
     137  std::string front = name + "_front." + extension;
     138  std::string back = name + "_back." + extension;
    139139
    140140  this->setTextures(top, bottom, left, right, front, back);
    141 
    142   // deleted alocated memory of this function
    143   delete []top;
    144   delete []bottom;
    145   delete []left;
    146   delete []right;
    147   delete []front;
    148   delete []back;
    149141}
    150142
     
    158150 * @param back the back texture.
    159151*/
    160 void SkyBox::setTextures(const char* top, const char* bottom, const char* left,
    161                           const char* right, const char* front, const char* back)
     152void SkyBox::setTextures(const std::string& top, const std::string& bottom, const std::string& left,
     153                          const std::string& right, const std::string& front, const std::string& back)
    162154{
    163155  this->material[0]->setDiffuseMap(top);
     
    171163}
    172164
    173 void SkyBox::loadCubeMapTextures(const char* top, const char* bottom, const char* left,
    174                                   const char* right, const char* front, const char* back)
     165void SkyBox::loadCubeMapTextures(const std::string& top, const std::string& bottom, const std::string& left,
     166                                  const std::string& right, const std::string& front, const std::string& back)
    175167{
    176168  this->cubeTexture[0] = (Texture*)ResourceManager::getInstance()->load(top, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT);
     
    304296
    305297  SYNCHELP_READ_FLOAT( size, NWT_SB_SIZE );
    306   if ( textureName )
     298  if ( !this->textureName.empty() )
    307299  {
    308     delete[] textureName;
    309     textureName = NULL;
     300    textureName = "";
    310301  }
    311   SYNCHELP_READ_STRINGM( textureName, NWT_SB_TEXTURENAME );
     302  char* texName;
     303  SYNCHELP_READ_STRINGM( texName, NWT_SB_TEXTURENAME );
    312304
    313305  this->setSize( size );
    314   this->setTextureAndType( textureName, "jpg" );
     306  this->setTextureAndType( texName, "jpg" );
    315307  this->rebuild();
    316308
     
    338330
    339331    SYNCHELP_WRITE_FLOAT(this->size, NWT_SB_SIZE);
    340     SYNCHELP_WRITE_STRING(this->textureName, NWT_SB_TEXTURENAME);
     332    SYNCHELP_WRITE_STRING(this->textureName.c_str(), NWT_SB_TEXTURENAME);
    341333
    342334    return SYNCHELP_WRITE_N;
  • branches/std/src/world_entities/skybox.h

    r6771 r7208  
    2828{
    2929 public:
    30   SkyBox(const char* fileName = NULL);
     30  SkyBox(const std::string& fileName = "");
    3131  SkyBox(const TiXmlElement* root);
    3232
     
    4444  void setSize(float size);
    4545  /** assumes jpg as input-format */
    46   void setTexture(const char* name) { if (textureName) delete[] textureName; textureName = new char[strlen(name)+1]; strcpy(textureName, name); this->setTextureAndType (name, "jpg"); };
     46  void setTexture(const std::string& name);
    4747
    48   void setTextureAndType(const char* name, const char* extension);
    49   void setTextures(const char* top, const char* bottom, const char* left,
    50                    const char* right, const char* front, const char* back);
     48  void setTextureAndType(const std::string& name, const std::string& extension);
     49  void setTextures(const std::string& top, const std::string& bottom, const std::string& left,
     50                   const std::string& right, const std::string& front, const std::string& back);
    5151
    52   void loadCubeMapTextures(const char* top, const char* bottom, const char* left,
    53                            const char* right, const char* front, const char* back);
     52  void loadCubeMapTextures(const std::string& top, const std::string& bottom, const std::string& left,
     53                           const std::string& right, const std::string& front, const std::string& back);
    5454
    5555  GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->getDiffuseTexture(): 0; };
     
    7171  float           size;            //!< Size of the SkyBox. This should match the frustum maximum range.
    7272  float           textureSize;     //!< this is the length of a texture (assumes a square texture)
    73   char*           textureName;     //!< Name of the Texture
     73  std::string     textureName;     //!< Name of the Texture
    7474
    7575};
Note: See TracChangeset for help on using the changeset viewer.