Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 6, 2006, 11:59:11 PM (19 years ago)
Author:
bensch
Message:

trunk: staticModel now uses vector instead of tArray (more portable)

Location:
trunk/src/lib/graphics/importer
Files:
2 edited

Legend:

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

    r6315 r6423  
    201201  this->buildTriangleList();
    202202
    203   this->pModelInfo.pVertices = this->vertices.getArray();
    204   this->pModelInfo.pNormals = this->normals.getArray();
    205   this->pModelInfo.pTexCoor = this->vTexture.getArray();
     203  this->pModelInfo.pVertices = &this->vertices[0];
     204  this->pModelInfo.pNormals = &this->normals[0];
     205  this->pModelInfo.pTexCoor = &this->vTexture[0];
    206206
    207207  this->finalized = true;
     
    402402  float subbuffer3;
    403403  sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    404   this->vertices.addEntry(subbuffer1*scaleFactor,
    405                           subbuffer2*scaleFactor,
    406                           subbuffer3*scaleFactor);
     404  this->vertices.push_back(subbuffer1*scaleFactor);
     405  this->vertices.push_back(subbuffer2*scaleFactor);
     406  this->vertices.push_back(subbuffer3*scaleFactor);
    407407  this->pModelInfo.numVertices++;
    408408  return true;
     
    418418{
    419419  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
    420   this->vertices.addEntry(x*scaleFactor,
    421                           y*scaleFactor,
    422                           z*scaleFactor);
     420  this->vertices.push_back(x*scaleFactor);
     421  this->vertices.push_back(y*scaleFactor);
     422  this->vertices.push_back(z*scaleFactor);
    423423  this->pModelInfo.numVertices++;
    424424  return true;
     
    437437  float subbuffer3;
    438438  sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    439   this->normals.addEntry(subbuffer1, subbuffer2, subbuffer3);
     439  this->normals.push_back(subbuffer1);
     440  this->normals.push_back(subbuffer2);
     441  this->normals.push_back(subbuffer3);
    440442  this->pModelInfo.numNormals++;
    441443  return true;
     
    453455{
    454456  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
    455   this->normals.addEntry(x, y, z);
     457  this->normals.push_back(x);
     458  this->normals.push_back(y);
     459  this->normals.push_back(z);
    456460  this->pModelInfo.numNormals++;
    457461  return true;
     
    472476  float subbuffer2;
    473477  sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
    474   this->vTexture.addEntry(subbuffer1);
    475   this->vTexture.addEntry(1 - subbuffer2);
     478  this->vTexture.push_back(subbuffer1);
     479  this->vTexture.push_back(1 - subbuffer2);
    476480  this->pModelInfo.numTexCoor++;
    477481  return true;
     
    489493{
    490494  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
    491   this->vTexture.addEntry(u);
    492   this->vTexture.addEntry(v);
     495  this->vTexture.push_back(u);
     496  this->vTexture.push_back(v);
    493497  this->pModelInfo.numTexCoor++;
    494498  return true;
     
    631635  PRINTF(4)("Normals are being calculated.\n");
    632636
    633   Vector* normArray = new Vector [vertices.getCount()/3];
    634   for (int i=0; i<vertices.getCount()/3;i++)
     637  Vector* normArray = new Vector [vertices.size()/3];
     638  for (int i=0; i<vertices.size()/3;i++)
    635639    normArray[i] = Vector(.0,.0,.0);
    636640
     
    669673                  curElem->normalNumber = curElem->vertexNumber;
    670674
    671                   curV = Vector (this->vertices.getArray()[curElem->vertexNumber*3],
    672                                  this->vertices.getArray()[curElem->vertexNumber*3+1],
    673                                  this->vertices.getArray()[curElem->vertexNumber*3+2]);
    674 
    675                   prevV = Vector (this->vertices.getArray()[prevElem->vertexNumber*3],
    676                                   this->vertices.getArray()[prevElem->vertexNumber*3+1],
    677                                   this->vertices.getArray()[prevElem->vertexNumber*3+2]) - curV;
    678 
    679                   nextV = Vector (this->vertices.getArray()[nextElem->vertexNumber*3],
    680                                   this->vertices.getArray()[nextElem->vertexNumber*3+1],
    681                                   this->vertices.getArray()[nextElem->vertexNumber*3+2]) - curV;
     675                  curV = Vector (this->vertices[curElem->vertexNumber*3],
     676                                 this->vertices[curElem->vertexNumber*3+1],
     677                                 this->vertices[curElem->vertexNumber*3+2]);
     678
     679                  prevV = Vector (this->vertices[prevElem->vertexNumber*3],
     680                                  this->vertices[prevElem->vertexNumber*3+1],
     681                                  this->vertices[prevElem->vertexNumber*3+2]) - curV;
     682
     683                  nextV = Vector (this->vertices[nextElem->vertexNumber*3],
     684                                  this->vertices[nextElem->vertexNumber*3+1],
     685                                  this->vertices[nextElem->vertexNumber*3+2]) - curV;
    682686                  normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
    683687
     
    691695    }
    692696
    693   for (int i=0; i < this->vertices.getCount()/3;i++)
     697  for (int i=0; i < this->vertices.size()/3;i++)
    694698    {
    695699      normArray[i].normalize();
     
    711715{
    712716  // finalize the Arrays
    713   this->vertices.finalizeArray();
    714   this->vTexture.finalizeArray();
    715   if (normals.getCount() == 0) // vertices-Array must be built for this
     717  if (normals.size() == 0) // vertices-Array must be built for this
    716718    this->buildVertexNormals();
    717   this->normals.finalizeArray();
    718719
    719720  this->currentGroup = this->firstGroup;
     
    806807    return true;
    807808  /* make sure, that all the arrays are finalized */
    808   if( unlikely(!this->vertices.isFinalized()))
    809     this->vertices.finalizeArray();
    810   if( unlikely(!this->vTexture.isFinalized()))
    811     this->vTexture.finalizeArray();
    812   if( normals.getCount() == 0) // vertices-Array must be built for this
     809  if( normals.size() == 0) // vertices-Array must be built for this
    813810    this->buildVertexNormals();
    814   if( unlikely(!this->normals.isFinalized()))
    815     this->normals.finalizeArray();
    816 
    817811
    818812  int index = 0;                   //!< the counter for the triangle array
     
    939933    {
    940934      if (likely(elem->texCoordNumber < this->pModelInfo.numTexCoor))
    941         glTexCoord2fv(this->vTexture.getArray() + elem->texCoordNumber * 2);
     935        glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2);
    942936      else
    943937        PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
     
    947941    {
    948942    if (likely(elem->normalNumber < this->pModelInfo.numNormals))
    949       glNormal3fv(this->normals.getArray() + elem->normalNumber * 3);
     943      glNormal3fv(&this->normals[0] + elem->normalNumber * 3);
    950944    else
    951945        PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
     
    955949    {
    956950      if (likely(elem->vertexNumber < this->pModelInfo.numVertices))
    957           glVertex3fv(this->vertices.getArray() + elem->vertexNumber * 3);
     951          glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3);
    958952      else
    959953        PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
  • trunk/src/lib/graphics/importer/static_model.h

    r6031 r6423  
    1111#include "material.h"
    1212#include "glincl.h"
    13 #include "array.h"
     13#include <vector>
    1414#include <list>
    1515
     
    153153  unsigned int               faceCount;       //!< A modelwide Counter for the faces
    154154
    155   tArray<GLfloat>            vertices;        //!< The Array that handles the Vertices.
    156   tArray<GLfloat>            normals;         //!< The Array that handles the Normals.
    157   tArray<GLfloat>            vTexture;        //!< The Array that handles the VertexTextureCoordinates.
     155  std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
     156  std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
     157  std::vector<GLfloat>       vTexture;        //!< The Array that handles the VertexTextureCoordinates.
    158158
    159159  ModelGroup*                firstGroup;      //!< The first of all groups.
Note: See TracChangeset for help on using the changeset viewer.