Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7666 in orxonox.OLD for branches/cd/src


Ignore:
Timestamp:
May 18, 2006, 1:41:35 AM (19 years ago)
Author:
patrick
Message:

cd: found the modelInfo bug, classical vertex index problem :D obb still not correct, but close to…

Location:
branches/cd/src/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cd/src/lib/collision_detection/obb_tree_node.cc

    r7665 r7666  
    719719        for( int i = 0; i < this->bvElement->modelInf->numTriangles; ++i)
    720720        {
    721           PRINTF(2)("triangle[%i]\n", i);
    722721          for(int j = 0; j < 3; ++j)
    723722          {
  • branches/cd/src/lib/graphics/importer/static_model.cc

    r7221 r7666  
    196196  this->buildTriangleList();
    197197
     198  // write out the modelInfo data used for the collision detection!
    198199  this->pModelInfo.pVertices = &this->vertices[0];
    199200  this->pModelInfo.pNormals = &this->normals[0];
     
    805806    this->buildVertexNormals();
    806807
    807   int index = 0;                   //!< the counter for the triangle array
    808   ModelFaceElement* tmpElem;       //!< the temporary faceelement reference
    809   ModelFace* tmpFace;              //!< the temporary face referece
     808  int                index = 0;                   //!< the counter for the triangle array
     809  ModelFaceElement*  tmpElem;       //!< the temporary faceelement reference
     810  ModelFace*         tmpFace;              //!< the temporary face referece
    810811
    811812  bool warned = false;
     813
     814  this->pModelInfo.numTriangles = 0;
    812815
    813816  /* count the number of triangles */
     
    819822    while( tmpFace != NULL)
    820823    {
    821 
    822824      /* if its a triangle just add it to the list */
    823       if( tmpFace->vertexCount == 3)
    824       {
     825      if( tmpFace->vertexCount == 3){
    825826        ++this->pModelInfo.numTriangles;
    826827      } /* if the polygon is a quad */
    827       else if( tmpFace->vertexCount == 4)
    828       {
     828      else if( tmpFace->vertexCount == 4) {
    829829        this->pModelInfo.numTriangles += 2;
    830830      }
    831       else if( tmpFace->vertexCount > 4)
    832       {
    833         if (!warned)
    834         {
     831      else if( tmpFace->vertexCount > 4) {
     832        if (!warned)        {
    835833          PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getName());
    836834          warned = true;
    837835        }
    838         //exit(0);
    839836      }
    840837      tmpFace = tmpFace->next;
     
    859856  while( this->currentGroup != NULL)
    860857  {
    861     // Putting Faces to GL
    862858    tmpFace = this->currentGroup->firstFace;
    863859    while( tmpFace != NULL)
     
    870866        for( int j = 0; j < 3; ++j)
    871867        {
    872           this->pModelInfo.pTriangles[index].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber /* * 3 */;
    873           this->pModelInfo.pTriangles[index].indexToNormals[j] = (unsigned int)tmpElem->normalNumber /* * 3 */;
    874           this->pModelInfo.pTriangles[index].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber /* * 3 */;
     868          this->pModelInfo.pTriangles[index].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber * 3 ;
     869          this->pModelInfo.pTriangles[index].indexToNormals[j] = (unsigned int)tmpElem->normalNumber * 3 ;
     870          this->pModelInfo.pTriangles[index].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber * 3 ;
    875871          tmpElem = tmpElem->next;
     872
    876873        }
    877874        ++index;
     
    880877      {
    881878
    882         this->pModelInfo.pTriangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
    883         this->pModelInfo.pTriangles[index].indexToNormals[0] = (unsigned int)tmpElem->normalNumber;
    884         this->pModelInfo.pTriangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
    885 
    886         this->pModelInfo.pTriangles[index + 1].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
    887         this->pModelInfo.pTriangles[index + 1].indexToNormals[0] = (unsigned int)tmpElem->normalNumber;
    888         this->pModelInfo.pTriangles[index + 1].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
     879        this->pModelInfo.pTriangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
     880        this->pModelInfo.pTriangles[index].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
     881        this->pModelInfo.pTriangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
     882
     883        this->pModelInfo.pTriangles[index + 1].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
     884        this->pModelInfo.pTriangles[index + 1].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
     885        this->pModelInfo.pTriangles[index + 1].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
    889886        tmpElem = tmpElem->next;
    890887
    891         this->pModelInfo.pTriangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
    892         this->pModelInfo.pTriangles[index].indexToNormals[1] = (unsigned int)tmpElem->normalNumber;
    893         this->pModelInfo.pTriangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
     888        this->pModelInfo.pTriangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
     889        this->pModelInfo.pTriangles[index].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
     890        this->pModelInfo.pTriangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
    894891        tmpElem = tmpElem->next;
    895892
    896         this->pModelInfo.pTriangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
    897         this->pModelInfo.pTriangles[index].indexToNormals[2] = (unsigned int)tmpElem->normalNumber;
    898         this->pModelInfo.pTriangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
    899 
    900         this->pModelInfo.pTriangles[index + 1].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
    901         this->pModelInfo.pTriangles[index + 1].indexToNormals[2] = (unsigned int)tmpElem->normalNumber;
    902         this->pModelInfo.pTriangles[index + 1].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
     893        this->pModelInfo.pTriangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
     894        this->pModelInfo.pTriangles[index].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
     895        this->pModelInfo.pTriangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
     896
     897        this->pModelInfo.pTriangles[index + 1].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
     898        this->pModelInfo.pTriangles[index + 1].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
     899        this->pModelInfo.pTriangles[index + 1].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
    903900        tmpElem = tmpElem->next;
    904901
    905         this->pModelInfo.pTriangles[index + 1].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
    906         this->pModelInfo.pTriangles[index + 1].indexToNormals[1] = (unsigned int)tmpElem->normalNumber;
    907         this->pModelInfo.pTriangles[index + 1].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
     902        this->pModelInfo.pTriangles[index + 1].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
     903        this->pModelInfo.pTriangles[index + 1].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
     904        this->pModelInfo.pTriangles[index + 1].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
    908905
    909906        index += 2;
Note: See TracChangeset for help on using the changeset viewer.