Changeset 7410 in orxonox.OLD
- Timestamp:
- Apr 27, 2006, 10:18:03 PM (19 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
r7395 r7410 127 127 size = SDL_SwapLE32(((int *)(header))[19]); 128 128 PRINTF(4)("BSP FILE: BrushesSize: %i Bytes. \n", size); 129 PRINTF(4)("BSP FILE: NumBrushes: %i. \n", size / 12);130 PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 12);129 PRINTF(4)("BSP FILE: NumBrushes: %i. \n", size / sizeof(brush)); 130 PRINTF(4)("BSP FILE: Remainder: %i. \n", size % sizeof(brush)); 131 131 PRINTF(4)("BSP FILE: BrushesOffset: %i. \n", offset); 132 this->brushes = new char [size];133 bspFile.seekg(offset); 134 bspFile.read( this->brushes, size);132 this->brushes = new brush [size/sizeof(brush)]; 133 bspFile.seekg(offset); 134 bspFile.read((char*)this->brushes, size); 135 135 136 136 // Get the brushSides … … 162 162 size = SDL_SwapLE32(((int *)(header))[25]); 163 163 PRINTF(4)("BSP FILE: MeshVertsSize: %i Bytes. \n", size); 164 PRINTF(4)("BSP FILE: NumMeshVerts: %i. \n", size / 4);165 PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 4);164 PRINTF(4)("BSP FILE: NumMeshVerts: %i. \n", size / sizeof(meshvert)); 165 PRINTF(4)("BSP FILE: Remainder: %i. \n", size % sizeof(meshvert)); 166 166 PRINTF(4)("BSP FILE: MeshVertsOffset: %i. \n", offset); 167 this->meshverts = new char [size];168 bspFile.seekg(offset); 169 bspFile.read( this->meshverts, size);167 this->meshverts = new meshvert [size / sizeof(meshvert)]; 168 bspFile.seekg(offset); 169 bspFile.read((char*)this->meshverts, size); 170 170 171 171 // Get the Faces … … 220 220 for( int i = 0; i < this->numFaces; i++) { 221 221 face& cFace = ((face *)(this->faces))[i]; 222 if ( cFace.type== 2)223 this->numPatches += ( cFace.size[0] -1 ) / 2 * (cFace.size[1]-1) / 2;222 if (SDL_SwapLE32(cFace.type) == 2) 223 this->numPatches += (SDL_SwapLE32(cFace.size[0]) -1 ) / 2 * (SDL_SwapLE32(cFace.size[1]) -1) / 2; 224 224 } 225 225 … … 234 234 // Do tesselation for all Faces of type 2 235 235 for( int i = 0; i < this->numFaces; i++) { 236 if ( ((face *)(this->faces))[i].type== 2)236 if (SDL_SwapLE32((this->faces)[i].type) == 2) 237 237 this->tesselate(i); 238 238 } … … 473 473 void BspFile::tesselate(int iface) 474 474 { 475 face* Face = & (((face *)(this->faces))[iface]);475 face* Face = &((this->faces)[iface]); 476 476 BspVertex * BspVrtx = (BspVertex*)this->vertice; 477 477 int level = 7; 478 478 int level1 = 8; 479 479 int size0 = SDL_SwapLE32(Face->size[0]); 480 int size1 = SDL_SwapLE32(Face->size[1]); 480 481 // For each patch... 481 for(int i = 0; i < (Face->size[0]- 1) ; i+=2) {482 for(int j = 0; j < (Face->size[1]-1) ; j+=2) {482 for(int i = 0; i < ( size0 - 1) ; i+=2) { 483 for(int j = 0; j < ( size1 -1) ; j+=2) { 483 484 484 485 … … 490 491 for(int k = 0; k < 3; k++) { 491 492 for(int l = 0; l < 3; l++) { 492 controls[k +3*l]. position[0] = BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].position[0];493 controls[k +3*l]. position[1] = BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].position[1];494 controls[k +3*l]. position[2] = BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].position[2]; /*Face->n_vertexes*/495 496 controlsTmp[2-k +6-3*l]. position[0] = BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].position[0];497 controlsTmp[2-k +6-3*l]. position[1] = BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].position[1];498 controlsTmp[2-k +6-3*l]. position[2] = BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].position[2]; /*Face->n_vertexes*/499 500 VControls[k +3*l]. position[0] = BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].position[0];501 VControls[k +3*l]. position[1] = BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].position[1];502 VControls[k +3*l]. position[2] = BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].position[2];503 504 VControls[k +3*l]. normal[0] = BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].normal[0];505 VControls[k +3*l]. normal[1] = BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].normal[1];506 VControls[k +3*l]. normal[2] = BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].normal[2];507 508 VControls[k +3*l]. texcoord[0][0]= BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].texcoord[0][0];509 VControls[k +3*l]. texcoord[0][1] = BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].texcoord[0][1];510 VControls[k +3*l]. texcoord[1][0] = BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].texcoord[1][0];511 VControls[k +3*l]. texcoord[1][1] = BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].texcoord[1][1];493 controls[k +3*l]. position[0] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[0]); 494 controls[k +3*l]. position[1] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]); 495 controls[k +3*l]. position[2] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/ 496 497 controlsTmp[2-k +6-3*l]. position[0] = SDL_SwapLE32( BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]); 498 controlsTmp[2-k +6-3*l]. position[1] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]); 499 controlsTmp[2-k +6-3*l]. position[2] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/ 500 501 VControls[k +3*l]. position[0] = SDL_SwapLE32( BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]); 502 VControls[k +3*l]. position[1] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]); 503 VControls[k +3*l]. position[2] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); 504 505 VControls[k +3*l]. normal[0] = SDL_SwapLE32( BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].normal[0]); 506 VControls[k +3*l]. normal[1] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].normal[1]); 507 VControls[k +3*l]. normal[2] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].normal[2]); 508 509 VControls[k +3*l]. texcoord[0][0]= SDL_SwapLE32( BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[0][0]); 510 VControls[k +3*l]. texcoord[0][1] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[0][1]); 511 VControls[k +3*l]. texcoord[1][0] = SDL_SwapLE32( BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[1][0]); 512 VControls[k +3*l]. texcoord[1][1] = SDL_SwapLE32( BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[1][1]); 512 513 513 514 … … 593 594 for(int v=0; v<=level; ++v) { 594 595 px=(float)v/level; 596 597 598 599 595 600 596 601 //Vertice[u*(tesselation+1)+v]= temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px); -
branches/bsp_model/src/lib/graphics/importer/bsp_file.h
r7395 r7410 147 147 face* faces; //!< 148 148 char* leafBrushes; //!< Buffer to store brush indice 149 char* brushes;//!< Buffer to store brushes149 brush* brushes; //!< Buffer to store brushes 150 150 char* brushSides; //!< 151 151 char* vertice; //!< 152 char* meshverts;//!<152 meshvert* meshverts; //!< 153 153 char* visData; //!< 154 154 char* textures; //!<
Note: See TracChangeset
for help on using the changeset viewer.