diff --git a/CodeWalker.Core/GameFiles/FileTypes/YddFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YddFile.cs index c084216..a7e4a24 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YddFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YddFile.cs @@ -110,26 +110,6 @@ namespace CodeWalker.GameFiles if (!string.IsNullOrEmpty(ddsfolder)) { ddsfolder = Path.Combine(outputFolder, ydd.Name); - - bool hastxd = false; - if (ydd?.DrawableDict?.Drawables?.data_items != null) - { - foreach (var d in ydd.DrawableDict.Drawables.data_items) - { - if (d?.ShaderGroup?.TextureDictionary != null) - { - hastxd = true; - break; - } - } - } - if (hastxd) - { - if (!Directory.Exists(ddsfolder)) - { - Directory.CreateDirectory(ddsfolder); - } - } } if (ydd?.DrawableDict != null) diff --git a/CodeWalker.Core/GameFiles/FileTypes/YdrFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YdrFile.cs index 5096590..ce02fb3 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YdrFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YdrFile.cs @@ -75,14 +75,6 @@ namespace CodeWalker.GameFiles if (!string.IsNullOrEmpty(ddsfolder)) { ddsfolder = Path.Combine(outputFolder, ydr.Name); - - if (ydr?.Drawable?.ShaderGroup?.TextureDictionary != null) - { - if (!Directory.Exists(ddsfolder)) - { - Directory.CreateDirectory(ddsfolder); - } - } } if (ydr?.Drawable != null) diff --git a/CodeWalker.Core/GameFiles/FileTypes/YftFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YftFile.cs index f531e59..3690964 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YftFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YftFile.cs @@ -79,40 +79,6 @@ namespace CodeWalker.GameFiles if (!string.IsNullOrEmpty(ddsfolder)) { ddsfolder = Path.Combine(outputFolder, yft.Name); - - bool hastxd = false; - if (yft?.Fragment != null) - { - hastxd = hastxd || (yft.Fragment.Drawable?.ShaderGroup?.TextureDictionary != null); - hastxd = hastxd || (yft.Fragment.Drawable2?.ShaderGroup?.TextureDictionary != null); - if (yft.Fragment.DrawableArray?.data_items != null) - { - foreach (var d in yft.Fragment.DrawableArray?.data_items) - { - if (hastxd) break; - if (d?.ShaderGroup?.TextureDictionary != null) - { - hastxd = true; - } - } - } - if (yft.Fragment.PhysicsLODGroup?.PhysicsLOD1?.Children?.data_items != null) - { - foreach (var child in yft.Fragment.PhysicsLODGroup.PhysicsLOD1.Children.data_items) - { - if (hastxd) break; - hastxd = hastxd || (child.Drawable1?.ShaderGroup?.TextureDictionary != null); - hastxd = hastxd || (child.Drawable2?.ShaderGroup?.TextureDictionary != null); - } - } - } - if (hastxd) - { - if (!Directory.Exists(ddsfolder)) - { - Directory.CreateDirectory(ddsfolder); - } - } } if (yft?.Fragment != null) diff --git a/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs index 96f0f55..35a28e8 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs @@ -127,26 +127,6 @@ namespace CodeWalker.GameFiles if (!string.IsNullOrEmpty(ddsfolder)) { ddsfolder = Path.Combine(outputFolder, ypt.Name); - - bool hastxd = false; - if (ypt?.DrawableDict != null) - { - foreach (var d in ypt.DrawableDict.Values) - { - if (d?.ShaderGroup?.TextureDictionary != null) - { - hastxd = true; - break; - } - } - } - if (hastxd) - { - if (!Directory.Exists(ddsfolder)) - { - Directory.CreateDirectory(ddsfolder); - } - } } if (ypt?.PtfxList != null) diff --git a/CodeWalker.Core/GameFiles/GameFileCache.cs b/CodeWalker.Core/GameFiles/GameFileCache.cs index 066ec44..f3a19a7 100644 --- a/CodeWalker.Core/GameFiles/GameFileCache.cs +++ b/CodeWalker.Core/GameFiles/GameFileCache.cs @@ -4194,9 +4194,9 @@ namespace CodeWalker.GameFiles } } } - if ((yft.Fragment.Clothes != null) && (yft.Fragment.Clothes.data_items != null)) + if ((yft.Fragment.Cloths != null) && (yft.Fragment.Cloths.data_items != null)) { - foreach (var cloth in yft.Fragment.Clothes.data_items) + foreach (var cloth in yft.Fragment.Cloths.data_items) { drawablecount++; foreach (var kvp in cloth.Drawable.VertexDecls) diff --git a/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs b/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs index 8007a75..d70ed26 100644 --- a/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs +++ b/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs @@ -1790,6 +1790,21 @@ namespace CodeWalker.GameFiles else SelfClosingTag(sb, indent, name); } + public static void WriteRawArrayContent(StringBuilder sb, T[] arr, int ind, Func formatter = null, int arrRowSize = 10) where T : struct + { + var aCount = arr?.Length ?? 0; + for (int n = 0; n < aCount; n++) + { + var col = n % arrRowSize; + if (col == 0) Indent(sb, ind); + if (col > 0) sb.Append(" "); + string str = (formatter != null) ? formatter(arr[n]) : arr[n].ToString(); + sb.Append(str); + bool lastcol = (col == (arrRowSize - 1)); + bool lastn = (n == (aCount - 1)); + if (lastcol || lastn) sb.AppendLine(); + } + } public static void WriteRawArray(StringBuilder sb, T[] arr, int ind, string name, string typeName, Func formatter = null, int arrRowSize = 10) where T : struct { var aCount = arr?.Length ?? 0; diff --git a/CodeWalker.Core/GameFiles/Resources/Clothes.cs b/CodeWalker.Core/GameFiles/Resources/Clothes.cs index 01412c4..e7e2e97 100644 --- a/CodeWalker.Core/GameFiles/Resources/Clothes.cs +++ b/CodeWalker.Core/GameFiles/Resources/Clothes.cs @@ -5,6 +5,7 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml; /* Copyright(c) 2017 Neodymium @@ -892,7 +893,7 @@ namespace CodeWalker.GameFiles } - [TypeConverter(typeof(ExpandableObjectConverter))] public class EnvironmentCloth : ResourceSystemBlock + [TypeConverter(typeof(ExpandableObjectConverter))] public class EnvironmentCloth : ResourceSystemBlock, IMetaXmlItem { // pgBase // clothBase (TODO) @@ -938,9 +939,6 @@ namespace CodeWalker.GameFiles private ResourceSystemStructBlock UnknownDataBlock = null; - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -992,10 +990,6 @@ namespace CodeWalker.GameFiles } } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -1037,10 +1031,15 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_78h); writer.Write(this.Unknown_7Ch); } + public void WriteXml(StringBuilder sb, int indent) + { + //TODO!! + } + public void ReadXml(XmlNode node) + { + //TODO!! + } - /// - /// Returns a list of data blocks which are referenced by this block. - /// public override IResourceBlock[] GetReferences() { var list = new List(); @@ -1054,6 +1053,7 @@ namespace CodeWalker.GameFiles } return list.ToArray(); } + } diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index 09573a6..3fa9429 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -19,20 +19,17 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_4h { get; set; } = 1; // 0x00000001 + public uint Unknown_4h = 1; // 0x00000001 public ulong TextureDictionaryPointer { get; set; } public ulong ShadersPointer { get; set; } public ushort ShadersCount1 { get; set; } public ushort ShadersCount2 { get; set; } - public uint Unknown_1Ch { get; set; } // 0x00000000 - public uint Unknown_20h { get; set; } // 0x00000000 - public uint Unknown_24h { get; set; } // 0x00000000 - public uint Unknown_28h { get; set; } // 0x00000000 - public uint Unknown_2Ch { get; set; } // 0x00000000 + public uint Unknown_1Ch; // 0x00000000 + public ulong Unknown_20h; // 0x0000000000000000 + public ulong Unknown_28h; // 0x0000000000000000 public uint Unknown_30h { get; set; }//wtf is this?? (shadercount-1)*3+8 ..? - public uint Unknown_34h { get; set; } // 0x00000000 - public uint Unknown_38h { get; set; } // 0x00000000 - public uint Unknown_3Ch { get; set; } // 0x00000000 + public uint Unknown_34h; // 0x00000000 + public ulong Unknown_38h; // 0x0000000000000000 // reference data public TextureDictionary TextureDictionary { get; set; } @@ -66,14 +63,11 @@ namespace CodeWalker.GameFiles this.ShadersCount1 = reader.ReadUInt16(); this.ShadersCount2 = reader.ReadUInt16(); this.Unknown_1Ch = reader.ReadUInt32(); - this.Unknown_20h = reader.ReadUInt32(); - this.Unknown_24h = reader.ReadUInt32(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); + this.Unknown_20h = reader.ReadUInt64(); + this.Unknown_28h = reader.ReadUInt64(); this.Unknown_30h = reader.ReadUInt32(); this.Unknown_34h = reader.ReadUInt32(); - this.Unknown_38h = reader.ReadUInt32(); - this.Unknown_3Ch = reader.ReadUInt32(); + this.Unknown_38h = reader.ReadUInt64(); // read reference data this.TextureDictionary = reader.ReadBlockAt( @@ -84,6 +78,7 @@ namespace CodeWalker.GameFiles this.ShadersCount1 ); + // wtf is Unknown_30h ??? //switch (ShadersCount1) //{ @@ -155,6 +150,18 @@ namespace CodeWalker.GameFiles //if (cnt != Unknown_30h) //{ } + //if (Unknown_4h != 1) + //{ } + //if (Unknown_1Ch != 0) + //{ } + //if (Unknown_20h != 0) + //{ } + //if (Unknown_28h != 0) + //{ } + //if (Unknown_34h != 0) + //{ } + //if (Unknown_38h != 0) + //{ } } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -173,13 +180,10 @@ namespace CodeWalker.GameFiles writer.Write(this.ShadersCount2); writer.Write(this.Unknown_1Ch); writer.Write(this.Unknown_20h); - writer.Write(this.Unknown_24h); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); writer.Write(this.Unknown_30h); writer.Write(this.Unknown_34h); writer.Write(this.Unknown_38h); - writer.Write(this.Unknown_3Ch); } public void WriteXml(StringBuilder sb, int indent, string ddsfolder) { @@ -249,20 +253,19 @@ namespace CodeWalker.GameFiles // structure data public ulong ParametersPointer { get; set; } public MetaHash Name { get; set; } //decal_emissive_only, emissive, spec - public uint Unknown_Ch { get; set; } // 0x00000000 + public uint Unknown_Ch; // 0x00000000 public byte ParameterCount { get; set; } public byte RenderBucket { get; set; } // 2, 0, public ushort Unknown_12h { get; set; } = 32768; // 32768 HasComment? public ushort ParameterSize { get; set; } //112, 208, 320 (with 16h) 10485872, 17826000, 26214720 public ushort ParameterDataSize { get; set; } //160, 272, 400 public MetaHash FileName { get; set; } //decal_emissive_only.sps, emissive.sps, spec.sps - public uint Unknown_1Ch { get; set; } // 0x00000000 + public uint Unknown_1Ch; // 0x00000000 public uint RenderBucketMask { get; set; } //65284, 65281 DrawBucketMask? (1< Parameters { get; set; } @@ -286,8 +289,7 @@ namespace CodeWalker.GameFiles this.Unknown_24h = reader.ReadUInt16(); this.Unknown_26h = reader.ReadByte(); this.TextureParametersCount = reader.ReadByte(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); + this.Unknown_28h = reader.ReadUInt64(); // read reference data this.ParametersList = reader.ReadBlockAt( @@ -323,6 +325,12 @@ namespace CodeWalker.GameFiles //{ }//no hit //if (Unknown_26h != 0) //{ }//no hit + //if (Unknown_Ch != 0) + //{ }//no hit + //if (Unknown_1Ch != 0) + //{ }//no hit + //if (Unknown_28h != 0) + //{ }//no hit } public override void Write(ResourceDataWriter writer, params object[] parameters) @@ -347,7 +355,6 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_26h); writer.Write(this.TextureParametersCount); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); } public void WriteXml(StringBuilder sb, int indent) { @@ -404,8 +411,8 @@ namespace CodeWalker.GameFiles // structure data public byte DataType { get; set; } //0: texture, 1: vector4 public byte Unknown_1h { get; set; } - public ushort Unknown_2h { get; set; }//0 - public uint Unknown_4h { get; set; }//0 + public ushort Unknown_2h; // 0x0000 + public uint Unknown_4h; // 0x00000000 public ulong DataPointer { get; set; } //public IResourceBlock Data { get; set; } @@ -859,8 +866,7 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } public uint Unknown_4h { get; set; } = 1; // 0x00000001 - public uint Unknown_8h { get; set; } // 0x00000000 - public uint Unknown_Ch { get; set; } // 0x00000000 + public ulong Unknown_8h; // 0x0000000000000000 public ulong BoneTagsPointer { get; set; } public ushort BoneTagsCapacity { get; set; } public ushort BoneTagsCount { get; set; } @@ -870,18 +876,16 @@ namespace CodeWalker.GameFiles public ulong TransformationsPointer { get; set; } public ulong ParentIndicesPointer { get; set; } public ulong ChildIndicesPointer { get; set; } - public uint Unknown_48h { get; set; } // 0x00000000 - public uint Unknown_4Ch { get; set; } // 0x00000000 + public ulong Unknown_48h; // 0x0000000000000000 public MetaHash Unknown_50h { get; set; } public MetaHash Unknown_54h { get; set; } public MetaHash Unknown_58h { get; set; } public ushort Unknown_5Ch { get; set; } = 1; // 0x0001 public ushort BonesCount { get; set; } public ushort ChildIndicesCount { get; set; } - public ushort Unknown_62h { get; set; } // 0x0000 - public uint Unknown_64h { get; set; } // 0x00000000 - public uint Unknown_68h { get; set; } // 0x00000000 - public uint Unknown_6Ch { get; set; } // 0x00000000 + public ushort Unknown_62h; // 0x0000 + public uint Unknown_64h; // 0x00000000 + public ulong Unknown_68h; // 0x0000000000000000 // reference data public ResourcePointerArray64 BoneTags { get; set; } @@ -909,8 +913,7 @@ namespace CodeWalker.GameFiles // read structure data this.VFT = reader.ReadUInt32(); this.Unknown_4h = reader.ReadUInt32(); - this.Unknown_8h = reader.ReadUInt32(); - this.Unknown_Ch = reader.ReadUInt32(); + this.Unknown_8h = reader.ReadUInt64(); this.BoneTagsPointer = reader.ReadUInt64(); this.BoneTagsCapacity = reader.ReadUInt16(); this.BoneTagsCount = reader.ReadUInt16(); @@ -920,8 +923,7 @@ namespace CodeWalker.GameFiles this.TransformationsPointer = reader.ReadUInt64(); this.ParentIndicesPointer = reader.ReadUInt64(); this.ChildIndicesPointer = reader.ReadUInt64(); - this.Unknown_48h = reader.ReadUInt32(); - this.Unknown_4Ch = reader.ReadUInt32(); + this.Unknown_48h = reader.ReadUInt64(); this.Unknown_50h = new MetaHash(reader.ReadUInt32()); this.Unknown_54h = new MetaHash(reader.ReadUInt32()); this.Unknown_58h = new MetaHash(reader.ReadUInt32()); @@ -930,8 +932,7 @@ namespace CodeWalker.GameFiles this.ChildIndicesCount = reader.ReadUInt16(); this.Unknown_62h = reader.ReadUInt16(); this.Unknown_64h = reader.ReadUInt32(); - this.Unknown_68h = reader.ReadUInt32(); - this.Unknown_6Ch = reader.ReadUInt32(); + this.Unknown_68h = reader.ReadUInt64(); // read reference data this.BoneTags = reader.ReadBlockAt>( @@ -957,6 +958,17 @@ namespace CodeWalker.GameFiles //BuildTransformations();//testing! //if (BoneTagsCount != Math.Min(BonesCount, BoneTagsCapacity)) //{ }//no hits + + //if (Unknown_8h != 0) + //{ } + //if (Unknown_48h != 0) + //{ } + //if (Unknown_62h != 0) + //{ } + //if (Unknown_64h != 0) + //{ } + //if (Unknown_68h != 0) + //{ } } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -977,7 +989,6 @@ namespace CodeWalker.GameFiles writer.Write(this.VFT); writer.Write(this.Unknown_4h); writer.Write(this.Unknown_8h); - writer.Write(this.Unknown_Ch); writer.Write(this.BoneTagsPointer); writer.Write(this.BoneTagsCapacity); writer.Write(this.BoneTagsCount); @@ -988,7 +999,6 @@ namespace CodeWalker.GameFiles writer.Write(this.ParentIndicesPointer); writer.Write(this.ChildIndicesPointer); writer.Write(this.Unknown_48h); - writer.Write(this.Unknown_4Ch); writer.Write(this.Unknown_50h); writer.Write(this.Unknown_54h); writer.Write(this.Unknown_58h); @@ -998,7 +1008,6 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_62h); writer.Write(this.Unknown_64h); writer.Write(this.Unknown_68h); - writer.Write(this.Unknown_6Ch); } public void WriteXml(StringBuilder sb, int indent) { @@ -1532,19 +1541,18 @@ namespace CodeWalker.GameFiles // structure data public Quaternion Rotation { get; set; } public Vector3 Translation { get; set; } - public uint Unknown_1Ch { get; set; } // 0x00000000 RHW? + public uint Unknown_1Ch; // 0x00000000 RHW? public Vector3 Scale { get; set; } public float Unknown_2Ch { get; set; } = 1.0f; // 1.0 RHW? public short NextSiblingIndex { get; set; } //limb end index? IK chain? public short ParentIndex { get; set; } - public uint Unknown_34h { get; set; } // 0x00000000 + public uint Unknown_34h; // 0x00000000 public ulong NamePointer { get; set; } public EBoneFlags Flags { get; set; } public short Index { get; set; } public ushort Tag { get; set; } public short Index2 { get; set; }//always same as Index - public uint Unknown_48h { get; set; } // 0x00000000 - public uint Unknown_4Ch { get; set; } // 0x00000000 + public ulong Unknown_48h; // 0x0000000000000000 // reference data public string Name { get; set; } @@ -1579,8 +1587,7 @@ namespace CodeWalker.GameFiles this.Index = reader.ReadInt16(); this.Tag = reader.ReadUInt16(); this.Index2 = reader.ReadInt16(); - this.Unknown_48h = reader.ReadUInt32(); - this.Unknown_4Ch = reader.ReadUInt32(); + this.Unknown_48h = reader.ReadUInt64(); // read reference data this.Name = reader.ReadStringAt(//BlockAt( @@ -1593,6 +1600,15 @@ namespace CodeWalker.GameFiles AnimRotation = Rotation; AnimTranslation = Translation; AnimScale = Scale; + + + //if (Unknown_1Ch != 0) + //{ } + //if (Unknown_34h != 0) + //{ } + //if (Unknown_48h != 0) + //{ } + } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -1614,7 +1630,6 @@ namespace CodeWalker.GameFiles writer.Write(this.Tag); writer.Write(this.Index2); writer.Write(this.Unknown_48h); - writer.Write(this.Unknown_4Ch); } public void WriteXml(StringBuilder sb, int indent) { @@ -1732,21 +1747,17 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_4h { get; set; } = 1; // 0x00000001 - public uint Unknown_8h { get; set; } // 0x00000000 - public uint Unknown_Ch { get; set; } // 0x00000000 + public uint Unknown_4h = 1; // 0x00000001 + public ulong Unknown_8h; // 0x0000000000000000 public ulong RotationLimitsPointer { get; set; } public ulong TranslationLimitsPointer { get; set; } - public uint Unknown_20h { get; set; } // 0x00000000 - public uint Unknown_24h { get; set; } // 0x00000000 - public uint Unknown_28h { get; set; } // 0x00000000 - public uint Unknown_2Ch { get; set; } // 0x00000000 + public ulong Unknown_20h; // 0x0000000000000000 + public ulong Unknown_28h; // 0x0000000000000000 public ushort RotationLimitsCount { get; set; } public ushort TranslationLimitsCount { get; set; } - public ushort Unknown_34h { get; set; } // 0x0000 - public ushort Unknown_36h { get; set; } = 1; // 0x0001 - public uint Unknown_38h { get; set; } // 0x00000000 - public uint Unknown_3Ch { get; set; } // 0x00000000 + public ushort Unknown_34h; // 0x0000 + public ushort Unknown_36h = 1; // 0x0001 + public ulong Unknown_38h; // 0x0000000000000000 // reference data public JointRotationLimit_s[] RotationLimits { get; set; } @@ -1761,25 +1772,37 @@ namespace CodeWalker.GameFiles // read structure data this.VFT = reader.ReadUInt32(); this.Unknown_4h = reader.ReadUInt32(); - this.Unknown_8h = reader.ReadUInt32(); - this.Unknown_Ch = reader.ReadUInt32(); + this.Unknown_8h = reader.ReadUInt64(); this.RotationLimitsPointer = reader.ReadUInt64(); this.TranslationLimitsPointer = reader.ReadUInt64(); - this.Unknown_20h = reader.ReadUInt32(); - this.Unknown_24h = reader.ReadUInt32(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); + this.Unknown_20h = reader.ReadUInt64(); + this.Unknown_28h = reader.ReadUInt64(); this.RotationLimitsCount = reader.ReadUInt16(); this.TranslationLimitsCount = reader.ReadUInt16(); this.Unknown_34h = reader.ReadUInt16(); this.Unknown_36h = reader.ReadUInt16(); - this.Unknown_38h = reader.ReadUInt32(); - this.Unknown_3Ch = reader.ReadUInt32(); + this.Unknown_38h = reader.ReadUInt64(); // read reference data this.RotationLimits = reader.ReadStructsAt(this.RotationLimitsPointer, this.RotationLimitsCount); this.TranslationLimits = reader.ReadStructsAt(this.TranslationLimitsPointer, this.TranslationLimitsCount); + //if (Unknown_4h != 1) + //{ } + //if (Unknown_8h != 0) + //{ } + //if (Unknown_20h != 0) + //{ } + //if (Unknown_28h != 0) + //{ } + //if (Unknown_34h != 0) + //{ } + //if (Unknown_36h != 1) + //{ } + //if (Unknown_38h != 0) + //{ } + + } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -1794,19 +1817,15 @@ namespace CodeWalker.GameFiles writer.Write(this.VFT); writer.Write(this.Unknown_4h); writer.Write(this.Unknown_8h); - writer.Write(this.Unknown_Ch); writer.Write(this.RotationLimitsPointer); writer.Write(this.TranslationLimitsPointer); writer.Write(this.Unknown_20h); - writer.Write(this.Unknown_24h); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); writer.Write(this.RotationLimitsCount); writer.Write(this.TranslationLimitsCount); writer.Write(this.Unknown_34h); writer.Write(this.Unknown_36h); writer.Write(this.Unknown_38h); - writer.Write(this.Unknown_3Ch); } public void WriteXml(StringBuilder sb, int indent) { @@ -2002,11 +2021,11 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_4h { get; set; } = 1; // 0x00000001 + public uint Unknown_4h = 1; // 0x00000001 public ulong GeometriesPointer { get; set; } public ushort GeometriesCount1 { get; set; } public ushort GeometriesCount2 { get; set; }//always equal to GeometriesCount1 - public uint Unknown_14h { get; set; } // 0x00000000 + public uint Unknown_14h; // 0x00000000 public ulong BoundsPointer { get; set; } public ulong ShaderMappingPointer { get; set; } public uint SkeletonBinding { get; set; }//4th byte is bone index, 2nd byte for skin meshes @@ -2156,7 +2175,10 @@ namespace CodeWalker.GameFiles // default: // break;//no hit //} - + //if (Unknown_4h != 1) + //{ }//no hit + //if (Unknown_14h != 0) + //{ }//no hit } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -2266,41 +2288,30 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_4h { get; set; } = 1; // 0x00000001 - public uint Unknown_8h { get; set; } // 0x00000000 - public uint Unknown_Ch { get; set; } // 0x00000000 - public uint Unknown_10h { get; set; } // 0x00000000 - public uint Unknown_14h { get; set; } // 0x00000000 + public uint Unknown_4h = 1; // 0x00000001 + public ulong Unknown_8h; // 0x0000000000000000 + public ulong Unknown_10h; // 0x0000000000000000 public ulong VertexBufferPointer { get; set; } - public uint Unknown_20h { get; set; } // 0x00000000 - public uint Unknown_24h { get; set; } // 0x00000000 - public uint Unknown_28h { get; set; } // 0x00000000 - public uint Unknown_2Ch { get; set; } // 0x00000000 - public uint Unknown_30h { get; set; } // 0x00000000 - public uint Unknown_34h { get; set; } // 0x00000000 + public ulong Unknown_20h; // 0x0000000000000000 + public ulong Unknown_28h; // 0x0000000000000000 + public ulong Unknown_30h; // 0x0000000000000000 public ulong IndexBufferPointer { get; set; } - public uint Unknown_40h { get; set; } // 0x00000000 - public uint Unknown_44h { get; set; } // 0x00000000 - public uint Unknown_48h { get; set; } // 0x00000000 - public uint Unknown_4Ch { get; set; } // 0x00000000 - public uint Unknown_50h { get; set; } // 0x00000000 - public uint Unknown_54h { get; set; } // 0x00000000 + public ulong Unknown_40h; // 0x0000000000000000 + public ulong Unknown_48h; // 0x0000000000000000 + public ulong Unknown_50h; // 0x0000000000000000 public uint IndicesCount { get; set; } public uint TrianglesCount { get; set; } public ushort VerticesCount { get; set; } - public ushort Unknown_62h { get; set; } = 3; // 0x0003 // indices per primitive (triangle) - public uint Unknown_64h { get; set; } // 0x00000000 + public ushort Unknown_62h = 3; // 0x0003 // indices per primitive (triangle) + public uint Unknown_64h; // 0x00000000 public ulong BoneIdsPointer { get; set; } public ushort VertexStride { get; set; } public ushort BoneIdsCount { get; set; } - public uint Unknown_74h { get; set; } // 0x00000000 + public uint Unknown_74h; // 0x00000000 public ulong VertexDataPointer { get; set; } - public uint Unknown_80h { get; set; } // 0x00000000 - public uint Unknown_84h { get; set; } // 0x00000000 - public uint Unknown_88h { get; set; } // 0x00000000 - public uint Unknown_8Ch { get; set; } // 0x00000000 - public uint Unknown_90h { get; set; } // 0x00000000 - public uint Unknown_94h { get; set; } // 0x00000000 + public ulong Unknown_80h; // 0x0000000000000000 + public ulong Unknown_88h; // 0x0000000000000000 + public ulong Unknown_90h; // 0x0000000000000000 // reference data public VertexBuffer VertexBuffer { get; set; } @@ -2322,24 +2333,16 @@ namespace CodeWalker.GameFiles // read structure data this.VFT = reader.ReadUInt32(); this.Unknown_4h = reader.ReadUInt32(); - this.Unknown_8h = reader.ReadUInt32(); - this.Unknown_Ch = reader.ReadUInt32(); - this.Unknown_10h = reader.ReadUInt32(); - this.Unknown_14h = reader.ReadUInt32(); + this.Unknown_8h = reader.ReadUInt64(); + this.Unknown_10h = reader.ReadUInt64(); this.VertexBufferPointer = reader.ReadUInt64(); - this.Unknown_20h = reader.ReadUInt32(); - this.Unknown_24h = reader.ReadUInt32(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); - this.Unknown_30h = reader.ReadUInt32(); - this.Unknown_34h = reader.ReadUInt32(); + this.Unknown_20h = reader.ReadUInt64(); + this.Unknown_28h = reader.ReadUInt64(); + this.Unknown_30h = reader.ReadUInt64(); this.IndexBufferPointer = reader.ReadUInt64(); - this.Unknown_40h = reader.ReadUInt32(); - this.Unknown_44h = reader.ReadUInt32(); - this.Unknown_48h = reader.ReadUInt32(); - this.Unknown_4Ch = reader.ReadUInt32(); - this.Unknown_50h = reader.ReadUInt32(); - this.Unknown_54h = reader.ReadUInt32(); + this.Unknown_40h = reader.ReadUInt64(); + this.Unknown_48h = reader.ReadUInt64(); + this.Unknown_50h = reader.ReadUInt64(); this.IndicesCount = reader.ReadUInt32(); this.TrianglesCount = reader.ReadUInt32(); this.VerticesCount = reader.ReadUInt16(); @@ -2350,12 +2353,9 @@ namespace CodeWalker.GameFiles this.BoneIdsCount = reader.ReadUInt16(); this.Unknown_74h = reader.ReadUInt32(); this.VertexDataPointer = reader.ReadUInt64(); - this.Unknown_80h = reader.ReadUInt32(); - this.Unknown_84h = reader.ReadUInt32(); - this.Unknown_88h = reader.ReadUInt32(); - this.Unknown_8Ch = reader.ReadUInt32(); - this.Unknown_90h = reader.ReadUInt32(); - this.Unknown_94h = reader.ReadUInt32(); + this.Unknown_80h = reader.ReadUInt64(); + this.Unknown_88h = reader.ReadUInt64(); + this.Unknown_90h = reader.ReadUInt64(); // read reference data this.VertexBuffer = reader.ReadBlockAt( @@ -2399,6 +2399,36 @@ namespace CodeWalker.GameFiles } //else //{ }//no hit + + + //if (Unknown_4h != 1) + //{ } + //if (Unknown_8h != 0) + //{ } + //if (Unknown_10h != 0) + //{ } + //if (Unknown_20h != 0) + //{ } + //if (Unknown_28h != 0) + //{ } + //if (Unknown_30h != 0) + //{ } + //if (Unknown_40h != 0) + //{ } + //if (Unknown_48h != 0) + //{ } + //if (Unknown_50h != 0) + //{ } + //if (Unknown_64h != 0) + //{ } + //if (Unknown_74h != 0) + //{ } + //if (Unknown_80h != 0) + //{ } + //if (Unknown_88h != 0) + //{ } + //if (Unknown_90h != 0) + //{ } } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -2417,23 +2447,15 @@ namespace CodeWalker.GameFiles writer.Write(this.VFT); writer.Write(this.Unknown_4h); writer.Write(this.Unknown_8h); - writer.Write(this.Unknown_Ch); writer.Write(this.Unknown_10h); - writer.Write(this.Unknown_14h); writer.Write(this.VertexBufferPointer); writer.Write(this.Unknown_20h); - writer.Write(this.Unknown_24h); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); writer.Write(this.Unknown_30h); - writer.Write(this.Unknown_34h); writer.Write(this.IndexBufferPointer); writer.Write(this.Unknown_40h); - writer.Write(this.Unknown_44h); writer.Write(this.Unknown_48h); - writer.Write(this.Unknown_4Ch); writer.Write(this.Unknown_50h); - writer.Write(this.Unknown_54h); writer.Write(this.IndicesCount); writer.Write(this.TrianglesCount); writer.Write(this.VerticesCount); @@ -2445,11 +2467,8 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_74h); writer.Write(this.VertexDataPointer); writer.Write(this.Unknown_80h); - writer.Write(this.Unknown_84h); writer.Write(this.Unknown_88h); - writer.Write(this.Unknown_8Ch); writer.Write(this.Unknown_90h); - writer.Write(this.Unknown_94h); } public void WriteXml(StringBuilder sb, int indent) { @@ -2547,35 +2566,25 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_4h { get; set; } = 1; // 0x00000001 + public uint Unknown_4h = 1; // 0x00000001 public ushort VertexStride { get; set; } public ushort Flags { get; set; } //only 0 or 1024 - public uint Unknown_Ch { get; set; } // 0x00000000 + public uint Unknown_Ch; // 0x00000000 public ulong DataPointer1 { get; set; } public uint VertexCount { get; set; } - public uint Unknown_1Ch { get; set; } // 0x00000000 + public uint Unknown_1Ch; // 0x00000000 public ulong DataPointer2 { get; set; } - public uint Unknown_28h { get; set; } // 0x00000000 - public uint Unknown_2Ch { get; set; } // 0x00000000 + public ulong Unknown_28h; // 0x0000000000000000 public ulong InfoPointer { get; set; } - public uint Unknown_38h { get; set; } // 0x00000000 - public uint Unknown_3Ch { get; set; } // 0x00000000 - public uint Unknown_40h { get; set; } // 0x00000000 - public uint Unknown_44h { get; set; } // 0x00000000 - public uint Unknown_48h { get; set; } // 0x00000000 - public uint Unknown_4Ch { get; set; } // 0x00000000 - public uint Unknown_50h { get; set; } // 0x00000000 - public uint Unknown_54h { get; set; } // 0x00000000 - public uint Unknown_58h { get; set; } // 0x00000000 - public uint Unknown_5Ch { get; set; } // 0x00000000 - public uint Unknown_60h { get; set; } // 0x00000000 - public uint Unknown_64h { get; set; } // 0x00000000 - public uint Unknown_68h { get; set; } // 0x00000000 - public uint Unknown_6Ch { get; set; } // 0x00000000 - public uint Unknown_70h { get; set; } // 0x00000000 - public uint Unknown_74h { get; set; } // 0x00000000 - public uint Unknown_78h { get; set; } // 0x00000000 - public uint Unknown_7Ch { get; set; } // 0x00000000 + public ulong Unknown_38h; // 0x0000000000000000 + public ulong Unknown_40h; // 0x0000000000000000 + public ulong Unknown_48h; // 0x0000000000000000 + public ulong Unknown_50h; // 0x0000000000000000 + public ulong Unknown_58h; // 0x0000000000000000 + public ulong Unknown_60h; // 0x0000000000000000 + public ulong Unknown_68h; // 0x0000000000000000 + public ulong Unknown_70h; // 0x0000000000000000 + public ulong Unknown_78h; // 0x0000000000000000 // reference data public VertexData Data1 { get; set; } @@ -2594,27 +2603,17 @@ namespace CodeWalker.GameFiles this.VertexCount = reader.ReadUInt32(); this.Unknown_1Ch = reader.ReadUInt32(); this.DataPointer2 = reader.ReadUInt64(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); + this.Unknown_28h = reader.ReadUInt64(); this.InfoPointer = reader.ReadUInt64(); - this.Unknown_38h = reader.ReadUInt32(); - this.Unknown_3Ch = reader.ReadUInt32(); - this.Unknown_40h = reader.ReadUInt32(); - this.Unknown_44h = reader.ReadUInt32(); - this.Unknown_48h = reader.ReadUInt32(); - this.Unknown_4Ch = reader.ReadUInt32(); - this.Unknown_50h = reader.ReadUInt32(); - this.Unknown_54h = reader.ReadUInt32(); - this.Unknown_58h = reader.ReadUInt32(); - this.Unknown_5Ch = reader.ReadUInt32(); - this.Unknown_60h = reader.ReadUInt32(); - this.Unknown_64h = reader.ReadUInt32(); - this.Unknown_68h = reader.ReadUInt32(); - this.Unknown_6Ch = reader.ReadUInt32(); - this.Unknown_70h = reader.ReadUInt32(); - this.Unknown_74h = reader.ReadUInt32(); - this.Unknown_78h = reader.ReadUInt32(); - this.Unknown_7Ch = reader.ReadUInt32(); + this.Unknown_38h = reader.ReadUInt64(); + this.Unknown_40h = reader.ReadUInt64(); + this.Unknown_48h = reader.ReadUInt64(); + this.Unknown_50h = reader.ReadUInt64(); + this.Unknown_58h = reader.ReadUInt64(); + this.Unknown_60h = reader.ReadUInt64(); + this.Unknown_68h = reader.ReadUInt64(); + this.Unknown_70h = reader.ReadUInt64(); + this.Unknown_78h = reader.ReadUInt64(); // read reference data this.Info = reader.ReadBlockAt( @@ -2644,6 +2643,33 @@ namespace CodeWalker.GameFiles // break; //} + //if (Unknown_4h != 1) + //{ } + //if (Unknown_Ch != 0) + //{ } + //if (Unknown_1Ch != 0) + //{ } + //if (Unknown_28h != 0) + //{ } + //if (Unknown_38h != 0) + //{ } + //if (Unknown_40h != 0) + //{ } + //if (Unknown_48h != 0) + //{ } + //if (Unknown_50h != 0) + //{ } + //if (Unknown_58h != 0) + //{ } + //if (Unknown_60h != 0) + //{ } + //if (Unknown_68h != 0) + //{ } + //if (Unknown_70h != 0) + //{ } + //if (Unknown_78h != 0) + //{ } + } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -2664,26 +2690,16 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_1Ch); writer.Write(this.DataPointer2); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); writer.Write(this.InfoPointer); writer.Write(this.Unknown_38h); - writer.Write(this.Unknown_3Ch); writer.Write(this.Unknown_40h); - writer.Write(this.Unknown_44h); writer.Write(this.Unknown_48h); - writer.Write(this.Unknown_4Ch); writer.Write(this.Unknown_50h); - writer.Write(this.Unknown_54h); writer.Write(this.Unknown_58h); - writer.Write(this.Unknown_5Ch); writer.Write(this.Unknown_60h); - writer.Write(this.Unknown_64h); writer.Write(this.Unknown_68h); - writer.Write(this.Unknown_6Ch); writer.Write(this.Unknown_70h); - writer.Write(this.Unknown_74h); writer.Write(this.Unknown_78h); - writer.Write(this.Unknown_7Ch); } public void WriteXml(StringBuilder sb, int indent) { @@ -2691,9 +2707,7 @@ namespace CodeWalker.GameFiles if (Info != null) { - YdrXml.OpenTag(sb, indent, "Layout type=\"" + Info.Types.ToString() + "\""); - Info.WriteXml(sb, indent + 1); - YdrXml.CloseTag(sb, indent, "Layout"); + Info.WriteXml(sb, indent, "Layout"); } if (Data1 != null) { @@ -3321,20 +3335,26 @@ namespace CodeWalker.GameFiles writer.Write(this.Count); writer.Write((ulong)this.Types); } - public void WriteXml(StringBuilder sb, int indent) + public void WriteXml(StringBuilder sb, int indent, string name) { + YdrXml.OpenTag(sb, indent, name + " type=\"" + Types.ToString() + "\""); + for (int k = 0; k < 16; k++) { if (((Flags >> k) & 0x1) == 1) { var componentSemantic = (VertexSemantics)k; var tag = componentSemantic.ToString(); - YdrXml.SelfClosingTag(sb, indent, tag); + YdrXml.SelfClosingTag(sb, indent + 1, tag); } } + + YdrXml.CloseTag(sb, indent, name); } public void ReadXml(XmlNode node) { + if (node == null) return; + Types = Xml.GetEnumValue(Xml.GetStringAttribute(node, "type")); uint f = 0; @@ -3425,28 +3445,19 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_4h { get; set; } = 1; // 0x00000001 + public uint Unknown_4h = 1; // 0x00000001 public uint IndicesCount { get; set; } - public uint Unknown_Ch { get; set; } // 0x00000000 + public uint Unknown_Ch; // 0x00000000 public ulong IndicesPointer { get; set; } - public uint Unknown_18h { get; set; } // 0x00000000 - public uint Unknown_1Ch { get; set; } // 0x00000000 - public uint Unknown_20h { get; set; } // 0x00000000 - public uint Unknown_24h { get; set; } // 0x00000000 - public uint Unknown_28h { get; set; } // 0x00000000 - public uint Unknown_2Ch { get; set; } // 0x00000000 - public uint Unknown_30h { get; set; } // 0x00000000 - public uint Unknown_34h { get; set; } // 0x00000000 - public uint Unknown_38h { get; set; } // 0x00000000 - public uint Unknown_3Ch { get; set; } // 0x00000000 - public uint Unknown_40h { get; set; } // 0x00000000 - public uint Unknown_44h { get; set; } // 0x00000000 - public uint Unknown_48h { get; set; } // 0x00000000 - public uint Unknown_4Ch { get; set; } // 0x00000000 - public uint Unknown_50h { get; set; } // 0x00000000 - public uint Unknown_54h { get; set; } // 0x00000000 - public uint Unknown_58h { get; set; } // 0x00000000 - public uint Unknown_5Ch { get; set; } // 0x00000000 + public ulong Unknown_18h; // 0x0000000000000000 + public ulong Unknown_20h; // 0x0000000000000000 + public ulong Unknown_28h; // 0x0000000000000000 + public ulong Unknown_30h; // 0x0000000000000000 + public ulong Unknown_38h; // 0x0000000000000000 + public ulong Unknown_40h; // 0x0000000000000000 + public ulong Unknown_48h; // 0x0000000000000000 + public ulong Unknown_50h; // 0x0000000000000000 + public ulong Unknown_58h; // 0x0000000000000000 // reference data //public ResourceSimpleArray Indices; @@ -3464,24 +3475,15 @@ namespace CodeWalker.GameFiles this.IndicesCount = reader.ReadUInt32(); this.Unknown_Ch = reader.ReadUInt32(); this.IndicesPointer = reader.ReadUInt64(); - this.Unknown_18h = reader.ReadUInt32(); - this.Unknown_1Ch = reader.ReadUInt32(); - this.Unknown_20h = reader.ReadUInt32(); - this.Unknown_24h = reader.ReadUInt32(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); - this.Unknown_30h = reader.ReadUInt32(); - this.Unknown_34h = reader.ReadUInt32(); - this.Unknown_38h = reader.ReadUInt32(); - this.Unknown_3Ch = reader.ReadUInt32(); - this.Unknown_40h = reader.ReadUInt32(); - this.Unknown_44h = reader.ReadUInt32(); - this.Unknown_48h = reader.ReadUInt32(); - this.Unknown_4Ch = reader.ReadUInt32(); - this.Unknown_50h = reader.ReadUInt32(); - this.Unknown_54h = reader.ReadUInt32(); - this.Unknown_58h = reader.ReadUInt32(); - this.Unknown_5Ch = reader.ReadUInt32(); + this.Unknown_18h = reader.ReadUInt64(); + this.Unknown_20h = reader.ReadUInt64(); + this.Unknown_28h = reader.ReadUInt64(); + this.Unknown_30h = reader.ReadUInt64(); + this.Unknown_38h = reader.ReadUInt64(); + this.Unknown_40h = reader.ReadUInt64(); + this.Unknown_48h = reader.ReadUInt64(); + this.Unknown_50h = reader.ReadUInt64(); + this.Unknown_58h = reader.ReadUInt64(); // read reference data //this.Indices = reader.ReadBlockAt>( @@ -3489,6 +3491,31 @@ namespace CodeWalker.GameFiles // this.IndicesCount //); this.Indices = reader.ReadUshortsAt(this.IndicesPointer, this.IndicesCount); + + + //if (Unknown_4h != 1) + //{ } + //if (Unknown_Ch != 0) + //{ } + //if (Unknown_18h != 0) + //{ } + //if (Unknown_20h != 0) + //{ } + //if (Unknown_28h != 0) + //{ } + //if (Unknown_30h != 0) + //{ } + //if (Unknown_38h != 0) + //{ } + //if (Unknown_40h != 0) + //{ } + //if (Unknown_48h != 0) + //{ } + //if (Unknown_50h != 0) + //{ } + //if (Unknown_58h != 0) + //{ } + } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -3503,23 +3530,14 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_Ch); writer.Write(this.IndicesPointer); writer.Write(this.Unknown_18h); - writer.Write(this.Unknown_1Ch); writer.Write(this.Unknown_20h); - writer.Write(this.Unknown_24h); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); writer.Write(this.Unknown_30h); - writer.Write(this.Unknown_34h); writer.Write(this.Unknown_38h); - writer.Write(this.Unknown_3Ch); writer.Write(this.Unknown_40h); - writer.Write(this.Unknown_44h); writer.Write(this.Unknown_48h); - writer.Write(this.Unknown_4Ch); writer.Write(this.Unknown_50h); - writer.Write(this.Unknown_54h); writer.Write(this.Unknown_58h); - writer.Write(this.Unknown_5Ch); } public void WriteXml(StringBuilder sb, int indent) { @@ -3719,7 +3737,7 @@ namespace CodeWalker.GameFiles public uint RenderMaskFlagsLow { get; set; } public uint RenderMaskFlagsVlow { get; set; } public ulong JointsPointer { get; set; } - public ushort Unknown_98h { get; set; } // 0 + public ushort Unknown_98h { get; set; } // 0x0000 public ushort Unknown_9Ah { get; set; } public uint Unknown_9Ch { get; set; } // 0x00000000 public ulong DrawableModelsXPointer { get; set; } @@ -4321,13 +4339,10 @@ namespace CodeWalker.GameFiles if (this is FragDrawable fd) { var f = new FragDrawable(); - f.Unknown_0A8h = fd.Unknown_0A8h; - f.Unknown_0ACh = fd.Unknown_0ACh; f.FragMatrix = fd.FragMatrix; f.FragMatricesIndsCount = fd.FragMatricesIndsCount; + f.FragMatricesCapacity = fd.FragMatricesCapacity; f.FragMatricesCount = fd.FragMatricesCount; - f.Count3 = fd.Count3; - f.Count4 = fd.Count4; f.Bound = fd.Bound; f.FragMatricesInds = fd.FragMatricesInds; f.FragMatrices = fd.FragMatrices; @@ -4387,8 +4402,7 @@ namespace CodeWalker.GameFiles // structure data public ulong NamePointer { get; set; } public ResourceSimpleList64_s LightAttributes { get; set; } - public uint Unknown_C0h { get; set; } // 0x00000000 - public uint Unknown_C4h { get; set; } // 0x00000000 + public ulong ParticlesPointer { get; set; } // pointer in YPT files! TODO: investigate what it points to! public ulong BoundPointer { get; set; } // reference data @@ -4408,8 +4422,7 @@ namespace CodeWalker.GameFiles // read structure data this.NamePointer = reader.ReadUInt64(); this.LightAttributes = reader.ReadBlock>(); - this.Unknown_C0h = reader.ReadUInt32(); - this.Unknown_C4h = reader.ReadUInt32(); + this.ParticlesPointer = reader.ReadUInt64(); this.BoundPointer = reader.ReadUInt64(); try @@ -4434,6 +4447,9 @@ namespace CodeWalker.GameFiles { ErrorMessage = ex.ToString(); } + + if (ParticlesPointer != 0) + { } } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -4446,8 +4462,7 @@ namespace CodeWalker.GameFiles // write structure data writer.Write(this.NamePointer); writer.WriteBlock(this.LightAttributes); - writer.Write(this.Unknown_C0h); - writer.Write(this.Unknown_C4h); + writer.Write(this.ParticlesPointer); writer.Write(this.BoundPointer); } public override void WriteXml(StringBuilder sb, int indent, string ddsfolder) @@ -4457,7 +4472,7 @@ namespace CodeWalker.GameFiles Bounds.WriteXmlNode(Bound, sb, indent); if (LightAttributes?.data_items != null) { - YdrXml.WriteItemArray(sb, LightAttributes.data_items, indent, "LightAttributes"); + YdrXml.WriteItemArray(sb, LightAttributes.data_items, indent, "Lights"); } } public override void ReadXml(XmlNode node, string ddsfolder) @@ -4471,7 +4486,7 @@ namespace CodeWalker.GameFiles } LightAttributes = new ResourceSimpleList64_s(); - LightAttributes.data_items = XmlMeta.ReadItemArray(node, "LightAttributes"); + LightAttributes.data_items = XmlMeta.ReadItemArray(node, "Lights"); } public static void WriteXmlNode(Drawable d, StringBuilder sb, int indent, string ddsfolder, string name = "Drawable") @@ -4633,18 +4648,16 @@ namespace CodeWalker.GameFiles } // structure data - public uint Unknown_10h { get; set; } // 0x00000000 - public uint Unknown_14h { get; set; } // 0x00000000 - public uint Unknown_18h { get; set; } // 0x00000001 - public uint Unknown_1Ch { get; set; } // 0x00000000 + public ulong Unknown_10h; // 0x0000000000000000 + public ulong Unknown_18h = 1; // 0x0000000000000001 public ulong HashesPointer { get; set; } public ushort HashesCount1 { get; set; } public ushort HashesCount2 { get; set; } - public uint Unknown_2Ch { get; set; } // 0x00000000 + public uint Unknown_2Ch; // 0x00000000 public ulong DrawablesPointer { get; set; } public ushort DrawablesCount1 { get; set; } public ushort DrawablesCount2 { get; set; } - public uint Unknown_3Ch { get; set; } // 0x00000000 + public uint Unknown_3Ch; // 0x00000000 // reference data //public ResourceSimpleArray Hashes { get; set; } @@ -4676,10 +4689,8 @@ namespace CodeWalker.GameFiles base.Read(reader, parameters); // read structure data - this.Unknown_10h = reader.ReadUInt32(); - this.Unknown_14h = reader.ReadUInt32(); - this.Unknown_18h = reader.ReadUInt32(); - this.Unknown_1Ch = reader.ReadUInt32(); + this.Unknown_10h = reader.ReadUInt64(); + this.Unknown_18h = reader.ReadUInt64(); this.HashesPointer = reader.ReadUInt64(); this.HashesCount1 = reader.ReadUInt16(); this.HashesCount2 = reader.ReadUInt16(); @@ -4696,6 +4707,15 @@ namespace CodeWalker.GameFiles this.DrawablesPointer, // offset this.DrawablesCount1 ); + + //if (Unknown_10h != 0) + //{ } + //if (Unknown_18h != 1) + //{ } + //if (Unknown_2Ch != 0) + //{ } + //if (Unknown_3Ch != 0) + //{ } } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -4711,9 +4731,7 @@ namespace CodeWalker.GameFiles // write structure data writer.Write(this.Unknown_10h); - writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); - writer.Write(this.Unknown_1Ch); writer.Write(this.HashesPointer); writer.Write(this.HashesCount1); writer.Write(this.HashesCount2); diff --git a/CodeWalker.Core/GameFiles/Resources/Frag.cs b/CodeWalker.Core/GameFiles/Resources/Frag.cs index 73b0f43..b076fbc 100644 --- a/CodeWalker.Core/GameFiles/Resources/Frag.cs +++ b/CodeWalker.Core/GameFiles/Resources/Frag.cs @@ -46,65 +46,49 @@ namespace CodeWalker.GameFiles } // structure data - public uint Unknown_10h { get; set; } // 0x00000000 - public uint Unknown_14h { get; set; } // 0x00000000 - public uint Unknown_18h { get; set; } // 0x00000000 - public uint Unknown_1Ch { get; set; } // 0x00000000 - public float Unknown_20h { get; set; } - public float Unknown_24h { get; set; } - public float Unknown_28h { get; set; } - public float Unknown_2Ch { get; set; } + public ulong Unknown_10h; // 0x0000000000000000 + public ulong Unknown_18h; // 0x0000000000000000 + public Vector3 BoundingSphereCenter { get; set; } + public float BoundingSphereRadius { get; set; } public ulong DrawablePointer { get; set; } public ulong DrawableArrayPointer { get; set; } public ulong DrawableArrayNamesPointer { get; set; } public uint DrawableArrayCount { get; set; } - public uint Unknown_4Ch { get; set; } //pointer? - public uint Unknown_50h { get; set; } // 0x00000000 - public uint Unknown_54h { get; set; } // 0x00000000 + public int DrawableArrayFlag { get; set; } // 0, -1 (DrawableArray flag: 0 when ArrayCount>0, -1 when not) + public ulong Unknown_50h; // 0x0000000000000000 public ulong NamePointer { get; set; } - public ResourcePointerList64 Clothes { get; set; } - public uint Unknown_70h { get; set; } // 0x00000000 - public uint Unknown_74h { get; set; } // 0x00000000 - public uint Unknown_78h { get; set; } // 0x00000000 - public uint Unknown_7Ch { get; set; } // 0x00000000 - public uint Unknown_80h { get; set; } // 0x00000000 - public uint Unknown_84h { get; set; } // 0x00000000 - public uint Unknown_88h { get; set; } // 0x00000000 - public uint Unknown_8Ch { get; set; } // 0x00000000 - public uint Unknown_90h { get; set; } // 0x00000000 - public uint Unknown_94h { get; set; } // 0x00000000 - public uint Unknown_98h { get; set; } // 0x00000000 - public uint Unknown_9Ch { get; set; } // 0x00000000 - public uint Unknown_A0h { get; set; } // 0x00000000 - public uint Unknown_A4h { get; set; } // 0x00000000 + public ResourcePointerList64 Cloths { get; set; } + public ulong Unknown_70h; // 0x0000000000000000 + public ulong Unknown_78h; // 0x0000000000000000 + public ulong Unknown_80h; // 0x0000000000000000 + public ulong Unknown_88h; // 0x0000000000000000 + public ulong Unknown_90h; // 0x0000000000000000 + public ulong Unknown_98h; // 0x0000000000000000 + public ulong Unknown_A0h; // 0x0000000000000000 public ulong BoneTransformsPointer { get; set; } - public uint Unknown_B0h { get; set; } // 0x00000000 - public uint Unknown_B4h { get; set; } // 0x00000000 - public uint Unknown_B8h { get; set; } - public uint Unknown_BCh { get; set; } - public uint Unknown_C0h { get; set; } - public uint Unknown_C4h { get; set; } - public uint Unknown_C8h { get; set; }//pointer? + public int Unknown_B0h { get; set; } // 0, 944, 1088, 1200 + public int Unknown_B4h; //0x00000000 + public int Unknown_B8h { get; set; } // -364 to 16976, multiple of 16! + public int Unknown_BCh { get; set; } // 0, -1 + public int Unknown_C0h { get; set; } // 0, 256, 512, 768, 1024, 65280 + public int Unknown_C4h { get; set; } // 1, 3, 65, 67 + public int Unknown_C8h = -1; // -1 public float Unknown_CCh { get; set; } public float Unknown_D0h { get; set; } public float Unknown_D4h { get; set; } - public byte Unknown_D8h { get; set; } + public byte Unknown_D8h; // 0x00 public byte GlassWindowsCount { get; set; } - public ushort Unknown_DAh { get; set; } - public uint Unknown_DCh { get; set; } // 0x00000000 + public ushort Unknown_DAh; // 0x0000 + public uint Unknown_DCh; // 0x00000000 public ulong GlassWindowsPointer { get; set; } - public uint Unknown_E8h { get; set; } // 0x00000000 - public uint Unknown_ECh { get; set; } // 0x00000000 + public ulong Unknown_E8h; // 0x0000000000000000 public ulong PhysicsLODGroupPointer { get; set; } public ulong Drawable2Pointer { get; set; } - public uint Unknown_100h { get; set; } // 0x00000000 - public uint Unknown_104h { get; set; } // 0x00000000 - public uint Unknown_108h { get; set; } // 0x00000000 - public uint Unknown_10Ch { get; set; } // 0x00000000 + public ulong Unknown_100h; // 0x0000000000000000 + public ulong Unknown_108h; // 0x0000000000000000 public ResourceSimpleList64_s LightAttributes { get; set; } public ulong VehicleGlassWindowsPointer { get; set; } - public uint Unknown_128h { get; set; } // 0x00000000 - public uint Unknown_12Ch { get; set; } // 0x00000000 + public ulong Unknown_128h; // 0x0000000000000000 // reference data public FragDrawable Drawable { get; set; } @@ -128,45 +112,33 @@ namespace CodeWalker.GameFiles base.Read(reader, parameters); // read structure data - this.Unknown_10h = reader.ReadUInt32(); - this.Unknown_14h = reader.ReadUInt32(); - this.Unknown_18h = reader.ReadUInt32(); - this.Unknown_1Ch = reader.ReadUInt32(); - this.Unknown_20h = reader.ReadSingle(); - this.Unknown_24h = reader.ReadSingle(); - this.Unknown_28h = reader.ReadSingle(); - this.Unknown_2Ch = reader.ReadSingle(); + this.Unknown_10h = reader.ReadUInt64(); + this.Unknown_18h = reader.ReadUInt64(); + this.BoundingSphereCenter = reader.ReadVector3(); + this.BoundingSphereRadius = reader.ReadSingle(); this.DrawablePointer = reader.ReadUInt64(); this.DrawableArrayPointer = reader.ReadUInt64(); this.DrawableArrayNamesPointer = reader.ReadUInt64(); this.DrawableArrayCount = reader.ReadUInt32(); - this.Unknown_4Ch = reader.ReadUInt32(); - this.Unknown_50h = reader.ReadUInt32(); - this.Unknown_54h = reader.ReadUInt32(); + this.DrawableArrayFlag = reader.ReadInt32(); + this.Unknown_50h = reader.ReadUInt64(); this.NamePointer = reader.ReadUInt64(); - this.Clothes = reader.ReadBlock>(); - this.Unknown_70h = reader.ReadUInt32(); - this.Unknown_74h = reader.ReadUInt32(); - this.Unknown_78h = reader.ReadUInt32(); - this.Unknown_7Ch = reader.ReadUInt32(); - this.Unknown_80h = reader.ReadUInt32(); - this.Unknown_84h = reader.ReadUInt32(); - this.Unknown_88h = reader.ReadUInt32(); - this.Unknown_8Ch = reader.ReadUInt32(); - this.Unknown_90h = reader.ReadUInt32(); - this.Unknown_94h = reader.ReadUInt32(); - this.Unknown_98h = reader.ReadUInt32(); - this.Unknown_9Ch = reader.ReadUInt32(); - this.Unknown_A0h = reader.ReadUInt32(); - this.Unknown_A4h = reader.ReadUInt32(); + this.Cloths = reader.ReadBlock>(); + this.Unknown_70h = reader.ReadUInt64(); + this.Unknown_78h = reader.ReadUInt64(); + this.Unknown_80h = reader.ReadUInt64(); + this.Unknown_88h = reader.ReadUInt64(); + this.Unknown_90h = reader.ReadUInt64(); + this.Unknown_98h = reader.ReadUInt64(); + this.Unknown_A0h = reader.ReadUInt64(); this.BoneTransformsPointer = reader.ReadUInt64(); - this.Unknown_B0h = reader.ReadUInt32(); - this.Unknown_B4h = reader.ReadUInt32(); - this.Unknown_B8h = reader.ReadUInt32(); - this.Unknown_BCh = reader.ReadUInt32(); - this.Unknown_C0h = reader.ReadUInt32(); - this.Unknown_C4h = reader.ReadUInt32(); - this.Unknown_C8h = reader.ReadUInt32(); + this.Unknown_B0h = reader.ReadInt32(); + this.Unknown_B4h = reader.ReadInt32(); + this.Unknown_B8h = reader.ReadInt32(); + this.Unknown_BCh = reader.ReadInt32(); + this.Unknown_C0h = reader.ReadInt32(); + this.Unknown_C4h = reader.ReadInt32(); + this.Unknown_C8h = reader.ReadInt32(); this.Unknown_CCh = reader.ReadSingle(); this.Unknown_D0h = reader.ReadSingle(); this.Unknown_D4h = reader.ReadSingle(); @@ -175,28 +147,35 @@ namespace CodeWalker.GameFiles this.Unknown_DAh = reader.ReadUInt16(); this.Unknown_DCh = reader.ReadUInt32(); this.GlassWindowsPointer = reader.ReadUInt64(); - this.Unknown_E8h = reader.ReadUInt32(); - this.Unknown_ECh = reader.ReadUInt32(); + this.Unknown_E8h = reader.ReadUInt64(); this.PhysicsLODGroupPointer = reader.ReadUInt64(); this.Drawable2Pointer = reader.ReadUInt64(); - this.Unknown_100h = reader.ReadUInt32(); - this.Unknown_104h = reader.ReadUInt32(); - this.Unknown_108h = reader.ReadUInt32(); - this.Unknown_10Ch = reader.ReadUInt32(); + this.Unknown_100h = reader.ReadUInt64(); + this.Unknown_108h = reader.ReadUInt64(); this.LightAttributes = reader.ReadBlock>(); this.VehicleGlassWindowsPointer = reader.ReadUInt64(); - this.Unknown_128h = reader.ReadUInt32(); - this.Unknown_12Ch = reader.ReadUInt32(); + this.Unknown_128h = reader.ReadUInt64(); // read reference data Drawable = reader.ReadBlockAt(this.DrawablePointer); + DrawableArray = reader.ReadBlockAt>(DrawableArrayPointer, DrawableArrayCount); + DrawableArrayNames = reader.ReadBlockAt>(DrawableArrayNamesPointer, DrawableArrayCount); + Name = reader.ReadStringAt(NamePointer); + BoneTransforms = reader.ReadBlockAt(BoneTransformsPointer); + GlassWindows = reader.ReadBlockAt>(GlassWindowsPointer, GlassWindowsCount); + PhysicsLODGroup = reader.ReadBlockAt(PhysicsLODGroupPointer); + Drawable2 = reader.ReadBlockAt(Drawable2Pointer); + VehicleGlassWindows = reader.ReadBlockAt(VehicleGlassWindowsPointer); + if (Drawable != null) { Drawable.OwnerFragment = this; } - - DrawableArray = reader.ReadBlockAt>(DrawableArrayPointer, DrawableArrayCount); - if ((DrawableArray != null) && (DrawableArray.data_items != null)) + if (Drawable2 != null) + { + Drawable2.OwnerFragment = this; + } + if (DrawableArray?.data_items != null) { for (int i = 0; i < DrawableArray.data_items.Length; i++) { @@ -207,27 +186,11 @@ namespace CodeWalker.GameFiles } } } - DrawableArrayNames = reader.ReadBlockAt>(DrawableArrayNamesPointer, DrawableArrayCount); - Name = reader.ReadStringAt(NamePointer); - BoneTransforms = reader.ReadBlockAt(BoneTransformsPointer); - GlassWindows = reader.ReadBlockAt>(GlassWindowsPointer, GlassWindowsCount); - PhysicsLODGroup = reader.ReadBlockAt(PhysicsLODGroupPointer); - Drawable2 = reader.ReadBlockAt(Drawable2Pointer); - if (Drawable2 != null) - { - Drawable2.OwnerFragment = this; - } - - VehicleGlassWindows = reader.ReadBlockAt(VehicleGlassWindowsPointer); - - - if (GlassWindows != null) { } if (VehicleGlassWindows != null) { } - //for vehicle wheels, the shaderGroup in the model seems to be missing, but have to use the main drawable's shaders. if ((Drawable != null) && (PhysicsLODGroup != null) && (PhysicsLODGroup.PhysicsLOD1 != null)) { @@ -246,6 +209,115 @@ namespace CodeWalker.GameFiles } + + + //just testing!! + if (BoundingSphereRadius <= 0.0f) + { } + if (DrawableArrayFlag != ((DrawableArrayCount == 0) ? -1 : 0)) + { } + switch (Unknown_B0h) + { + case 0: + case 944: + case 1088: + case 1200: + break; + default: + break; + } + switch (Unknown_B8h) + { + case -364: + case -80: + case -48: + case -32: + case -16: + case 0: + case 16: + case 32: + case 48: + case 64: + case 96: + case 160: + case 192: + case 208: + case 480: + case 736: + case 3356: + case 5008: + case 5024: + case 5056: + case 5520: + case 5680: + case 5856: + case 6176: + case 6432: + case 6448: + case 7088: + case 7216: + case 7776: + case 8032: + case 8048: + case 8064: + case 8080: + case 8112: + case 8144: + case 8688: + case 8928: + case 9216: + case 9808: + case 9872: + case 9888: + case 10480: + case 10704: + case 11248: + case 13696: + case 14344: + case 14640: + case 14720: + case 14752: + case 14768: + case 14944: + case 15112: + case 16656: + case 16976: + break; + default: + break; + } + switch (Unknown_BCh) + { + case 0: + case -1: + break; + default: + break; + } + switch (Unknown_C0h) + { + case 0: + case 256: + case 512: + case 768: + case 1024: + case 65280: + break; + default: + break; + } + switch (Unknown_C4h) + { + case 1: + case 3: + case 65: + case 67: + break; + default: + break; + } + + } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -266,36 +338,24 @@ namespace CodeWalker.GameFiles // write structure data writer.Write(this.Unknown_10h); - writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); - writer.Write(this.Unknown_1Ch); - writer.Write(this.Unknown_20h); - writer.Write(this.Unknown_24h); - writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); + writer.Write(this.BoundingSphereCenter); + writer.Write(this.BoundingSphereRadius); writer.Write(this.DrawablePointer); writer.Write(this.DrawableArrayPointer); writer.Write(this.DrawableArrayNamesPointer); writer.Write(this.DrawableArrayCount); - writer.Write(this.Unknown_4Ch); + writer.Write(this.DrawableArrayFlag); writer.Write(this.Unknown_50h); - writer.Write(this.Unknown_54h); writer.Write(this.NamePointer); - writer.WriteBlock(this.Clothes); + writer.WriteBlock(this.Cloths); writer.Write(this.Unknown_70h); - writer.Write(this.Unknown_74h); writer.Write(this.Unknown_78h); - writer.Write(this.Unknown_7Ch); writer.Write(this.Unknown_80h); - writer.Write(this.Unknown_84h); writer.Write(this.Unknown_88h); - writer.Write(this.Unknown_8Ch); writer.Write(this.Unknown_90h); - writer.Write(this.Unknown_94h); writer.Write(this.Unknown_98h); - writer.Write(this.Unknown_9Ch); writer.Write(this.Unknown_A0h); - writer.Write(this.Unknown_A4h); writer.Write(this.BoneTransformsPointer); writer.Write(this.Unknown_B0h); writer.Write(this.Unknown_B4h); @@ -313,25 +373,145 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_DCh); writer.Write(this.GlassWindowsPointer); writer.Write(this.Unknown_E8h); - writer.Write(this.Unknown_ECh); writer.Write(this.PhysicsLODGroupPointer); writer.Write(this.Drawable2Pointer); writer.Write(this.Unknown_100h); - writer.Write(this.Unknown_104h); writer.Write(this.Unknown_108h); - writer.Write(this.Unknown_10Ch); writer.WriteBlock(this.LightAttributes); writer.Write(this.VehicleGlassWindowsPointer); writer.Write(this.Unknown_128h); - writer.Write(this.Unknown_12Ch); } public void WriteXml(StringBuilder sb, int indent, string ddsfolder) { - //TODO + YftXml.StringTag(sb, indent, "Name", YftXml.XmlEscape(Name)); + YftXml.SelfClosingTag(sb, indent, "BoundingSphereCenter " + FloatUtil.GetVector3XmlString(BoundingSphereCenter)); + YftXml.ValueTag(sb, indent, "BoundingSphereRadius", FloatUtil.ToString(BoundingSphereRadius)); + YftXml.ValueTag(sb, indent, "UnknownB0", Unknown_B0h.ToString()); + YftXml.ValueTag(sb, indent, "UnknownB8", Unknown_B8h.ToString()); + YftXml.ValueTag(sb, indent, "UnknownBC", Unknown_BCh.ToString()); + YftXml.ValueTag(sb, indent, "UnknownC0", Unknown_C0h.ToString()); + YftXml.ValueTag(sb, indent, "UnknownC4", Unknown_C4h.ToString()); + YftXml.ValueTag(sb, indent, "UnknownCC", FloatUtil.ToString(Unknown_CCh)); + YftXml.ValueTag(sb, indent, "UnknownD0", FloatUtil.ToString(Unknown_D0h)); + YftXml.ValueTag(sb, indent, "UnknownD4", FloatUtil.ToString(Unknown_D4h)); + if (Drawable != null) + { + FragDrawable.WriteXmlNode(Drawable, sb, indent, ddsfolder, "Drawable"); + } + if (Drawable2 != null) + { + FragDrawable.WriteXmlNode(Drawable2, sb, indent, ddsfolder, "Drawable2"); + } + if ((DrawableArray?.data_items?.Length ?? 0) > 0) + { + var danames = DrawableArrayNames?.data_items; + YftXml.OpenTag(sb, indent, "DrawableArray"); + for (int i = 0; i < DrawableArray.data_items.Length; i++) + { + var d = DrawableArray.data_items[i]; + var name = (i < (danames?.Length ?? 0)) ? danames[i] : null; + if (d.Name != name.Value) + { } + FragDrawable.WriteXmlNode(d, sb, indent + 1, ddsfolder, "Item"); + } + YftXml.CloseTag(sb, indent, "DrawableArray"); + } + if (BoneTransforms != null) + { + BoneTransforms.WriteXml(sb, indent, "BoneTransforms"); + } + if (PhysicsLODGroup != null) + { + YftXml.OpenTag(sb, indent, "Physics"); + PhysicsLODGroup.WriteXml(sb, indent + 1, ddsfolder); + YftXml.CloseTag(sb, indent, "Physics"); + } + if (VehicleGlassWindows != null) + { + YftXml.OpenTag(sb, indent, "VehicleGlassWindows"); + VehicleGlassWindows.WriteXml(sb, indent + 1); + YftXml.CloseTag(sb, indent, "VehicleGlassWindows"); + } + if (GlassWindows?.data_items != null) + { + YftXml.WriteItemArray(sb, GlassWindows.data_items, indent, "GlassWindows"); + } + if (LightAttributes?.data_items != null) + { + YftXml.WriteItemArray(sb, LightAttributes.data_items, indent, "Lights"); + } + if (Cloths?.data_items != null) + { + YftXml.WriteItemArray(sb, Cloths.data_items, indent, "Cloths"); + } } public void ReadXml(XmlNode node, string ddsfolder) { - //TODO + Name = Xml.GetChildInnerText(node, "Name"); + BoundingSphereCenter = Xml.GetChildVector3Attributes(node, "BoundingSphereCenter", "x", "y", "z"); + BoundingSphereRadius = Xml.GetChildFloatAttribute(node, "BoundingSphereRadius", "value"); + Unknown_B0h = Xml.GetChildIntAttribute(node, "UnknownB0", "value"); + Unknown_B8h = Xml.GetChildIntAttribute(node, "UnknownB8", "value"); + Unknown_BCh = Xml.GetChildIntAttribute(node, "UnknownBC", "value"); + Unknown_C0h = Xml.GetChildIntAttribute(node, "UnknownC0", "value"); + Unknown_CCh = Xml.GetChildFloatAttribute(node, "UnknownCC", "value"); + Unknown_D0h = Xml.GetChildFloatAttribute(node, "UnknownD0", "value"); + Unknown_D4h = Xml.GetChildFloatAttribute(node, "UnknownD4", "value"); + var dnode = node.SelectSingleNode("Drawable"); + if (dnode != null) + { + Drawable = FragDrawable.ReadXmlNode(dnode, ddsfolder); + } + var dnode2 = node.SelectSingleNode("Drawable2"); + if (dnode2 != null) + { + Drawable2 = FragDrawable.ReadXmlNode(dnode2, ddsfolder); + } + var danode = node.SelectSingleNode("DrawableArray"); + if (danode != null) + { + var dlist = new List(); + var nlist = new List(); + var dnodes = danode.SelectNodes("Item"); + foreach (XmlNode dn in dnodes) + { + var d = FragDrawable.ReadXmlNode(dn, ddsfolder); + dlist.Add(d); + nlist.Add((string_r)d?.Name); + } + DrawableArray = new ResourcePointerArray64(); + DrawableArray.data_items = dlist.ToArray(); + DrawableArrayNames = new ResourcePointerArray64(); + DrawableArrayNames.data_items = nlist.ToArray(); + } + var btnode = node.SelectSingleNode("BoneTransforms"); + if (btnode != null) + { + BoneTransforms = new FragBoneTransforms(); + BoneTransforms.ReadXml(btnode); + } + var pnode = node.SelectSingleNode("Physics"); + if (pnode != null) + { + PhysicsLODGroup = new FragPhysicsLODGroup(); + PhysicsLODGroup.ReadXml(pnode, ddsfolder); + } + var vgnode = node.SelectSingleNode("VehicleGlassWindows"); + if (vgnode != null) + { + VehicleGlassWindows = new FragVehicleGlassWindows(); + VehicleGlassWindows.ReadXml(vgnode); + } + var gwinds = XmlMeta.ReadItemArray(node, "GlassWindows"); + if ((gwinds != null) && (gwinds.Length > 0)) + { + GlassWindows = new ResourcePointerArray64(); + GlassWindows.data_items = gwinds; + } + LightAttributes = new ResourceSimpleList64_s(); + LightAttributes.data_items = XmlMeta.ReadItemArray(node, "Lights"); + Cloths = new ResourcePointerList64(); + Cloths.data_items = XmlMeta.ReadItemArray(node, "Cloths"); } public static void WriteXmlNode(FragType f, StringBuilder sb, int indent, string ddsfolder, string name = "Fragment") { @@ -370,7 +550,7 @@ namespace CodeWalker.GameFiles public override Tuple[] GetParts() { return new Tuple[] { - new Tuple(0x60, Clothes), + new Tuple(0x60, Cloths), new Tuple(0x110, LightAttributes) }; } @@ -384,31 +564,24 @@ namespace CodeWalker.GameFiles } // structure data - public uint Unknown_0A8h { get; set; } - public uint Unknown_0ACh { get; set; } - public Matrix FragMatrix { get; set; } //unknown? + public ulong Unknown_0A8h; // 0x0000000000000000 + public Matrix FragMatrix { get; set; } public ulong BoundPointer { get; set; } public ulong FragMatricesIndsPointer { get; set; } public ushort FragMatricesIndsCount { get; set; } - public ushort FragMatricesCount { get; set; } - public uint Unknown_104h { get; set; } // 0x00000000 + public ushort FragMatricesCapacity { get; set; } + public uint Unknown_104h; // 0x00000000 public ulong FragMatricesPointer { get; set; } - public ushort Count3 { get; set; } - public ushort Count4 { get; set; } - public uint Unknown_114h { get; set; } // 0x00000000 - public uint Unknown_118h { get; set; } // 0x00000000 - public uint Unknown_11Ch { get; set; } // 0x00000000 - public uint Unknown_120h { get; set; } // 0x00000000 - public uint Unknown_124h { get; set; } // 0x00000000 - public uint Unknown_128h { get; set; } // 0x00000000 - public uint Unknown_12Ch { get; set; } // 0x00000000 + public ushort FragMatricesCount { get; set; } + public ushort Unknown_112h = 1; // 1 + public uint Unknown_114h; // 0x00000000 + public ulong Unknown_118h; // 0x0000000000000000 + public ulong Unknown_120h; // 0x0000000000000000 + public ulong Unknown_128h; // 0x0000000000000000 public ulong NamePointer { get; set; } - public uint Unknown_138h { get; set; } // 0x00000000 - public uint Unknown_13Ch { get; set; } // 0x00000000 - public uint Unknown_140h { get; set; } // 0x00000000 - public uint Unknown_144h { get; set; } // 0x00000000 - public uint Unknown_148h { get; set; } // 0x00000000 - public uint Unknown_14Ch { get; set; } // 0x00000000 + public ulong Unknown_138h; // 0x0000000000000000 + public ulong Unknown_140h; // 0x0000000000000000 + public ulong Unknown_148h; // 0x0000000000000000 // reference data public Bounds Bound { get; set; } @@ -421,8 +594,8 @@ namespace CodeWalker.GameFiles public FragPhysTypeChild OwnerFragmentPhys { get; set; } - private ResourceSystemStructBlock Unknown_F8h_DataBlock = null; //used for saving only - private ResourceSystemStructBlock Unknown_108h_DataBlock = null; + private ResourceSystemStructBlock FragMatricesIndsBlock = null; //used for saving only + private ResourceSystemStructBlock FragMatricesBlock = null; private string_r NameBlock = null; public override void Read(ResourceDataReader reader, params object[] parameters) @@ -430,36 +603,29 @@ namespace CodeWalker.GameFiles base.Read(reader, parameters); // read structure data - this.Unknown_0A8h = reader.ReadUInt32(); - this.Unknown_0ACh = reader.ReadUInt32(); + this.Unknown_0A8h = reader.ReadUInt64(); this.FragMatrix = reader.ReadStruct(); this.BoundPointer = reader.ReadUInt64(); this.FragMatricesIndsPointer = reader.ReadUInt64(); this.FragMatricesIndsCount = reader.ReadUInt16(); - this.FragMatricesCount = reader.ReadUInt16(); + this.FragMatricesCapacity = reader.ReadUInt16(); this.Unknown_104h = reader.ReadUInt32(); this.FragMatricesPointer = reader.ReadUInt64(); - this.Count3 = reader.ReadUInt16(); - this.Count4 = reader.ReadUInt16(); + this.FragMatricesCount = reader.ReadUInt16(); + this.Unknown_112h = reader.ReadUInt16(); this.Unknown_114h = reader.ReadUInt32(); - this.Unknown_118h = reader.ReadUInt32(); - this.Unknown_11Ch = reader.ReadUInt32(); - this.Unknown_120h = reader.ReadUInt32(); - this.Unknown_124h = reader.ReadUInt32(); - this.Unknown_128h = reader.ReadUInt32(); - this.Unknown_12Ch = reader.ReadUInt32(); + this.Unknown_118h = reader.ReadUInt64(); + this.Unknown_120h = reader.ReadUInt64(); + this.Unknown_128h = reader.ReadUInt64(); this.NamePointer = reader.ReadUInt64(); - this.Unknown_138h = reader.ReadUInt32(); - this.Unknown_13Ch = reader.ReadUInt32(); - this.Unknown_140h = reader.ReadUInt32(); - this.Unknown_144h = reader.ReadUInt32(); - this.Unknown_148h = reader.ReadUInt32(); - this.Unknown_14Ch = reader.ReadUInt32(); + this.Unknown_138h = reader.ReadUInt64(); + this.Unknown_140h = reader.ReadUInt64(); + this.Unknown_148h = reader.ReadUInt64(); // read reference data Bound = reader.ReadBlockAt(BoundPointer); FragMatricesInds = reader.ReadUlongsAt(FragMatricesIndsPointer, FragMatricesIndsCount); - FragMatrices = reader.ReadStructsAt(FragMatricesPointer, FragMatricesCount); + FragMatrices = reader.ReadStructsAt(FragMatricesPointer, FragMatricesCapacity); Name = reader.ReadStringAt(NamePointer); if (Bound != null) @@ -467,12 +633,40 @@ namespace CodeWalker.GameFiles Bound.Owner = this; } - if ((Count3 != Count4)&&(Count4!=1)&&(Count3!=0)) - { } + + if (FragMatricesInds != null) { } if (FragMatrices != null) { } + if ((FragMatrices != null) != (FragMatricesInds != null)) + { } + + //if ((FragMatricesCount != 0) != (FragMatricesCapacity != 0)) + //{ } + //if (FragMatricesCount > FragMatricesCapacity) + //{ } + //if (Unknown_0A8h != 0) + //{ } + //if (Unknown_104h != 0) + //{ } + //if (Unknown_112h != 1) + //{ } + //if (Unknown_114h != 0) + //{ } + //if (Unknown_118h != 0) + //{ } + //if (Unknown_120h != 0) + //{ } + //if (Unknown_128h != 0) + //{ } + //if (Unknown_138h != 0) + //{ } + //if (Unknown_140h != 0) + //{ } + //if (Unknown_148h != 0) + //{ } + } public override void Write(ResourceDataWriter writer, params object[] parameters) { @@ -480,48 +674,90 @@ namespace CodeWalker.GameFiles // update structure data this.BoundPointer = (ulong)(this.Bound != null ? this.Bound.FilePosition : 0); - this.FragMatricesIndsPointer = (ulong)(this.Unknown_F8h_DataBlock != null ? this.Unknown_F8h_DataBlock.FilePosition : 0); - this.FragMatricesIndsCount = (ushort)(this.Unknown_F8h_DataBlock != null ? this.Unknown_F8h_DataBlock.ItemCount : 0); - this.FragMatricesCount = (ushort)(this.Unknown_108h_DataBlock != null ? this.Unknown_108h_DataBlock.ItemCount : 0); - this.FragMatricesPointer = (ulong)(this.Unknown_108h_DataBlock != null ? this.Unknown_108h_DataBlock.FilePosition : 0); + this.FragMatricesIndsPointer = (ulong)(this.FragMatricesIndsBlock != null ? this.FragMatricesIndsBlock.FilePosition : 0); + this.FragMatricesIndsCount = (ushort)(this.FragMatricesIndsBlock != null ? this.FragMatricesIndsBlock.ItemCount : 0); + this.FragMatricesCapacity = (ushort)(this.FragMatricesBlock != null ? this.FragMatricesBlock.ItemCount : 0); + this.FragMatricesPointer = (ulong)(this.FragMatricesBlock != null ? this.FragMatricesBlock.FilePosition : 0); this.NamePointer = (ulong)(this.NameBlock != null ? this.NameBlock.FilePosition : 0); // write structure data writer.Write(this.Unknown_0A8h); - writer.Write(this.Unknown_0ACh); writer.Write(this.FragMatrix); writer.Write(this.BoundPointer); writer.Write(this.FragMatricesIndsPointer); writer.Write(this.FragMatricesIndsCount); - writer.Write(this.FragMatricesCount); + writer.Write(this.FragMatricesCapacity); writer.Write(this.Unknown_104h); writer.Write(this.FragMatricesPointer); - writer.Write(this.Count3); - writer.Write(this.Count4); + writer.Write(this.FragMatricesCount); + writer.Write(this.Unknown_112h); writer.Write(this.Unknown_114h); writer.Write(this.Unknown_118h); - writer.Write(this.Unknown_11Ch); writer.Write(this.Unknown_120h); - writer.Write(this.Unknown_124h); writer.Write(this.Unknown_128h); - writer.Write(this.Unknown_12Ch); writer.Write(this.NamePointer); writer.Write(this.Unknown_138h); - writer.Write(this.Unknown_13Ch); writer.Write(this.Unknown_140h); - writer.Write(this.Unknown_144h); writer.Write(this.Unknown_148h); - writer.Write(this.Unknown_14Ch); } public override void WriteXml(StringBuilder sb, int indent, string ddsfolder) { + YftXml.StringTag(sb, indent, "Name", YftXml.XmlEscape(Name)); + YftXml.WriteRawArray(sb, FragMatrix.ToArray(), indent, "Matrix", "", FloatUtil.ToString, 4); + if ((FragMatrices != null) && (FragMatrices.Length > 0)) + { + YftXml.OpenTag(sb, indent, "Matrices capacity=\"" + FragMatrices.Length.ToString() + "\""); + var cind = indent + 1; + var cnt = Math.Min(FragMatrices.Length, FragMatricesCount); + for (int i = 0; i < FragMatrices.Length; i++) + { + var idx = ((FragMatricesInds != null) && (i < FragMatricesInds.Length)) ? FragMatricesInds[i] : 0; + YftXml.OpenTag(sb, cind, "Item id=\"" + idx.ToString() + "\""); + YftXml.WriteRawArrayContent(sb, FragMatrices[i].ToArray(), cind + 1, FloatUtil.ToString, 4); + YftXml.CloseTag(sb, cind, "Item"); + } + YftXml.CloseTag(sb, indent, "Matrices"); + } + base.WriteXml(sb, indent, ddsfolder); - //TODO + + Bounds.WriteXmlNode(Bound, sb, indent); } public override void ReadXml(XmlNode node, string ddsfolder) { + Name = Xml.GetChildInnerText(node, "Name"); + FragMatrix = Xml.GetChildMatrix(node, "Matrix"); + + var msnode = node.SelectSingleNode("Matrices"); + if (msnode != null) + { + var mats = new List(); + var matinds = new List(); + var cap = Xml.GetIntAttribute(msnode, "capacity"); + var inodes = msnode.SelectNodes("Item"); + foreach (XmlNode inode in inodes) + { + var id = Xml.GetULongAttribute(inode, "id"); + var mat = Xml.GetMatrix(inode); + matinds.Add(id); + mats.Add(mat); + } + for (int i = mats.Count; i < cap; i++) + { + matinds.Add(0); + mats.Add(new Matrix(float.NaN)); + } + FragMatrices = mats.ToArray(); + FragMatricesInds = matinds.ToArray(); + } + base.ReadXml(node, ddsfolder); - //TODO + + var bnode = node.SelectSingleNode("Bounds"); + if (bnode != null) + { + Bound = Bounds.ReadXmlNode(bnode, this); + } } public static void WriteXmlNode(FragDrawable d, StringBuilder sb, int indent, string ddsfolder, string name = "FragDrawable") { @@ -544,13 +780,13 @@ namespace CodeWalker.GameFiles if (Bound != null) list.Add(Bound); if (FragMatricesInds != null) { - Unknown_F8h_DataBlock = new ResourceSystemStructBlock(FragMatricesInds); - list.Add(Unknown_F8h_DataBlock); + FragMatricesIndsBlock = new ResourceSystemStructBlock(FragMatricesInds); + list.Add(FragMatricesIndsBlock); } if (FragMatrices != null) { - Unknown_108h_DataBlock = new ResourceSystemStructBlock(FragMatrices); - list.Add(Unknown_108h_DataBlock); + FragMatricesBlock = new ResourceSystemStructBlock(FragMatrices); + list.Add(FragMatricesBlock); } if (Name != null) { @@ -569,62 +805,95 @@ namespace CodeWalker.GameFiles } // structure data - public uint Unknown_00h { get; set; } // 0x00000000 - public uint Unknown_04h { get; set; } // 0x00000000 - public uint Unknown_08h { get; set; } // 0x00000000 - public uint Unknown_0Ch { get; set; } // 0x00000000 + public ulong Unknown_00h; // 0x0000000000000000 + public ulong Unknown_08h; // 0x0000000000000000 public byte ItemCount1 { get; set; } public byte ItemCount2 { get; set; } - public ushort Unknown_12h { get; set; } - public uint Unknown_14h { get; set; } // 0x00000000 - public uint Unknown_18h { get; set; } // 0x00000000 - public uint Unknown_1Ch { get; set; } // 0x00000000 + public ushort Unknown_12h { get; set; } // 0, 1 + public uint Unknown_14h; // 0x00000000 + public ulong Unknown_18h; // 0x0000000000000000 public Matrix3_s[] Items { get; set; } - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data - this.Unknown_00h = reader.ReadUInt32(); - this.Unknown_04h = reader.ReadUInt32(); - this.Unknown_08h = reader.ReadUInt32(); - this.Unknown_0Ch = reader.ReadUInt32(); + this.Unknown_00h = reader.ReadUInt64(); + this.Unknown_08h = reader.ReadUInt64(); this.ItemCount1 = reader.ReadByte(); this.ItemCount2 = reader.ReadByte(); this.Unknown_12h = reader.ReadUInt16(); this.Unknown_14h = reader.ReadUInt32(); - this.Unknown_18h = reader.ReadUInt32(); - this.Unknown_1Ch = reader.ReadUInt32(); + this.Unknown_18h = reader.ReadUInt64(); this.Items = reader.ReadStructs(ItemCount1); - if ((Unknown_12h != 0) && (Unknown_12h != 1)) - { } - } + //if (ItemCount1 != ItemCount2) + //{ } + //if ((Unknown_12h != 0) && (Unknown_12h != 1)) + //{ } + //if (Unknown_00h != 0) + //{ } + //if (Unknown_08h != 0) + //{ } + //if (Unknown_14h != 0) + //{ } + //if (Unknown_18h != 0) + //{ } - /// - /// Writes the data-block to a stream. - /// + } public override void Write(ResourceDataWriter writer, params object[] parameters) { // write structure data writer.Write(this.Unknown_00h); - writer.Write(this.Unknown_04h); writer.Write(this.Unknown_08h); - writer.Write(this.Unknown_0Ch); writer.Write(this.ItemCount1); writer.Write(this.ItemCount2); writer.Write(this.Unknown_12h); writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); - writer.Write(this.Unknown_1Ch); writer.WriteStructs(Items); } + public void WriteXml(StringBuilder sb, int indent, string name) + { + var tag = name + " unk=\"" + Unknown_12h.ToString() + "\""; + if ((Items != null) && (Items.Length > 0)) + { + YftXml.OpenTag(sb, indent, tag); + var cind = indent + 1; + foreach (var mat in Items) + { + YftXml.OpenTag(sb, cind, "Item"); + YftXml.WriteRawArrayContent(sb, mat.ToArray(), cind + 1, FloatUtil.ToString, 4); + YftXml.CloseTag(sb, cind, "Item"); + } + YftXml.CloseTag(sb, indent, name); + } + else + { + YftXml.SelfClosingTag(sb, indent, tag); + } + } + public void ReadXml(XmlNode node) + { + Unknown_12h = (ushort)Xml.GetUIntAttribute(node, "unk"); + var inodes = node.SelectNodes("Item"); + if (inodes != null) + { + var mats = new List(); + foreach (XmlNode inode in inodes) + { + var arr = Xml.GetRawFloatArray(inode); + var mat = new Matrix3_s(arr); + mats.Add(mat); + } + Items = (mats.Count > 0) ? mats.ToArray() : null; + ItemCount1 = ItemCount2 = (byte)mats.Count; + } + + } } - [TypeConverter(typeof(ExpandableObjectConverter))] public class FragGlassWindow : ResourceSystemBlock + [TypeConverter(typeof(ExpandableObjectConverter))] public class FragGlassWindow : ResourceSystemBlock, IMetaXmlItem { public override long BlockLength { @@ -633,47 +902,33 @@ namespace CodeWalker.GameFiles // structure data public Matrix Matrix { get; set; } //column 4 is NaN,NaN,NaN,1 - public uint VertexDeclFlags { get; set; } // 0x000000D9 - public ushort VertexDeclStride { get; set; } // 0x002C - public byte VertexDeclUnk { get; set; } //0x00 - public byte VertexDeclCount { get; set; } //0x05 - public ulong VertexDeclTypes { get; set; } // 0x7655555555996996 + public VertexDeclaration VertexDeclaration { get; set; } = new VertexDeclaration(); public MetaHash Unknown_50h { get; set; } //looks floaty? flagsy? 0xXXXX0000 - public ushort Unknown_54h { get; set; }//2 + public ushort Unknown_54h { get; set; } = 2; //2 public ushort Flags { get; set; }//512, 768, 1280 etc ... flags public Vector3 Vector1 { get; set; } public Vector3 Vector2 { get; set; } // z = 0x7F800001 (NaN) + public ushort Unknown50 + { + get { return (ushort)(Unknown_50h.Hash >> 16); } + set { Unknown_50h = (Unknown_50h & 0xFFFF) + ((uint)value << 16); } + } public ulong VertexDeclId //this all equates to VertexTypePNCTT { get { - ulong res = 0; - for (int i = 0; i < 16; i++) - { - if (((VertexDeclFlags >> i) & 1) == 1) - { - res += (VertexDeclTypes & (0xFu << (i * 4))); - } - } - return res; + return VertexDeclaration?.GetDeclarationId() ?? 0; } } - public VertexType VertexType { get { return (VertexType)VertexDeclFlags; } } + public VertexType VertexType { get { return (VertexType)(VertexDeclaration?.Flags ?? 0); } } - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data this.Matrix = reader.ReadStruct(); - this.VertexDeclFlags = reader.ReadUInt32(); - this.VertexDeclStride = reader.ReadUInt16(); - this.VertexDeclUnk = reader.ReadByte(); - this.VertexDeclCount = reader.ReadByte(); - this.VertexDeclTypes = reader.ReadUInt64(); + this.VertexDeclaration.Read(reader); this.Unknown_50h = reader.ReadUInt32(); this.Unknown_54h = reader.ReadUInt16(); this.Flags = reader.ReadUInt16(); @@ -685,25 +940,35 @@ namespace CodeWalker.GameFiles if (Unknown_54h != 2) { } } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // write structure data writer.Write(this.Matrix); - writer.Write(this.VertexDeclFlags); - writer.Write(this.VertexDeclStride); - writer.Write(this.VertexDeclUnk); - writer.Write(this.VertexDeclCount); - writer.Write(this.VertexDeclTypes); + this.VertexDeclaration.Write(writer); writer.Write(this.Unknown_50h); writer.Write(this.Unknown_54h); writer.Write(this.Flags); writer.Write(this.Vector1); writer.Write(this.Vector2); } + public void WriteXml(StringBuilder sb, int indent) + { + YftXml.ValueTag(sb, indent, "Flags", Flags.ToString()); + YftXml.ValueTag(sb, indent, "Unknown50", Unknown50.ToString()); + YftXml.SelfClosingTag(sb, indent, "Vector1 " + FloatUtil.GetVector3XmlString(Vector1)); + YftXml.SelfClosingTag(sb, indent, "Vector2 " + FloatUtil.GetVector3XmlString(Vector2)); + YftXml.WriteRawArray(sb, Matrix.ToArray(), indent, "Matrix", "", FloatUtil.ToString, 4); + VertexDeclaration.WriteXml(sb, indent, "Layout"); + } + public void ReadXml(XmlNode node) + { + Flags = (ushort)Xml.GetChildUIntAttribute(node, "Flags", "value"); + Unknown50 = (ushort)Xml.GetChildUIntAttribute(node, "Unknown50", "value"); + Vector1 = Xml.GetChildVector3Attributes(node, "Vector1", "x", "y", "z"); + Vector2 = Xml.GetChildVector3Attributes(node, "Vector2", "x", "y", "z"); + Matrix = Xml.GetChildMatrix(node, "Matrix"); + VertexDeclaration.ReadXml(node.SelectSingleNode("Layout")); + } } [TypeConverter(typeof(ExpandableObjectConverter))] public class FragVehicleGlassWindows : ResourceSystemBlock { @@ -723,35 +988,33 @@ namespace CodeWalker.GameFiles } [TypeConverter(typeof(ExpandableObjectConverter))] public class ItemStruct { - public Matrix UnkMatrix { get; set; } + public Matrix Matrix { get; set; } public uint UnkUint1 { get; set; } = 0x56475743; // "VGWC" vehicle glass window C..? public ushort ItemID { get; set; } //matches UnkStruct1.Item public ushort UnkUshort1 { get; set; } public ushort UnkUshort2 { get; set; } public ushort ItemDataCount { get; set; }//count of item data arrays public ushort ItemDataByteLength { get; set; }//total byte length of ItemDatas plus byte length of ItemDataOffsets - public ushort UnkUshort3 { get; set; } + public ushort UnkUshort3 { get; set; } = 0; //0 public uint UnkUint2 { get; set; } = 0; //0 public uint UnkUint3 { get; set; } = 0; //0 - public float UnkFloat0 { get; set; } public float UnkFloat1 { get; set; } + public float UnkFloat2 { get; set; } public ushort UnkUshort4 { get; set; } //0, 1 public ushort UnkUshort5 { get; set; } //2, 2050 - public float UnkFloat2 { get; set; } + public float UnkFloat3 { get; set; } public uint UnkUint4 { get; set; } = 0; //0 public uint UnkUint5 { get; set; } = 0; //0 public ushort[] ItemDataOffsets { get; set; }//byte offsets for following array public ItemDataStruct[] ItemDatas { get; set; } - public byte[] Leftovers { get; set; }//should just be leftover padding, TODO: getrid of this + public byte[] Padding { get; set; }//should just be leftover padding, TODO: getrid of this - public uint TotalLength + public uint ItemDataLength { get { - uint bc = 112; - bc += (ItemDataOffsets != null) ? ItemDataCount * 2u : 0; - bc += (uint)(Leftovers?.Length??0); + uint bc = (ItemDataOffsets != null) ? ItemDataCount * 2u : 0; if (ItemDatas != null) { foreach (var u in ItemDatas) @@ -762,24 +1025,34 @@ namespace CodeWalker.GameFiles return bc; } } + public uint TotalLength + { + get + { + uint bc = 112; + //bc += (uint)(Padding?.Length??0); + bc += ItemDataLength; + return bc; + } + } public void Read(ResourceDataReader reader) { - UnkMatrix = reader.ReadStruct(); + Matrix = reader.ReadStruct(); UnkUint1 = reader.ReadUInt32(); //0x56475743 "VGWC" ItemID = reader.ReadUInt16(); UnkUshort1 = reader.ReadUInt16(); UnkUshort2 = reader.ReadUInt16(); ItemDataCount = reader.ReadUInt16();//count of item data arrays ItemDataByteLength = reader.ReadUInt16();//total byte length of ItemDatas plus byte length of ItemDataOffsets - UnkUshort3 = reader.ReadUInt16(); + UnkUshort3 = reader.ReadUInt16();//0 UnkUint2 = reader.ReadUInt32();//0 UnkUint3 = reader.ReadUInt32();//0 - UnkFloat0 = reader.ReadSingle(); UnkFloat1 = reader.ReadSingle(); + UnkFloat2 = reader.ReadSingle(); UnkUshort4 = reader.ReadUInt16();//0, 1 UnkUshort5 = reader.ReadUInt16();//2, 2050 - UnkFloat2 = reader.ReadSingle(); + UnkFloat3 = reader.ReadSingle(); UnkUint4 = reader.ReadUInt32();//0 UnkUint5 = reader.ReadUInt32();//0 @@ -787,50 +1060,104 @@ namespace CodeWalker.GameFiles if (ItemDataByteLength != 0)//sometimes this is 0 and UnkUshort3>0, which is weird { ItemDataOffsets = reader.ReadStructs(ItemDataCount);//byte offsets for following array - - long coffset = 0; ItemDatas = new ItemDataStruct[ItemDataCount]; for (int i = 0; i < ItemDataCount; i++) { - var toffset = ItemDataOffsets[i]; - var cbrem = toffset - coffset; - if (cbrem > 0) - { - var leftovers = reader.ReadBytes((int)cbrem); - if (i > 0) - { - ItemDatas[i - 1].Leftovers = leftovers; - } - else - { } - coffset += cbrem; - } - else if (cbrem < 0) - { } - - var rpos = reader.Position; + //var toffset = ItemDataOffsets[i]; var u = new ItemDataStruct(); u.Read(reader); ItemDatas[i] = u; - coffset += reader.Position - rpos; } - } else { } - if ((UnkUint2 != 0) || (UnkUint3 != 0) || (UnkUint4 != 0) || (UnkUint5 != 0)) - { } - if ((UnkUshort4 != 0) && (UnkUshort4 != 1)) //1 in carbonrs.yft, policeb.yft, vader.yft - { } - if ((UnkUshort5 != 2) && (UnkUshort5 != 2050)) //2050 in cablecar.yft, submersible2.yft - { } + //switch (UnkUshort1) + //{ + // case 3: + // case 4: + // case 5: + // case 6: + // case 7: + // case 8: + // case 9: + // case 10: + // case 11: + // case 12: + // case 13: + // case 14: + // case 15: + // case 16: + // case 17: + // case 18: + // case 19: + // case 20: + // case 21: + // case 22: + // case 23: + // case 24: + // case 25: + // break; + // default: + // break; + //} + //switch (UnkUshort2) + //{ + // case 1: + // case 10: + // case 15: + // case 20: + // case 22: + // case 23: + // case 25: + // case 26: + // case 28: + // case 29: + // case 32: + // case 34: + // case 36: + // case 37: + // case 39: + // case 41: + // case 46: + // case 47: + // case 48: + // case 49: + // case 50: + // case 51: + // case 52: + // case 53: + // case 54: + // case 55: + // case 56: + // case 57: + // case 58: + // case 59: + // case 61: + // case 66: + // case 74: + // case 77: + // case 106: + // break; + // default: + // break;//+more... + //} + //if (UnkUshort3 != 0) + //{ }//no hit + //if ((UnkUint2 != 0) || (UnkUint3 != 0) || (UnkUint4 != 0) || (UnkUint5 != 0)) + //{ }//no hit + //if ((UnkUshort4 != 0) && (UnkUshort4 != 1)) //1 in carbonrs.yft, policeb.yft, vader.yft + //{ }//no hit + //if ((UnkUshort5 != 2) && (UnkUshort5 != 2050)) //2050 in cablecar.yft, submersible2.yft + //{ }//no hit + ////testing! + //BuildOffsets(); } public void Write(ResourceDataWriter writer) { - writer.Write(UnkMatrix); + writer.Write(Matrix); writer.Write(UnkUint1); writer.Write(ItemID); writer.Write(UnkUshort1); @@ -840,11 +1167,11 @@ namespace CodeWalker.GameFiles writer.Write(UnkUshort3); writer.Write(UnkUint2); writer.Write(UnkUint3); - writer.Write(UnkFloat0); writer.Write(UnkFloat1); + writer.Write(UnkFloat2); writer.Write(UnkUshort4); writer.Write(UnkUshort5); - writer.Write(UnkFloat2); + writer.Write(UnkFloat3); writer.Write(UnkUint4); writer.Write(UnkUint5); writer.WriteStructs(ItemDataOffsets); @@ -857,11 +1184,112 @@ namespace CodeWalker.GameFiles } } - if (Leftovers != null) + //if (Padding != null) + //{ + // writer.Write(Padding); + //} + + } + public void WriteXml(StringBuilder sb, int indent) + { + YftXml.ValueTag(sb, indent, "ItemID", ItemID.ToString()); + YftXml.ValueTag(sb, indent, "UnkUshort1", UnkUshort1.ToString()); + YftXml.ValueTag(sb, indent, "UnkUshort2", UnkUshort2.ToString()); + YftXml.ValueTag(sb, indent, "UnkUshort4", UnkUshort4.ToString()); + YftXml.ValueTag(sb, indent, "UnkUshort5", UnkUshort5.ToString()); + YftXml.ValueTag(sb, indent, "UnkFloat1", FloatUtil.ToString(UnkFloat1)); + YftXml.ValueTag(sb, indent, "UnkFloat2", FloatUtil.ToString(UnkFloat2)); + YftXml.ValueTag(sb, indent, "UnkFloat3", FloatUtil.ToString(UnkFloat3)); + YftXml.WriteRawArray(sb, Matrix.ToArray(), indent, "Matrix", "", FloatUtil.ToString, 4); + if (ItemDatas != null) { - writer.Write(Leftovers); + YftXml.OpenTag(sb, indent, "Items"); + var cind = indent + 1; + var cind2 = cind + 1; + foreach (var item in ItemDatas) + { + YftXml.OpenTag(sb, cind, "Item"); + item.WriteXml(sb, cind2); + YftXml.CloseTag(sb, cind, "Item"); + } + YftXml.CloseTag(sb, indent, "Items"); + } + } + public void ReadXml(XmlNode node) + { + ItemID = (ushort)Xml.GetChildUIntAttribute(node, "ItemID", "value"); + UnkUshort1 = (ushort)Xml.GetChildUIntAttribute(node, "UnkUshort1", "value"); + UnkUshort2 = (ushort)Xml.GetChildUIntAttribute(node, "UnkUshort2", "value"); + UnkUshort4 = (ushort)Xml.GetChildUIntAttribute(node, "UnkUshort4", "value"); + UnkUshort5 = (ushort)Xml.GetChildUIntAttribute(node, "UnkUshort5", "value"); + UnkFloat1 = Xml.GetChildFloatAttribute(node, "UnkFloat1", "value"); + UnkFloat2 = Xml.GetChildFloatAttribute(node, "UnkFloat2", "value"); + UnkFloat3 = Xml.GetChildFloatAttribute(node, "UnkFloat3", "value"); + Matrix = Xml.GetChildMatrix(node, "Matrix"); + var dnode = node.SelectSingleNode("Items"); + if (dnode != null) + { + var ilist = new List(); + var inodes = dnode.SelectNodes("Item"); + if (inodes != null) + { + foreach (XmlNode inode in inodes) + { + var item = new ItemDataStruct(); + item.ReadXml(inode); + ilist.Add(item); + } + } + ItemDatas = ilist.ToArray(); + } + BuildOffsets(); + } + + public void BuildOffsets() + { + var o = 0u; + var offs = new List(); + //var maxlen = 0u; + //var minlen = 0xFFFFFFFFu; + if (ItemDatas != null) + { + foreach (var item in ItemDatas) + { + offs.Add((ushort)o); + o += item.TotalLength; + var dl = item.DataLength + item.Start1; + //maxlen = Math.Max(maxlen, dl); + //minlen = Math.Min(minlen, dl); + } + o += (uint)(ItemDatas.Length * 2); } + ////testing + //if ((ItemDataOffsets?.Length ?? 0) != offs.Count) + //{ } + //else + //{ + // for (int i = 0; i < offs.Count; i++) + // { + // if (ItemDataOffsets[i] != offs[i]) + // { }//no hit! + // } + //} + + ItemDataOffsets = offs.ToArray(); + + ////testing + //if (ItemDataByteLength != o) + //{ }//no hit! + ItemDataByteLength = (ushort)o; + + ItemDataCount = (ushort)(ItemDatas?.Length ?? 0); + + //if (UnkUshort1 != minlen+1) + //{ } + //if (UnkUshort2 != maxlen) + //{ } + //UnkUshort2 = (ushort)maxunk; } public override string ToString() @@ -871,54 +1299,119 @@ namespace CodeWalker.GameFiles } [TypeConverter(typeof(ExpandableObjectConverter))] public class ItemDataStruct { - public byte UnkByte0 { get; set; } - public byte UnkByte1 { get; set; } - public byte[] UnkBytes { get; set; } - public byte[] Leftovers { get; set; }//still contains some data. how to read it properly? TODO: getrid of this + public byte Start1 { get; set; } + public byte End1 { get; set; } + public byte[] Data1 { get; set; } + public byte Start2 { get; set; } + public byte End2 { get; set; } + public byte[] Data2 { get; set; } + public uint DataLength + { + get + { + uint bc = 0; + bc += (uint)(Data1?.Length ?? 0); + bc += (uint)(Data2?.Length ?? 0); + return bc; + } + } public uint TotalLength { get { uint bc = 2; - bc += (uint)(UnkBytes?.Length ?? 0); - bc += (uint)(Leftovers?.Length ?? 0); + bc += DataLength; + if (Data1 != null) bc++; + if (Start2 != 255) bc++; return bc; } } + public void Read(ResourceDataReader reader) { - UnkByte0 = reader.ReadByte();//start? - UnkByte1 = reader.ReadByte();//end? + Start1 = reader.ReadByte(); + End1 = reader.ReadByte(); - int n = (UnkByte1 - UnkByte0) + 2; + int n = (End1 - Start1) + 1; if (n > 0) { - UnkBytes = reader.ReadBytes(n); + Data1 = reader.ReadBytes(n); + Start2 = reader.ReadByte(); + + if (Start2 != 255) + { + End2 = reader.ReadByte(); + + var n2 = (End2 - Start2) + 1; + if (n2 > 0) + { + Data2 = reader.ReadBytes(n2); + } + } } - else if (n < 0) + else { } } public void Write(ResourceDataWriter writer) { - writer.Write(UnkByte0); - writer.Write(UnkByte1); + writer.Write(Start1); + writer.Write(End1); - if (UnkBytes != null) + if (Data1 != null) { - writer.Write(UnkBytes); + writer.Write(Data1); + writer.Write(Start2); + + if (Start2 != 255) + { + writer.Write(End2); + + if (Data2 != null) + { + writer.Write(Data2); + } + } } - if (Leftovers != null) + + + } + public void WriteXml(StringBuilder sb, int indent) + { + YftXml.ValueTag(sb, indent, "Start1", Start1.ToString()); + if (Data1 != null) { - writer.Write(Leftovers); + YftXml.WriteRawArray(sb, Data1, indent, "Data1", ""); + } + if (Data2 != null) + { + YftXml.ValueTag(sb, indent, "Start2", Start2.ToString()); + YftXml.WriteRawArray(sb, Data2, indent, "Data2", ""); + } + } + public void ReadXml(XmlNode node) + { + Data1 = Xml.GetChildRawByteArray(node, "Data1", 10); + Data2 = Xml.GetChildRawByteArray(node, "Data2", 10); + Start1 = (byte)Xml.GetChildUIntAttribute(node, "Start1", "value"); + End1 = (byte)(Start1 + (Data1?.Length ?? 0) - 1); + if (Data2 != null) + { + Start2 = (byte)Xml.GetChildUIntAttribute(node, "Start2", "value"); + End2 = (byte)(Start2 + (Data2?.Length ?? 0) - 1); + } + else + { + Start2 = 255; + End2 = 0; } } public override string ToString() { - return UnkByte0.ToString() + ": " + UnkByte1.ToString(); + return Start1.ToString() + ": " + End1.ToString() + ", " + Start2.ToString() + ": " + End2.ToString(); } } @@ -932,12 +1425,7 @@ namespace CodeWalker.GameFiles public uint UnkUint0 { get; set; } = 0; public ItemStruct[] Items { get; set; } - public byte[] Leftovers { get; set; } //leftover (unparsed) data, should just be padding. TODO: getrid of this! - - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -953,68 +1441,31 @@ namespace CodeWalker.GameFiles Items = new ItemStruct[ItemCount]; for (int i = 0; i < ItemCount; i++) { - var us1 = ItemOffsets[i]; - var cbrem = us1.Offset - coffset; - if (cbrem > 0) - { - var leftovers = reader.ReadBytes((int)cbrem); - if (i > 0) - { - Items[i - 1].Leftovers = leftovers; - } - else - { } - coffset += cbrem; - } - else if (cbrem < 0) - { } - var rpos = reader.Position; var u = new ItemStruct(); u.Read(reader); Items[i] = u; coffset += reader.Position - rpos; - } - var leftover = (int)(TotalLength - coffset); - if (leftover > 0) - { - Leftovers = reader.ReadBytes(leftover); - if (ItemCount > 0) + var padd = (int)(16 - (coffset % 16)) % 16; + if (padd > 0) { - Items[ItemCount - 1].Leftovers = Leftovers; - Leftovers = null;//hackity hack + u.Padding = reader.ReadBytes(padd); + coffset += padd; } - else - { } } - else if (leftover < 0) - { } + //if (Unknown_4h != 112) + //{ }//no hit + //if (UnkUint0 != 0) + //{ }//no hit - if (Unknown_4h != 112) - { } - if (UnkUint0 != 0) - { } - + //// just testing + //BuildOffsets(); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { - long bc = 16; - bc += ItemOffsets.Length*8; - foreach (var ud2 in Items) - { - bc += ud2.TotalLength; - } - bc += (uint)(Leftovers?.Length ?? 0); - - if (TotalLength != bc) - { } - TotalLength = (uint)bc; + BuildOffsets(); // write structure data writer.Write(this.Unknown_0h); @@ -1022,20 +1473,101 @@ namespace CodeWalker.GameFiles writer.Write(this.ItemCount); writer.Write(this.TotalLength); - writer.WriteStructs(ItemOffsets); writer.Write(UnkUint0); - foreach (var ud2 in Items) + long coffset = 16 + ItemOffsets.Length * 8; + + foreach (var item in Items) { - ud2.Write(writer); + var rpos = writer.Position; + + item.Write(writer); + + coffset += writer.Position - rpos; + var padd = (int)(16 - (coffset % 16)) % 16; + if (padd > 0) + { + writer.Write(new byte[padd]); + coffset += padd; + } } - if (Leftovers != null) + } + public void WriteXml(StringBuilder sb, int indent) + { + if (Items != null) { - writer.Write(Leftovers); + foreach (var item in Items) + { + YftXml.OpenTag(sb, indent, "Item"); + item.WriteXml(sb, indent + 1); + YftXml.CloseTag(sb, indent, "Item"); + } } } + public void ReadXml(XmlNode node) + { + var inodes = node.SelectNodes("Item"); + var ilist = new List(); + if (inodes != null) + { + foreach (XmlNode inode in inodes) + { + var item = new ItemStruct(); + item.ReadXml(inode); + ilist.Add(item); + } + } + Items = ilist.ToArray(); + + BuildOffsets(); + } + + + + public void BuildOffsets() + { + var offs = new List(); + var bc = 16u + (uint)ItemOffsets.Length*8u; + if (Items != null) + { + foreach (var item in Items) + { + var off = new ItemOffsetStruct(); + off.Item = item.ItemID; + off.Offset = bc; + offs.Add(off); + bc += item.TotalLength; + bc += (16 - (bc % 16)) % 16;//account for padding + } + if ((offs.Count % 2) != 0) + { + offs.Add(new ItemOffsetStruct()); + } + } + + //// just testing + //if (TotalLength != bc) + //{ } + TotalLength = bc; + + //// just testing + //if ((ItemOffsets?.Length ?? 0) != offs.Count) + //{ } + //else + //{ + // for (int i = 0; i < offs.Count; i++) + // { + // var oo = ItemOffsets[i]; + // var no = offs[i]; + // if ((no.Item != oo.Item) || (no.Offset != oo.Offset)) + // { } + // } + //} + ItemOffsets = offs.ToArray(); + + } } @@ -1048,35 +1580,28 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_04h { get; set; } // 0x00000001 - public uint Unknown_08h { get; set; } // 0x00000000 - public uint Unknown_0Ch { get; set; } // 0x00000000 + public uint Unknown_04h = 1; // 0x00000001 + public ulong Unknown_08h; // 0x0000000000000000 public ulong PhysicsLOD1Pointer { get; set; } public ulong PhysicsLOD2Pointer { get; set; } public ulong PhysicsLOD3Pointer { get; set; } - public uint Unknown_28h { get; set; } // 0x00000000 - public uint Unknown_2Ch { get; set; } // 0x00000000 + public ulong Unknown_28h; // 0x0000000000000000 // reference data public FragPhysicsLOD PhysicsLOD1 { get; set; } public FragPhysicsLOD PhysicsLOD2 { get; set; } public FragPhysicsLOD PhysicsLOD3 { get; set; } - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data this.VFT = reader.ReadUInt32(); this.Unknown_04h = reader.ReadUInt32(); - this.Unknown_08h = reader.ReadUInt32(); - this.Unknown_0Ch = reader.ReadUInt32(); + this.Unknown_08h = reader.ReadUInt64(); this.PhysicsLOD1Pointer = reader.ReadUInt64(); this.PhysicsLOD2Pointer = reader.ReadUInt64(); this.PhysicsLOD3Pointer = reader.ReadUInt64(); - this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); + this.Unknown_28h = reader.ReadUInt64(); // read reference data this.PhysicsLOD1 = reader.ReadBlockAt( @@ -1088,11 +1613,14 @@ namespace CodeWalker.GameFiles this.PhysicsLOD3 = reader.ReadBlockAt( this.PhysicsLOD3Pointer // offset ); - } - /// - /// Writes the data-block to a stream. - /// + //if (Unknown_04h != 1) + //{ }//no hit + //if (Unknown_08h != 0) + //{ }//no hit + //if (Unknown_28h != 0) + //{ }//no hit + } public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -1104,17 +1632,54 @@ namespace CodeWalker.GameFiles writer.Write(this.VFT); writer.Write(this.Unknown_04h); writer.Write(this.Unknown_08h); - writer.Write(this.Unknown_0Ch); writer.Write(this.PhysicsLOD1Pointer); writer.Write(this.PhysicsLOD2Pointer); writer.Write(this.PhysicsLOD3Pointer); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); + } + public void WriteXml(StringBuilder sb, int indent, string ddsfolder) + { + if (PhysicsLOD1 != null) + { + YftXml.OpenTag(sb, indent, "LOD1"); + PhysicsLOD1.WriteXml(sb, indent + 1, ddsfolder); + YftXml.CloseTag(sb, indent, "LOD1"); + } + if (PhysicsLOD2 != null) + { + YftXml.OpenTag(sb, indent, "LOD2"); + PhysicsLOD2.WriteXml(sb, indent + 1, ddsfolder); + YftXml.CloseTag(sb, indent, "LOD2"); + } + if (PhysicsLOD3 != null) + { + YftXml.OpenTag(sb, indent, "LOD3"); + PhysicsLOD3.WriteXml(sb, indent + 1, ddsfolder); + YftXml.CloseTag(sb, indent, "LOD3"); + } + } + public void ReadXml(XmlNode node, string ddsfolder) + { + var l1node = node.SelectSingleNode("LOD1"); + if (l1node != null) + { + PhysicsLOD1 = new FragPhysicsLOD(); + PhysicsLOD1.ReadXml(l1node, ddsfolder); + } + var l2node = node.SelectSingleNode("LOD2"); + if (l2node != null) + { + PhysicsLOD2 = new FragPhysicsLOD(); + PhysicsLOD2.ReadXml(l2node, ddsfolder); + } + var l3node = node.SelectSingleNode("LOD3"); + if (l3node != null) + { + PhysicsLOD3 = new FragPhysicsLOD(); + PhysicsLOD3.ReadXml(l3node, ddsfolder); + } } - /// - /// Returns a list of data blocks which are referenced by this block. - /// public override IResourceBlock[] GetReferences() { var list = new List(); @@ -1134,15 +1699,14 @@ namespace CodeWalker.GameFiles // structure data public uint VFT { get; set; } - public uint Unknown_04h { get; set; } // 0x00000001 - public uint Unknown_08h { get; set; } // 0x00000000 - public uint Unknown_0Ch { get; set; } // 0x00000000 - public uint Unknown_10h { get; set; } // 0x00000000 - public uint Unknown_14h { get; set; } - public uint Unknown_18h { get; set; } - public uint Unknown_1Ch { get; set; } + public uint Unknown_04h = 1; // 0x00000001 + public ulong Unknown_08h; // 0x0000000000000000 + public uint Unknown_10h; // 0x00000000 + public float Unknown_14h { get; set; } + public float Unknown_18h { get; set; } + public float Unknown_1Ch { get; set; } public ulong ArticulatedBodyTypePointer { get; set; } - public ulong Unknown_28h_Pointer { get; set; } + public ulong ChildrenUnkUintsPointer { get; set; } public Vector4 Unknown_30h { get; set; } public Vector4 Unknown_40h { get; set; } public Vector4 Unknown_50h { get; set; } @@ -1159,26 +1723,24 @@ namespace CodeWalker.GameFiles public ulong Archetype2Pointer { get; set; } public ulong BoundPointer { get; set; } public ulong InertiaTensorsPointer { get; set; } - public ulong Unknown_F8h_Pointer { get; set; } + public ulong ChildrenUnkVecsPointer { get; set; } public ulong FragTransformsPointer { get; set; } - public ulong Unknown_108h_Pointer { get; set; } - public ulong Unknown_110h_Pointer { get; set; } - public byte Count1 { get; set; } - public byte Count2 { get; set; } + public ulong UnknownData1Pointer { get; set; } + public ulong UnknownData2Pointer { get; set; } + public byte UnknownData1Count { get; set; } + public byte UnknownData2Count { get; set; } public byte GroupsCount { get; set; } public byte Unknown_11Bh { get; set; } public byte Unknown_11Ch { get; set; } public byte ChildrenCount { get; set; } - public byte Count3 { get; set; } - public byte Unknown_11Fh { get; set; } // 0x00 - public uint Unknown_120h { get; set; } // 0x00000000 - public uint Unknown_124h { get; set; } // 0x00000000 - public uint Unknown_128h { get; set; } // 0x00000000 - public uint Unknown_12Ch { get; set; } // 0x00000000 + public byte ChildrenCount2 { get; set; } + public byte Unknown_11Fh; // 0x00 + public ulong Unknown_120h; // 0x0000000000000000 + public ulong Unknown_128h; // 0x0000000000000000 // reference data public FragPhysArticulatedBodyType ArticulatedBodyType { get; set; } - public uint[] Unknown_28h_Data { get; set; } + public uint[] ChildrenUnkUints { get; set; } public ResourcePointerArray64_s GroupNames { get; set; } public ResourcePointerArray64_s Groups { get; set; } public ResourcePointerArray64 Children { get; set; } @@ -1186,35 +1748,31 @@ namespace CodeWalker.GameFiles public FragPhysArchetype Archetype2 { get; set; } public Bounds Bound { get; set; } public Vector4[] InertiaTensors { get; set; } - public Vector4[] Unknown_F8h_Data { get; set; } + public Vector4[] ChildrenUnkVecs { get; set; } public FragPhysUnknown_F_002 FragTransforms { get; set; } - public byte[] Unknown_108h_Data { get; set; } - public byte[] Unknown_110h_Data { get; set; } + public byte[] UnknownData1 { get; set; } + public byte[] UnknownData2 { get; set; } - private ResourceSystemStructBlock Unknown_28h_DataBlock = null; //used only for saving + private ResourceSystemStructBlock ChildrenUnkUintsBlock = null; //used only for saving private ResourceSystemStructBlock InertiaTensorsBlock = null; - private ResourceSystemStructBlock Unknown_F8h_DataBlock = null; - private ResourceSystemStructBlock Unknown_108h_DataBlock = null; - private ResourceSystemStructBlock Unknown_110h_DataBlock = null; + private ResourceSystemStructBlock ChildrenUnkVecsBlock = null; + private ResourceSystemStructBlock UnknownData1Block = null; + private ResourceSystemStructBlock UnknownData2Block = null; - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data this.VFT = reader.ReadUInt32(); this.Unknown_04h = reader.ReadUInt32(); - this.Unknown_08h = reader.ReadUInt32(); - this.Unknown_0Ch = reader.ReadUInt32(); + this.Unknown_08h = reader.ReadUInt64(); this.Unknown_10h = reader.ReadUInt32(); - this.Unknown_14h = reader.ReadUInt32(); - this.Unknown_18h = reader.ReadUInt32(); - this.Unknown_1Ch = reader.ReadUInt32(); + this.Unknown_14h = reader.ReadSingle(); + this.Unknown_18h = reader.ReadSingle(); + this.Unknown_1Ch = reader.ReadSingle(); this.ArticulatedBodyTypePointer = reader.ReadUInt64(); - this.Unknown_28h_Pointer = reader.ReadUInt64(); + this.ChildrenUnkUintsPointer = reader.ReadUInt64(); this.Unknown_30h = reader.ReadStruct(); this.Unknown_40h = reader.ReadStruct(); this.Unknown_50h = reader.ReadStruct(); @@ -1231,28 +1789,26 @@ namespace CodeWalker.GameFiles this.Archetype2Pointer = reader.ReadUInt64(); this.BoundPointer = reader.ReadUInt64(); this.InertiaTensorsPointer = reader.ReadUInt64(); - this.Unknown_F8h_Pointer = reader.ReadUInt64(); + this.ChildrenUnkVecsPointer = reader.ReadUInt64(); this.FragTransformsPointer = reader.ReadUInt64(); - this.Unknown_108h_Pointer = reader.ReadUInt64(); - this.Unknown_110h_Pointer = reader.ReadUInt64(); - this.Count1 = reader.ReadByte(); - this.Count2 = reader.ReadByte(); + this.UnknownData1Pointer = reader.ReadUInt64(); + this.UnknownData2Pointer = reader.ReadUInt64(); + this.UnknownData1Count = reader.ReadByte(); + this.UnknownData2Count = reader.ReadByte(); this.GroupsCount = reader.ReadByte(); this.Unknown_11Bh = reader.ReadByte(); this.Unknown_11Ch = reader.ReadByte(); this.ChildrenCount = reader.ReadByte(); - this.Count3 = reader.ReadByte(); + this.ChildrenCount2 = reader.ReadByte(); this.Unknown_11Fh = reader.ReadByte(); - this.Unknown_120h = reader.ReadUInt32(); - this.Unknown_124h = reader.ReadUInt32(); - this.Unknown_128h = reader.ReadUInt32(); - this.Unknown_12Ch = reader.ReadUInt32(); + this.Unknown_120h = reader.ReadUInt64(); + this.Unknown_128h = reader.ReadUInt64(); // read reference data this.ArticulatedBodyType = reader.ReadBlockAt( this.ArticulatedBodyTypePointer // offset ); - this.Unknown_28h_Data = reader.ReadUintsAt(this.Unknown_28h_Pointer, this.ChildrenCount); + this.ChildrenUnkUints = reader.ReadUintsAt(this.ChildrenUnkUintsPointer, this.ChildrenCount); this.GroupNames = reader.ReadBlockAt>( this.GroupNamesPointer, // offset @@ -1276,12 +1832,12 @@ namespace CodeWalker.GameFiles this.BoundPointer // offset ); this.InertiaTensors = reader.ReadStructsAt(this.InertiaTensorsPointer, this.ChildrenCount); - this.Unknown_F8h_Data = reader.ReadStructsAt(this.Unknown_F8h_Pointer, this.ChildrenCount); + this.ChildrenUnkVecs = reader.ReadStructsAt(this.ChildrenUnkVecsPointer, this.ChildrenCount); this.FragTransforms = reader.ReadBlockAt( this.FragTransformsPointer // offset ); - this.Unknown_108h_Data = reader.ReadBytesAt(this.Unknown_108h_Pointer, this.Count1); - this.Unknown_110h_Data = reader.ReadBytesAt(this.Unknown_110h_Pointer, this.Count2); + this.UnknownData1 = reader.ReadBytesAt(this.UnknownData1Pointer, this.UnknownData1Count); + this.UnknownData2 = reader.ReadBytesAt(this.UnknownData2Pointer, this.UnknownData2Count); @@ -1308,16 +1864,28 @@ namespace CodeWalker.GameFiles { Bound.Owner = this; } - } - /// - /// Writes the data-block to a stream. - /// + + //if (Unknown_04h != 1) + //{ }//no hit + //if (Unknown_08h != 0) + //{ }//no hit + //if (Unknown_10h != 0) + //{ }//no hit + //if (Unknown_11Fh != 0) + //{ }//no hit + //if (Unknown_120h != 0) + //{ }//no hit + //if (Unknown_128h != 0) + //{ }//no hit + //if (ChildrenCount2 != ChildrenCount) + //{ }//no hit + } public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data this.ArticulatedBodyTypePointer = (ulong)(this.ArticulatedBodyType != null ? this.ArticulatedBodyType.FilePosition : 0); - this.Unknown_28h_Pointer = (ulong)(this.Unknown_28h_DataBlock != null ? this.Unknown_28h_DataBlock.FilePosition : 0); + this.ChildrenUnkUintsPointer = (ulong)(this.ChildrenUnkUintsBlock != null ? this.ChildrenUnkUintsBlock.FilePosition : 0); this.GroupNamesPointer = (ulong)(this.GroupNames != null ? this.GroupNames.FilePosition : 0); this.GroupsPointer = (ulong)(this.Groups != null ? this.Groups.FilePosition : 0); this.ChildrenPointer = (ulong)(this.Children != null ? this.Children.FilePosition : 0); @@ -1325,28 +1893,28 @@ namespace CodeWalker.GameFiles this.Archetype2Pointer = (ulong)(this.Archetype2 != null ? this.Archetype2.FilePosition : 0); this.BoundPointer = (ulong)(this.Bound != null ? this.Bound.FilePosition : 0); this.InertiaTensorsPointer = (ulong)(this.InertiaTensorsBlock != null ? this.InertiaTensorsBlock.FilePosition : 0); - this.Unknown_F8h_Pointer = (ulong)(this.Unknown_F8h_DataBlock != null ? this.Unknown_F8h_DataBlock.FilePosition : 0); + this.ChildrenUnkVecsPointer = (ulong)(this.ChildrenUnkVecsBlock != null ? this.ChildrenUnkVecsBlock.FilePosition : 0); this.FragTransformsPointer = (ulong)(this.FragTransforms != null ? this.FragTransforms.FilePosition : 0); - this.Unknown_108h_Pointer = (ulong)(this.Unknown_108h_DataBlock != null ? this.Unknown_108h_DataBlock.FilePosition : 0); - this.Unknown_110h_Pointer = (ulong)(this.Unknown_110h_DataBlock != null ? this.Unknown_110h_DataBlock.FilePosition : 0); + this.UnknownData1Pointer = (ulong)(this.UnknownData1Block != null ? this.UnknownData1Block.FilePosition : 0); + this.UnknownData2Pointer = (ulong)(this.UnknownData2Block != null ? this.UnknownData2Block.FilePosition : 0); - this.Count1 = (byte)(this.Unknown_108h_DataBlock != null ? this.Unknown_108h_DataBlock.ItemCount : 0); - this.Count2 = (byte)(this.Unknown_110h_DataBlock != null ? this.Unknown_110h_DataBlock.ItemCount : 0); + this.UnknownData1Count = (byte)(this.UnknownData1Block != null ? this.UnknownData1Block.ItemCount : 0); + this.UnknownData2Count = (byte)(this.UnknownData2Block != null ? this.UnknownData2Block.ItemCount : 0); this.GroupsCount = (byte)(this.Groups != null ? this.Groups.Count : 0); this.ChildrenCount = (byte)(this.Children != null ? this.Children.Count : 0); + this.ChildrenCount2 = this.ChildrenCount; // write structure data writer.Write(this.VFT); writer.Write(this.Unknown_04h); writer.Write(this.Unknown_08h); - writer.Write(this.Unknown_0Ch); writer.Write(this.Unknown_10h); writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); writer.Write(this.ArticulatedBodyTypePointer); - writer.Write(this.Unknown_28h_Pointer); + writer.Write(this.ChildrenUnkUintsPointer); writer.Write(this.Unknown_30h); writer.Write(this.Unknown_40h); writer.Write(this.Unknown_50h); @@ -1363,35 +1931,37 @@ namespace CodeWalker.GameFiles writer.Write(this.Archetype2Pointer); writer.Write(this.BoundPointer); writer.Write(this.InertiaTensorsPointer); - writer.Write(this.Unknown_F8h_Pointer); + writer.Write(this.ChildrenUnkVecsPointer); writer.Write(this.FragTransformsPointer); - writer.Write(this.Unknown_108h_Pointer); - writer.Write(this.Unknown_110h_Pointer); - writer.Write(this.Count1); - writer.Write(this.Count2); + writer.Write(this.UnknownData1Pointer); + writer.Write(this.UnknownData2Pointer); + writer.Write(this.UnknownData1Count); + writer.Write(this.UnknownData2Count); writer.Write(this.GroupsCount); writer.Write(this.Unknown_11Bh); writer.Write(this.Unknown_11Ch); writer.Write(this.ChildrenCount); - writer.Write(this.Count3); + writer.Write(this.ChildrenCount2); writer.Write(this.Unknown_11Fh); writer.Write(this.Unknown_120h); - writer.Write(this.Unknown_124h); writer.Write(this.Unknown_128h); - writer.Write(this.Unknown_12Ch); + } + public void WriteXml(StringBuilder sb, int indent, string ddsfolder) + { + } + public void ReadXml(XmlNode node, string ddsfolder) + { } - /// - /// Returns a list of data blocks which are referenced by this block. - /// + public override IResourceBlock[] GetReferences() { var list = new List(); if (ArticulatedBodyType != null) list.Add(ArticulatedBodyType); - if (Unknown_28h_Data != null) + if (ChildrenUnkUints != null) { - Unknown_28h_DataBlock = new ResourceSystemStructBlock(Unknown_28h_Data); - list.Add(Unknown_28h_DataBlock); + ChildrenUnkUintsBlock = new ResourceSystemStructBlock(ChildrenUnkUints); + list.Add(ChildrenUnkUintsBlock); } if (Groups != null) list.Add(Groups); if (Children != null) list.Add(Children); @@ -1403,21 +1973,21 @@ namespace CodeWalker.GameFiles InertiaTensorsBlock = new ResourceSystemStructBlock(InertiaTensors); list.Add(InertiaTensorsBlock); } - if (Unknown_F8h_Data != null) + if (ChildrenUnkVecs != null) { - Unknown_F8h_DataBlock = new ResourceSystemStructBlock(Unknown_F8h_Data); - list.Add(Unknown_F8h_DataBlock); + ChildrenUnkVecsBlock = new ResourceSystemStructBlock(ChildrenUnkVecs); + list.Add(ChildrenUnkVecsBlock); } if (FragTransforms != null) list.Add(FragTransforms); - if (Unknown_108h_Data != null) + if (UnknownData1 != null) { - Unknown_108h_DataBlock = new ResourceSystemStructBlock(Unknown_108h_Data); - list.Add(Unknown_108h_DataBlock); + UnknownData1Block = new ResourceSystemStructBlock(UnknownData1); + list.Add(UnknownData1Block); } - if (Unknown_110h_Data != null) + if (UnknownData2 != null) { - Unknown_110h_DataBlock = new ResourceSystemStructBlock(Unknown_110h_Data); - list.Add(Unknown_110h_DataBlock); + UnknownData2Block = new ResourceSystemStructBlock(UnknownData2); + list.Add(UnknownData2Block); } if (GroupNames != null) list.Add(GroupNames); return list.ToArray(); @@ -1486,9 +2056,6 @@ namespace CodeWalker.GameFiles private ResourceSystemStructBlock UnknownDataBlock = null;//only used for saving - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -1545,10 +2112,6 @@ namespace CodeWalker.GameFiles this.UnknownData = reader.ReadStructsAt(this.UnknownPointer, this.UnknownCount); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -1603,10 +2166,13 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_A8h); writer.Write(this.Unknown_ACh); } + public void WriteXml(StringBuilder sb, int indent) + { + } + public void ReadXml(XmlNode node) + { + } - /// - /// Returns a list of data blocks which are referenced by this block. - /// public override IResourceBlock[] GetReferences() { var list = new List(); @@ -1638,9 +2204,6 @@ namespace CodeWalker.GameFiles public uint Unknown_18h { get; set; } // 0x00000000 public uint Unknown_1Ch { get; set; } // 0x00000000 - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -1655,10 +2218,6 @@ namespace CodeWalker.GameFiles this.Unknown_18h = reader.ReadUInt32(); this.Unknown_1Ch = reader.ReadUInt32(); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // write structure data @@ -1673,6 +2232,12 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); } + public virtual void WriteXml(StringBuilder sb, int indent) + { + } + public virtual void ReadXml(XmlNode node) + { + } public IResourceSystemBlock GetType(ResourceDataReader reader, params object[] parameters) { @@ -1733,9 +2298,6 @@ namespace CodeWalker.GameFiles public uint Unknown_A8h { get; set; } // 0x4CBEBC20 (float: 1.0E8) public uint Unknown_ACh { get; set; } // 0xCCBEBC20 (float:-1.0E8) - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { base.Read(reader, parameters); @@ -1778,10 +2340,6 @@ namespace CodeWalker.GameFiles this.Unknown_A8h = reader.ReadUInt32(); this.Unknown_ACh = reader.ReadUInt32(); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { base.Write(writer, parameters); @@ -1824,6 +2382,12 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_A8h); writer.Write(this.Unknown_ACh); } + public override void WriteXml(StringBuilder sb, int indent) + { + } + public override void ReadXml(XmlNode node) + { + } } [TypeConverter(typeof(ExpandableObjectConverter))] public class FragPhysJoint3DofType : FragPhysJointType { @@ -1886,9 +2450,6 @@ namespace CodeWalker.GameFiles public uint Unknown_E8h { get; set; } // 0x00000000 public uint Unknown_ECh { get; set; } // 0x00000000 - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { base.Read(reader, parameters); @@ -1947,10 +2508,6 @@ namespace CodeWalker.GameFiles this.Unknown_E8h = reader.ReadUInt32(); this.Unknown_ECh = reader.ReadUInt32(); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { base.Write(writer, parameters); @@ -2009,6 +2566,12 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_E8h); writer.Write(this.Unknown_ECh); } + public override void WriteXml(StringBuilder sb, int indent) + { + } + public override void ReadXml(XmlNode node) + { + } } [TypeConverter(typeof(ExpandableObjectConverter))] public class FragPhysUnknown_F_002 : ResourceSystemBlock @@ -2029,9 +2592,6 @@ namespace CodeWalker.GameFiles public uint Unknown_1Ch { get; set; } // 0x00000000 public Matrix[] Data { get; set; } - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -2046,10 +2606,6 @@ namespace CodeWalker.GameFiles this.Data = reader.ReadStructsAt((ulong)reader.Position, DataCount); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { DataCount = (uint)(Data?.Length ?? 0); @@ -2065,7 +2621,12 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_1Ch); writer.WriteStructs(Data); } - + public void WriteXml(StringBuilder sb, int indent) + { + } + public void ReadXml(XmlNode node) + { + } } [TypeConverter(typeof(ExpandableObjectConverter))] public class FragPhysArchetype : ResourceSystemBlock @@ -2115,9 +2676,6 @@ namespace CodeWalker.GameFiles private string_r NameBlock = null;//used only when saving - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -2165,10 +2723,6 @@ namespace CodeWalker.GameFiles Bound.Owner = this; } } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -2207,10 +2761,13 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_C0h); writer.Write(this.Unknown_D0h); } + public void WriteXml(StringBuilder sb, int indent) + { + } + public void ReadXml(XmlNode node) + { + } - /// - /// Returns a list of data blocks which are referenced by this block. - /// public override IResourceBlock[] GetReferences() { var list = new List(); @@ -2306,9 +2863,6 @@ namespace CodeWalker.GameFiles public int OwnerFragPhysIndex { get; set; } public MetaHash GroupNameHash { get; set; } - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -2396,10 +2950,6 @@ namespace CodeWalker.GameFiles } } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -2471,10 +3021,13 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_F8h); writer.Write(this.Unknown_FCh); } + public void WriteXml(StringBuilder sb, int indent, string ddsfolder) + { + } + public void ReadXml(XmlNode node, string ddsfolder) + { + } - /// - /// Returns a list of data blocks which are referenced by this block. - /// public override IResourceBlock[] GetReferences() { var list = new List(); @@ -2511,9 +3064,6 @@ namespace CodeWalker.GameFiles public uint Unknown_28h { get; set; } // 0x00000000 public uint Unknown_2Ch { get; set; } // 0x00000000 - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { // read structure data @@ -2530,10 +3080,6 @@ namespace CodeWalker.GameFiles this.Unknown_28h = reader.ReadUInt32(); this.Unknown_2Ch = reader.ReadUInt32(); } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { // write structure data @@ -2550,9 +3096,15 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_28h); writer.Write(this.Unknown_2Ch); } + public void WriteXml(StringBuilder sb, int indent) + { + } + public void ReadXml(XmlNode node) + { + } } - [TypeConverter(typeof(ExpandableObjectConverter))] public struct FragPhysTypeGroup_s + [TypeConverter(typeof(ExpandableObjectConverter))] public struct FragPhysTypeGroup_s : IMetaXmlItem { // structure data public float Unknown_00h { get; set; } // 0x00000000 @@ -2598,6 +3150,14 @@ namespace CodeWalker.GameFiles public float Unknown_A8h { get; set; } public float Unknown_ACh { get; set; } // 0x00000000 + + public void WriteXml(StringBuilder sb, int indent) + { + } + public void ReadXml(XmlNode node) + { + } + public override string ToString() { return Name.ToString(); diff --git a/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs b/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs index af05315..4a9823f 100644 --- a/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs +++ b/CodeWalker.Core/GameFiles/Resources/ResourceBaseTypes.cs @@ -140,6 +140,28 @@ namespace CodeWalker.GameFiles //public float Unknown_22 { get; set; } //public float Unknown_23 { get; set; } //public float Unknown_24 { get; set; } + + + public Matrix3_s(float[] a) + { + if ((a != null) && (a.Length == 12)) + { + Row1 = new Vector4(a[0], a[1], a[2], a[3]); + Row2 = new Vector4(a[4], a[5], a[6], a[7]); + Row3 = new Vector4(a[8], a[9], a[10], a[11]); + } + else + { + Row1 = new Vector4(1, 0, 0, 0); + Row2 = new Vector4(0, 1, 0, 0); + Row3 = new Vector4(0, 0, 1, 0); + } + } + public float[] ToArray() + { + return new[] { Row1.X, Row1.Y, Row1.Z, Row1.W, Row2.X, Row2.Y, Row2.Z, Row2.W, Row3.X, Row3.Y, Row3.Z, Row3.W }; + } + } [TypeConverter(typeof(ExpandableObjectConverter))] public struct AABB_s diff --git a/CodeWalker.Core/GameFiles/Resources/Texture.cs b/CodeWalker.Core/GameFiles/Resources/Texture.cs index cbe63e3..fc96e07 100644 --- a/CodeWalker.Core/GameFiles/Resources/Texture.cs +++ b/CodeWalker.Core/GameFiles/Resources/Texture.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -506,9 +507,16 @@ namespace CodeWalker.GameFiles try { - var filepath = System.IO.Path.Combine(ddsfolder, (Name ?? "null") + ".dds"); - var dds = DDSIO.GetDDSFile(this); - System.IO.File.WriteAllBytes(filepath, dds); + if (!string.IsNullOrEmpty(ddsfolder)) + { + if (!Directory.Exists(ddsfolder)) + { + Directory.CreateDirectory(ddsfolder); + } + var filepath = Path.Combine(ddsfolder, (Name ?? "null") + ".dds"); + var dds = DDSIO.GetDDSFile(this); + File.WriteAllBytes(filepath, dds); + } } catch { } } @@ -526,10 +534,10 @@ namespace CodeWalker.GameFiles try { - var filepath = System.IO.Path.Combine(ddsfolder, filename); - if (System.IO.File.Exists(filepath)) + var filepath = Path.Combine(ddsfolder, filename); + if (File.Exists(filepath)) { - var dds = System.IO.File.ReadAllBytes(filepath); + var dds = File.ReadAllBytes(filepath); var tex = DDSIO.GetTexture(dds); if (tex != null) { diff --git a/CodeWalker.Core/GameFiles/Resources/VertexType.cs b/CodeWalker.Core/GameFiles/Resources/VertexType.cs index 1fc25ee..d154bab 100644 --- a/CodeWalker.Core/GameFiles/Resources/VertexType.cs +++ b/CodeWalker.Core/GameFiles/Resources/VertexType.cs @@ -74,6 +74,7 @@ namespace CodeWalker.GameFiles GTAV1 = 0x7755555555996996, // GTAV - used by most drawables GTAV2 = 0x030000000199A006, // GTAV - used on cloth? GTAV3 = 0x0300000001996006, // GTAV - used on cloth? + GTAV4 = 0x7655555555996996, // GTAV - used by FragGlassWindow //Types4 = 0x0000000007097007, // Max Payne 3 //Types5 = 0x0700000007097977, // Max Payne 3 diff --git a/CodeWalker.Core/Utils/FbxConverter.cs b/CodeWalker.Core/Utils/FbxConverter.cs index 8b361d4..376c59e 100644 --- a/CodeWalker.Core/Utils/FbxConverter.cs +++ b/CodeWalker.Core/Utils/FbxConverter.cs @@ -708,7 +708,6 @@ namespace CodeWalker shader.Unknown_24h = 0; shader.Unknown_26h = 0; shader.Unknown_28h = 0; - shader.Unknown_2Ch = 0; switch (spsName) diff --git a/CodeWalker.Core/Utils/Xml.cs b/CodeWalker.Core/Utils/Xml.cs index 566c4cf..75e4af9 100644 --- a/CodeWalker.Core/Utils/Xml.cs +++ b/CodeWalker.Core/Utils/Xml.cs @@ -41,6 +41,14 @@ namespace CodeWalker uint.TryParse(val, out i); return i; } + public static ulong GetULongAttribute(XmlNode node, string attribute) + { + if (node == null) return 0; + string val = node.Attributes[attribute]?.InnerText; + ulong i; + ulong.TryParse(val, out i); + return i; + } public static float GetFloatAttribute(XmlNode node, string attribute) { if (node == null) return 0; @@ -199,7 +207,7 @@ namespace CodeWalker - public static byte[] GetRawByteArray(XmlNode node) + public static byte[] GetRawByteArray(XmlNode node, int fromBase = 16) { if (node == null) return new byte[0]; var data = new List(); @@ -210,16 +218,16 @@ namespace CodeWalker { var str = split[i]; if (string.IsNullOrEmpty(str)) continue; - var val = Convert.ToByte(str, 16); + var val = Convert.ToByte(str, fromBase); data.Add(val); } } return data.ToArray(); } - public static byte[] GetChildRawByteArray(XmlNode node, string name) + public static byte[] GetChildRawByteArray(XmlNode node, string name, int fromBase = 16) { var cnode = node.SelectSingleNode(name); - return GetRawByteArray(cnode); + return GetRawByteArray(cnode, fromBase); } public static ushort[] GetRawUshortArray(XmlNode node) @@ -450,6 +458,18 @@ namespace CodeWalker return GetRawVector4Array(cnode); } + public static Matrix GetMatrix(XmlNode node) + { + if (node == null) return Matrix.Identity; + var arr = GetRawFloatArray(node); + if ((arr == null) || (arr.Length != 16)) return Matrix.Identity; + return new Matrix(arr); + } + public static Matrix GetChildMatrix(XmlNode node, string name) + { + var cnode = node.SelectSingleNode(name); + return GetMatrix(cnode); + } } }