public static UnsafeBuffer Decode(VoidPtr data, byte divisor, uint length, WiiVertexComponentType componentType, bool UVs, int isSpecial) { float scale = VQuant.DeQuantTable[divisor]; int type = isSpecial * 5 + (UVs ? 0 : 10) + (int)componentType; ElementDecoder decoder = ElementCodec.Decoders[type]; int bytesPerVal = (UVs ? isSpecial + 1 : isSpecial + 2) * (componentType < WiiVertexComponentType.UInt16 ? 1 : componentType < WiiVertexComponentType.Float ? 2 : 4); int count = (int)(length / bytesPerVal); UnsafeBuffer buffer = new UnsafeBuffer(count * (UVs ? 8 : 12)); byte *pIn = (byte *)data, pOut = (byte *)buffer.Address; for (int i = 0; i < count; i++) { decoder(ref pIn, ref pOut, scale); } return(buffer); }
public static UnsafeBuffer Decode(MDL0VertexData *header) { int count = header->_numVertices; float scale = VQuant.DeQuantTable[header->_divisor]; int type = ((header->_isXYZ == 0) ? (int)ElementCodec.CodecType.XY : (int)ElementCodec.CodecType.XYZ) + (int)header->_type; ElementDecoder decoder = ElementCodec.Decoders[type]; UnsafeBuffer buffer = new UnsafeBuffer(count * 12); byte *pIn = (byte *)header->Data, pOut = (byte *)buffer.Address; for (int i = 0; i < count; i++) { decoder(ref pIn, ref pOut, scale); } return(buffer); }
public static UnsafeBuffer Decode(MDL0UVData *header) { int count = header->_numEntries; float scale = VQuant.DeQuantTable[header->_divisor]; int type = ((header->_isST == 0) ? (int)ElementCodec.CodecType.S : (int)ElementCodec.CodecType.ST) + (int)header->_format; ElementDecoder decoder = ElementCodec.Decoders[type]; UnsafeBuffer buffer = new UnsafeBuffer(count * 8); byte *pIn = (byte *)header->Entries, pOut = (byte *)buffer.Address; for (int i = 0; i < count; i++) { decoder(ref pIn, ref pOut, scale); } return(buffer); }
public static UnsafeBuffer Decode(MDL0NormalData *header) { int count = header->_numVertices; float scale = VQuant.DeQuantTable[header->_divisor]; //Should always be zero? int type = (int)ElementCodec.CodecType.XYZ + (int)header->_type; ElementDecoder decoder = ElementCodec.Decoders[type]; UnsafeBuffer buffer; if (header->_isNBT != 0) { count *= 3; //Format is the same, just with three Vectors each } buffer = new UnsafeBuffer(count * 12); byte *pIn = (byte *)header->Data, pOut = (byte *)buffer.Address; for (int i = 0; i < count; i++) { decoder(ref pIn, ref pOut, scale); } return(buffer); }