Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7208 in orxonox.OLD for branches/std/src/world_entities


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

orxonox/std: less evil

Location:
branches/std/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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.