Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 10, 2005, 2:32:13 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: model is now able to return the values of its vertices

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

Legend:

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

    r4109 r4577  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1717
    1818#include "array.h"
     19
     20#include "debug.h"
    1921
    2022/**
     
    6668void Array::finalizeArray (void)
    6769{
    68   PRINTF(4)("Finalizing array. Length: %i\n", entryCount); 
     70  PRINTF(4)("Finalizing array. Length: %i\n", entryCount);
    6971  //  if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
    7072  if (!(this->array = new GLfloat [this->entryCount]))
     
    9092    {
    9193      PRINTF(5)("adding new Entry to Array: %f\n", entry);
    92      
     94
    9395      this->currentEntry->value = entry;
    9496      this->currentEntry->next = new Entry;
     
    9799      ++this->entryCount;
    98100    }
    99   else 
     101  else
    100102    PRINTF(2)("adding failed, because list has been finalized\n");
    101103}
     
    110112  this->addEntry (entry2);
    111113}
    112  
     114
    113115/**
    114116   \brief Simple debug info about the Array
  • orxonox/trunk/src/lib/graphics/importer/array.h

    r4109 r4577  
    88#ifndef _ARRAY_H
    99#define _ARRAY_H
    10 
    11 #include "stdincl.h"
     10#include "glincl.h"
    1211
    1312//! Array Class that handles dynamic-float arrays.
     
    2221  void addEntry (GLfloat entry);
    2322  void addEntry(GLfloat entry0, GLfloat entry1, GLfloat entry2);
    24  
     23
    2524  /** \returns The array */
    26   inline const GLfloat* getArray () const {return this->array;}
     25  inline const GLfloat* getArray () const { return this->array; };
    2726  /**   \returns The Count of entries in the Array*/
    28   inline int getCount(void)const {return this->entryCount;}
     27  inline int getCount(void)const { return this->entryCount; };
    2928  void debug(void) const ;
    3029 private:
     
    4140  Entry* firstEntry;   //!< Pointer to the first Entry of this Array
    4241  Entry* currentEntry; //!< Pointer to the current Entry of this Array. The one Entry we are working with.
    43  
    44  
     42
     43
    4544};
    4645
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r4357 r4577  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2121#include <stdarg.h>
    2222
    23 #include "array.h"
    2423#include "vector.h"
    2524#include "list.h"
     
    3837  this->vertexNumber = -1;
    3938  this->normalNumber = -1;
    40   this->texCoordNumber = -1;   
     39  this->texCoordNumber = -1;
    4140
    4241  this->next = NULL;
     
    6059
    6160  this->firstElem = NULL;
    62  
     61
    6362  this->material = NULL;
    64  
     63
    6564  this->next = NULL;
    6665
     
    7675  if (this->firstElem != NULL)
    7776    delete this->firstElem;
    78  
     77
    7978  if (this->next != NULL)
    8079    delete this->next;
     
    8988  this->name = "";
    9089  this->faceMode = -1;
    91   this->faceCount = 0; 
     90  this->faceCount = 0;
    9291  this->next = NULL;
    93  
     92
    9493  this->firstFace = new ModelFace;
    9594  this->currentFace = this->firstFace;
     
    135134Model::Model(const char* modelName, MODEL_TYPE type)
    136135{
    137   PRINTF(4)("new 3D-Model is being created\n");
    138   this->name = NULL;
     136  PRINTF(4)("new 3D-Model is being created\n");
    139137  this->setName(modelName);
    140138  this->type = type;
     
    147145  this->normalCount = 0;
    148146  this->texCoordCount = 0;
    149  
     147
    150148  this->scaleFactor = 1;
    151149
     
    168166{
    169167  PRINTF(4)("Deleting Model ");
    170   if (this->name)
    171     {
    172       PRINT(4)("%s\n", this->name);
    173       delete []this->name;
     168  if (this->getName())
     169    {
     170      PRINT(4)("%s\n", this->getName());
    174171    }
    175172  else
     
    204201  // this creates the display List.
    205202  this->importToDisplayList();
    206  
     203
    207204
    208205  // deletes everything we allocated.
     
    223220void Model::draw (void) const
    224221{
    225   PRINTF(4)("drawing the 3D-Models\n"); 
     222  PRINTF(4)("drawing the 3D-Models\n");
    226223  ModelGroup* tmpGroup = this->firstGroup;
    227224  while (tmpGroup != NULL)
     
    239236   It does this by just calling the List that must have been created earlier.
    240237*/
    241 void Model::draw (int groupNumber) const 
     238void Model::draw (int groupNumber) const
    242239{
    243240  if (groupNumber >= this->groupCount)
     
    246243      return;
    247244    }
    248   PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
     245  PRINTF(4)("drawing the requested 3D-Models if found.\n");
    249246  ModelGroup* tmpGroup = this->firstGroup;
    250247  int counter = 0;
     
    252249    {
    253250      if (counter == groupNumber)
    254         {
    255           PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name);
    256           glCallList (tmpGroup->listNumber);
    257           return;
    258         }
     251        {
     252          PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name);
     253          glCallList (tmpGroup->listNumber);
     254          return;
     255        }
    259256      ++counter;
    260257      tmpGroup = tmpGroup->next;
    261258    }
    262   PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->name);
     259  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getName());
    263260  return;
    264261
     
    273270void Model::draw (char* groupName) const
    274271{
    275   PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
     272  PRINTF(4)("drawing the requested 3D-Models if found.\n");
    276273  ModelGroup* tmpGroup = this->firstGroup;
    277274  while (tmpGroup != NULL)
    278275    {
    279276      if (!strcmp(tmpGroup->name, groupName))
    280         {
    281           PRINTF(4)("Drawing model %s\n", tmpGroup->name);
    282           glCallList (tmpGroup->listNumber);
    283           return;
    284         }
     277        {
     278          PRINTF(4)("Drawing model %s\n", tmpGroup->name);
     279          glCallList (tmpGroup->listNumber);
     280          return;
     281        }
    285282      tmpGroup = tmpGroup->next;
    286283    }
    287   PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->name);
     284  PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->getName());
    288285  return;
    289286}
     
    292289// INIT //
    293290//////////
    294 /**
    295    \brief sets a name to the Model
    296    \param name The name to set to this Model
    297 */
    298 void Model::setName(const char* name)
    299 {
    300   if (this->name)
    301     delete []this->name;
    302   if (name)
    303     {
    304       this->name = new char[strlen(name)+1];
    305       strcpy(this->name, name);
    306     }
    307   else
    308     this->name = NULL;
    309 }
    310 
    311291/**
    312292   \brief deletes all the arrays
     
    334314  PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
    335315  this->firstGroup->cleanup();
    336   return true;
    337 }
    338 
    339 
     316  return true;
     317}
    340318
    341319//////////
     
    366344
    367345  // adding material to the List of materials
    368   this->materialList->add(newMat); 
     346  this->materialList->add(newMat);
    369347  return newMat;
    370348}
     
    382360    {
    383361      if (!strcmp(material->getName(), materialName))
    384         {
    385           delete tmpIt;
    386           return material;
    387         }
     362        {
     363          delete tmpIt;
     364          return material;
     365        }
    388366      material = tmpIt->nextElement();
    389367    }
     
    396374   \param groupString the new Group to create
    397375
    398    This function initializes a new Group. 
     376   This function initializes a new Group.
    399377   With it you should be able to create Models with more than one SubModel inside
    400378*/
     
    439417   \param y the Y-coordinate of the Vertex to add.
    440418   \param z the Z-coordinate of the Vertex to add.
    441    
     419
    442420*/
    443421bool Model::addVertex(float x, float y, float z)
     
    538516    {
    539517      if (this->currentGroup->currentFace->vertexCount>0)
    540           tmpElem = tmpElem->next = new ModelFaceElement;
     518          tmpElem = tmpElem->next = new ModelFaceElement;
    541519      tmpElem->next = NULL;
    542520
     
    552530
    553531      if ((texture = strstr (vertex, "/")) != NULL)
    554         {
    555           texture[0] = '\0';
    556           texture ++;
    557          
    558           if ((normal = strstr (texture, "/")) !=NULL)
    559             {
    560               normal[0] = '\0';
    561               normal ++;
    562             }     
    563         }
     532        {
     533          texture[0] = '\0';
     534          texture ++;
     535
     536          if ((normal = strstr (texture, "/")) !=NULL)
     537            {
     538              normal[0] = '\0';
     539              normal ++;
     540            }
     541        }
    564542      if (vertex)
    565         tmpElem->vertexNumber = atoi(vertex)-1;
     543        tmpElem->vertexNumber = atoi(vertex)-1;
    566544      if (texture)
    567         tmpElem->texCoordNumber = atoi(texture)-1;
     545        tmpElem->texCoordNumber = atoi(texture)-1;
    568546      if (normal)
    569         tmpElem->normalNumber = atoi(normal)-1;
     547        tmpElem->normalNumber = atoi(normal)-1;
    570548
    571549      faceString += tmpLen;
    572550      if (strcmp (faceString, "\0"))
    573         faceString++;
     551        faceString++;
    574552      this->currentGroup->currentFace->vertexCount++;
    575553    }
     
    587565  if (this->currentGroup->faceCount > 0)
    588566    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
    589  
     567
    590568  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
    591  
     569
    592570  va_list itemlist;
    593571  va_start (itemlist, type);
     
    596574    {
    597575      if (this->currentGroup->currentFace->vertexCount > 0)
    598         tmpElem = tmpElem->next = new ModelFaceElement;
     576        tmpElem = tmpElem->next = new ModelFaceElement;
    599577
    600578      tmpElem->vertexNumber = va_arg (itemlist, int);
    601579      if (type & TEXCOORD)
    602         tmpElem->texCoordNumber = va_arg (itemlist, int);
     580        tmpElem->texCoordNumber = va_arg (itemlist, int);
    603581      if (type & NORMAL)
    604         tmpElem->normalNumber = va_arg(itemlist, int);
     582        tmpElem->normalNumber = va_arg(itemlist, int);
    605583      this->currentGroup->currentFace->vertexCount++;
    606584    }
     
    618596  if (this->currentGroup->faceCount > 0)
    619597    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
    620  
     598
    621599  this->currentGroup->currentFace->material = this->findMaterialByName(matString);
    622600
     
    633611  if (this->currentGroup->faceCount > 0)
    634612    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
    635  
     613
    636614  this->currentGroup->currentFace->material = mtl;
    637615
     
    650628*/
    651629bool Model::buildVertexNormals ()
    652 { 
     630{
    653631  PRINTF(4)("Normals are being calculated.\n");
    654632
     
    656634  for (int i=0; i<vertices->getCount()/3;i++)
    657635    normArray[i] = Vector(.0,.0,.0);
    658  
     636
    659637  int firstTouch;
    660638  int secondTouch;
     
    668646      ModelFace* tmpFace = tmpGroup->firstFace;
    669647      while (tmpFace)
    670         {
    671           if (tmpFace->firstElem)
    672             {
    673               ModelFaceElement* firstElem = tmpFace->firstElem;
    674               ModelFaceElement* prevElem;
    675               ModelFaceElement* curElem = firstElem;
    676               ModelFaceElement* nextElem;
    677               ModelFaceElement* lastElem;
    678               // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop.
    679               while (curElem)
    680                 {
    681                   prevElem = curElem;
    682                   curElem = curElem->next;
    683                 }
    684               lastElem = prevElem;
    685              
    686               curElem = firstElem;
    687               for (int j=0; j<tmpFace->vertexCount; j++)
    688                 {
    689                   if (!(nextElem = curElem->next))
    690                     nextElem = firstElem;
    691                   curElem->normalNumber = curElem->vertexNumber;
    692                  
    693                   curV = Vector (vertices->getArray()[curElem->vertexNumber*3], vertices->getArray()[curElem->vertexNumber*3+1], vertices->getArray()[curElem->vertexNumber*3+2]);
    694                   prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV;
    695                   nextV = Vector (vertices->getArray()[nextElem->vertexNumber*3], vertices->getArray()[nextElem->vertexNumber*3+1], vertices->getArray()[nextElem->vertexNumber*3+2]) - curV;
    696                   normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
    697 
    698                   prevElem = curElem;
    699                   curElem = curElem->next;
    700                 }
    701             }
    702           tmpFace = tmpFace->next;
    703         }
     648        {
     649          if (tmpFace->firstElem)
     650            {
     651              ModelFaceElement* firstElem = tmpFace->firstElem;
     652              ModelFaceElement* prevElem;
     653              ModelFaceElement* curElem = firstElem;
     654              ModelFaceElement* nextElem;
     655              ModelFaceElement* lastElem;
     656              // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop.
     657              while (curElem)
     658                {
     659                  prevElem = curElem;
     660                  curElem = curElem->next;
     661                }
     662              lastElem = prevElem;
     663
     664              curElem = firstElem;
     665              for (int j=0; j<tmpFace->vertexCount; j++)
     666                {
     667                  if (!(nextElem = curElem->next))
     668                    nextElem = firstElem;
     669                  curElem->normalNumber = curElem->vertexNumber;
     670
     671                  curV = Vector (vertices->getArray()[curElem->vertexNumber*3], vertices->getArray()[curElem->vertexNumber*3+1], vertices->getArray()[curElem->vertexNumber*3+2]);
     672                  prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV;
     673                  nextV = Vector (vertices->getArray()[nextElem->vertexNumber*3], vertices->getArray()[nextElem->vertexNumber*3+1], vertices->getArray()[nextElem->vertexNumber*3+2]) - curV;
     674                  normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
     675
     676                  prevElem = curElem;
     677                  curElem = curElem->next;
     678                }
     679            }
     680          tmpFace = tmpFace->next;
     681        }
    704682      tmpGroup = tmpGroup->next;
    705683    }
     
    709687      normArray[i].normalize();
    710688      PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
    711      
     689
    712690      this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z);
    713691
    714692    }
    715   delete []normArray; 
     693  delete []normArray;
    716694}
    717695
     
    738716      // creating a glList for the Group
    739717      if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
    740         {
    741           PRINTF(2)("glList could not be created for this Model\n");
    742           return false;
    743         }
     718        {
     719          PRINTF(2)("glList could not be created for this Model\n");
     720          return false;
     721        }
    744722      glNewList (this->currentGroup->listNumber, GL_COMPILE);
    745723
     
    747725      ModelFace* tmpFace = this->currentGroup->firstFace;
    748726      while (tmpFace != NULL)
    749         {
    750           if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
    751             {
    752               if (this->currentGroup->faceMode != -1)
    753                 glEnd();
    754               this->currentGroup->faceMode = 0;
    755               Material* tmpMat;
    756               if (tmpFace->material != NULL)
    757                 {
    758                   tmpFace->material->select();
    759                   PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName());
    760                 }
    761             }
    762 
    763           else if (tmpFace->vertexCount == 3)
    764             {
    765               if (this->currentGroup->faceMode != 3)
    766                 {
    767                   if (this->currentGroup->faceMode != -1)
    768                     glEnd();
    769                   glBegin(GL_TRIANGLES);
    770                 }
    771              
    772               this->currentGroup->faceMode = 3;
    773               PRINTF(5)("found triag.\n");
    774             }
    775          
    776           else if (tmpFace->vertexCount == 4)
    777             {
    778               if (this->currentGroup->faceMode != 4)
    779                 {
    780                   if (this->currentGroup->faceMode != -1)
    781                     glEnd();
    782                   glBegin(GL_QUADS);
    783                 }
    784               this->currentGroup->faceMode = 4;
    785               PRINTF(5)("found quad.\n");
    786             }
    787          
    788           else if (tmpFace->vertexCount > 4)
    789             {
    790               if (this->currentGroup->faceMode != -1)
    791                 glEnd();
    792               glBegin(GL_POLYGON);
    793               PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount);
    794               this->currentGroup->faceMode = tmpFace->vertexCount;
    795             }
    796          
    797           ModelFaceElement* tmpElem = tmpFace->firstElem;
    798           while (tmpElem != NULL)
    799             {
    800               //      PRINTF(2)("%s\n", tmpElem->value);
    801               this->addGLElement(tmpElem);
    802               tmpElem = tmpElem->next;
    803             }
    804           tmpFace = tmpFace->next;
    805         }
     727        {
     728          if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
     729            {
     730              if (this->currentGroup->faceMode != -1)
     731                glEnd();
     732              this->currentGroup->faceMode = 0;
     733              Material* tmpMat;
     734              if (tmpFace->material != NULL)
     735                {
     736                  tmpFace->material->select();
     737                  PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName());
     738                }
     739            }
     740
     741          else if (tmpFace->vertexCount == 3)
     742            {
     743              if (this->currentGroup->faceMode != 3)
     744                {
     745                  if (this->currentGroup->faceMode != -1)
     746                    glEnd();
     747                  glBegin(GL_TRIANGLES);
     748                }
     749
     750              this->currentGroup->faceMode = 3;
     751              PRINTF(5)("found triag.\n");
     752            }
     753
     754          else if (tmpFace->vertexCount == 4)
     755            {
     756              if (this->currentGroup->faceMode != 4)
     757                {
     758                  if (this->currentGroup->faceMode != -1)
     759                    glEnd();
     760                  glBegin(GL_QUADS);
     761                }
     762              this->currentGroup->faceMode = 4;
     763              PRINTF(5)("found quad.\n");
     764            }
     765
     766          else if (tmpFace->vertexCount > 4)
     767            {
     768              if (this->currentGroup->faceMode != -1)
     769                glEnd();
     770              glBegin(GL_POLYGON);
     771              PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount);
     772              this->currentGroup->faceMode = tmpFace->vertexCount;
     773            }
     774
     775          ModelFaceElement* tmpElem = tmpFace->firstElem;
     776          while (tmpElem != NULL)
     777            {
     778              //      PRINTF(2)("%s\n", tmpElem->value);
     779              this->addGLElement(tmpElem);
     780              tmpElem = tmpElem->next;
     781            }
     782          tmpFace = tmpFace->next;
     783        }
    806784      glEnd();
    807785      glEndList();
    808786
    809787      this->currentGroup = this->currentGroup->next;
    810     } 
     788    }
    811789}
    812790
     
    832810
    833811/**
    834    \brief Adds a Face-element (one vertex of a face) with all its information. 
     812   \brief Adds a Face-element (one vertex of a face) with all its information.
    835813   \param elem The FaceElement to add to the OpenGL-environment.
    836814
     
    848826    {
    849827      if (likely(elem->texCoordNumber < this->texCoordCount))
    850         glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2);
     828        glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2);
    851829      else
    852         PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
    853                   elem->texCoordNumber, this->texCoordCount);
     830        PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
     831                  elem->texCoordNumber, this->texCoordCount);
    854832    }
    855833  if (elem->normalNumber != -1)
     
    858836      glNormal3fv(this->normals->getArray() + elem->normalNumber * 3);
    859837    else
    860         PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
    861                   elem->normalNumber, this->normalCount);     
     838        PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
     839                  elem->normalNumber, this->normalCount);
    862840    }
    863841  if (elem->vertexNumber != -1)
    864842    {
    865843      if (likely(elem->vertexNumber < this->vertexCount))
    866           glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3);
     844          glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3);
    867845      else
    868         PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
    869                   elem->vertexNumber, this->vertexCount);     
    870     }   
     846        PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
     847                  elem->vertexNumber, this->vertexCount);
     848    }
    871849
    872850}
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r4529 r4577  
    77#define _MODEL_H
    88
     9#include "base_object.h"
    910#include "material.h"
    1011#include "glincl.h"
     12#include "array.h"
     13
    1114
    1215// FORWARD DEFINITION //
     
    1922   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.
    2023   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.
     24 * \todo implement this stuff
    2125*/
    2226typedef enum MODEL_TYPE {MODEL_DISPLAY_LIST,
    23                         MODEL_VERTEX_ARRAY};
     27                        MODEL_VERTEX_ARRAY};
    2428
    2529
     
    3034
    3135//! an enumerator for VERTEX_FORMAT
    32 typedef enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,
    33                             VERTEX_NORMAL = NORMAL,
    34                             VERTEX_TEXCOORD = TEXCOORD,
    35                             VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD};
     36typedef enum VERTEX_FORMAT { VERTEX_ONLY = VERTEX,
     37                             VERTEX_NORMAL = NORMAL,
     38                             VERTEX_TEXCOORD = TEXCOORD,
     39                             VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD };
    3640
    3741////////////////////
     
    4549  ~ModelFaceElement();
    4650
    47   int                vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
    48   int                normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
    49   int                texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
     51  int                 vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
     52  int                 normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
     53  int                 texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
    5054
    51   ModelFaceElement*  next;                 //!< Point to the next FaceElement in this List.
     55  ModelFaceElement*   next;                 //!< Point to the next FaceElement in this List.
    5256};
    5357
     
    5862  ModelFace();
    5963  ~ModelFace();
    60  
    61   int                 vertexCount;     //!< The Count of vertices this Face has.
     64
     65  unsigned int        vertexCount;     //!< The Count of vertices this Face has.
    6266  ModelFaceElement*   firstElem;       //!< Points to the first Vertex (FaceElement) of this Face.
    6367  Material*           material;        //!< The Material to use.
    64  
     68
    6569  ModelFace*          next;            //!< Pointer to the next Face.
    66 }; 
     70};
    6771
    6872//! Group to handle multiple Models per obj-file.
     
    8286  int          faceMode;       //!< The Mode the Face is in: initially -1, 0 for FaceList opened, 1 for Material,  3 for triangle, 4 for Quad, 5+ for Poly \todo ENUM...
    8387  int          faceCount;      //!< The Number of Faces this Group holds.
    84  
     88
    8589  ModelGroup*  next;           //!< Pointer to the next Group.
    8690};
     
    9195
    9296//! Class that handles 3D-Models. it can also read them in and display them.
    93 class Model
     97class Model : public BaseObject
    9498{
    9599 public:
     
    97101  virtual ~Model(void);
    98102
    99   void setName(const char* name);
    100   /** \returns the Name of the Model */
    101   inline const char* getName() {return this->name;}
    102  
    103103  void draw(void) const;
    104104  void draw(int groupNumber) const;
     
    106106
    107107  /** \returns Count of the Models (Groups) in this File */
    108   inline int getGroupCount(void) const {return this->groupCount;}
     108  inline int getGroupCount(void) const { return this->groupCount; };
     109
     110  /** \returns a Pointer to the Vertex-Array, if it was deleted it returns NULL */
     111  inline const GLfloat* getVertexArray(void) const { return this->vertices->getArray(); };
     112  /** \returns the VertexCount of this Model */
     113  inline unsigned int getVertexArrayCount(void) const { return this->vertexCount; };
     114
     115  /** \returns a Pointer to the Normals-Array, if it was deleted it returns NULL */
     116  inline const GLfloat* getNormalsArray(void) const { return this->normals->getArray(); };
     117  /** \returns the NormalsCount of this Model */
     118  inline unsigned int getNormalsArrayCount(void) const { return this->normalCount; };
     119
     120  /** \returns a Pointer to the TexCoord-Array, if it was deleted it returns NULL */
     121  inline const GLfloat* getTexCoordArray(void) const { return this->vTexture->getArray(); };
     122  /** \returns the TexCoord-Count of this Model */
     123  inline unsigned int getTexCoordArrayCount(void) const { return this->texCoordCount; };
     124
    109125
    110126  Material* addMaterial(Material* material);
     
    152168
    153169 private:
    154   char*            name;            //!< This is the name of the Model.
    155170  MODEL_TYPE       type;            //!< A type for the Model
    156171  bool             finalized;       //!< Sets the Object to be finalized.
    157172
    158   int              vertexCount;     //!< A modelwide Counter for vertices.
    159   int              normalCount;     //!< A modelwide Counter for the normals.
    160   int              texCoordCount;   //!< A modelwide Counter for the texCoord.
     173  unsigned int     vertexCount;     //!< A modelwide Counter for vertices.
     174  unsigned int     normalCount;     //!< A modelwide Counter for the normals.
     175  unsigned int     texCoordCount;   //!< A modelwide Counter for the texCoord.
    161176  Array*           vertices;        //!< The Array that handles the Vertices.
    162177  Array*           normals;         //!< The Array that handles the Normals.
Note: See TracChangeset for help on using the changeset viewer.