Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4799 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Jul 6, 2005, 3:55:22 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: the triangle data should be constructed correctly now, if you start orxonox you will only see shit… this means, that the trangles data are not correct at all… I'm woking on this one

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

Legend:

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

    r4797 r4799  
    4141    inline unsigned int getCount()const { return this->entryCount; };
    4242    inline int getIndex(T* entry) const;
    43     inline bool isFinalized() { return this->finalized; }
     43    inline bool isFinalized() const { return this->finalized; }
    4444    void debug() const ;
    4545
     
    104104  //  if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
    105105  if (!(this->array = new GLfloat [this->entryCount]))
    106     PRINTF(1)("could not allocate %i data Blocks\n", this->entryCount);
     106    PRINTF(0)("could not allocate %i data Blocks\n", this->entryCount);
    107107  Entry* walker = this->firstEntry;
    108108  for (int i=0; i<this->entryCount; i++)
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r4798 r4799  
    225225void Model::draw () const
    226226{
     227  /*
    227228  PRINTF(4)("drawing the 3D-Models\n");
    228229  ModelGroup* tmpGroup = this->firstGroup;
     
    233234      tmpGroup = tmpGroup->next;
    234235    }
     236  */
     237
     238  if(unlikely(this->triangles == NULL))
     239    return;
     240
     241  const GLfloat* pVertices = NULL;
     242
     243  glBegin(GL_TRIANGLES);
     244  for( int i = 0; i < this->triangleCount; ++i)
     245  {
     246    pVertices = &this->vertices->getArray()[this->triangles[i].indexToVertices[0]];
     247    glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
     248
     249    pVertices = &this->vertices->getArray()[this->triangles[i].indexToVertices[1]];
     250    glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
     251
     252    pVertices = &this->vertices->getArray()[this->triangles[i].indexToVertices[2]];
     253    glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
     254
     255
     256//     glVertex3fv(&this->vertices->getArray()[this->triangles[i].indexToVertices[1]]);
     257//     glVertex3fv(&this->vertices->getArray()[this->triangles[i].indexToVertices[2]]);
     258  }
     259  glEnd();
    235260}
    236261
     
    874899
    875900  /* allocate memory for the new triangle structures */
    876   if( unlikely((this->triangles = new sTriangleExt[this->triangleCount]) == 0));
     901  if( (this->triangles = new sTriangleExt[this->triangleCount]) == NULL)
    877902  {
    878     PRINTF(2)("Could not allocate memory for triangle list\n");
     903    PRINTF(1)("Could not allocate memory for triangle list\n");
    879904    return false;
    880905  }
     
    907932        this->triangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
    908933        this->triangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
     934
     935        this->triangles[index + 1].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
     936        this->triangles[index + 1].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
    909937        tmpElem = tmpElem->next;
    910938
    911939        this->triangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
    912940        this->triangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
     941
     942        this->triangles[index + 1].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
     943        this->triangles[index + 1].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
    913944        tmpElem = tmpElem->next;
    914945
    915946        this->triangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
    916947        this->triangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
    917         ++index;
    918 
    919         this->triangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
    920         this->triangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
    921948        tmpElem = tmpElem->next;
    922949
    923         this->triangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
    924         this->triangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
    925         tmpElem = tmpElem->next;
    926 
    927         this->triangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
    928         this->triangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
    929         ++index;
     950        this->triangles[index + 1].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
     951        this->triangles[index + 1].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
     952
     953        index += 2;
    930954      }
     955      tmpFace = tmpFace->next;
    931956    }
    932957    this->currentGroup = this->currentGroup->next;
    933958  }
     959  return true;
    934960}
    935961
Note: See TracChangeset for help on using the changeset viewer.