private BspMipTexture[] ReadMipTextures(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_TEXTURES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numberOfTextures = reader.ReadInt32(); int[] mipTexturesOffset = new int[numberOfTextures]; for (int i = 0; i < numberOfTextures; i++) { mipTexturesOffset[i] = (entitiesLump.Offset + reader.ReadInt32()); } var mipTextures = new List <BspMipTexture>(); for (int i = 0; i < numberOfTextures; i++) { int textureOffset = mipTexturesOffset[i]; reader.BaseStream.Seek(textureOffset, SeekOrigin.Begin); mipTextures.Add(new BspMipTexture { Name = reader.ReadString(16), Width = reader.ReadUInt32(), Height = reader.ReadUInt32(), Offsets = reader.ReadUInt32Array(4) }); } return(mipTextures.ToArray()); }
private byte[] ReadVisData(BinaryReader reader, int length) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_VISIBILITY]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); byte[] vis = reader.ReadBytes(length); return(vis); }
private BspVisData ReadVisData(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_VISIBILITY]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); byte[] vis = reader.ReadBytes(entitiesLump.Length); return(new BspVisData { CompressedVis = vis }); }
private Entities ReadEntities(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_ENTITIES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); var bytes = reader.ReadBytes(entitiesLump.Length); string rawEntities = Encoding.ASCII.GetString(bytes); var parser = new EntityParser(bytes); var entities = parser.Parse(); return(entities); }
private short[] ReadMarkSurfaces(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_MARKSURFACES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numMarkSurfaces = entitiesLump.Length / 2; var markSurfaces = new List <short>(); for (int i = 0; i < numMarkSurfaces; i++) { markSurfaces.Add(reader.ReadInt16()); } return(markSurfaces.ToArray()); }
private int[] ReadSurfEdges(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_SURFEDGES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numSurfedges = entitiesLump.Length / 4; var surfedges = new List <int>(); for (int i = 0; i < numSurfedges; i++) { surfedges.Add(reader.ReadInt32()); } return(surfedges.ToArray()); }
private BspPlane[] ReadPlanes(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_PLANES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numPlanes = entitiesLump.Length / BspPlane.SizeInBytes; var planes = new List <BspPlane>(); for (int i = 0; i < numPlanes; i++) { planes.Add(new BspPlane { Normal = reader.ReadSingleArray(), Distance = reader.ReadSingle(), Type = reader.ReadInt32() }); } return(planes.ToArray()); }
private BspFace[] ReadFaces(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_FACES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numFaces = entitiesLump.Length / BspFace.SizeInBytes; var faces = new List <BspFace>(); for (int i = 0; i < numFaces; i++) { faces.Add(new BspFace { PlaneId = reader.ReadInt16(), PlaneSide = reader.ReadInt16(), FirstEdge = reader.ReadInt32(), NumEdges = reader.ReadInt16(), TextureInfo = reader.ReadInt16(), Styles = reader.ReadBytes(4), LightmapOffset = reader.ReadInt32() }); } return(faces.ToArray()); }
private BspVertex[] ReadVertices(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_VERTEXES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numVertices = entitiesLump.Length / BspVertex.SizeInBytes; var vertices = new List <BspVertex>(); for (int i = 0; i < numVertices; i++) { vertices.Add(new BspVertex { Point = reader.ReadSingleArray() }); } return(vertices.ToArray()); }
private BspEdge[] ReadEdges(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_EDGES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numEdges = entitiesLump.Length / BspEdge.SizeInBytes; var edges = new List <BspEdge>(); for (int i = 0; i < numEdges; i++) { edges.Add(new BspEdge { Vertices = reader.ReadUInt16Array() }); } return(edges.ToArray()); }
private BspLeaf[] ReadLeafs(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_LEAFS]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numLeafs = entitiesLump.Length / BspLeaf.SizeInBytes; var leafs = new List <BspLeaf>(); for (int i = 0; i < numLeafs; i++) { leafs.Add(new BspLeaf { Contents = reader.ReadInt32(), VisOffset = reader.ReadInt32(), Mins = reader.ReadInt16Array(), Maxs = reader.ReadInt16Array(), FirstMarkSurface = reader.ReadUInt16(), NumMarkSurfaces = reader.ReadUInt16(), AmbientLevels = reader.ReadBytes(4) }); } return(leafs.ToArray()); }
private BspNode[] ReadNodes(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_NODES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numNodes = entitiesLump.Length / BspNode.SizeInBytes; var nodes = new List <BspNode>(); for (int i = 0; i < numNodes; i++) { nodes.Add(new BspNode { PlaneId = reader.ReadInt32(), Children = reader.ReadInt16Array(2), Mins = reader.ReadInt16Array(), Maxs = reader.ReadInt16Array(), FirstFace = reader.ReadUInt16(), NumFaces = reader.ReadUInt16() }); } return(nodes.ToArray()); }
private BspClipNode[] ReadClipNodes(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_CLIPNODES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numClipNodes = entitiesLump.Length / BspClipNode.SizeInBytes; var clipNodes = new List <BspClipNode>(); for (int i = 0; i < numClipNodes; i++) { clipNodes.Add(new BspClipNode { PlaneId = reader.ReadInt32(), Children = reader.ReadInt16Array(2) }); } return(clipNodes.ToArray()); }
private BspModel[] ReadModels(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_MODELS]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numModels = entitiesLump.Length / 64; var models = new List <BspModel>(); for (int i = 0; i < numModels; i++) { models.Add(new BspModel { Mins = reader.ReadSingleArray(), Maxs = reader.ReadSingleArray(), Origin = reader.ReadSingleArray(), Nodes = reader.ReadInt32Array(), NumLeafs = reader.ReadInt32(), FirstFace = reader.ReadInt32(), NumFaces = reader.ReadInt32() }); } return(models.ToArray()); }
private BspTextureHeader ReadTextureHeader(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_TEXTURES]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numberOfTextures = reader.ReadInt32(); int[] mipTexturesOffsets = new int[numberOfTextures]; for (int i = 0; i < numberOfTextures; i++) { mipTexturesOffsets[i] = reader.ReadInt32(); } return(new BspTextureHeader { NumberMipTextures = numberOfTextures, Offsets = mipTexturesOffsets }); }
private BspTextureInfo[] ReadTextureInfos(BinaryReader reader) { BspLump entitiesLump = _header.Lumps[BspDefs.LUMP_TEXINFO]; reader.BaseStream.Seek(entitiesLump.Offset, SeekOrigin.Begin); int numTextureInfos = entitiesLump.Length / 40; var textureInfos = new List <BspTextureInfo>(); for (int i = 0; i < numTextureInfos; i++) { textureInfos.Add(new BspTextureInfo { Vec3s = reader.ReadSingleArray(), SShift = reader.ReadSingle(), Vec3t = reader.ReadSingleArray(), TShift = reader.ReadSingle(), MipTex = reader.ReadUInt32(), Flags = reader.ReadUInt32() }); } return(textureInfos.ToArray()); }