public DrawElement(FileReader reader, BIN_Parser header) { MaterialIndex = reader.ReadInt16(); ShapeBatchIndex = reader.ReadInt16(); Material = header.ReadSection <Material>(reader, MaterialIndex); Batch = header.ReadSection <ShapeBatch>(reader, ShapeBatchIndex); }
public void Write(ShapeBatch batch, FileWriter writer, BIN_Parser header) { writer.Write(OpCode); writer.Write((ushort)Vertices.Length); for (int i = 0; i < Vertices.Length; i++) { writer.Write(Vertices[i].PositionIndex); if (batch.AttributeFlags.HasFlag(GXAttributes.Normal)) { writer.Write(Vertices[i].NormalIndex); if (batch.NbtFlag != 0) { writer.Write(Vertices[i].BinormalIndex); writer.Write(Vertices[i].TangentIndex); } } if (batch.AttributeFlags.HasFlag(GXAttributes.Color0)) { writer.Write(Vertices[i].Color0Index); } if (batch.AttributeFlags.HasFlag(GXAttributes.Color1)) { writer.Write(Vertices[i].Color1Index); } for (int t = 0; t < batch.TexCoordFlag; t++) { if (batch.AttributeFlags.HasFlag((GXAttributes)(1 << (13 + t)))) { writer.Write(Vertices[i].TexCoordIndex[t]); } } } }