From 273a9dbaea74abc0ca1aa8e76288eb9bf0bf3256 Mon Sep 17 00:00:00 2001 From: Carmine Date: Thu, 4 Jan 2018 00:17:43 +0100 Subject: [PATCH 1/4] Drawable: more field names --- GameFiles/Resources/Drawable.cs | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/GameFiles/Resources/Drawable.cs b/GameFiles/Resources/Drawable.cs index a1b0768..f4f68ad 100644 --- a/GameFiles/Resources/Drawable.cs +++ b/GameFiles/Resources/Drawable.cs @@ -1031,7 +1031,7 @@ namespace CodeWalker.GameFiles public ushort GeometriesCount1 { get; set; } public ushort GeometriesCount2 { get; set; } public uint Unknown_14h { get; set; } // 0x00000000 - public ulong Unknown_18h_Pointer { get; set; } + public ulong BoundsPointer { get; set; } public ulong ShaderMappingPointer { get; set; } public uint Unknown_28h { get; set; } public uint Unknown_2Ch { get; set; } @@ -1040,7 +1040,7 @@ namespace CodeWalker.GameFiles public ResourcePointerArray64 Geometries { get; set; } //public ResourceSimpleArray Unknown_18h_Data; //public ResourceSimpleArray ShaderMapping; - public AABB_s[] Unknown_18h_Data { get; set; } + public AABB_s[] BoundsData { get; set; } public ushort[] ShaderMapping { get; set; } public long MemoryUsage @@ -1074,9 +1074,9 @@ namespace CodeWalker.GameFiles } } } - if (Unknown_18h_Data != null) + if (BoundsData != null) { - val += Unknown_18h_Data.Length * 32; + val += BoundsData.Length * 32; } return val; } @@ -1094,7 +1094,7 @@ namespace CodeWalker.GameFiles this.GeometriesCount1 = reader.ReadUInt16(); this.GeometriesCount2 = reader.ReadUInt16(); this.Unknown_14h = reader.ReadUInt32(); - this.Unknown_18h_Pointer = reader.ReadUInt64(); + this.BoundsPointer = reader.ReadUInt64(); this.ShaderMappingPointer = reader.ReadUInt64(); this.Unknown_28h = reader.ReadUInt32(); this.Unknown_2Ch = reader.ReadUInt32(); @@ -1112,7 +1112,7 @@ namespace CodeWalker.GameFiles // this.ShaderMappingPointer, // offset // this.GeometriesCount1 //); - this.Unknown_18h_Data = reader.ReadStructsAt(this.Unknown_18h_Pointer, (uint)(this.GeometriesCount1 > 1 ? this.GeometriesCount1 + 1 : this.GeometriesCount1)); + this.BoundsData = reader.ReadStructsAt(this.BoundsPointer, (uint)(this.GeometriesCount1 > 1 ? this.GeometriesCount1 + 1 : this.GeometriesCount1)); this.ShaderMapping = reader.ReadUshortsAt(this.ShaderMappingPointer, this.GeometriesCount1); } @@ -1136,7 +1136,7 @@ namespace CodeWalker.GameFiles writer.Write(this.GeometriesCount1); writer.Write(this.GeometriesCount2); writer.Write(this.Unknown_14h); - writer.Write(this.Unknown_18h_Pointer); + writer.Write(this.BoundsPointer); writer.Write(this.ShaderMappingPointer); writer.Write(this.Unknown_28h); writer.Write(this.Unknown_2Ch); @@ -1189,7 +1189,7 @@ namespace CodeWalker.GameFiles public uint Unknown_50h { get; set; } // 0x00000000 public uint Unknown_54h { get; set; } // 0x00000000 public uint IndicesCount { get; set; } - public uint Unknown_5Ch { get; set; } + public uint TrianglesCount { get; set; } public ushort VerticesCount { get; set; } public ushort Unknown_62h { get; set; } // 0x0003 public uint Unknown_64h { get; set; } // 0x00000000 @@ -1239,7 +1239,7 @@ namespace CodeWalker.GameFiles this.Unknown_50h = reader.ReadUInt32(); this.Unknown_54h = reader.ReadUInt32(); this.IndicesCount = reader.ReadUInt32(); - this.Unknown_5Ch = reader.ReadUInt32(); + this.TrianglesCount = reader.ReadUInt32(); this.VerticesCount = reader.ReadUInt16(); this.Unknown_62h = reader.ReadUInt16(); this.Unknown_64h = reader.ReadUInt32(); @@ -1333,7 +1333,7 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_50h); writer.Write(this.Unknown_54h); writer.Write(this.IndicesCount); - writer.Write(this.Unknown_5Ch); + writer.Write(this.TrianglesCount); writer.Write(this.VerticesCount); writer.Write(this.Unknown_62h); writer.Write(this.Unknown_64h); @@ -2099,10 +2099,10 @@ namespace CodeWalker.GameFiles public ulong DrawableModelsMediumPointer { get; set; } public ulong DrawableModelsLowPointer { get; set; } public ulong DrawableModelsVeryLowPointer { get; set; } - public float Unknown_70h { get; set; } - public float Unknown_74h { get; set; } - public float Unknown_78h { get; set; } - public float Unknown_7Ch { get; set; } + public float LodGroupHigh { get; set; } + public float LodGroupMed { get; set; } + public float LodGroupLow { get; set; } + public float LodGroupVlow { get; set; } public uint Unknown_80h { get; set; } public uint Unknown_84h { get; set; } public uint Unknown_88h { get; set; } @@ -2169,10 +2169,10 @@ namespace CodeWalker.GameFiles this.DrawableModelsMediumPointer = reader.ReadUInt64(); this.DrawableModelsLowPointer = reader.ReadUInt64(); this.DrawableModelsVeryLowPointer = reader.ReadUInt64(); - this.Unknown_70h = reader.ReadSingle(); - this.Unknown_74h = reader.ReadSingle(); - this.Unknown_78h = reader.ReadSingle(); - this.Unknown_7Ch = reader.ReadSingle(); + this.LodGroupHigh = reader.ReadSingle(); + this.LodGroupMed = reader.ReadSingle(); + this.LodGroupLow = reader.ReadSingle(); + this.LodGroupVlow = reader.ReadSingle(); this.Unknown_80h = reader.ReadUInt32(); this.Unknown_84h = reader.ReadUInt32(); this.Unknown_88h = reader.ReadUInt32(); @@ -2307,10 +2307,10 @@ namespace CodeWalker.GameFiles writer.Write(this.DrawableModelsMediumPointer); writer.Write(this.DrawableModelsLowPointer); writer.Write(this.DrawableModelsVeryLowPointer); - writer.Write(this.Unknown_70h); - writer.Write(this.Unknown_74h); - writer.Write(this.Unknown_78h); - writer.Write(this.Unknown_7Ch); + writer.Write(this.LodGroupHigh); + writer.Write(this.LodGroupMed); + writer.Write(this.LodGroupLow); + writer.Write(this.LodGroupVlow); writer.Write(this.Unknown_80h); writer.Write(this.Unknown_84h); writer.Write(this.Unknown_88h); From 4f87bf5d982a7698eba2c8ea57b6fb0f0e0a14d6 Mon Sep 17 00:00:00 2001 From: Carmine Date: Thu, 4 Jan 2018 00:55:10 +0100 Subject: [PATCH 2/4] LightAttribute: Changed two names --- GameFiles/Resources/Drawable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GameFiles/Resources/Drawable.cs b/GameFiles/Resources/Drawable.cs index f4f68ad..6255b4f 100644 --- a/GameFiles/Resources/Drawable.cs +++ b/GameFiles/Resources/Drawable.cs @@ -2034,10 +2034,10 @@ namespace CodeWalker.GameFiles public byte ColorB { get; set; } public byte Unknown_1Bh { get; set; } public float Intensity { get; set; } - public uint Unknown_20h { get; set; } + public uint Flags { get; set; } public ushort BoneId { get; set; } public ushort Type { get; set; } - public uint Unknown_28h { get; set; } + public uint TimeFlags { get; set; } public float Falloff { get; set; } public float FalloffExponent { get; set; } public float CullingPlaneNormalX { get; set; } From b6cbcb6ea75eb99e6f687cf981bdf513f6f163db Mon Sep 17 00:00:00 2001 From: Carmine Date: Thu, 4 Jan 2018 10:35:38 +0100 Subject: [PATCH 3/4] DrawableModel: replaced more names --- GameFiles/FileTypes/GtxdFile.cs | 4 ++-- GameFiles/Resources/Drawable.cs | 15 ++++++++++++--- Rendering/Renderable.cs | 6 +++--- WorldForm.cs | 6 +++--- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/GameFiles/FileTypes/GtxdFile.cs b/GameFiles/FileTypes/GtxdFile.cs index f3260cc..e0ee813 100644 --- a/GameFiles/FileTypes/GtxdFile.cs +++ b/GameFiles/FileTypes/GtxdFile.cs @@ -135,8 +135,8 @@ namespace CodeWalker.GameFiles private void LoadMapParentTxds(string xml) { XmlDocument xmldoc = new XmlDocument(); - xmldoc.LoadXml(xml); - XmlNodeList items = xmldoc.SelectNodes("CMapParentTxds/txdRelationships/Item"); + xmldoc.LoadXml(xml); //maybe better load xml.ToLower() and use "cmapparenttxds/txdrelationships/item" as xpath? + XmlNodeList items = xmldoc.SelectNodes("CMapParentTxds/txdRelationships/Item | CMapParentTxds/txdRelationships/item"); CMapParentTxds = new Dictionary(); for (int i = 0; i < items.Count; i++) diff --git a/GameFiles/Resources/Drawable.cs b/GameFiles/Resources/Drawable.cs index 6255b4f..50693c0 100644 --- a/GameFiles/Resources/Drawable.cs +++ b/GameFiles/Resources/Drawable.cs @@ -1034,7 +1034,10 @@ namespace CodeWalker.GameFiles public ulong BoundsPointer { get; set; } public ulong ShaderMappingPointer { get; set; } public uint Unknown_28h { get; set; } - public uint Unknown_2Ch { get; set; } + public byte Mask { get; set; } + public byte Unknown_2Dh { get; set; } + public byte Unknown_2Eh { get; set; } //ShaderMappingCount ?? + public byte Unknown_2Fh { get; set; } // reference data public ResourcePointerArray64 Geometries { get; set; } @@ -1097,7 +1100,10 @@ namespace CodeWalker.GameFiles this.BoundsPointer = reader.ReadUInt64(); this.ShaderMappingPointer = reader.ReadUInt64(); this.Unknown_28h = reader.ReadUInt32(); - this.Unknown_2Ch = reader.ReadUInt32(); + this.Mask = reader.ReadByte(); + this.Unknown_2Dh = reader.ReadByte(); + this.Unknown_2Eh = reader.ReadByte(); + this.Unknown_2Fh = reader.ReadByte(); // read reference data this.Geometries = reader.ReadBlockAt>( @@ -1139,7 +1145,10 @@ namespace CodeWalker.GameFiles writer.Write(this.BoundsPointer); writer.Write(this.ShaderMappingPointer); writer.Write(this.Unknown_28h); - writer.Write(this.Unknown_2Ch); + writer.Write(this.Mask); + writer.Write(this.Unknown_2Dh); + writer.Write(this.Unknown_2Eh); + writer.Write(this.Unknown_2Fh); } /// diff --git a/Rendering/Renderable.cs b/Rendering/Renderable.cs index e7af2ac..68c046d 100644 --- a/Rendering/Renderable.cs +++ b/Rendering/Renderable.cs @@ -282,7 +282,7 @@ namespace CodeWalker.Rendering Unk4h = dmodel.Unknown_4h; Unk14h = dmodel.Unknown_14h; Unk28h = dmodel.Unknown_28h; - Unk2Ch = dmodel.Unknown_2Ch; + Unk2Ch = dmodel.Mask; DrawableModel = dmodel; @@ -300,9 +300,9 @@ namespace CodeWalker.Rendering Geometries[i] = rgeom; GeometrySize += rgeom.TotalDataSize; - if ((dmodel.Unknown_18h_Data != null) && (i < dmodel.Unknown_18h_Data.Length)) + if ((dmodel.BoundsData != null) && (i < dmodel.BoundsData.Length)) { - GeometryBounds[i] = dmodel.Unknown_18h_Data[i]; + GeometryBounds[i] = dmodel.BoundsData[i]; } else { diff --git a/WorldForm.cs b/WorldForm.cs index 81c0bd0..d2e00b0 100644 --- a/WorldForm.cs +++ b/WorldForm.cs @@ -2130,7 +2130,7 @@ namespace CodeWalker for (int i = 0; i < dmodels.data_items.Length; i++) { var m = dmodels.data_items[i]; - if (m.Unknown_18h_Data == null) + if (m.BoundsData == null) { usegeomboxes = false; break; } } } @@ -2152,10 +2152,10 @@ namespace CodeWalker for (int i = 0; i < dmodels.data_items.Length; i++) { var m = dmodels.data_items[i]; - int gbbcount = m.Unknown_18h_Data.Length; + int gbbcount = m.BoundsData.Length; for (int j = 0; j < gbbcount; j++) //first box seems to be whole model { - var gbox = m.Unknown_18h_Data[j]; + var gbox = m.BoundsData[j]; gbbox.Minimum = gbox.Min.XYZ(); gbbox.Maximum = gbox.Max.XYZ(); bbox.Minimum = gbbox.Minimum * scale; From e12fbc674351b7184c8b6ed20141838b57cd74bd Mon Sep 17 00:00:00 2001 From: Carmine Date: Thu, 4 Jan 2018 18:01:18 +0100 Subject: [PATCH 4/4] Reverted Unknown_2Ch in DrawableModel, added the info as comment --- GameFiles/Resources/Drawable.cs | 15 +++------------ Rendering/Renderable.cs | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/GameFiles/Resources/Drawable.cs b/GameFiles/Resources/Drawable.cs index 50693c0..089b290 100644 --- a/GameFiles/Resources/Drawable.cs +++ b/GameFiles/Resources/Drawable.cs @@ -1034,10 +1034,7 @@ namespace CodeWalker.GameFiles public ulong BoundsPointer { get; set; } public ulong ShaderMappingPointer { get; set; } public uint Unknown_28h { get; set; } - public byte Mask { get; set; } - public byte Unknown_2Dh { get; set; } - public byte Unknown_2Eh { get; set; } //ShaderMappingCount ?? - public byte Unknown_2Fh { get; set; } + public uint Unknown_2Ch { get; set; } //First byte is called "Mask" in GIMS EVO, third byte is always equal to GeometriesCount, is it ShaderMappingCount? // reference data public ResourcePointerArray64 Geometries { get; set; } @@ -1100,10 +1097,7 @@ namespace CodeWalker.GameFiles this.BoundsPointer = reader.ReadUInt64(); this.ShaderMappingPointer = reader.ReadUInt64(); this.Unknown_28h = reader.ReadUInt32(); - this.Mask = reader.ReadByte(); - this.Unknown_2Dh = reader.ReadByte(); - this.Unknown_2Eh = reader.ReadByte(); - this.Unknown_2Fh = reader.ReadByte(); + this.Unknown_2Ch = reader.ReadUInt32(); // read reference data this.Geometries = reader.ReadBlockAt>( @@ -1145,10 +1139,7 @@ namespace CodeWalker.GameFiles writer.Write(this.BoundsPointer); writer.Write(this.ShaderMappingPointer); writer.Write(this.Unknown_28h); - writer.Write(this.Mask); - writer.Write(this.Unknown_2Dh); - writer.Write(this.Unknown_2Eh); - writer.Write(this.Unknown_2Fh); + writer.Write(this.Unknown_2Ch); } /// diff --git a/Rendering/Renderable.cs b/Rendering/Renderable.cs index 68c046d..e002c22 100644 --- a/Rendering/Renderable.cs +++ b/Rendering/Renderable.cs @@ -282,7 +282,7 @@ namespace CodeWalker.Rendering Unk4h = dmodel.Unknown_4h; Unk14h = dmodel.Unknown_14h; Unk28h = dmodel.Unknown_28h; - Unk2Ch = dmodel.Mask; + Unk2Ch = dmodel.Unknown_2Ch; //only the first byte of Unknown_2Ch seems be related to this DrawableModel = dmodel;