// LWOB static IEnumerable<Polygon> ReadPolygons5(ChunkReader reader, uint vertex_offset) { // fill in the new polygons while (reader.BytesLeft > 0) { var vertex_count = reader.ReadUInt16(); var newPolygon = new Polygon(PolygonType.ID_FACE); for (var j = 0; j < vertex_count; j++) newPolygon.Vertices.Add( new PolygonVertex(reader.ReadUInt16() + vertex_offset) ); var index = (int)reader.ReadSInt16(); if (index < 0) { index = (int)-index; reader.ReadSInt16(); // skip 2 bytes - Q: why?? } newPolygon.surf_index = (uint)(index - 1); yield return newPolygon; } }
static IEnumerable<Polygon> ReadPolygons(ChunkReader reader, uint vertex_offset) { var type = reader.ReadID<PolygonType>(); // fill in the new polygons while (reader.BytesLeft > 0) { var vertex_count = reader.ReadUInt16(); var flags = vertex_count & 0xFC00; vertex_count &= 0x03FF; var newPolygon = new Polygon(type, flags); for (var j = 0; j < vertex_count; j++) newPolygon.Vertices.Add( new PolygonVertex(reader.ReadVariableLengthIndex() + vertex_offset) ); yield return newPolygon; } }