public static Bone Read(byte[] rawBytes, int offset, int unkDataOffset, int index) { Bone bone = new Bone(); bone.Index = (ushort)index; bone.I_00 = BitConverter.ToUInt16(rawBytes, offset + 0); bone.I_02 = BitConverter.ToUInt16(rawBytes, offset + 2); bone.I_04 = BitConverter.ToUInt16(rawBytes, offset + 4); bone.I_06 = BitConverter.ToUInt16(rawBytes, offset + 6); bone.I_08 = BitConverter.ToUInt16(rawBytes, offset + 8); bone.I_10 = BitConverter.ToUInt16(rawBytes, offset + 10); bone.I_12 = BitConverter.ToUInt16(rawBytes, offset + 12); bone.I_14 = BitConverter.ToUInt16(rawBytes, offset + 14); bone.Matrix = TransformMatrix.Read(rawBytes, offset + 16); if (unkDataOffset > 0) { bone.UnknownValues = UnkSkeletonData.Read(rawBytes, unkDataOffset); } return(bone); }
public static Skeleton Parse(byte[] rawBytes, List <byte> bytes, int skeletonOffset) { Skeleton skeleton = new Skeleton(); skeleton.Bones = new List <Bone>(); //Header skeleton.I_02 = BitConverter.ToUInt16(rawBytes, skeletonOffset + 2); skeleton.I_06 = BitConverter.ToUInt16(rawBytes, skeletonOffset + 6); skeleton.I_16 = BitConverter.ToInt32(rawBytes, skeletonOffset + 16); skeleton.I_20 = BitConverter.ToInt32(rawBytes, skeletonOffset + 20); skeleton.I_36 = BitConverter.ToInt32(rawBytes, skeletonOffset + 36); skeleton.I_40 = BitConverter.ToInt32(rawBytes, skeletonOffset + 40); skeleton.I_44 = BitConverter.ToInt32(rawBytes, skeletonOffset + 44); skeleton.I_48 = BitConverter.ToInt32(rawBytes, skeletonOffset + 48); skeleton.I_52 = BitConverter.ToUInt16(rawBytes, skeletonOffset + 52); skeleton.I_54 = BitConverter.ToUInt16(rawBytes, skeletonOffset + 54); skeleton.F_56 = BitConverter.ToSingle(rawBytes, skeletonOffset + 56); skeleton.F_60 = BitConverter.ToSingle(rawBytes, skeletonOffset + 60); int boneCount = BitConverter.ToUInt16(rawBytes, skeletonOffset + 0); int ikCount = BitConverter.ToUInt16(rawBytes, skeletonOffset + 4); int boneOffset = BitConverter.ToInt32(rawBytes, skeletonOffset + 8); int namesOffset = BitConverter.ToInt32(rawBytes, skeletonOffset + 12); int unkDataOffset = BitConverter.ToInt32(rawBytes, skeletonOffset + 24); int matrixDataOffset = BitConverter.ToInt32(rawBytes, skeletonOffset + 28); int ikOffset = BitConverter.ToInt32(rawBytes, skeletonOffset + 32); //Bones for (int i = 0; i < boneCount; i++) { skeleton.Bones.Add(Bone.Read(rawBytes, boneOffset + skeletonOffset, (unkDataOffset != 0) ? unkDataOffset + skeletonOffset : 0, i)); boneOffset += 80; if (unkDataOffset > 0) { unkDataOffset += 8; } } //Names for (int i = 0; i < boneCount; i++) { int directNameOffset = BitConverter.ToInt32(rawBytes, namesOffset + skeletonOffset) + skeletonOffset; skeleton.Bones[i].Name = Utils.GetString(bytes, directNameOffset); namesOffset += 4; } //Matrix Data if (matrixDataOffset > 0) { Console.WriteLine("MatrixData present"); Console.Read(); skeleton.MatrixData = TransformMatrix.Read(rawBytes, matrixDataOffset + skeletonOffset); } if (ikCount > 0) { if (ikCount > 1) { throw new Exception("ikCount > 1. Load failed."); } skeleton.IKEntries = new List <IKEntry>(); skeleton.IKEntries.Add(IKEntry.Read(rawBytes, ikOffset + skeletonOffset)); } return(skeleton); }