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 virtual void Load(byte[] data, ref int offset) { Type = FSHelpers.ReadString(data, offset, 4); ChunkSize = FSHelpers.Read32(data, offset + 4); _dataCopy = FSHelpers.ReadN(data, offset, ChunkSize); }
public void Load(byte[] data, uint offset) { ArrayType = (ArrayTypes)FSHelpers.Read32(data, (int)offset); ArrayCount = (uint)FSHelpers.Read32(data, (int)offset + 4); DataType = (DataTypes)FSHelpers.Read32(data, (int)offset + 8); DecimalPoint = FSHelpers.Read8(data, (int)offset + 12); }
public void Load(byte[] data, ref int offset) { Position = new Vector3( FSHelpers.ConvertIEEE754Float((uint)FSHelpers.Read32(data, offset)), FSHelpers.ConvertIEEE754Float((uint)FSHelpers.Read32(data, offset + 4)), FSHelpers.ConvertIEEE754Float((uint)FSHelpers.Read32(data, offset + 8))); offset += Size; }
public void WriteData(BinaryWriter stream) { FSHelpers.WriteString(stream, DestinationName, 8); FSHelpers.Write8(stream, SpawnNumber); FSHelpers.Write8(stream, DestinationRoomNumber); FSHelpers.Write8(stream, ExitType); FSHelpers.Write8(stream, UnknownPadding); }
public void WriteData(BinaryWriter stream) { FSHelpers.Write8(stream, DawnIndex); FSHelpers.Write8(stream, MorningIndex); FSHelpers.Write8(stream, NoonIndex); FSHelpers.Write8(stream, AfternoonIndex); FSHelpers.Write8(stream, DuskIndex); FSHelpers.Write8(stream, NightIndex); }
public BatchPacketLocation GetBatchPacketLocation(uint index) { BatchPacketLocation newBp = new BatchPacketLocation(); newBp.PacketSize = (uint)FSHelpers.Read32(_dataCopy, (int)(_packetLocationOffset + (index * BatchPacketLocation.Size) + 0x0)); newBp.Offset = (uint)FSHelpers.Read32(_dataCopy, (int)(_packetLocationOffset + (index * BatchPacketLocation.Size) + 0x4)); return(newBp); }
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 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 void Save(BinaryWriter stream) { for (int i = 0; i < 3; i++) { FSHelpers.Write16(stream, Vertices[i]); } FSHelpers.Write16(stream, Unknown1); FSHelpers.Write16(stream, Unknown2); }
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) { Magic = FSHelpers.ReadString(data, 0, 4); Type = FSHelpers.ReadString(data, 4, 4); FileSize = FSHelpers.Read32(data, 8); ChunkCount = FSHelpers.Read32(data, 12); //Four variables are followed by an unused tag and some padding. offset += 32; }
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 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 Vector4 GetColor0(int index) { Vector4 newColor = new Vector4(); for (int i = 0; i < 4; i++) { newColor[i] = FSHelpers.Read8(_dataCopy, (int)_color0DataOffset + (index * 4) + i) / 255f; } return(newColor); }
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 Vector3 GetPosition(uint index) { Vector3 newPos = new Vector3(); for (int i = 0; i < 3; i++) { newPos[i] = FSHelpers.ReadFloat(_dataCopy, (int)(_positionDataOffset + (index * Vector3.SizeInBytes) + (i * 4))); } return(newPos); }
public void WriteData(BinaryWriter stream) { FSHelpers.Write8(stream, ClearColorIndexA); FSHelpers.Write8(stream, RainingColorIndexA); FSHelpers.Write8(stream, SnowingColorIndexA); FSHelpers.Write8(stream, UnknownColorIndexA); FSHelpers.Write8(stream, ClearColorIndexB); FSHelpers.Write8(stream, RainingColorIndexB); FSHelpers.Write8(stream, SnowingColorIndexB); FSHelpers.Write8(stream, UnknownColorIndexB); }
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); }
public void Save(BinaryWriter stream) { FSHelpers.Write32(stream, NameOffset); FSHelpers.WriteVector(stream, Unknown1); FSHelpers.Write32(stream, Unknown2); FSHelpers.Write32(stream, Unknown3); FSHelpers.WriteVector(stream, Unknown4); FSHelpers.Write32(stream, Unknown5); FSHelpers.Write32(stream, Unknown6); FSHelpers.Write32(stream, Unknown7); FSHelpers.Write32(stream, Unknown8); }
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 Save(BinaryWriter stream) { FSHelpers.WriteString(stream, Magic, 4); FSHelpers.WriteString(stream, Type, 4); FSHelpers.Write32(stream, FileSize); FSHelpers.Write32(stream, ChunkCount); //Write in the unused tag and padding FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0x53565233, 4)); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0xFFFFFFFF, 4)); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0xFFFFFFFF, 4)); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0xFFFFFFFF, 4)); }
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 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 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 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 void Save(BinaryWriter stream) { FSHelpers.Write32(stream, (int)VertexCount); FSHelpers.Write32(stream, (int)VertexOffset); FSHelpers.Write32(stream, (int)TriangleCount); FSHelpers.Write32(stream, (int)TriangleOffset); FSHelpers.Write32(stream, (int)Unknown1Count); FSHelpers.Write32(stream, (int)Unknown1Offset); FSHelpers.Write32(stream, (int)Unknown2Count); FSHelpers.Write32(stream, (int)Unknown2Offset); FSHelpers.Write32(stream, (int)TypeCount); FSHelpers.Write32(stream, (int)TypeOffset); FSHelpers.Write32(stream, (int)Unknown3Count); FSHelpers.Write32(stream, (int)Unknown3Offset); }
public Matrix3x4 GetMatrix(ushort index) { Matrix3x4 matrix = new Matrix3x4(); for (int row = 0; row < 3; row++) { for (int col = 0; col < 4; col++) { float rawFloat = FSHelpers.ReadFloat(_dataCopy, (int)_matrixDataOffset + (index * (3 * 4 * 4)) + ((row * 4 * 4) + (col * 4))); matrix[row, col] = (float)Math.Round(rawFloat, 4); } } return(matrix); }
public void WriteData(BinaryWriter stream) { FSHelpers.WriteString(stream, Name, 8); FSHelpers.Write8(stream, EventIndex); FSHelpers.Write8(stream, Unknown1); FSHelpers.Write8(stream, SpawnType); FSHelpers.Write8(stream, RoomNumber); FSHelpers.WriteFloat(stream, Position.X); FSHelpers.WriteFloat(stream, Position.Y); FSHelpers.WriteFloat(stream, Position.Z); FSHelpers.Write16(stream, (ushort)Rotation.X); FSHelpers.Write16(stream, (ushort)Rotation.Y); FSHelpers.Write16(stream, (ushort)Rotation.Z); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0xFFFF, 2)); }
public void WriteData(BinaryWriter stream) { //Fixed values that doesn't seem to change. FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0x80000000, 4)); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0x80000000, 4)); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0x80000000, 4)); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0x80000000, 4)); FSHelpers.WriteArray(stream, HorizonCloudColor.GetBytes()); FSHelpers.WriteArray(stream, CenterCloudColor.GetBytes()); FSHelpers.WriteArray(stream, CenterSkyColor.GetBytes()); FSHelpers.WriteArray(stream, HorizonColor.GetBytes()); FSHelpers.WriteArray(stream, SkyFadeTo.GetBytes()); FSHelpers.WriteArray(stream, FSHelpers.ToBytes(0xFFFFFF, 3)); //3 Bytes Padding }