Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5304 in orxonox.OLD


Ignore:
Timestamp:
Oct 7, 2005, 3:28:25 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: so, ResourceManager now operates on BaseObjects. If this is better, i do not know, but at least it is more intuitive, i think

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r5261 r5304  
    161161  CL_TEXT                       =    0x00b01801,
    162162  CL_FONT                       =    0x00000802,
    163   CL_MATERIAL                   =    0x00000803,
    164   CL_MODEL                      =    0x00000804, //!< @todo make this a SUBCLASS maybe
    165   CL_OBJMODEL                   =    0x00000805,
    166   CL_PROMITIVE_MODEL            =    0x00000806,
    167   CL_MD2Model                   =    0x00000807,
    168   CL_LIGHT                      =    0x00000808,
    169   CL_PARTICLE_EMITTER           =    0x00000809,
     163  CL_TEXTURE                    =    0x00000803,
     164  CL_MATERIAL                   =    0x00000804,
     165  CL_MODEL                      =    0x00000805, //!< @todo make this a SUBCLASS maybe
     166  CL_OBJMODEL                   =    0x00000806,
     167  CL_PROMITIVE_MODEL            =    0x00000807,
     168  CL_MD2Model                   =    0x00000808,
     169  CL_LIGHT                      =    0x00000809,
     170  CL_PARTICLE_EMITTER           =    0x0000080a,
    170171  CL_PARTICLE_SYSTEM            =    0x0000080a,
    171172  CL_ENVIRONMENT                =    0x00000810,
  • trunk/src/lib/graphics/importer/md2Model.h

    r5087 r5304  
    103103
    104104//! class to store the md2 data in
    105 class MD2Data
     105class MD2Data : public BaseObject
    106106{
    107107 public:
  • trunk/src/lib/graphics/importer/model.cc

    r5218 r5304  
    167167  this->normals = new Array<GLfloat>();
    168168
    169   this->materialList = new tList<Material>;
    170   this->materialsExtern = false;
     169  this->materialList = new tList<ModelMaterial>;
    171170
    172171  if (this->type == MODEL_VERTEX_ARRAY)
     
    196195
    197196  // deleting the MaterialList
    198   if (!this->materialsExtern)
     197  PRINTF(5)("Deleting Materials.\n");
     198
     199  tIterator<ModelMaterial>* tmpIt = this->materialList->getIterator();
     200  ModelMaterial* modMat = tmpIt->firstElement();
     201  //! @todo do we really have to delete this material??
     202  while(modMat != NULL)
    199203  {
    200     PRINTF(5)("Deleting Materials.\n");
    201 
    202     tIterator<Material>* tmpIt = this->materialList->getIterator();
    203     Material* material = tmpIt->firstElement();
    204   //! @todo do we really have to delete this material??
    205     while(material)
    206     {
    207       delete material;
    208       material = tmpIt->nextElement();
    209     }
    210     delete tmpIt;
     204    if (!modMat->external)
     205      delete modMat->material;
     206    delete modMat;
     207    modMat = tmpIt->nextElement();
    211208  }
     209  delete tmpIt;
    212210  delete materialList;
    213211  delete this->pModelInfo;
     
    391389 * this also tells this Model, that all the Materials are handled externally
    392390 * with this option set the Materials will not be deleted with the Model.
    393  * !! -> NO MATERIALS GET DELETED WITH ONE CALL TO THIS FUNCTION !!
    394 */
     391 */
    395392Material* Model::addMaterial(Material* material)
    396393{
    397   this->materialList->add(material);
    398   this->materialsExtern = true;
    399   return material;
     394  ModelMaterial* modMat = new ModelMaterial;
     395  modMat->external = true;
     396  modMat->material = material;
     397  this->materialList->add(modMat);
     398  return modMat->material;
    400399}
    401400
     
    407406Material* Model::addMaterial(const char* materialName)
    408407{
    409   Material* newMat = new Material();
    410   newMat->setName(materialName);
     408  ModelMaterial* modMat = new ModelMaterial;
     409  modMat->external = false;
     410  modMat->material = new Material();
     411  modMat->material->setName(materialName);
    411412
    412413  // adding material to the List of materials
    413   this->materialList->add(newMat);
    414   return newMat;
     414  this->materialList->add(modMat);
     415  return modMat->material;
    415416}
    416417
     
    422423Material* Model::findMaterialByName(const char* materialName)
    423424{
    424   tIterator<Material>* tmpIt = this->materialList->getIterator();
    425   Material* material = tmpIt->firstElement();
    426   while(material)
    427     {
    428       if (!strcmp(material->getName(), materialName))
     425  tIterator<ModelMaterial>* tmpIt = this->materialList->getIterator();
     426  ModelMaterial* modMat = tmpIt->firstElement();
     427  while(modMat != NULL)
     428    {
     429      if (!strcmp(modMat->material->getName(), materialName))
    429430        {
    430431          delete tmpIt;
    431           return material;
     432          return modMat->material;
    432433        }
    433       material = tmpIt->nextElement();
     434      modMat = tmpIt->nextElement();
    434435    }
    435436  delete tmpIt;
  • trunk/src/lib/graphics/importer/model.h

    r4836 r5304  
    9696};
    9797
     98struct ModelMaterial
     99{
     100  Material* material;
     101  bool external;
     102};
     103
    98104/////////////
    99105/// MODEL ///
    100106/////////////
    101 
    102107//! Class that handles 3D-Models. it can also read them in and display them.
    103108class Model : public AbstractModel
     
    172177
    173178 private:
    174   MODEL_TYPE       type;            //!< A type for the Model
    175   bool             finalized;       //!< Sets the Object to be finalized.
     179  MODEL_TYPE             type;            //!< A type for the Model
     180  bool                   finalized;       //!< Sets the Object to be finalized.
    176181
    177   unsigned int     vertexCount;     //!< A modelwide Counter for vertices.
    178   unsigned int     normalCount;     //!< A modelwide Counter for the normals.
    179   unsigned int     texCoordCount;   //!< A modelwide Counter for the texCoord.
    180   unsigned int     faceCount;       //!< A modelwide Counter for the faces
    181   unsigned int     triangleCount;   //!< Number of triangles >= faceCount
    182   Array<GLfloat>*  vertices;        //!< The Array that handles the Vertices.
    183   Array<GLfloat>*  normals;         //!< The Array that handles the Normals.
    184   Array<GLfloat>*  vTexture;        //!< The Array that handles the VertexTextureCoordinates.
    185   sTriangleExt*    triangles;       //!< The Array of triangles in the abstract_model.h style
     182  unsigned int           vertexCount;     //!< A modelwide Counter for vertices.
     183  unsigned int           normalCount;     //!< A modelwide Counter for the normals.
     184  unsigned int           texCoordCount;   //!< A modelwide Counter for the texCoord.
     185  unsigned int           faceCount;       //!< A modelwide Counter for the faces
     186  unsigned int           triangleCount;   //!< Number of triangles >= faceCount
     187  Array<GLfloat>*        vertices;        //!< The Array that handles the Vertices.
     188  Array<GLfloat>*        normals;         //!< The Array that handles the Normals.
     189  Array<GLfloat>*        vTexture;        //!< The Array that handles the VertexTextureCoordinates.
     190  sTriangleExt*          triangles;       //!< The Array of triangles in the abstract_model.h style
    186191
    187   ModelGroup*      firstGroup;      //!< The first of all groups.
    188   ModelGroup*      currentGroup;    //!< The currentGroup. this is the one we will work with.
    189   int              groupCount;      //!< The Count of Groups.
     192  ModelGroup*            firstGroup;      //!< The first of all groups.
     193  ModelGroup*            currentGroup;    //!< The currentGroup. this is the one we will work with.
     194  int                    groupCount;      //!< The Count of Groups.
    190195
    191   tList<Material>* materialList;    //!< A list for all the Materials in this Model
    192   bool             materialsExtern; //!< If the materials given to this Object are extern.
     196  tList<ModelMaterial>*  materialList;    //!< A list for all the Materials in this Model
    193197};
    194198
  • trunk/src/lib/graphics/importer/texture.cc

    r5293 r5304  
    3232Texture::Texture(const char* imageName)
    3333{
     34  this->setClassID(CL_TEXTURE, "Texture");
     35
    3436  this->bAlpha = false;
    3537  this->texture = 0;
  • trunk/src/lib/graphics/importer/texture.h

    r5239 r5304  
    1010
    1111#include "glincl.h"
     12#include "base_object.h"
    1213
    1314#include "debug.h"
     
    2021
    2122//! A Class, that reads in Textures from different fileformats.
    22 class Texture
     23class Texture : public  BaseObject
    2324{
    2425 public:
  • trunk/src/util/resource_manager.cc

    r5303 r5304  
    7373
    7474  if (this->resourceList->getSize() > 0)
    75     PRINTF(1)("Not removed all Textures, since there are still %d resources registered\n", this->resourceList->getSize());
     75    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
    7676
    7777  delete this->resourceList;
     
    185185 * @returns a pointer to a desired Resource.
    186186*/
    187 void* ResourceManager::load(const char* fileName, ResourcePriority prio, void* param1, void* param2, void* param3)
     187BaseObject* ResourceManager::load(const char* fileName, ResourcePriority prio, void* param1, void* param2, void* param3)
    188188{
    189189  ResourceType tmpType;
     
    243243 * @returns a pointer to a desired Resource.
    244244*/
    245 void* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
     245BaseObject* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
    246246                            void* param1, void* param2, void* param3)
    247247{
  • trunk/src/util/resource_manager.h

    r5121 r5304  
    6565struct Resource
    6666{
    67   void*             pointer;           //!< Pointer to the Resource.
     67  BaseObject*       pointer;           //!< Pointer to the Resource.
    6868  int               count;             //!< How many times this Resource has been loaded.
    6969
     
    105105  bool checkDataDir(const char* fileInside);
    106106  bool addImageDir(const char* imageDir);
    107   void* load(const char* fileName, ResourcePriority prio = RP_NO,
     107  BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO,
    108108             void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
    109   void* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
     109  BaseObject* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
    110110             void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
    111111  bool unload(void* pointer, ResourcePriority prio = RP_NO);
Note: See TracChangeset for help on using the changeset viewer.