Changeset 9417 in orxonox.OLD for branches/terrain/src/lib/graphics/importer/bsp_file.cc
- Timestamp:
- Jul 24, 2006, 1:23:47 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/bsp_file.cc
r9414 r9417 102 102 this->numTextures = lump.length/sizeof(BspTexture); 103 103 this->textures = new char[lump.length]; 104 file.seekg( lump.offset ); 105 file.read( TEXTURE_SEMANTICS, this->numTextures, 104 file.seekg( lump.offset ); 105 file.read( TEXTURE_SEMANTICS, this->numTextures, 106 106 this->textures, slurpedBytes ); 107 107 } 108 108 void BspFile::readPlanes() 109 { 109 { 110 110 size_t slurpedBytes; 111 111 bsp_lump& lump = header.lumps[Planes]; … … 113 113 this->planes = new plane[this->numPlanes]; 114 114 file.seekg( lump.offset ); 115 file.read( PLANE_SEMANTICS, this->numPlanes, 115 file.read( PLANE_SEMANTICS, this->numPlanes, 116 116 this->planes, slurpedBytes ); 117 117 } … … 124 124 this->nodes = new node[this->numNodes]; 125 125 file.seekg( lump.offset ); 126 file.read( NODE_SEMANTICS, this->numNodes, 126 file.read( NODE_SEMANTICS, this->numNodes, 127 127 this->nodes, slurpedBytes ); 128 128 } … … 135 135 this->leaves = new leaf[this->numLeafs]; 136 136 file.seekg( lump.offset ); 137 file.read( LEAF_SEMANTICS, this->numLeafs, 138 this->leaves, slurpedBytes ); 137 file.read( LEAF_SEMANTICS, this->numLeafs, 138 this->leaves, slurpedBytes ); 139 139 } 140 140 … … 146 146 this->leafFaces = (char*)( new int[this->numLeafFaces] ); 147 147 file.seekg( lump.offset ); 148 file.read( "i", this->numLeafFaces, 148 file.read( "i", this->numLeafFaces, 149 149 this->leafFaces, slurpedBytes ); 150 150 } … … 157 157 this->leafBrushes = (char*) ( new int[this->numLeafBrushes] ); 158 158 file.seekg( lump.offset ); 159 file.read( "i", this->numLeafBrushes, 160 this->leafBrushes, slurpedBytes ); 159 file.read( "i", this->numLeafBrushes, 160 this->leafBrushes, slurpedBytes ); 161 161 } 162 162 … … 168 168 this->bspModels = new model[this->numBspModels]; 169 169 file.seekg( lump.offset ); 170 file.read( MODEL_SEMANTICS, this->numBspModels, 170 file.read( MODEL_SEMANTICS, this->numBspModels, 171 171 this->bspModels, slurpedBytes ); 172 172 } … … 179 179 this->brushes = new brush[numBrushes]; 180 180 file.seekg( lump.offset ); 181 file.read( BRUSH_SEMANTICS, numBrushes, 181 file.read( BRUSH_SEMANTICS, numBrushes, 182 182 this->brushes, slurpedBytes ); 183 183 } … … 189 189 this->vertice = (char*)( new BspVertex[this->numVertex] ); 190 190 file.seekg( lump.offset ); 191 file.read( VERTEX_SEMANTICS, this->numVertex, 191 file.read( VERTEX_SEMANTICS, this->numVertex, 192 192 this->vertice, slurpedBytes ); 193 193 } … … 215 215 this->faces = new face[this->numFaces]; 216 216 file.seekg( lump.offset ); 217 file.read( FACE_SEMANTICS, this->numFaces, 217 file.read( FACE_SEMANTICS, this->numFaces, 218 218 this->faces, slurpedBytes ); 219 219 } … … 226 226 this->lightMaps = new lightmap[this->numLightMaps]; 227 227 file.seekg( lump.offset ); 228 file.read( LIGHTMAP_SEMANTICS, this->numLightMaps, 228 file.read( LIGHTMAP_SEMANTICS, this->numLightMaps, 229 229 this->lightMaps, slurpedBytes ); 230 230 } 231 231 void BspFile::readLightvols() 232 232 { 233 /* not loaded atm */ 233 /* not loaded atm */ 234 234 } 235 235 void BspFile::readBrushSides() … … 241 241 this->brushSides = new brushside[this->numBrushSides]; 242 242 file.seekg( lump.offset ); 243 file.read( BRUSHSIDE_SEMANTICS, this->numBrushSides, 243 file.read( BRUSHSIDE_SEMANTICS, this->numBrushSides, 244 244 this->brushSides, slurpedBytes ); 245 245 } … … 251 251 file.seekg( lump.offset ); 252 252 file.read( "i2", 1, this->visData, slurpedBytes ); 253 file.read( "b", lump.length-8, 254 this->visData+8, slurpedBytes ); 253 file.read( "b", lump.length-8, 254 this->visData+8, slurpedBytes ); 255 255 } 256 256 /** … … 267 267 if (file.exists() && file.open( File::ReadOnly ) ) { 268 268 PRINTF(0)("BSP FILE: Datei %s gefunden. \n", name); 269 269 270 270 //BSP-Files have little endian order. 271 271 file.setByteorder( LittleEndian ); 272 272 file.read( HEADER_SEMANTICS, (void*)&header, slurpedBytes ); 273 273 if ( header.version != 46 ) { 274 PRINTF(0)("BSP FILE: Wrong BSPVersion. We only handle 0x2e-files!\n"); 275 //!< now, we should do some error handling 274 PRINTF(0)("BSP FILE: Wrong BSPVersion. We only handle 0x2e-files!\n"); 275 //!< now, we should do some error handling 276 276 return ( -1 ); 277 277 } … … 280 280 readPlanes(); 281 281 readNodes(); 282 readLeafs(); readLeafFaces(); readLeafBrushes(); 283 readModels(); 282 readLeafs(); readLeafFaces(); readLeafBrushes(); 283 readModels(); 284 284 readVertices(); readMeshVerts(); 285 285 readBrushSides(); readBrushes(); … … 287 287 readFaces(); 288 288 readLightmaps(); readLightvols(); 289 readVisdata( 289 readVisdata(); 290 290 file.close(); 291 291
Note: See TracChangeset
for help on using the changeset viewer.