private Node[] GetNodes(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpNodes]; Node[] nodesData = new Node[lump.Length / 32]; stream.Position = lump.Offset; for (int i = 0; i < nodesData.Length; i++) { nodesData[i] = new Node { planenum = UtilityReader.ReadInt(stream), children = new int[2] }; nodesData[i].children[0] = UtilityReader.ReadInt(stream); nodesData[i].children[1] = UtilityReader.ReadInt(stream); nodesData[i].mins = new short[3]; nodesData[i].mins[0] = UtilityReader.ReadShort(stream); nodesData[i].mins[1] = UtilityReader.ReadShort(stream); nodesData[i].mins[2] = UtilityReader.ReadShort(stream); nodesData[i].maxs = new short[3]; nodesData[i].maxs[0] = UtilityReader.ReadShort(stream); nodesData[i].maxs[1] = UtilityReader.ReadShort(stream); nodesData[i].maxs[2] = UtilityReader.ReadShort(stream); nodesData[i].firstface = UtilityReader.ReadUShort(stream); nodesData[i].numfaces = UtilityReader.ReadUShort(stream); nodesData[i].area = UtilityReader.ReadShort(stream); nodesData[i].paddding = UtilityReader.ReadShort(stream); } return(nodesData); }
private Leaf[] GetLeafs(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpLeafs]; Leaf[] leafData = new Leaf[lump.Length / 56]; stream.Position = lump.Offset; for (int i = 0; i < leafData.Length; i++) { leafData[i] = new Leaf { contents = (ContentsFlag)UtilityReader.ReadInt(stream), cluster = UtilityReader.ReadShort(stream), area = UtilityReader.ReadShort(stream), flags = UtilityReader.ReadShort(stream), mins = new short[3] }; leafData[i].mins[0] = UtilityReader.ReadShort(stream); leafData[i].mins[1] = UtilityReader.ReadShort(stream); leafData[i].mins[2] = UtilityReader.ReadShort(stream); leafData[i].maxs = new short[3]; leafData[i].maxs[0] = UtilityReader.ReadShort(stream); leafData[i].maxs[1] = UtilityReader.ReadShort(stream); leafData[i].maxs[2] = UtilityReader.ReadShort(stream); leafData[i].firstleafface = UtilityReader.ReadUShort(stream); leafData[i].numleaffaces = UtilityReader.ReadUShort(stream); leafData[i].firstleafbrush = UtilityReader.ReadUShort(stream); leafData[i].numleafbrushes = UtilityReader.ReadUShort(stream); leafData[i].leafWaterDataID = UtilityReader.ReadShort(stream); } return(leafData); }
private Plane[] GetPlanes(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpPlanes]; Plane[] planes = new Plane[lump.Length / 20]; stream.Position = lump.Offset; for (int i = 0; i < planes.Length; i++) { planes[i] = new Plane(); Vector3 normal = new Vector3 { X = UtilityReader.ReadFloat(stream), Y = UtilityReader.ReadFloat(stream), Z = UtilityReader.ReadFloat(stream) }; planes[i].normal = normal; planes[i].distance = UtilityReader.ReadFloat(stream); planes[i].type = UtilityReader.ReadInt(stream); } return(planes); }
private int[] GetSurfedges(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpSurfedges]; int[] surfedges = new int[lump.Length / 4]; stream.Position = lump.Offset; for (int i = 0; i < lump.Length / 4; i++) { surfedges[i] = UtilityReader.ReadInt(stream); } return(surfedges); }
private SurfFlag[] GetTextureInfo(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpTexinfo]; SurfFlag[] textureData = new SurfFlag[lump.Length / 72]; stream.Position = lump.Offset; for (int i = 0; i < textureData.Length; i++) { stream.Position += 64; textureData[i] = (SurfFlag)UtilityReader.ReadInt(stream); stream.Position += 4; } return(textureData); }
private Brush[] GetBrushes(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpBrushes]; Brush[] brushes = new Brush[lump.Length / 12]; stream.Position = lump.Offset; for (int i = 0; i < brushes.Length; i++) { brushes[i] = new Brush { firstside = UtilityReader.ReadInt(stream), numsides = UtilityReader.ReadInt(stream), contents = (ContentsFlag)UtilityReader.ReadInt(stream) }; } return(brushes); }
private Face[] GetFaces(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpFaces]; stream.Position = lump.Offset; Face[] faces = new Face[lump.Length / 56]; for (int i = 0; i < faces.Length; i++) { faces[i] = new Face { planeNumber = UtilityReader.ReadUShort(stream), side = UtilityReader.ReadByte(stream), onNode = UtilityReader.ReadByte(stream), firstEdge = UtilityReader.ReadInt(stream), numEdges = UtilityReader.ReadShort(stream), texinfo = UtilityReader.ReadShort(stream), dispinfo = UtilityReader.ReadShort(stream), surfaceFogVolumeID = UtilityReader.ReadShort(stream), styles = new byte[4] }; faces[i].styles[0] = UtilityReader.ReadByte(stream); faces[i].styles[1] = UtilityReader.ReadByte(stream); faces[i].styles[2] = UtilityReader.ReadByte(stream); faces[i].styles[3] = UtilityReader.ReadByte(stream); faces[i].lightOffset = UtilityReader.ReadInt(stream); faces[i].area = UtilityReader.ReadFloat(stream); faces[i].LightmapTextureMinsInLuxels = new int[2]; faces[i].LightmapTextureMinsInLuxels[0] = UtilityReader.ReadInt(stream); faces[i].LightmapTextureMinsInLuxels[1] = UtilityReader.ReadInt(stream); faces[i].LightmapTextureSizeInLuxels = new int[2]; faces[i].LightmapTextureSizeInLuxels[0] = UtilityReader.ReadInt(stream); faces[i].LightmapTextureSizeInLuxels[1] = UtilityReader.ReadInt(stream); faces[i].originalFace = UtilityReader.ReadInt(stream); faces[i].numPrims = UtilityReader.ReadUShort(stream); faces[i].firstPrimID = UtilityReader.ReadUShort(stream); faces[i].smoothingGroups = UtilityReader.ReadUInt(stream); } return(faces); }
private Header GetHeader(Stream stream) { Header header = new Header { ident = UtilityReader.ReadInt(stream) }; UtilityReader.BigEndian = header.ident != 'V' + ('B' << 8) + ('S' << 16) + ('P' << 24); header.version = UtilityReader.ReadInt(stream); header.lumps = new Lump[64]; for (int i = 0; i < header.lumps.Length; i++) { header.lumps[i] = new Lump { Type = (LumpType)i, Offset = UtilityReader.ReadInt(stream), Length = UtilityReader.ReadInt(stream), Version = UtilityReader.ReadInt(stream), FourCc = UtilityReader.ReadInt(stream) }; } header.mapRevision = UtilityReader.ReadInt(stream); return(header); }