Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3916 in orxonox.OLD for orxonox/trunk/src/lib/graphics/importer


Ignore:
Timestamp:
Apr 21, 2005, 3:07:36 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: prepare for VertexArrays

Location:
orxonox/trunk/src/lib/graphics/importer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r3915 r3916  
    3333   \brief Creates a 3D-Model. and assigns it a Name.
    3434*/
    35 Model::Model(const char* modelName)
     35Model::Model(const char* modelName, MODEL_TYPE type)
    3636{
    3737  PRINTF(4)("new 3D-Model is being created\n");
    3838  this->name = NULL;
    3939  this->setName(modelName);
    40 
     40  this->type = type;
    4141
    4242  this->finalized = false;
     
    8282    }
    8383
     84  // deleting Arrays
     85  this->deleteArrays();
     86
    8487  // deleting the MaterialList
    8588  PRINTF(5)("Deleting Materials.\n");
    86 
    8789  tIterator<Material>* tmpIt = this->materialList->getIterator();
    8890  Material* material = tmpIt->nextElement();
     
    101103void Model::finalize(void)
    102104{
    103   this->importToGL ();
     105  // this creates the display List.
     106  this->importToDisplayList();
    104107 
     108
     109  // deletes everything we allocated.
     110  if (this->type == MODEL_DISPLAY_LIST)
     111    this->deleteArrays();
    105112  this->cleanup();
    106113
     
    248255
    249256/**
    250    \brief finalizes an Model.
    251    This funcion is needed, to delete all the Lists, and arrays that are no more needed because they are already imported into openGL. This will be applied at the end of the importing Process.
    252 */
    253 bool Model::cleanup(void)
    254 {
    255   PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
    256 
     257   \brief deletes all the arrays
     258*/
     259bool Model::deleteArrays(void)
     260{
    257261  if (this->vertices)
    258262    delete this->vertices;
     
    261265  if (this->normals)
    262266    delete this->normals;
    263 
     267  this->vertices = NULL;
     268  this->vTexture = NULL;
     269  this->normals = NULL;
     270}
     271
     272/**
     273   \brief finalizes an Model.
     274   This funcion is needed, to delete all the Lists, and arrays that are no more needed because they are already imported into openGL. This will be applied at the end of the importing Process.
     275*/
     276bool Model::cleanup(void)
     277{
     278  PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
    264279  this->cleanupGroup(this->firstGroup);
    265280  return true;
     
    703718   \brief reads and includes the Faces/Materials into the openGL state Machine
    704719*/
    705 bool Model::importToGL (void)
    706 {
    707 
     720bool Model::importToDisplayList(void)
     721{
    708722  // finalize the Arrays
    709723  this->vertices->finalizeArray();
     
    794808
    795809/**
     810   \brief reads and includes the Faces/Materials into the openGL state Machine
     811*/
     812bool Model::importToVertexArray(void)
     813{
     814  // finalize the Arrays
     815  this->vertices->finalizeArray();
     816  this->vTexture->finalizeArray();
     817  if (normals->getCount() == 0) // vertices-Array must be built for this
     818    this->buildVertexNormals();
     819  this->normals->finalizeArray();
     820
     821  this->currentGroup = this->firstGroup;
     822
     823
     824}
     825
     826
     827
     828/**
    796829   \brief Adds a Face-element (one vertex of a face) with all its information.
    797830   \param elem The FaceElement to add to the OpenGL-environment.
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3915 r3916  
    1414template<class T> class tList;
    1515
     16//! an enumerator fot the different Model Types.
     17/**
     18   MODEL_DISPLAY_LIST means, that a DisplayList will be built out of the model. This model will be STATIC, meaning it cannot be changed after initialisation.
     19   MODEL_VERTEX_ARRAY means, that a VertexArray will be built out of the model. This moel will be DYNAMIX, meaning that one can change the properties from outside of the model.
     20*/
     21typedef enum MODEL_TYPE {MODEL_DISPLAY_LIST,
     22                         MODEL_VERTEX_ARRAY};
    1623
    17 
    18 using namespace std;
    1924
    2025// definition of different modes for setting up Faces
     
    2328#define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
    2429//! an enumerator for VERTEX_FORMAT
    25 enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,
     30typedef enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,
    2631                    VERTEX_NORMAL = NORMAL,
    2732                    VERTEX_TEXCOORD = TEXCOORD,
     
    7075
    7176  char* name;            //!< This is the name of the Model.
     77  MODEL_TYPE type;
    7278  bool finalized;        //!< Sets the Object to be finalized.
    7379
     
    8187  int groupCount;       //!< The Count of Groups.
    8288
     89  tList<Material>* materialList;
     90 
     91
    8392  bool initGroup(Group* group);
    8493  bool initFace (Face* face);
     
    8695  bool buildVertexNormals(void);
    8796
    88   bool importToGL(void);
     97  bool importToDisplayList(void);
    8998  bool addGLElement(FaceElement* elem);
    9099
     100  bool importToVertexArray(void);
     101
     102  bool deleteArrays(void);
    91103  bool cleanup(void);
    92104  bool cleanupGroup(Group* group);
     
    94106  bool cleanupFaceElement(FaceElement* faceElem);
    95107
    96   tList<Material>* materialList;
    97108
    98109 protected:
     
    104115
    105116 public:
    106   Model(const char* modelName = NULL);
     117  Model(const char* modelName = NULL, MODEL_TYPE type = MODEL_DISPLAY_LIST);
    107118  virtual ~Model(void);
    108119
  • orxonox/trunk/src/lib/graphics/importer/objModel.cc

    r3915 r3916  
    3232   \param scaling The factor that the model will be scaled with.
    3333*/
    34 OBJModel::OBJModel(char* fileName, float scaling)
     34OBJModel::OBJModel(const char* fileName, float scaling) : Model(fileName)
    3535{
    3636  this->initializeOBJ();
     
    7272   \param fileName The file to import
    7373*/
    74 bool OBJModel::importFile (char* fileName)
     74bool OBJModel::importFile (const char* fileName)
    7575{
    7676  PRINTF(4)("preparing to read in file: %s\n", fileName);
     
    8484  char pathSplitter='/';
    8585#endif /* __WIN32__ */
    86   char* tmpName = fileName;
     86  char* tmpName;
     87  strcpy(tmpName, fileName);
    8788  if (tmpName[0] == pathSplitter)
    8889    tmpName++;
     
    191192
    192193*/
    193 bool OBJModel::readMtlLib (char* mtlFile)
     194bool OBJModel::readMtlLib (const char* mtlFile)
    194195{
    195196  this->mtlFileName = new char [strlen(mtlFile)+1];
  • orxonox/trunk/src/lib/graphics/importer/objModel.h

    r3655 r3916  
    1313{
    1414 public:
    15   OBJModel(char* fileName, float scaling = 1.0);
     15  OBJModel(const char* fileName, float scaling = 1.0);
    1616  virtual ~OBJModel();
    1717  void initializeOBJ(void);
     
    2424
    2525  ///// readin /////
    26   bool importFile (char* fileName);
     26  bool importFile (const char* fileName);
    2727  bool readFromObjFile (void);
    28   bool readMtlLib (char* matFile);
     28  bool readMtlLib (const char* matFile);
    2929};
    3030
Note: See TracChangeset for help on using the changeset viewer.