From f27672d6ad4e5aab5dc60dfde4365b6524ca9ee2 Mon Sep 17 00:00:00 2001 From: Carmine Date: Sat, 11 Aug 2018 17:58:52 +0200 Subject: [PATCH 1/5] Added checkbox to disable rendering of drawables --- Rendering/Renderer.cs | 59 +++++++++++++++++++++++-------------------- WorldForm.Designer.cs | 26 +++++++++++++++---- WorldForm.cs | 5 ++++ 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/Rendering/Renderer.cs b/Rendering/Renderer.cs index aa74391..31e957f 100644 --- a/Rendering/Renderer.cs +++ b/Rendering/Renderer.cs @@ -98,7 +98,7 @@ namespace CodeWalker.Rendering public bool renderinteriors = true; public bool renderproxies = false; public bool renderchildents = false;//when rendering single ymap, render root only or not... - + public bool renderentities = true; public bool rendergrass = true; public bool renderdistlodlights = true; @@ -1537,41 +1537,44 @@ namespace CodeWalker.Rendering //if an entity is not fully loaded, set a flag for its parent, then traverse to root //until found an entity that is fully loaded. //on a second loop, build a final render list based on the flags. - - for (int i = 0; i < renderworldentities.Count; i++) + if(renderentities) { - var ent = renderworldentities[i]; - var arch = ent.Archetype; - var pent = ent.Parent; - var drawable = gameFileCache.TryGetDrawable(arch); - Renderable rndbl = TryGetRenderable(arch, drawable); - if ((rndbl != null) && rndbl.IsLoaded && (rndbl.AllTexturesLoaded || !waitforchildrentoload)) + + for (int i = 0; i < renderworldentities.Count; i++) { - RenderableEntity rent = new RenderableEntity(); - rent.Entity = ent; - rent.Renderable = rndbl; - renderworldrenderables.Add(rent); - } - else if (waitforchildrentoload) - { - //todo: render parent if children loading....... + var ent = renderworldentities[i]; + var arch = ent.Archetype; + var pent = ent.Parent; + var drawable = gameFileCache.TryGetDrawable(arch); + Renderable rndbl = TryGetRenderable(arch, drawable); + if ((rndbl != null) && rndbl.IsLoaded && (rndbl.AllTexturesLoaded || !waitforchildrentoload)) + { + RenderableEntity rent = new RenderableEntity(); + rent.Entity = ent; + rent.Renderable = rndbl; + renderworldrenderables.Add(rent); + } + else if (waitforchildrentoload) + { + //todo: render parent if children loading....... + } + + if (ent.IsMlo && rendercollisionmeshes && renderinteriors) + { + RenderInteriorCollisionMesh(ent); + } } - if (ent.IsMlo && rendercollisionmeshes && renderinteriors) + for (int i = 0; i < renderworldrenderables.Count; i++) { - RenderInteriorCollisionMesh(ent); + var rent = renderworldrenderables[i]; + var ent = rent.Entity; + var arch = ent.Archetype; + + RenderArchetype(arch, ent, rent.Renderable, false); } } - for (int i = 0; i < renderworldrenderables.Count; i++) - { - var rent = renderworldrenderables[i]; - var ent = rent.Entity; - var arch = ent.Archetype; - - RenderArchetype(arch, ent, rent.Renderable, false); - } - if (rendergrass) diff --git a/WorldForm.Designer.cs b/WorldForm.Designer.cs index f50fd73..11532c9 100644 --- a/WorldForm.Designer.cs +++ b/WorldForm.Designer.cs @@ -109,6 +109,7 @@ namespace CodeWalker this.tabPage4 = new System.Windows.Forms.TabPage(); this.OptionsTabControl = new System.Windows.Forms.TabControl(); this.tabPage8 = new System.Windows.Forms.TabPage(); + this.RenderEntitiesCheckBox = new System.Windows.Forms.CheckBox(); this.AdvancedSettingsButton = new System.Windows.Forms.Button(); this.ControlSettingsButton = new System.Windows.Forms.Button(); this.MapViewDetailLabel = new System.Windows.Forms.Label(); @@ -1295,6 +1296,7 @@ namespace CodeWalker // // tabPage8 // + this.tabPage8.Controls.Add(this.RenderEntitiesCheckBox); this.tabPage8.Controls.Add(this.AdvancedSettingsButton); this.tabPage8.Controls.Add(this.ControlSettingsButton); this.tabPage8.Controls.Add(this.MapViewDetailLabel); @@ -1327,6 +1329,19 @@ namespace CodeWalker this.tabPage8.Text = "General"; this.tabPage8.UseVisualStyleBackColor = true; // + // EntitiesCheckBox + // + this.RenderEntitiesCheckBox.AutoSize = true; + this.RenderEntitiesCheckBox.Checked = true; + this.RenderEntitiesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.RenderEntitiesCheckBox.Location = new System.Drawing.Point(10, 32); + this.RenderEntitiesCheckBox.Name = "EntitiesCheckBox"; + this.RenderEntitiesCheckBox.Size = new System.Drawing.Size(89, 17); + this.RenderEntitiesCheckBox.TabIndex = 67; + this.RenderEntitiesCheckBox.Text = "Show entities"; + this.RenderEntitiesCheckBox.UseVisualStyleBackColor = true; + this.RenderEntitiesCheckBox.CheckedChanged += new System.EventHandler(this.RenderEntitiesCheckBox_CheckedChanged); + // // AdvancedSettingsButton // this.AdvancedSettingsButton.Location = new System.Drawing.Point(101, 456); @@ -1411,7 +1426,7 @@ namespace CodeWalker this.WaterQuadsCheckBox.AutoSize = true; this.WaterQuadsCheckBox.Checked = true; this.WaterQuadsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.WaterQuadsCheckBox.Location = new System.Drawing.Point(10, 104); + this.WaterQuadsCheckBox.Location = new System.Drawing.Point(10, 129); this.WaterQuadsCheckBox.Name = "WaterQuadsCheckBox"; this.WaterQuadsCheckBox.Size = new System.Drawing.Size(114, 17); this.WaterQuadsCheckBox.TabIndex = 39; @@ -1440,7 +1455,7 @@ namespace CodeWalker // TimedEntitiesAlwaysOnCheckBox // this.TimedEntitiesAlwaysOnCheckBox.AutoSize = true; - this.TimedEntitiesAlwaysOnCheckBox.Location = new System.Drawing.Point(131, 58); + this.TimedEntitiesAlwaysOnCheckBox.Location = new System.Drawing.Point(131, 83); this.TimedEntitiesAlwaysOnCheckBox.Name = "TimedEntitiesAlwaysOnCheckBox"; this.TimedEntitiesAlwaysOnCheckBox.Size = new System.Drawing.Size(58, 17); this.TimedEntitiesAlwaysOnCheckBox.TabIndex = 37; @@ -1453,7 +1468,7 @@ namespace CodeWalker this.GrassCheckBox.AutoSize = true; this.GrassCheckBox.Checked = true; this.GrassCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.GrassCheckBox.Location = new System.Drawing.Point(10, 35); + this.GrassCheckBox.Location = new System.Drawing.Point(10, 57); this.GrassCheckBox.Name = "GrassCheckBox"; this.GrassCheckBox.Size = new System.Drawing.Size(81, 17); this.GrassCheckBox.TabIndex = 35; @@ -1466,7 +1481,7 @@ namespace CodeWalker this.InteriorsCheckBox.AutoSize = true; this.InteriorsCheckBox.Checked = true; this.InteriorsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.InteriorsCheckBox.Location = new System.Drawing.Point(10, 81); + this.InteriorsCheckBox.Location = new System.Drawing.Point(10, 106); this.InteriorsCheckBox.Name = "InteriorsCheckBox"; this.InteriorsCheckBox.Size = new System.Drawing.Size(92, 17); this.InteriorsCheckBox.TabIndex = 38; @@ -1586,7 +1601,7 @@ namespace CodeWalker this.TimedEntitiesCheckBox.AutoSize = true; this.TimedEntitiesCheckBox.Checked = true; this.TimedEntitiesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.TimedEntitiesCheckBox.Location = new System.Drawing.Point(10, 58); + this.TimedEntitiesCheckBox.Location = new System.Drawing.Point(10, 83); this.TimedEntitiesCheckBox.Name = "TimedEntitiesCheckBox"; this.TimedEntitiesCheckBox.Size = new System.Drawing.Size(117, 17); this.TimedEntitiesCheckBox.TabIndex = 36; @@ -3581,5 +3596,6 @@ namespace CodeWalker private System.Windows.Forms.ToolStripMenuItem ToolbarSnapToGroundGridButton; private System.Windows.Forms.NumericUpDown SnapGridSizeUpDown; private System.Windows.Forms.Label label26; + private System.Windows.Forms.CheckBox RenderEntitiesCheckBox; } } \ No newline at end of file diff --git a/WorldForm.cs b/WorldForm.cs index c39cf6f..f1ccbe8 100644 --- a/WorldForm.cs +++ b/WorldForm.cs @@ -7553,6 +7553,11 @@ namespace CodeWalker { SnapGridSize = (float)SnapGridSizeUpDown.Value; } + + private void RenderEntitiesCheckBox_CheckedChanged(object sender, EventArgs e) + { + Renderer.renderentities = RenderEntitiesCheckBox.Checked; + } } From 8caee271f7cfb87652a64b137cf9086d408e4a83 Mon Sep 17 00:00:00 2001 From: Carmine Date: Sat, 11 Aug 2018 18:13:52 +0200 Subject: [PATCH 2/5] Renamed some fields in Bone --- .../GameFiles/Resources/Drawable.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index f229e0b..bc74416 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -718,16 +718,16 @@ namespace CodeWalker.GameFiles //public float TranslationX { get; set; } //public float TranslationY { get; set; } //public float TranslationZ { get; set; } - public uint Unknown_1Ch { get; set; } // 0x00000000 - public float Unknown_20h { get; set; } // 1.0 - public float Unknown_24h { get; set; } // 1.0 - public float Unknown_28h { get; set; } // 1.0 - public float Unknown_2Ch { get; set; } // 1.0 - public ushort Unknown_30h { get; set; } //limb end index? IK chain? + public uint Unknown_1Ch { get; set; } // 0x00000000 RHW? + public float ScaleX { get; set; } // 1.0 + public float ScaleY { get; set; } // 1.0 + public float ScaleZ { get; set; } // 1.0 + public float Unknown_2Ch { get; set; } // 1.0 RHW? + public ushort NextSiblingIndex { get; set; } //limb end index? IK chain? public short ParentIndex { get; set; } public uint Unknown_34h { get; set; } // 0x00000000 public ulong NamePointer { get; set; } - public ushort Unknown_40h { get; set; } + public ushort Flags { get; set; } public ushort Unknown_42h { get; set; } public ushort Id { get; set; } public ushort Unknown_46h { get; set; } @@ -756,15 +756,15 @@ namespace CodeWalker.GameFiles //this.TranslationY = reader.ReadSingle(); //this.TranslationZ = reader.ReadSingle(); this.Unknown_1Ch = reader.ReadUInt32(); - this.Unknown_20h = reader.ReadSingle(); - this.Unknown_24h = reader.ReadSingle(); - this.Unknown_28h = reader.ReadSingle(); + this.ScaleX = reader.ReadSingle(); + this.ScaleY = reader.ReadSingle(); + this.ScaleZ = reader.ReadSingle(); this.Unknown_2Ch = reader.ReadSingle(); - this.Unknown_30h = reader.ReadUInt16(); + this.NextSiblingIndex = reader.ReadUInt16(); this.ParentIndex = reader.ReadInt16(); this.Unknown_34h = reader.ReadUInt32(); this.NamePointer = reader.ReadUInt64(); - this.Unknown_40h = reader.ReadUInt16(); + this.Flags = reader.ReadUInt16(); this.Unknown_42h = reader.ReadUInt16(); this.Id = reader.ReadUInt16(); this.Unknown_46h = reader.ReadUInt16(); @@ -796,15 +796,15 @@ namespace CodeWalker.GameFiles //writer.Write(this.TranslationY); //writer.Write(this.TranslationZ); writer.Write(this.Unknown_1Ch); - writer.Write(this.Unknown_20h); - writer.Write(this.Unknown_24h); - writer.Write(this.Unknown_28h); + writer.Write(this.ScaleX); + writer.Write(this.ScaleY); + writer.Write(this.ScaleZ); writer.Write(this.Unknown_2Ch); - writer.Write(this.Unknown_30h); + writer.Write(this.NextSiblingIndex); writer.Write(this.ParentIndex); writer.Write(this.Unknown_34h); writer.Write(this.NamePointer); - writer.Write(this.Unknown_40h); + writer.Write(this.Flags); writer.Write(this.Unknown_42h); writer.Write(this.Id); writer.Write(this.Unknown_46h); From 1b94cd4f047c021f1b8b41f5b7df3b51c404e7da Mon Sep 17 00:00:00 2001 From: Carmine Date: Sat, 11 Aug 2018 18:15:23 +0200 Subject: [PATCH 3/5] Renamed Min and Max limits in JointRotationLimit_s --- CodeWalker.Core/GameFiles/Resources/Drawable.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index bc74416..d9c7c7a 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -968,12 +968,12 @@ namespace CodeWalker.GameFiles public float Unknown_50h { get; set; } // -pi public float Unknown_54h { get; set; } // pi public float Unknown_58h { get; set; } // 1.0 - public float Unknown_5Ch { get; set; } - public float Unknown_60h { get; set; } - public float Unknown_64h { get; set; } - public float Unknown_68h { get; set; } - public float Unknown_6Ch { get; set; } - public float Unknown_70h { get; set; } + public float MinX { get; set; } + public float MinY { get; set; } + public float MinZ { get; set; } + public float MaxX { get; set; } + public float MaxY { get; set; } + public float MaxZ { get; set; } public float Unknown_74h { get; set; } // pi public float Unknown_78h { get; set; } // -pi public float Unknown_7Ch { get; set; } // pi From aec2426d7b21fae8e2067c14a4a1badca63da6fb Mon Sep 17 00:00:00 2001 From: Carmine Date: Sun, 12 Aug 2018 18:04:34 +0200 Subject: [PATCH 4/5] Moved renderentities check --- Rendering/Renderer.cs | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Rendering/Renderer.cs b/Rendering/Renderer.cs index 31e957f..7abd0cb 100644 --- a/Rendering/Renderer.cs +++ b/Rendering/Renderer.cs @@ -1537,34 +1537,34 @@ namespace CodeWalker.Rendering //if an entity is not fully loaded, set a flag for its parent, then traverse to root //until found an entity that is fully loaded. //on a second loop, build a final render list based on the flags. - if(renderentities) + + for (int i = 0; i < renderworldentities.Count; i++) { - - for (int i = 0; i < renderworldentities.Count; i++) + var ent = renderworldentities[i]; + var arch = ent.Archetype; + var pent = ent.Parent; + var drawable = gameFileCache.TryGetDrawable(arch); + Renderable rndbl = TryGetRenderable(arch, drawable); + if ((rndbl != null) && rndbl.IsLoaded && (rndbl.AllTexturesLoaded || !waitforchildrentoload)) { - var ent = renderworldentities[i]; - var arch = ent.Archetype; - var pent = ent.Parent; - var drawable = gameFileCache.TryGetDrawable(arch); - Renderable rndbl = TryGetRenderable(arch, drawable); - if ((rndbl != null) && rndbl.IsLoaded && (rndbl.AllTexturesLoaded || !waitforchildrentoload)) - { - RenderableEntity rent = new RenderableEntity(); - rent.Entity = ent; - rent.Renderable = rndbl; - renderworldrenderables.Add(rent); - } - else if (waitforchildrentoload) - { - //todo: render parent if children loading....... - } - - if (ent.IsMlo && rendercollisionmeshes && renderinteriors) - { - RenderInteriorCollisionMesh(ent); - } + RenderableEntity rent = new RenderableEntity(); + rent.Entity = ent; + rent.Renderable = rndbl; + renderworldrenderables.Add(rent); + } + else if (waitforchildrentoload) + { + //todo: render parent if children loading....... } + if (ent.IsMlo && rendercollisionmeshes && renderinteriors) + { + RenderInteriorCollisionMesh(ent); + } + } + + if(renderentities) + { for (int i = 0; i < renderworldrenderables.Count; i++) { var rent = renderworldrenderables[i]; From b3069321e1c8e4506ae02a03651fa7216ef1c532 Mon Sep 17 00:00:00 2001 From: Carmine Date: Tue, 14 Aug 2018 12:15:52 +0200 Subject: [PATCH 5/5] Replaced floats with Vector3 for JointRotationLimit_s Min and Max --- CodeWalker.Core/GameFiles/Resources/Drawable.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index d9c7c7a..72acf0b 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -968,12 +968,8 @@ namespace CodeWalker.GameFiles public float Unknown_50h { get; set; } // -pi public float Unknown_54h { get; set; } // pi public float Unknown_58h { get; set; } // 1.0 - public float MinX { get; set; } - public float MinY { get; set; } - public float MinZ { get; set; } - public float MaxX { get; set; } - public float MaxY { get; set; } - public float MaxZ { get; set; } + public Vector3 Min { get; set; } + public Vector3 Max { get; set; } public float Unknown_74h { get; set; } // pi public float Unknown_78h { get; set; } // -pi public float Unknown_7Ch { get; set; } // pi