Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

orxonox/trunk: prepare for VertexArrays

File:
1 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.
Note: See TracChangeset for help on using the changeset viewer.