Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7203 in orxonox.OLD for branches/std/src/lib/graphics/importer


Ignore:
Timestamp:
Mar 9, 2006, 5:28:10 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: compiles again, BUT well…. i do not expect it to run anymore

Location:
branches/std/src/lib/graphics/importer
Files:
15 edited

Legend:

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

    r7193 r7203  
    333333}
    334334
    335 HeightMap::HeightMap(const char* height_map_name = NULL) : VertexArrayModel()
     335HeightMap::HeightMap(const std::string& height_map_name = "")
     336  : VertexArrayModel()
    336337{
    337338   this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    338    heightMap =  IMG_Load(height_map_name);
     339   heightMap =  IMG_Load(height_map_name.c_str());
    339340   if(heightMap!=NULL) {
    340341
    341                  PRINTF(0)("loading Image %s\n", height_map_name);
     342     PRINTF(0)("loading Image %s\n", height_map_name.c_str());
    342343                 PRINTF(0)("width : %i\n", heightMap->w);
    343344                 PRINTF(0)("height : %i\n", heightMap->h);
     
    350351                }
    351352
    352      else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
     353                else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name.c_str());
    353354
    354355
     
    361362}
    362363
    363 HeightMap::HeightMap(const char* height_map_name = NULL, const char* colour_map_name = NULL) : VertexArrayModel()
     364HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& colour_map_name = NULL)
     365  : VertexArrayModel()
    364366{
    365367this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    366368
    367    heightMap =  IMG_Load(height_map_name);
     369   heightMap =  IMG_Load(height_map_name.c_str());
    368370   if(heightMap!=NULL) {
    369371
    370                  PRINTF(0)("loading Image %s\n", height_map_name);
     372     PRINTF(0)("loading Image %s\n", height_map_name.c_str());
    371373                 PRINTF(0)("width : %i\n", heightMap->w);
    372374                 PRINTF(0)("height : %i\n", heightMap->h);
     
    379381                }
    380382
    381      else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
     383                else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name.c_str());
    382384
    383385
     
    385387
    386388  colourMap=NULL;
    387   if(colour_map_name != NULL)
     389  if(colour_map_name != "")
    388390  {
    389   colourMap = IMG_Load(colour_map_name);
     391    colourMap = IMG_Load(colour_map_name.c_str());
    390392  }
    391393
    392394  if(colourMap != NULL)
    393395                {
    394                  PRINTF(0)("loading Image %s\n", colour_map_name);
     396                  PRINTF(0)("loading Image %s\n", colour_map_name.c_str());
    395397                 PRINTF(0)("width : %i\n", colourMap->w);
    396398                 PRINTF(0)("height : %i\n", colourMap->h);
  • branches/std/src/lib/graphics/importer/height_map.h

    r6981 r7203  
    5959void load();
    6060void load(int Mode);
    61 void load(const char*, int Mode);
     61void load(const std::string&, int Mode);
    6262void scale( Vector V);
    6363void setAbsCoor(Vector V);
     
    6565float getNormal(float x, float y);
    6666HeightMap();
    67 HeightMap(const char*);
    68 HeightMap(const char*, const char*);
     67HeightMap(const std::string&);
     68HeightMap(const std::string&, const std::string&);
    6969virtual ~HeightMap();
    7070
  • branches/std/src/lib/graphics/importer/material.cc

    r7193 r7203  
    3434 * @param mtlName Name of the Material to be added to the Material List
    3535 */
    36 Material::Material (const char* mtlName)
     36Material::Material (const std::string& mtlName)
    3737{
    3838  this->setClassID(CL_MATERIAL, "Material");
     
    278278 * @param pathName The Path to add.
    279279*/
    280 void Material::addTexturePath(const char* pathName)
     280void Material::addTexturePath(const std::string& pathName)
    281281{
    282282  ResourceManager::getInstance()->addImageDir(pathName);
     
    289289 * @param dMap the Name of the Image to Use
    290290*/
    291 void Material::setDiffuseMap(const char* dMap, GLenum target)
     291void Material::setDiffuseMap(const std::string& dMap, GLenum target)
    292292{
    293293  PRINTF(5)("setting Diffuse Map %s\n", dMap);
     
    297297  //! @todo check if RESOURCE MANAGER is availiable
    298298  //! @todo Textures from .mtl-file need special care.
    299   if (dMap != NULL)
     299  if (!dMap.empty())
    300300    this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target);
    301301  else
     
    308308   @todo implement this
    309309*/
    310 void Material::setAmbientMap(const char* aMap, GLenum target)
     310void Material::setAmbientMap(const std::string& aMap, GLenum target)
    311311{
    312312  SDL_Surface* ambientMap;
     
    319319   @todo implement this
    320320*/
    321 void Material::setSpecularMap(const char* sMap, GLenum target)
     321void Material::setSpecularMap(const std::string& sMap, GLenum target)
    322322{
    323323  SDL_Surface* specularMap;
     
    330330   @todo implemet this
    331331*/
    332 void Material::setBump(const char* bump)
    333 {
    334 
    335 }
     332void Material::setBump(const std::string& bump)
     333{
     334
     335}
  • branches/std/src/lib/graphics/importer/material.h

    r7057 r7203  
    2626{
    2727 public:
    28   Material (const char* mtlName = NULL);
     28  Material (const std::string& mtlName = "");
    2929  virtual ~Material ();
    3030
     
    4949
    5050 // MAPPING //
    51   void setDiffuseMap(const char* dMap, GLenum target = GL_TEXTURE_2D);
    52   void setAmbientMap(const char* aMap, GLenum target = GL_TEXTURE_2D);
    53   void setSpecularMap(const char* sMap, GLenum target = GL_TEXTURE_2D);
    54   void setBump(const char* bump);
     51  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D);
     52  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
     53  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
     54  void setBump(const std::string& bump);
    5555  GLuint getDiffuseTexture() const { return (this->diffuseTexture)? this->diffuseTexture->getTexture() : 0; };
    5656
    57   static void addTexturePath(const char* pathName);
     57  static void addTexturePath(const std::string& pathName);
    5858
    5959  private:
  • branches/std/src/lib/graphics/importer/md2Model.cc

    r7193 r7203  
    7575  \brief simple constructor initializing all variables
    7676*/
    77 MD2Model::MD2Model(const char* modelFileName, const char* skinFileName, float scale)
     77MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale)
    7878{
    7979  this->setClassID(CL_MD2_MODEL, "MD2Model");
     
    352352{
    353353  PRINT(0)("\n==========================| MD2Model::debug() |===\n");
    354   PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName);
    355   PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName);
     354  PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
     355  PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
    356356  PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
    357357  PRINT(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
     
    370370  \brief simple constructor
    371371*/
    372 MD2Data::MD2Data(const char* modelFileName, const char* skinFileName, float scale)
     372MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
    373373{
    374374  scale *= 0.1f;
     
    387387  this->scaleFactor = scale;
    388388
    389   this->fileName = NULL;
    390   this->skinFileName = NULL;
     389  this->fileName = "";
     390  this->skinFileName = "";
    391391  this->loadModel(modelFileName);
    392392  this->loadSkin(skinFileName);
     
    401401MD2Data::~MD2Data()
    402402{
    403   delete [] this->fileName;
    404   delete [] this->skinFileName;
    405403  delete this->header;
    406404
     
    419417  \return true if success
    420418*/
    421 bool MD2Data::loadModel(const char* fileName)
     419bool MD2Data::loadModel(const std::string& fileName)
    422420{
    423421  FILE *pFile;                            //file stream
     
    428426
    429427  //! @todo this chek should include deleting a loaded model (eventually)
    430   if (fileName == NULL)
     428  if (fileName.empty())
    431429    return false;
    432430
    433   pFile = fopen(fileName, "rb");
     431  pFile = fopen(fileName.c_str(), "rb");
    434432  if( unlikely(!pFile))
    435433    {
     
    442440  if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
    443441    {
    444       PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName);
     442      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
    445443      return false;
    446444    }
    447445
    448   this->fileName = new char[strlen(fileName)+1];
    449   strcpy(this->fileName, fileName);
     446  this->fileName =fileName;
    450447  /* got the data: map it to locals */
    451448  this->numFrames = this->header->numFrames;
     
    507504  \return true if success
    508505*/
    509 bool MD2Data::loadSkin(const char* fileName)
    510 {
    511   if( fileName == NULL)
    512     {
    513       this->skinFileName = NULL;
     506bool MD2Data::loadSkin(const std::string& fileName)
     507{
     508  if( fileName.empty())
     509    {
     510      this->skinFileName = "";
    514511      return false;
    515512    }
    516513
    517   this->skinFileName = new char[strlen(fileName)+1];
    518   strcpy(this->skinFileName, fileName);
     514  this->skinFileName =fileName;
    519515
    520516  this->material.setName("md2ModelMaterial");
  • branches/std/src/lib/graphics/importer/md2Model.h

    r7123 r7203  
    189189{
    190190 public:
    191    MD2Data(const char* modelFileName, const char* skinFileName, float scale = 1.0f);
     191   MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
    192192  virtual ~MD2Data();
    193193
    194194 private:
    195   bool loadModel(const char* fileName);
    196   bool loadSkin(const char* fileName = NULL);
     195   bool loadModel(const std::string& fileName);
     196   bool loadSkin(const std::string& fileName = NULL);
    197197
    198198 public:
     
    202202  int                numTexCoor;            //!< number of texture coordinates
    203203  int                numGLCommands;         //!< number of gl commands in the glList (tells how to draw)
    204   char*              fileName;              //!< file name of the model File
    205   char*              skinFileName;          //!< file name of the skin file
     204  std::string        fileName;              //!< file name of the model File
     205  std::string        skinFileName;          //!< file name of the skin file
    206206  MD2Header*         header;                //!< the header file
    207207
     
    223223
    224224public:
    225   MD2Model(const char* modelFileName, const char* skinFileName = NULL, float scale = 1.0f);
     225  MD2Model(const std::string& modelFileName, const std::string& skinFileName = NULL, float scale = 1.0f);
    226226  virtual ~MD2Model();
    227227
  • branches/std/src/lib/graphics/importer/media_container.cc

    r7193 r7203  
    101101
    102102  // Open video file
    103   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
    104   {
    105     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
     103  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
     104  {
     105    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
    106106    return false;
    107107  }
     
    110110  if (av_find_stream_info(format_context) < 0)
    111111  {
    112     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
     112    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
    113113    return false;
    114114  }
     
    116116  // Find the first video stream and take it
    117117  video_stream = av_find_default_stream_index(format_context);
    118  
     118
    119119  if(video_stream == -1)
    120120  {
    121     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
     121    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
    122122    return false;
    123123  }
     
    202202      // Free the packet that was allocated by av_read_frame
    203203      av_free_packet(&packet);
    204      
     204
    205205      // Did we get a video frame?
    206206      if(frame_finished)
     
    216216          memcpy(&data[i*codec_context->width*3],
    217217                 ((AVPicture*)RGB_frame)->data[0]+i *
    218                  ((AVPicture*)RGB_frame)->linesize[0], 
     218                 ((AVPicture*)RGB_frame)->linesize[0],
    219219                  codec_context->width*sizeof(uint8_t)*3);
    220220
     
    258258  }
    259259  else
    260     return NULL;
    261 }
     260    return 0;
     261}
  • branches/std/src/lib/graphics/importer/movie_player.cc

    r7193 r7203  
    3131
    3232
    33 MoviePlayer::MoviePlayer(const char* filename)
     33MoviePlayer::MoviePlayer(const std::string& filename)
    3434{
    3535  // set the class id for the base object
     
    8383
    8484
    85 bool MoviePlayer::loadMovie(const char* filename)
     85bool MoviePlayer::loadMovie(const std::string& filename)
    8686{
    8787  this->unloadMedia();
    8888
    89   if(filename == NULL)
     89  if(filename.empty())
    9090    return false;
    9191  // check whether file exists
    9292  if(!ResourceManager::isInDataDir(filename))
    9393  {
    94     PRINTF(1)("Could not find %s\n", filename);
     94    PRINTF(1)("Could not find %s\n", filename.c_str());
    9595    return false;
    9696  }
     
    100100
    101101  // Open video file
    102   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
    103   {
    104     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
     102  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
     103  {
     104    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
    105105    return false;
    106106  }
     
    109109  if (av_find_stream_info(format_context) < 0)
    110110  {
    111     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
     111    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
    112112    return false;
    113113  }
     
    118118  if(video_stream == -1)
    119119  {
    120     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
     120    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
    121121    return false;
    122122  }
  • branches/std/src/lib/graphics/importer/movie_player.h

    r6981 r7203  
    5858public:
    5959
    60   MoviePlayer(const char* filename = NULL);
     60  MoviePlayer(const std::string& filename = NULL);
    6161  virtual ~MoviePlayer();
    6262
    63   bool loadMovie(const char* filename);
     63  bool loadMovie(const std::string& filename);
    6464
    6565  void start(float start_time);
  • branches/std/src/lib/graphics/importer/objModel.cc

    r6162 r7203  
    3232 * @param scaling The factor that the model will be scaled with.
    3333*/
    34 OBJModel::OBJModel(const char* fileName, float scaling) : StaticModel(fileName)
     34OBJModel::OBJModel(const std::string& fileName, float scaling)
     35  : StaticModel(fileName)
    3536{
    3637  this->setClassID(CL_OBJ_MODEL, "OBJModel");
     
    5152*/
    5253OBJModel::~OBJModel()
    53 {
    54   PRINTF(4)("Deleting the obj-names\n");
    55   if (this->objPath)
    56     delete []this->objPath;
    57 }
     54{ }
    5855
    5956/**
     
    6360   Splits the FileName from the DirectoryName
    6461*/
    65 bool OBJModel::importFile (const char* fileName)
    66 {
     62bool OBJModel::importFile (const std::string& fileNameInput)
     63{
     64  const char* fileName = fileNameInput.c_str();
    6765  PRINTF(4)("preparing to read in file: %s\n", fileName);
    6866  // splitting the
     
    7472    {
    7573      int len = split - fileName+1;
    76       this->objPath = new char[len +2];
    77       strncpy(this->objPath, fileName, len);
     74      this->objPath =  fileName;
     75      this->objPath.erase(len, this->objPath.size());
    7876      this->objPath[len] = '\0';
    7977      PRINTF(4)("Resolved file %s to Path %s.\n", fileName, this->objPath);
     
    9189   This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks
    9290*/
    93 bool OBJModel::readFromObjFile(const char* fileName)
     91bool OBJModel::readFromObjFile(const std::string& fileName)
    9492{
    9593  FILE* stream;
    96   if( (stream = fopen (fileName, "r")) == NULL)
    97     {
    98       PRINTF(2)("Object File Could not be Opened %s\n", fileName);
     94  if( (stream = fopen (fileName.c_str(), "r")) == NULL)
     95    {
     96      PRINTF(2)("Object File Could not be Opened %s\n", fileName.c_str());
    9997      return false;
    10098    }
     
    162160 * that a material does not have to be able to read itself in from a File.
    163161 */
    164 bool OBJModel::readMtlLib (const char* mtlFile)
    165 {
    166   char* fileName = new char [strlen(this->objPath) + strlen(mtlFile)+1];
    167   sprintf(fileName, "%s%s", this->objPath, mtlFile);
     162bool OBJModel::readMtlLib (const std::string& mtlFile)
     163{
     164  std::string fileName = this->objPath + mtlFile;
    168165
    169166  FILE* stream;
    170   if( (stream = fopen (fileName, "r")) == NULL)
    171     {
    172       PRINTF(2)("MaterialLibrary could not be opened %s\n", fileName);
    173       delete[] fileName;
     167  if( (stream = fopen (fileName.c_str(), "r")) == NULL)
     168    {
     169      PRINTF(2)("MaterialLibrary could not be opened %s\n", fileName.c_str());
    174170      return false;
    175171    }
     
    258254    }
    259255  fclose(stream);
    260   delete []fileName;
    261256  return true;
    262257}
  • branches/std/src/lib/graphics/importer/objModel.h

    r6022 r7203  
    1313{
    1414 public:
    15   OBJModel(const char* fileName, float scaling = 1.0);
     15   OBJModel(const std::string& fileName, float scaling = 1.0);
    1616  virtual ~OBJModel();
    1717
    1818 private:
    1919  ///// readin /////
    20   bool importFile (const char* fileName);
    21   bool readFromObjFile (const char* fileName);
    22   bool readMtlLib (const char* matFile);
     20   bool importFile (const std::string& fileName);
     21   bool readFromObjFile (const std::string& fileName);
     22   bool readMtlLib (const std::string& matFile);
    2323
    2424 private:
    25   char*       objPath;     //!< The Path where the obj and mtl-file are located.
     25   std::string       objPath;     //!< The Path where the obj and mtl-file are located.
    2626};
    2727
  • branches/std/src/lib/graphics/importer/static_model.cc

    r6423 r7203  
    2323#include <stdarg.h>
    2424
    25 #include "vector.h"
    26 
    2725using namespace std;
    2826
     
    8684{
    8785  PRINTF(4)("Adding new Group\n");
    88   this->name = NULL;
     86  this->name = "";
    8987  this->faceMode = -1;
    9088  this->faceCount = 0;
     
    109107  if (this->listNumber != 0)
    110108    glDeleteLists(this->listNumber, 1);
    111 
    112   if (this->name != NULL)
    113     delete[] this->name;
    114109
    115110  if (this->next !=NULL)
     
    142137 * assigns it a Name and a Type
    143138 */
    144 StaticModel::StaticModel(const char* modelName)
     139StaticModel::StaticModel(const std::string& modelName)
    145140{
    146141  this->setClassID(CL_STATIC_MODEL, "StaticModel");
     
    276271 * It does this by just calling the List that must have been created earlier.
    277272 */
    278 void StaticModel::draw (char* groupName) const
    279 {
    280   if (groupName == NULL)
    281      return;
     273void StaticModel::draw (const std::string& groupName) const
     274{
    282275  PRINTF(4)("drawing the requested 3D-Models if found.\n");
    283276  ModelGroup* tmpGroup = this->firstGroup;
    284277  while (tmpGroup != NULL)
    285278    {
    286       if (tmpGroup->name != NULL && !strcmp(tmpGroup->name, groupName))
     279      if (tmpGroup->name == groupName)
    287280        {
    288           PRINTF(4)("Drawing model %s\n", tmpGroup->name);
     281          PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str());
    289282          glCallList (tmpGroup->listNumber);
    290283          return;
     
    292285      tmpGroup = tmpGroup->next;
    293286    }
    294   PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->getName());
     287    PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getName());
    295288  return;
    296289}
     
    341334 * @returns the added material
    342335 */
    343 Material* StaticModel::addMaterial(const char* materialName)
     336Material* StaticModel::addMaterial(const std::string& materialName)
    344337{
    345338  ModelMaterial* modMat = new ModelMaterial;
     
    357350 * @returns the Material if found, NULL otherwise
    358351 */
    359 Material* StaticModel::findMaterialByName(const char* materialName)
     352Material* StaticModel::findMaterialByName(const std::string& materialName)
    360353{
    361354  list<ModelMaterial*>::iterator modMat;
    362355  for  (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
    363     if (!strcmp((*modMat)->material->getName(), materialName))
     356    if (materialName == (*modMat)->material->getName())
    364357      return (*modMat)->material;
    365358  return NULL;
     
    373366 * With it you should be able to create Models with more than one SubModel inside
    374367 */
    375 bool StaticModel::addGroup(const char* groupString)
     368bool StaticModel::addGroup(const std::string& groupString)
    376369{
    377370  PRINTF(5)("Read Group: %s.\n", groupString);
     
    382375    }
    383376  // setting the group name if not default.
    384   if (strcmp(groupString, "default"))
    385     {
    386       this->currentGroup->name = new char [strlen(groupString)+1];
    387       strcpy(this->currentGroup->name, groupString);
     377  if (groupString == "default")
     378    {
     379      this->currentGroup->name = groupString;
    388380    }
    389381  ++this->groupCount;
     
    396388 *  If a vertex line is found this function will inject it into the vertex-Array
    397389 */
    398 bool StaticModel::addVertex (const char* vertexString)
     390bool StaticModel::addVertex (const std::string& vertexString)
    399391{
    400392  float subbuffer1;
    401393  float subbuffer2;
    402394  float subbuffer3;
    403   sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
     395  sscanf (vertexString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    404396  this->vertices.push_back(subbuffer1*scaleFactor);
    405397  this->vertices.push_back(subbuffer2*scaleFactor);
     
    431423 * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    432424 */
    433 bool StaticModel::addVertexNormal (const char* normalString)
     425bool StaticModel::addVertexNormal (const std::string& normalString)
    434426{
    435427  float subbuffer1;
    436428  float subbuffer2;
    437429  float subbuffer3;
    438   sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
     430  sscanf (normalString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    439431  this->normals.push_back(subbuffer1);
    440432  this->normals.push_back(subbuffer2);
     
    471463 * !! WARNING THIS IS DIFFERNT FROM addVervexTexture(float, float); because it changes the second entry to 1-v !!
    472464 */
    473 bool StaticModel::addVertexTexture (const char* vTextureString)
     465bool StaticModel::addVertexTexture (const std::string& vTextureString)
    474466{
    475467  float subbuffer1;
    476468  float subbuffer2;
    477   sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
     469  sscanf (vTextureString.c_str(), "%f %f", &subbuffer1, &subbuffer2);
    478470  this->vTexture.push_back(subbuffer1);
    479471  this->vTexture.push_back(1 - subbuffer2);
     
    508500 * in this, that the first Vertex/Normal/Texcoord is 1 instead of 0
    509501 */
    510 bool StaticModel::addFace (const char* faceString)
    511 {
     502bool StaticModel::addFace (const std::string& faceStringInput)
     503{
     504  const char* faceString = faceStringInput.c_str();
    512505  if (this->currentGroup->faceCount >0)
    513506    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
     
    596589 * @param matString the Material that will be set.
    597590*/
    598 bool StaticModel::setMaterial(const char* matString)
     591bool StaticModel::setMaterial(const std::string& matString)
    599592{
    600593  if (this->currentGroup->faceCount > 0)
  • branches/std/src/lib/graphics/importer/static_model.h

    r6423 r7203  
    1313#include <vector>
    1414#include <list>
    15 
    16 // FORWARD DECLARATION //
    17 template<class T> class tArray;
    1815
    1916// definition of different modes for setting up Faces
     
    7067  void cleanup();
    7168
    72   char*        name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
     69  std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
    7370  GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
    7471  GLuint       listNumber;     //!< The number of the GL-List this Group gets.
     
    9895{
    9996 public:
    100   StaticModel(const char* modelName = NULL);
     97  StaticModel(const std::string& modelName = NULL);
    10198  virtual ~StaticModel();
    10299
    103100  virtual void draw() const;
    104101  void draw(int groupNumber) const;
    105   void draw(char* groupName) const;
     102  void draw(const std::string& groupName) const;
    106103
    107104  void rebuild();
    108105
    109106  Material* addMaterial(Material* material);
    110   Material* addMaterial(const char* materialName);
     107  Material* addMaterial(const std::string& materialName);
    111108
    112   bool addGroup(const char* groupString);
     109  bool addGroup(const std::string& groupString);
    113110
    114   bool addVertex(const char* vertexString);
     111  bool addVertex(const std::string& vertexString);
    115112  bool addVertex(float x, float y, float z);
    116113
    117   bool addFace(const char* faceString);
     114  bool addFace(const std::string& faceString);
    118115  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
    119116
    120   bool addVertexNormal(const char* normalString);
     117  bool addVertexNormal(const std::string& normalString);
    121118  bool addVertexNormal(float x, float y, float z);
    122119
    123   bool addVertexTexture(const char* vTextureString);
     120  bool addVertexTexture(const std::string& vTextureString);
    124121  bool addVertexTexture(float u, float v);
    125122
    126   bool setMaterial(const char* mtlString);
     123  bool setMaterial(const std::string& mtlString);
    127124  bool setMaterial(Material* mtl);
    128125
     
    133130  void cubeModel();
    134131
    135   Material* findMaterialByName(const char* materialName);
     132  Material* findMaterialByName(const std::string& materialName);
    136133
    137134 protected:
  • branches/std/src/lib/graphics/importer/texture.cc

    r6871 r7203  
    3232 *  Constructor for a Texture
    3333*/
    34 Texture::Texture(const char* imageName, GLenum target)
     34Texture::Texture(const std::string& imageName, GLenum target)
    3535{
    3636  this->setClassID(CL_TEXTURE, "Texture");
     
    4141  this->priority = 0.5;
    4242
    43   if (imageName != NULL)
     43  if (!imageName.empty())
    4444  {
    4545    this->setName(imageName);
     
    6767 * @param imageName The image to load
    6868*/
    69 bool Texture::loadImage(const char* imageName, GLenum target)
     69bool Texture::loadImage(const std::string& imageName, GLenum target)
    7070{
    7171  if (Texture::texturesEnabled)
     
    8181      this->texture = 0;
    8282    }
    83     if (imageName != NULL)
     83    if (!imageName.empty())
    8484    {
    8585      SDL_Surface* tmpSurf;
     
    8787        glDeleteTextures(1, &this->texture);
    8888      // load the new Image to memory
    89       tmpSurf = IMG_Load(imageName);
     89      tmpSurf = IMG_Load(imageName.c_str());
    9090      if(tmpSurf != NULL)
    9191      {
  • branches/std/src/lib/graphics/importer/texture.h

    r6981 r7203  
    1818  {
    1919    public:
    20       Texture(const char* imageName = NULL, GLenum target = GL_TEXTURE_2D);
     20      Texture(const std::string& imageName = NULL, GLenum target = GL_TEXTURE_2D);
    2121  //  Texture(TEXTURE_TYPE type, int resolution);
    2222      virtual ~Texture();
    2323
    24       bool loadImage(const char* imageName, GLenum target = GL_TEXTURE_2D);
     24      bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    2525      virtual bool rebuild();
    2626
Note: See TracChangeset for help on using the changeset viewer.