Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 edited

Legend:

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