private static byte[] DecodeRgb5A3(byte[] fileData, uint dataOffset, uint width, uint height) { uint numBlocksW = width / 4; //4 byte block width uint numBlocksH = height / 4; //4 byte block height byte[] decodedData = new byte[width * height * 4]; for (int yBlock = 0; yBlock < numBlocksH; yBlock++) { for (int xBlock = 0; xBlock < numBlocksW; xBlock++) { //For each block, we're going to examine block width / block height number of 'pixels' for (int pY = 0; pY < 4; pY++) { for (int pX = 0; pX < 4; pX++) { //Ensure the pixel we're checking is within bounds of the image. if ((xBlock * 4 + pX >= width) || (yBlock * 4 + pY >= height)) { continue; } ushort sourcePixel = (ushort)FSHelpers.Read16(fileData, (int)dataOffset); RGB5A3ToRGBA8(sourcePixel, ref decodedData, (int)(4 * (width * ((yBlock * 4) + pY) + (xBlock * 4) + pX))); dataOffset += 2; } } } } return(decodedData); }
public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); _textureCount = (ushort)FSHelpers.Read16(data, offset + 0x08); _textureHeaderOffset = (uint)FSHelpers.Read32(data, offset + 0xC); _stringTableOffset = (uint)FSHelpers.Read32(data, offset + 0x10); offset += ChunkSize; }
public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); _sectionCount = (ushort)FSHelpers.Read16(data, offset + 0x8); _isWeightedOffset = (uint)FSHelpers.Read32(data, offset + 0xC); _dataOffset = (uint)FSHelpers.Read32(data, offset + 0x10); offset += ChunkSize; }
public StringTableEntry GetStringTableEntry(ushort index) { var ste = new StringTableEntry(); /* String Table Header */ ste.UnknownIndex = (ushort)FSHelpers.Read16(_dataCopy, (int)_stringTableOffset + 0x4 + (index * 0x4)); ste.StringOffset = (ushort)FSHelpers.Read16(_dataCopy, (int)_stringTableOffset + 0x6 + (index * 0x4)); return(ste); }
public void Load(byte[] data, ref int offset) { Vertices[0] = (ushort)FSHelpers.Read16(data, offset); Vertices[1] = (ushort)FSHelpers.Read16(data, offset + 2); Vertices[2] = (ushort)FSHelpers.Read16(data, offset + 4); Unknown1 = (ushort)FSHelpers.Read16(data, offset + 6); Unknown2 = (ushort)FSHelpers.Read16(data, offset + 8); offset += Size; }
public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); _unknown = (ushort)FSHelpers.Read16(data, offset + 8); _packetCount = (uint)FSHelpers.Read32(data, offset + 12); //2 bytes padding after _unusedEntryCount _vertexCount = (uint)FSHelpers.Read32(data, offset + 16); _hierarchyDataOffset = (uint)FSHelpers.Read32(data, offset + 20); offset += ChunkSize; }
public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); _jointCount = (ushort)FSHelpers.Read16(data, offset + 0x8); _entryOffset = (uint)FSHelpers.Read32(data, offset + 0xC); _stringIdTableOffset = (uint)FSHelpers.Read32(data, offset + 0x10); _stringTableOffset = (uint)FSHelpers.Read32(data, offset + 0x14); offset += ChunkSize; }
public Vector2 GetTex0(int index, int decimalPlace) { Vector2 newTexCoord = new Vector2(); float scaleFactor = (float)Math.Pow(0.5, decimalPlace); for (int i = 0; i < 2; i++) { newTexCoord[i] = FSHelpers.Read16(_dataCopy, (int)_tex0DataOffset + (index * 4) + (i * 0x2)) * scaleFactor; } return(newTexCoord); }
private uint _matrixDataOffset; //3x4 float array. Indeded into by something else. 15 in BST public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); _sectionCount = (ushort)FSHelpers.Read16(data, offset + 0x8); _countsArrayOffset = (uint)FSHelpers.Read32(data, offset + 0xC); _indicesOffset = (uint)FSHelpers.Read32(data, offset + 0x10); _weightsOffset = (uint)FSHelpers.Read32(data, offset + 0x14); _matrixDataOffset = (uint)FSHelpers.Read32(data, offset + 0x18); offset += ChunkSize; }
public Vector3 GetNormal(uint index, int decimalPlace) { Vector3 newNormal = new Vector3(); float scaleFactor = (float)Math.Pow(0.5, decimalPlace); for (int i = 0; i < 3; i++) { newNormal[i] = FSHelpers.Read16(_dataCopy, (int)(_normalDataOffset + (index * 6) + (i * 2))) * scaleFactor; } return(newNormal); }
public void Load(byte[] data, uint offset) { _unknown1 = (ushort)FSHelpers.Read16(data, (int)offset + 0x0); //One byte padding. _unknown2 = (byte)FSHelpers.Read16(data, (int)offset + 0x3); _scale = FSHelpers.ReadVector3(data, (int)offset + 0x4); _rotation = FSHelpers.ReadHalfRot(data, offset + 0x10); //2 bytes padding _translation = FSHelpers.ReadVector3(data, (int)offset + 0x18); _unknown3 = FSHelpers.ReadFloat(data, (int)offset + 0x24); _boundingBoxMin = FSHelpers.ReadVector3(data, (int)offset + 0x28); _boundingBoxMax = FSHelpers.ReadVector3(data, (int)offset + 0x34); }
public void Load(byte[] data, uint offset) { MatrixType = FSHelpers.Read8(data, (int)offset); Unknown0 = FSHelpers.Read8(data, (int)offset + 1); PacketCount = (ushort)FSHelpers.Read16(data, (int)offset + 0x2); AttribOffset = (ushort)FSHelpers.Read16(data, (int)offset + 0x4); FirstMatrixIndex = (ushort)FSHelpers.Read16(data, (int)offset + 0x6); PacketIndex = (ushort)FSHelpers.Read16(data, (int)offset + 0x8); Unknown = FSHelpers.ReadFloat(data, (int)offset + 0xC); BoundingBoxMin = FSHelpers.ReadVector3(data, (int)offset + 0x10); BoundingBoxMax = FSHelpers.ReadVector3(data, (int)offset + 0x1C); }
public ushort GetPrimitiveIndex(uint offset, BatchAttribute primitiveAttrib) { switch (primitiveAttrib.DataType) { case DataTypes.Signed16: return((ushort)FSHelpers.Read16(_dataCopy, (int)(_primitiveDataOffset + offset))); case DataTypes.Signed8: return(FSHelpers.Read8(_dataCopy, (int)(_primitiveDataOffset + offset))); default: throw new Exception("Unknown datatype index."); } }
public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); //Load information from header _batchCount = (ushort)FSHelpers.Read16(data, offset + 0x8); _batchDataOffset = (uint)FSHelpers.Read32(data, offset + 0xC); _unknownTableOffset = (uint)FSHelpers.Read32(data, offset + 0x10); _zero = (uint)FSHelpers.Read32(data, offset + 0x14); _attributeOffset = (uint)FSHelpers.Read32(data, offset + 0x18); _matrixTableOffset = (uint)FSHelpers.Read32(data, offset + 0x1C); _primitiveDataOffset = (uint)FSHelpers.Read32(data, offset + 0x20); _matrixDataOffset = (uint)FSHelpers.Read32(data, offset + 0x24); _packetLocationOffset = (uint)FSHelpers.Read32(data, offset + 0x28); offset += ChunkSize; }
private static void UnpackPixelFromPalette(int paletteIndex, ref byte[] dest, int offset, byte[] paletteData, PaletteFormat format) { switch (format) { case PaletteFormat.IA8: dest[0] = paletteData[2 * paletteIndex + 1]; dest[1] = paletteData[2 * paletteIndex + 0]; break; case PaletteFormat.RGB565: RGB565ToRGBA8((ushort)FSHelpers.Read16(paletteData, 2 * paletteIndex), ref dest, offset); break; case PaletteFormat.RGB5A3: RGB5A3ToRGBA8((ushort)FSHelpers.Read16(paletteData, 2 * paletteIndex), ref dest, offset); break; } }
public override void Load(byte[] data, ref int offset) { base.Load(data, ref offset); _materialCount = (ushort)FSHelpers.Read16(data, offset + 0x8); //Two bytes padding _materialInitDataOffset = (uint)FSHelpers.Read32(data, offset + 0xC); _materialIndexOffset = (uint)FSHelpers.Read32(data, offset + 0x10); _stringTableOffset = (uint)FSHelpers.Read32(data, offset + 0x14); _indirectTextureOffset = (uint)FSHelpers.Read32(data, offset + 0x18); _gxCullModeOffset = (uint)FSHelpers.Read32(data, offset + 0x1C); _gxColorOffset = (uint)FSHelpers.Read32(data, offset + 0x20); _colorChannelNumOffset = (uint)FSHelpers.Read32(data, offset + 0x24); _colorChannelInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x28); _gxColor2Offset = (uint)FSHelpers.Read32(data, offset + 0x2C); _lightInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x30); _texGenNumberOffset = (uint)FSHelpers.Read32(data, offset + 0x34); _texCoordInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x38); _texCoordInfo2Offset = (uint)FSHelpers.Read32(data, offset + 0x3C); _texMatrixInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x40); _texMatrix2InfoOffset = (uint)FSHelpers.Read32(data, offset + 0x44); _textureIndex = (uint)FSHelpers.Read32(data, offset + 0x48); _tevOrderInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x4C); _gxColorS10Offset = (uint)FSHelpers.Read32(data, offset + 0x50); _gxColor3Offset = (uint)FSHelpers.Read32(data, offset + 0x54); _tevStageNumInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x58); _tevStageInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x5C); _tevSwapModeInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x60); _tevSwapModeTableInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x64); _fogInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x68); _alphaCompareInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x6C); _blendInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x70); _zModeInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x74); _zCompareInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x78); _ditherINfoOffset = (uint)FSHelpers.Read32(data, offset + 0x7C); _nbtScaleInfoOffset = (uint)FSHelpers.Read32(data, offset + 0x80); offset += ChunkSize; GetMaterialInitData(0); }
} //Relative to file header public void Load(byte[] data, uint offset) { Format = (TextureFormat)FSHelpers.Read8(data, (int)offset + 0x00); _alphaUnknownSetting = FSHelpers.Read8(data, (int)offset + 0x01); Width = (ushort)FSHelpers.Read16(data, (int)offset + 0x02); Height = (ushort)FSHelpers.Read16(data, (int)offset + 0x04); WrapS = (WrapMode)FSHelpers.Read8(data, (int)offset + 0x06); WrapT = (WrapMode)FSHelpers.Read8(data, (int)offset + 0x07); PaletteFormat = (PaletteFormat)FSHelpers.Read8(data, (int)offset + 0x8); _unknown1 = FSHelpers.Read8(data, (int)offset + 0x09); PaletteEntryCount = (ushort)FSHelpers.Read16(data, (int)offset + 0xA); PaletteDataOffset = (uint)FSHelpers.Read32(data, (int)offset + 0xC); _unknown2 = (uint)FSHelpers.Read32(data, (int)offset + 0x10); FilterSettingMin = (FilterMode)FSHelpers.Read8(data, (int)offset + 0x14); FilterSettingMag = (FilterMode)FSHelpers.Read8(data, (int)offset + 0x15); _padding1 = (ushort)FSHelpers.Read16(data, (int)offset + 0x16); _imageCount = FSHelpers.Read8(data, (int)offset + 0x18); _padding2 = FSHelpers.Read8(data, (int)offset + 0x19); _padding3 = (ushort)FSHelpers.Read16(data, (int)offset + 0x1A); ImageDataOffset = (uint)FSHelpers.Read32(data, (int)offset + 0x1C); }
private static byte[] DecodeRgb565(byte[] fileData, uint dataOffset, uint width, uint height) { //16 bpp, 4 block width/height, block size 32 bytes, color. uint numBlocksW = width / 4; uint numBlocksH = height / 4; byte[] decodedData = new byte[width * height * 4]; //Read the indexes from the file for (int yBlock = 0; yBlock < numBlocksH; yBlock++) { for (int xBlock = 0; xBlock < numBlocksW; xBlock++) { //Inner Loop for pixels for (int pY = 0; pY < 4; pY++) { for (int pX = 0; pX < 4; pX++) { //Ensure we're not reading past the end of the image. if ((xBlock * 4 + pX >= width) || (yBlock * 4 + pY >= height)) { continue; } ushort sourcePixel = (ushort)FSHelpers.Read16(fileData, (int)dataOffset); RGB565ToRGBA8(sourcePixel, ref decodedData, (int)(4 * (width * ((yBlock * 4) + pY) + (xBlock * 4) + pX))); dataOffset += 2; } } } } return(decodedData); }
public ushort GetIndex(ushort index) { return((ushort)FSHelpers.Read16(_dataCopy, (int)_dataOffset + (index * 0x2))); }
public void Load(byte[] data, uint offset) { Unknown = (ushort)FSHelpers.Read16(data, (int)(offset + 0x0)); Count = (ushort)FSHelpers.Read16(data, (int)(offset + 0x2)); FirstIndex = (uint)FSHelpers.Read32(data, (int)(offset + 0x4)); }
public void Load(byte[] data, uint offset) { Type = (PrimitiveTypes)FSHelpers.Read8(data, (int)offset); VertexCount = (ushort)FSHelpers.Read16(data, (int)offset + 0x1); }
public ushort GetMaterialIndex(uint index) { return((ushort)FSHelpers.Read16(_dataCopy, (int)(_textureIndex + (index * 0x2)))); }
public ushort GetMaterialRemapTable(ushort index) { return((ushort)FSHelpers.Read16(_dataCopy, (int)(_materialIndexOffset + (index * 0x2)))); }
public ushort GetUnknown(uint index) { return((ushort)FSHelpers.Read16(_dataCopy, (int)(_unknownTableOffset + (index * 0x2)))); }
public ushort GetMatrixTableIndex(ushort index) { return((ushort)FSHelpers.Read16(_dataCopy, (int)(_matrixTableOffset + (index * 0x2)))); }
private ushort[] _unconfirmedIndexes = new ushort[16]; //16 of them! public void Load(byte[] data, uint offset) { _unknown1 = FSHelpers.Read8(data, (int)offset + 0x0); _unknown2 = FSHelpers.Read8(data, (int)offset + 0x1); _padding1 = (ushort)FSHelpers.Read16(data, (int)offset + 0x2); _indirectTexturingIndex = (ushort)FSHelpers.Read16(data, (int)offset + 0x4); _cullModeIndex = (ushort)FSHelpers.Read16(data, (int)offset + 0x6); for (int i = 0; i < 2; i++) { _ambientColorIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x8 + (i * 0x2)); } for (int i = 0; i < 4; i++) { _colorChannelIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0xC + (i * 0x2)); } for (int i = 0; i < 2; i++) { _materialColorIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x14 + (i * 0x2)); } for (int i = 0; i < 8; i++) { _lightingIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x18 + (i * 0x2)); } for (int i = 0; i < 8; i++) { _texCoordIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x28 + (i * 0x2)); } for (int i = 0; i < 8; i++) { _texCoord2Index[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x38 + (i * 0x2)); } for (int i = 0; i < 8; i++) { _texMatrixIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x48 + (i * 0x2)); } for (int i = 0; i < 8; i++) { _texMatrix2Index[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x58 + (i * 0x2)); } for (int i = 0; i < 8; i++) { _textureIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x84 + (i * 0x2)); } for (int i = 0; i < 4; i++) { _tevConstantColorIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x94 + (i * 0x2)); } for (int i = 0; i < 16; i++) { _constColorSel[i] = FSHelpers.Read8(data, (int)offset + 0x9C + (i * 0x1)); } for (int i = 0; i < 16; i++) { _constAlphaSel[i] = FSHelpers.Read8(data, (int)offset + 0xAC + (i * 0x1)); } for (int i = 0; i < 16; i++) { _tevOrderIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0xBC + (i * 0x2)); } for (int i = 0; i < 4; i++) { _tevColorIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0xDC + (i * 0x2)); } for (int i = 0; i < 16; i++) { _tevStageInfoIndex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0xE4 + (i * 0x2)); } for (int i = 0; i < 16; i++) { _tevSwapModeInfoindex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x104 + (i * 0x2)); } for (int i = 0; i < 4; i++) { _tevSwapModeTableInfoindex[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x124 + (i * 0x2)); } for (int i = 0; i < 16; i++) { _unconfirmedIndexes[i] = (ushort)FSHelpers.Read16(data, (int)offset + 0x12C + (i * 0x2)); } }
public void Load(byte[] data, uint offset) { Type = (HierarchyDataTypes)FSHelpers.Read16(data, (int)offset); Index = (ushort)FSHelpers.Read16(data, (int)offset + 0x2); }
public ushort GetIndexOffset(ushort offset) { return((ushort)FSHelpers.Read16(_dataCopy, (int)_indicesOffset + offset)); }
public ushort GetStringTableSize() { return((ushort)FSHelpers.Read16(_dataCopy, (int)_stringTableOffset)); }
public ushort GetStringIndex(ushort index) { return((ushort)FSHelpers.Read16(_dataCopy, (int)_stringIdTableOffset + (index * 0x2))); }