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 Vector3[] GetVertices(Stream stream) { Lump lump = _header.lumps[(int)LumpType.LumpVertexes]; stream.Position = lump.Offset; Vector3[] vertices = new Vector3[(lump.Length / 3) / 4]; for (int i = 0; i < vertices.Length; i++) { vertices[i] = new Vector3 { X = UtilityReader.ReadFloat(stream), Y = UtilityReader.ReadFloat(stream), Z = UtilityReader.ReadFloat(stream) }; } return(vertices); }
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); }