Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4793 in orxonox.OLD


Ignore:
Timestamp:
Jul 6, 2005, 12:50:31 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some comments, started implementing the Model::buildTriangleList() function, Array::getIndex now makes a value not reference comparison

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

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/array.h

    r4792 r4793  
    155155
    156156
    157 
     157/**
     158   \brief gets back the index of the entry in the array. value check
     159   \param entry: the entry to look up
     160   \returns the index in the array, -1 if not found
     161 */
    158162template<class T>
    159163int Array<T>::getIndex(T* entry) const
     
    164168  for(int i = 0; i < this->entryCount; ++i)
    165169  {
    166     if( unlikely(entry == &this->array[i]))
     170    if( unlikely(*entry == this->array[i]))
    167171      return i;
    168172  }
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r4791 r4793  
    1212   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
     14
     15   2005-07-06: (Patrick) added new function buildTriangleList()
    1416*/
    1517
     
    817819bool Model::buildTriangleList()
    818820{
    819 
     821  /* make sure, that all the arrays are finalized */
     822  this->vertices->finalizeArray();
     823  this->vTexture->finalizeArray();
     824  if( normals->getCount() == 0) // vertices-Array must be built for this
     825    this->buildVertexNormals();
     826  this->normals->finalizeArray();
     827
     828  if( unlikely((this->triangles = new sTriangle[this->vertices->getCount()]) == 0));
     829  {
     830    PRINTF(2)("Could not allocate memory for triangle list\n");
     831    return false;
     832  }
     833
     834  int i = 0;                       //!< the counter for the triangle array
     835  ModelFaceElement* tmpElem;       //!< the temporary face element
     836
     837  /* now iterate through all groups and build up the triangle list */
     838  this->currentGroup = this->firstGroup;
     839  while( this->currentGroup != NULL)
     840  {
     841      // Putting Faces to GL
     842    ModelFace* tmpFace = this->currentGroup->firstFace;
     843    while (tmpFace != NULL)
     844    {
     845      tmpElem = tmpFace->firstElem;
     846
     847      /* if its a triangle just add it to the list */
     848      if (tmpFace->vertexCount == 3)
     849      {
     850        for(int j = 0; j < 3; ++j)
     851        {
     852          //this->triangles[i].indexToVertices[j] = this->vertices->getIndex(tmpElem);
     853          tmpElem = tmpElem->next;
     854        }
     855      }
     856
     857      ModelFaceElement* tmpElem = tmpFace->firstElem;
     858      while (tmpElem != NULL)
     859      {
     860              //      PRINTF(2)("%s\n", tmpElem->value);
     861        this->addGLElement(tmpElem);
     862        tmpElem = tmpElem->next;
     863      }
     864      tmpFace = tmpFace->next;
     865    }
     866    glEnd();
     867    glEndList();
     868
     869    this->currentGroup = this->currentGroup->next;
     870  }
    820871}
    821872
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r4791 r4793  
    77#define _MODEL_H
    88
     9#include "abstract_model.h"
    910#include "base_object.h"
    1011#include "material.h"
     
    1718template<class T> class Array;
    1819template<class T> class tList;
     20
    1921
    2022//! an enumerator fot the different Model Types.
     
    176178  Array<GLfloat>*  normals;         //!< The Array that handles the Normals.
    177179  Array<GLfloat>*  vTexture;        //!< The Array that handles the VertexTextureCoordinates.
     180  sTriangle*       triangles;       //!< The Array of triangles in the abstract_model.h style
    178181
    179182  ModelGroup*      firstGroup;      //!< The first of all groups.
Note: See TracChangeset for help on using the changeset viewer.