Changeset 6423 in orxonox.OLD for trunk/src/lib/graphics/importer
- Timestamp:
- Jan 6, 2006, 11:59:11 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/static_model.cc
r6315 r6423 201 201 this->buildTriangleList(); 202 202 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]; 206 206 207 207 this->finalized = true; … … 402 402 float subbuffer3; 403 403 sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3); 404 this->vertices. addEntry(subbuffer1*scaleFactor,405 subbuffer2*scaleFactor, 406 404 this->vertices.push_back(subbuffer1*scaleFactor); 405 this->vertices.push_back(subbuffer2*scaleFactor); 406 this->vertices.push_back(subbuffer3*scaleFactor); 407 407 this->pModelInfo.numVertices++; 408 408 return true; … … 418 418 { 419 419 PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z); 420 this->vertices. addEntry(x*scaleFactor,421 y*scaleFactor, 422 420 this->vertices.push_back(x*scaleFactor); 421 this->vertices.push_back(y*scaleFactor); 422 this->vertices.push_back(z*scaleFactor); 423 423 this->pModelInfo.numVertices++; 424 424 return true; … … 437 437 float subbuffer3; 438 438 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); 440 442 this->pModelInfo.numNormals++; 441 443 return true; … … 453 455 { 454 456 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); 456 460 this->pModelInfo.numNormals++; 457 461 return true; … … 472 476 float subbuffer2; 473 477 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); 476 480 this->pModelInfo.numTexCoor++; 477 481 return true; … … 489 493 { 490 494 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); 493 497 this->pModelInfo.numTexCoor++; 494 498 return true; … … 631 635 PRINTF(4)("Normals are being calculated.\n"); 632 636 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++) 635 639 normArray[i] = Vector(.0,.0,.0); 636 640 … … 669 673 curElem->normalNumber = curElem->vertexNumber; 670 674 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; 682 686 normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV); 683 687 … … 691 695 } 692 696 693 for (int i=0; i < this->vertices. getCount()/3;i++)697 for (int i=0; i < this->vertices.size()/3;i++) 694 698 { 695 699 normArray[i].normalize(); … … 711 715 { 712 716 // 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 716 718 this->buildVertexNormals(); 717 this->normals.finalizeArray();718 719 719 720 this->currentGroup = this->firstGroup; … … 806 807 return true; 807 808 /* 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 813 810 this->buildVertexNormals(); 814 if( unlikely(!this->normals.isFinalized()))815 this->normals.finalizeArray();816 817 811 818 812 int index = 0; //!< the counter for the triangle array … … 939 933 { 940 934 if (likely(elem->texCoordNumber < this->pModelInfo.numTexCoor)) 941 glTexCoord2fv( this->vTexture.getArray()+ elem->texCoordNumber * 2);935 glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2); 942 936 else 943 937 PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n", … … 947 941 { 948 942 if (likely(elem->normalNumber < this->pModelInfo.numNormals)) 949 glNormal3fv( this->normals.getArray()+ elem->normalNumber * 3);943 glNormal3fv(&this->normals[0] + elem->normalNumber * 3); 950 944 else 951 945 PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete", … … 955 949 { 956 950 if (likely(elem->vertexNumber < this->pModelInfo.numVertices)) 957 glVertex3fv( this->vertices.getArray()+ elem->vertexNumber * 3);951 glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3); 958 952 else 959 953 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 11 11 #include "material.h" 12 12 #include "glincl.h" 13 #include "array.h"13 #include <vector> 14 14 #include <list> 15 15 … … 153 153 unsigned int faceCount; //!< A modelwide Counter for the faces 154 154 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. 158 158 159 159 ModelGroup* firstGroup; //!< The first of all groups.
Note: See TracChangeset
for help on using the changeset viewer.