public bool Read(BinaryReaderExt Reader, GX_Attribute[] Attributes) { PrimitiveType = (GXPrimitiveType)Reader.ReadByte(); if (PrimitiveType == 0) { return(false); } var count = Reader.ReadInt16(); Indices = new GX_IndexGroup[count]; for (int j = 0; j < count; j++) { GX_IndexGroup g = new GX_IndexGroup(); g.Indices = new ushort[Attributes.Length]; int i = 0; Indices[j] = g; foreach (var att in Attributes) { if (att.AttributeName == GXAttribName.GX_VA_NULL) { continue; } switch (att.AttributeType) { case GXAttribType.GX_DIRECT: if (att.AttributeName == GXAttribName.GX_VA_CLR0) { g.Clr0 = ReadDirectGXColor(Reader, (int)att.CompType); } else if (att.AttributeName == GXAttribName.GX_VA_CLR1) { g.Clr1 = ReadDirectGXColor(Reader, (int)att.CompType); } else { g.Indices[i] = Reader.ReadByte(); } break; case GXAttribType.GX_INDEX8: g.Indices[i] = Reader.ReadByte(); break; case GXAttribType.GX_INDEX16: g.Indices[i] = Reader.ReadUInt16(); break; } i++; } } return(true); }
public void Write(BinaryWriterExt writer, GX_Attribute[] Attributes) { writer.Write((byte)PrimitiveType); writer.Write((ushort)Indices.Length); foreach (GX_IndexGroup ig in Indices) { GX_IndexGroup g = ig; int i = 0; foreach (var att in Attributes) { if (att.AttributeName == GXAttribName.GX_VA_NULL) { continue; } switch (att.AttributeType) { case GXAttribType.GX_DIRECT: if (att.AttributeName == GXAttribName.GX_VA_CLR0) { WriteGXClr(g.Clr0, writer, att.CompType); } else if (att.AttributeName == GXAttribName.GX_VA_CLR1) { WriteGXClr(g.Clr1, writer, att.CompType); } else { writer.Write((byte)g.Indices[i]); } break; case GXAttribType.GX_INDEX8: writer.Write((byte)g.Indices[i]); break; case GXAttribType.GX_INDEX16: writer.Write(g.Indices[i]); break; } i++; } } }