//========================================================================== // BSP File Read Functions //========================================================================== bspheader Readheader() { br.BaseStream.Seek(0, SeekOrigin.Begin); bspheader header = new bspheader(); header.magic = new string (br.ReadChars(4)); header.version = br.ReadInt32(); header.lumps = new bsplump[SourceBSPStructs.HEADER_LUMPS]; for (int i = 0; i < SourceBSPStructs.HEADER_LUMPS; i++) { header.lumps[i] = new bsplump(); if (!Test.Inst.isL4D2) { header.lumps[i].fileofs = br.ReadInt32(); header.lumps[i].filelen = br.ReadInt32(); header.lumps[i].version = br.ReadInt32(); header.lumps[i].fourCC = new string(br.ReadChars(4)); } else { header.lumps[i].version = br.ReadInt32(); header.lumps[i].fileofs = br.ReadInt32(); header.lumps[i].filelen = br.ReadInt32(); header.lumps[i].fourCC = new string(br.ReadChars(4)); } } Debug.Log(header.magic + " version: " + header.version); return(header); }
public BSPFile(BinaryReader nbr, string name) { LevelName = name; br = nbr; header = Readheader(); if (uSrcSettings.Inst.entities) { entitiesLump = ReadEntities(); } //ParseEntities (entitiesLump); //planesLump = ReadPlanes (); texdataLump = ReadTexData(); vertexesLump = ReadVertexes(); // // texinfosLump = ReadTexInfos(); facesLump = ReadFaces(); if (uSrcSettings.Inst.lightmaps) { lightingLump = ReadLighting(); } else { hasLightmaps = false; } // // // edgesLump = ReadEdges(); surfedgesLump = ReadSurfedges(); modelsLump = ReadModels(); //Debug.Log ("World lights lump length: " + header.lumps [SourceBSPStructs.LUMP_WORLDLIGHTS].filelen); if (uSrcSettings.Inst.displacements) { dispinfoLump = ReadDispInfo(); // dispVertsLump = ReadDispVerts(); // } if (uSrcSettings.Inst.props) { gameLump = ReadGameLump(); ParseGameLumps(); } // // // if (uSrcSettings.Inst.textures) { readTexdataString(); } }
//========================================================================== // BSP File Read Functions //========================================================================== bspheader Readheader() { br.BaseStream.Seek(0, SeekOrigin.Begin); bspheader header = new bspheader(); header.ident = br.ReadInt32(); header.version = br.ReadInt32(); header.lumps = new bsplump[SourceBSPStructs.HEADER_LUMPS]; for (int i = 0; i < SourceBSPStructs.HEADER_LUMPS; i++) { header.lumps[i] = new bsplump(); if (!Test.Inst.isL4D2) { header.lumps[i].fileofs = br.ReadInt32(); header.lumps[i].filelen = br.ReadInt32(); header.lumps[i].version = br.ReadInt32(); header.lumps[i].fourCC = new string(br.ReadChars(4)); } else { header.lumps[i].version = br.ReadInt32(); header.lumps[i].fileofs = br.ReadInt32(); header.lumps[i].filelen = br.ReadInt32(); header.lumps[i].fourCC = new string(br.ReadChars(4)); } } if (header.ident == SourceBSPStructs.VBSP) { Debug.Log("VBSP version: " + header.version); } else { throw new Exception("Unknown format"); } return(header); }
public BSPFile(BinaryReader nbr, string name) { LevelName = name; br = nbr; header = Readheader(); if (uSrcSettings.Inst.entities) { entitiesLump = ReadEntities(); } //ParseEntities (entitiesLump); //planesLump = ReadPlanes (); texdataLump = ReadTexData(); vertexesLump = ReadVertexes(); // // texinfosLump = ReadTexInfos(); if (uSrcSettings.Inst.lightmaps) { if (!Test.Inst.forceHDR & header.lumps[SourceBSPStructs.LUMP_LIGHTING].filelen > 0) { hasLightmaps = true; lightingLump = ReadLighting(); onlyHDR = false; if (header.version > 17) { facesLump = ReadFaces(SourceBSPStructs.LUMP_FACES); } else { facesLump = ReadFaces17(SourceBSPStructs.LUMP_FACES); // Vampire: The Masquerade - Bloodlines } } else if (header.lumps[SourceBSPStructs.LUMP_LIGHTING_HDR].filelen > 0) { hasLightmaps = true; lightingLump = ReadHDRLighting(); onlyHDR = true; if (header.version > 17) { facesLump = ReadFaces(SourceBSPStructs.LUMP_FACES_HDR); } else { facesLump = ReadFaces17(SourceBSPStructs.LUMP_FACES_HDR); // Vampire: The Masquerade - Bloodlines } } else { hasLightmaps = false; } } else { hasLightmaps = false; if (header.version > 17) { facesLump = ReadFaces(SourceBSPStructs.LUMP_FACES); } else { facesLump = ReadFaces17(SourceBSPStructs.LUMP_FACES); // Vampire: The Masquerade - Bloodlines } } // // // edgesLump = ReadEdges(); surfedgesLump = ReadSurfedges(); modelsLump = ReadModels(); //Debug.Log ("World lights lump length: " + header.lumps [SourceBSPStructs.LUMP_WORLDLIGHTS].filelen); if (uSrcSettings.Inst.displacements) { dispinfoLump = ReadDispInfo(); // //dispAlphasLumps= ReadDispAlphas(); dispVertsLump = ReadDispVerts(); // } vertNormalsLump = ReadVertNormals(); vertNormalIndicesLump = ReadVertNormalsIndices(); int normalIndex = 0; faceNormalPointers = new int[facesLump.Length]; for (int i = 0; i < facesLump.Length; i++) { faceNormalPointers[i] = normalIndex; normalIndex += facesLump[i].numedges; } if (uSrcSettings.Inst.props) { gameLump = ReadGameLump(); ParseGameLumps(); } // // // //if(uSrcSettings.Inst.textures) readTexdataString(); }