Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5308 in orxonox.OLD


Ignore:
Timestamp:
Oct 8, 2005, 12:32:52 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Fixed a reversive BUG in the ResourceManager:
Since resources, that depend on each other are loaded left tgo right they must be unlinked right to left… this cost me 3 hours.
What a luck i found this :)

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/glmenu/glmenu_imagescreen.cc

    r5300 r5308  
    284284  SDL_GL_SwapBuffers();
    285285}
    286 
    287 
  • trunk/src/lib/graphics/importer/material.cc

    r5306 r5308  
    5757Material::~Material()
    5858{
    59   PRINTF(4)("delete Material %s.\n", this->getName());
     59  PRINTF(5)("delete Material %s.\n", this->getName());
    6060
    6161  if (this->diffuseTexture != NULL)
     62  {
    6263    ResourceManager::getInstance()->unload(this->diffuseTexture);
     64  }
    6365  if (this->ambientTexture != NULL)
    6466    ResourceManager::getInstance()->unload(this->ambientTexture);
     
    6971/**
    7072 *  sets the material with which the following Faces will be painted
    71 */
    72 bool Material::select ()
     73 */
     74bool Material::select () const
    7375{
    7476  // setting diffuse color
     
    127129 *  Sets the Material Illumination Model.
    128130 *  illu illumination Model in int form
    129 */
     131 */
    130132void Material::setIllum (int illum)
    131133{
     
    133135  this->illumModel = illum;
    134136}
     137
    135138/**
    136139 *  Sets the Material Illumination Model.
    137140 *  illu illumination Model in char* form
    138 */void Material::setIllum (char* illum)
     141 */
     142void Material::setIllum (char* illum)
    139143{
    140144  this->setIllum (atoi(illum));
     
    146150 * @param g Green Color Channel.
    147151 * @param b Blue Color Channel.
    148 */
     152 */
    149153void Material::setDiffuse (float r, float g, float b)
    150154{
     
    156160
    157161}
     162
    158163/**
    159164 *  Sets the Material Diffuse Color.
    160165 * @param rgb The red, green, blue channel in char format (with spaces between them)
    161 */
     166 */
    162167void Material::setDiffuse (char* rgb)
    163168{
     
    181186  this->ambient[3] = 1.0;
    182187}
     188
    183189/**
    184190 *  Sets the Material Ambient Color.
    185191 * @param rgb The red, green, blue channel in char format (with spaces between them)
    186 */
     192 */
    187193void Material::setAmbient (char* rgb)
    188194{
     
    197203 * @param g Green Color Channel.
    198204 * @param b Blue Color Channel.
    199 */
     205 */
    200206void Material::setSpecular (float r, float g, float b)
    201207{
     
    206212  this->specular[3] = 1.0;
    207213 }
     214
    208215/**
    209216 *  Sets the Material Specular Color.
     
    269276void Material::setDiffuseMap(const char* dMap)
    270277{
    271   PRINTF(4)("setting Diffuse Map %s\n", dMap);
     278  PRINTF(5)("setting Diffuse Map %s\n", dMap);
    272279  if (this->diffuseTexture != NULL)
    273280    ResourceManager::getInstance()->unload(this->diffuseTexture);
  • trunk/src/lib/graphics/importer/material.h

    r4836 r5308  
    2626 public:
    2727  Material (const char* mtlName = NULL);
    28   ~Material ();
     28  virtual ~Material ();
    2929
    30   bool select ();
     30  bool select () const;
    3131
    3232  void setIllum (int illum);
     
    5858  float       shininess;        //!< The shininess of the Material.
    5959  float       transparency;     //!< The transperency of the Material.
    60 
     60  public:
    6161  Texture*    diffuseTexture;   //!< The diffuse texture of the Material.
    6262  Texture*    ambientTexture;   //!< The ambient texture of the Material.
  • trunk/src/lib/graphics/importer/model.cc

    r5304 r5308  
    6565
    6666  this->next = NULL;
    67 
    6867}
    6968
     
    383382//////////
    384383/**
    385  *  adds a new Material to the Material List
     384 * adds a new Material to the Material List
    386385 * @param material the Material to add
    387386 * @returns the added material
     
    392391Material* Model::addMaterial(Material* material)
    393392{
     393  if (material == NULL)
     394    return NULL;
    394395  ModelMaterial* modMat = new ModelMaterial;
    395396  modMat->external = true;
     
    408409  ModelMaterial* modMat = new ModelMaterial;
    409410  modMat->external = false;
    410   modMat->material = new Material();
    411   modMat->material->setName(materialName);
     411  modMat->material = new Material(materialName);
    412412
    413413  // adding material to the List of materials
     
    474474  float subbuffer3;
    475475  sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    476   PRINTF(5)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3);
    477476  this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor);
    478477  this->vertexCount++;
     
    507506  float subbuffer3;
    508507  sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    509   PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
    510508  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
    511509  this->normalCount++;
     
    543541  float subbuffer2;
    544542  sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
    545   PRINTF(5)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2);
    546543  this->vTexture->addEntry(subbuffer1);
    547544  this->vTexture->addEntry(1 - subbuffer2);
     
    659656
    660657/**
    661  *  Function that selects a material, if changed in the obj file.
     658 * Function that selects a material, if changed in the obj file.
    662659 * @param matString the Material that will be set.
    663660*/
     
    674671
    675672/**
    676  *  Function that selects a material, if changed in the obj file.
     673 * Function that selects a material, if changed in the obj file.
    677674 * @param mtl the Material that will be set.
    678675*/
     
    11061103  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,16, 7,10,17, 5,11,18, 3,3,19);
    11071104  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,12,20, 0,0,21, 2,2,22, 4,13,23);
    1108 
    1109 }
     1105}
  • trunk/src/lib/graphics/importer/texture.h

    r5304 r5308  
    2121
    2222//! A Class, that reads in Textures from different fileformats.
    23 class Texture : public  BaseObject
     23class Texture : public BaseObject
    2424{
    2525 public:
  • trunk/src/util/resource_manager.cc

    r5307 r5308  
    251251    {
    252252      PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
    253 //      printf("adding %s count: %d\n", tmpResource->pointer->getName(),  tmpResource->count);
    254253      tmpResource->count++;
    255254      if(tmpResource->prio < prio)
     
    409408    }
    410409  else
    411     unload(tmpResource, prio);
     410    return unload(tmpResource, prio);
    412411}
    413412
     
    416415 * @param resource: The resource to unloade
    417416 * @param prio the PriorityLevel to unload this resource
     417 * @returns true on success, false otherwise.
    418418*/
    419419bool ResourceManager::unload(Resource* resource, ResourcePriority prio)
     
    421421  if (resource == NULL)
    422422    return false;
    423 //  printf("removing %s count: %d\n", resource->pointer->getName(),  resource->count);
    424423  if (resource->count > 0)
    425424    resource->count--;
     
    427426  if (resource->prio <= prio)
    428427    {
    429       if (resource->count <= 0)
     428      if (resource->count == 0)
    430429        {
    431430          // deleting the Resource
     
    480479
    481480/**
    482  *  unloads all alocated Memory of Resources with a pririty lower than prio
     481 * unloads all alocated Memory of Resources with a pririty lower than prio
    483482 * @param prio The priority to delete
    484483*/
     
    486485{
    487486  tIterator<Resource>* iterator = resourceList->getIterator();
    488   Resource* enumRes = iterator->firstElement();
     487  Resource* enumRes = iterator->lastElement();
    489488  while (enumRes)
    490489    {
     
    496495                   enumRes->name, enumRes->count);
    497496      //enumRes = resourceList->nextElement();
    498       enumRes = iterator->nextElement();
     497      enumRes = iterator->prevElement();
    499498    }
    500499  delete iterator;
  • trunk/src/util/resource_manager.h

    r5306 r5308  
    6666{
    6767  BaseObject*       pointer;           //!< Pointer to the Resource.
    68   int               count;             //!< How many times this Resource has been loaded.
     68  unsigned int      count;             //!< How many times this Resource has been loaded.
    6969
    7070  char*             name;              //!< Name of the Resource.
     
    8585//! The ResourceManager is a class, that decides if a file/resource should be loaded
    8686/**
    87    If a file/resource was already loaded the resourceManager will
    88    return a void pointer to the desired resource.
    89    Otherwise it will instruct the corresponding resource-loader to load,
    90    and receive the pointer to it.
    91 
    92    It does it by looking, if a desired file has already been loaded.
    93 */
     87 * If a file/resource was already loaded the resourceManager will
     88 * return a pointer to the desired resource.
     89 * Otherwise it will instruct the corresponding resource-loader to load,
     90 * and receive the pointer to it.
     91 *
     92 * It does it by looking, if a desired file has already been loaded.
     93 * There is also the possibility to check for some variables
     94 */
    9495class ResourceManager : public BaseObject
    9596{
     
    101102  bool setDataDir(const char* dataDir);
    102103  /** @returns the Name of the data directory */
    103   inline const char* getDataDir() const {return this->dataDir;}
     104  inline const char* getDataDir() const { return this->dataDir; };
    104105
    105106  bool checkDataDir(const char* fileInside);
     
    135136  static ResourceManager*  singletonRef;       //!< singleton Reference
    136137
     138  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    137139  tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
    138   char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    139140  tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
    140141
  • trunk/src/world_entities/environment.cc

    r5285 r5308  
    3434{
    3535  this->setClassID(CL_ENVIRONMENT, "Environment");
    36   this->model = (Model*)ResourceManager::getInstance()->load("models/ships/bolido.obj", OBJ, RP_CAMPAIGN);
     36  this->loadModel("models/ships/bolido.obj");
    3737
    3838/*  if(this->obbTree == NULL)
  • trunk/src/world_entities/skybox.cc

    r5302 r5308  
    101101  for (int i = 0; i < 6; i++)
    102102    delete this->material[i];
    103   delete []this->material;
     103  delete[] this->material;
    104104  delete this->model;
    105105  this->model = NULL; //< so that WorldEntity does not try to delete it again.
  • trunk/src/world_entities/terrain.cc

    r5143 r5308  
    3939  this->loadParams(root);
    4040
    41   this->ssp = new SpatialSeparation((AbstractModel*)this->model, 10.0f);
     41//  if (this->model != NULL)
     42    //this->ssp = new SpatialSeparation((AbstractModel*)this->model, 10.0f);
    4243}
    4344
     
    5354  this->init();
    5455
    55   if (strstr(fileName, ".obj") || strstr(fileName, ".OBJ"))
    56     {
    57       this->model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_LEVEL);
     56  if (!strcasestr(fileName, ".obj") )
     57    {
     58      this->loadModel(fileName);
    5859    }
    5960  else
     
    6566/**
    6667 *  a Constructor for the Debug-Worlds
    67 
    68    @todo make it not compileable when not in debug-mode
    69 */
     68 */
    7069Terrain::Terrain(DebugTerrain debugTerrain)
    7170{
     
    9291
    9392  this->objectList = 0;
     93  this->ssp = NULL;
    9494}
    9595
     
    122122
    123123  /* THIS IS ONLY FOR DEBUGGING INFORMATION */
    124   this->ssp->drawQuadtree();
     124  if (this->ssp != NULL)
     125    this->ssp->drawQuadtree();
    125126}
    126127
     
    289290      */
    290291    }
    291 
    292 }
     292}
  • trunk/src/world_entities/terrain.h

    r5039 r5308  
    4242 private:
    4343  int objectList;
    44 
    4544};
    4645
Note: See TracChangeset for help on using the changeset viewer.