From 13449c81d1d3f9f03030a2ac69066bc871ca7949 Mon Sep 17 00:00:00 2001 From: dexyfex Date: Mon, 3 Dec 2018 19:39:42 +1100 Subject: [PATCH] GenerateNavMeshPanel WIP --- .../Panels/EditYmapEntityPanel.Designer.cs | 30 ++--- Project/Panels/GenerateNavMeshPanel.cs | 122 +++++++++++++++--- 2 files changed, 116 insertions(+), 36 deletions(-) diff --git a/Project/Panels/EditYmapEntityPanel.Designer.cs b/Project/Panels/EditYmapEntityPanel.Designer.cs index f33c0e7..d12ebea 100644 --- a/Project/Panels/EditYmapEntityPanel.Designer.cs +++ b/Project/Panels/EditYmapEntityPanel.Designer.cs @@ -71,6 +71,7 @@ this.EntityNumChildrenTextBox = new System.Windows.Forms.TextBox(); this.label25 = new System.Windows.Forms.Label(); this.EntityExtensionsTabPage = new System.Windows.Forms.TabPage(); + this.label1 = new System.Windows.Forms.Label(); this.EntityPivotTabPage = new System.Windows.Forms.TabPage(); this.label95 = new System.Windows.Forms.Label(); this.EntityPivotEditCheckBox = new System.Windows.Forms.CheckBox(); @@ -79,7 +80,6 @@ this.EntityPivotRotationNormalizeButton = new System.Windows.Forms.Button(); this.label94 = new System.Windows.Forms.Label(); this.EntityPivotRotationTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); this.EntityTabControl.SuspendLayout(); this.EntityGeneralTabPage.SuspendLayout(); this.EntityLodTabPage.SuspendLayout(); @@ -153,12 +153,12 @@ this.EntityFlagsCheckedListBox.CheckOnClick = true; this.EntityFlagsCheckedListBox.FormattingEnabled = true; this.EntityFlagsCheckedListBox.Items.AddRange(new object[] { - "1 - Unk01", + "1 - Allow full rotation", "2 - Unk02", "4 - Unk03", "8 - Unk04", "16 - Unk05", - "32 - Unk06", + "32 - Static entity", "64 - Unk07", "128 - Unk08", "256 - Unk09", @@ -178,11 +178,11 @@ "4194304 - Unk23", "8388608 - Unk24", "16777216 - Unk25", - "33554432 - Unk26", + "33554432 - Interior proxy", "67108864 - Unk27", - "134217728 - Unk28", + "134217728 - Reflection proxy", "268435456 - Unk29", - "536870912 - Unk30", + "536870912 - Mirror proxy", "1073741824 - Unk31", "2147483648 - Unk32"}); this.EntityFlagsCheckedListBox.Location = new System.Drawing.Point(348, 113); @@ -575,6 +575,15 @@ this.EntityExtensionsTabPage.Text = "Extensions"; this.EntityExtensionsTabPage.UseVisualStyleBackColor = true; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(27, 27); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(157, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Entity extensions editing TODO!"; + // // EntityPivotTabPage // this.EntityPivotTabPage.Controls.Add(this.label95); @@ -660,15 +669,6 @@ this.EntityPivotRotationTextBox.TabIndex = 25; this.EntityPivotRotationTextBox.TextChanged += new System.EventHandler(this.EntityPivotRotationTextBox_TextChanged); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(27, 27); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(157, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Entity extensions editing TODO!"; - // // EditYmapEntityPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/Project/Panels/GenerateNavMeshPanel.cs b/Project/Panels/GenerateNavMeshPanel.cs index b140713..2745394 100644 --- a/Project/Panels/GenerateNavMeshPanel.cs +++ b/Project/Panels/GenerateNavMeshPanel.cs @@ -325,7 +325,8 @@ namespace CodeWalker.Project.Panels private List CornersB = new List(); private List CornersT = new List(); - + private List VerticesB = new List(); + private List VerticesT = new List(); public void BeginGrid(int vertexCountX, int vertexCountY) { @@ -529,6 +530,7 @@ namespace CodeWalker.Project.Panels + { //if (dnx > 0) //can move along +X //{ // AssignVertices(ref vplane, plthresh, i, dnx, dny, dpy, 2, poly); @@ -553,7 +555,7 @@ namespace CodeWalker.Project.Panels //{ // polys.Add(poly); //} - + } @@ -705,15 +707,6 @@ namespace CodeWalker.Project.Panels { int pid = poly.Index; int qi = i; - //int maxdnx = Math.Min(dnx, 40); - //int maxdpy = 50;// dpy;// - //int maxdny = 50;// dny;// - //int cdpy = dpy; - //int cdny = dny; - //int vertexCountP = 0; - //int vertexCountN = 0; - //int lastqx = 0; - //int lastqi = i; CornersB.Clear(); CornersT.Clear(); @@ -745,8 +738,8 @@ namespace CodeWalker.Project.Panels int ony = 0; int ldyb = 0; int ldyt = 0; - int corndxb = 0; - int corndxt = 0; + //int corndxb = 0; + //int corndxt = 0; for (int x = 0; x < 50; x++) { @@ -833,8 +826,8 @@ namespace CodeWalker.Project.Panels int nextsyb = nextyb - ony - dyb; int nextsyt = nextyt + ony - dyt; - corndxb++; - corndxt++; + //corndxb++; + //corndxt++; bool iscornerb = false; @@ -869,7 +862,7 @@ namespace CodeWalker.Project.Panels if (nextsyb > syb) nextsyb = syb; } - + if (iscornerb) { } @@ -891,6 +884,93 @@ namespace CodeWalker.Project.Panels } + private void AssignVertices3(ref Plane vpl, float plt, int i, int dir, GenPoly poly) + { + int pid = poly.Index; + int qi = i; + CornersB.Clear(); + CornersT.Clear(); + VerticesB.Clear(); + VerticesT.Clear(); + + + int dirpy, dirny, dirpx; + switch (dir) //lookup perpendicular directions + { + default: + case 0: dirpy = 3; dirny = 1; dirpx = 2; break; + case 1: dirpy = 0; dirny = 2; dirpx = 3; break; + case 2: dirpy = 1; dirny = 3; dirpx = 0; break; + case 3: dirpy = 2; dirny = 0; dirpx = 1; break; + } + + int ti = i; + while (CanPolyIncludeNext(ref vpl, plt, ti, dirpx, out ti)) + { + qi = ti; //make sure to start at the leftmost point... + } + + + //find the bottom and top leftmost points to start the first col, and fill the col + int qib = qi; + int qit = qi; + int dyb = 0; + int dyt = 0; + while (CanPolyIncludeNext(ref vpl, plt, qib, dirpy, out ti)) + { + Vertices[ti].PolyID = pid; + qib = ti; + dyb++; + } + while (CanPolyIncludeNext(ref vpl, plt, qit, dirny, out ti)) + { + Vertices[ti].PolyID = pid; + qit = ti; + dyt++; + } + int dy = dyb + dyt; //total distance between bottom and top + + CornersB.Add(qib); + CornersT.Add(qit); + + + + //find bottom and top slopes + float slopeb = FindSlope(ref vpl, plt, qib, dir, dirpy, dirny, dyb > 0 ? dyb : 100); + float slopet = FindSlope(ref vpl, plt, qit, dir, dirny, dirpy, dyt > 0 ? dyt : 100); + int syob = MaxOffsetFromSlope(slopeb); + int syot = MaxOffsetFromSlope(slopet); + + //find the next bottom and top indexes, step by the max offset + int nqib = qib; + int nqit = qit; + int ndyb = 0; + int ndyt = 0; + + + + + } + + + + private int FindNextID(ref Plane vpl, float plt, int i, int dirnx, int dirny, int dirpy, float slope, out int dx, out int dy) + { + //find the next vertex along the slope in the given direction + + int ti = i; + int qi = i; + + bool cgx = CanPolyIncludeNext(ref vpl, plt, i, dirnx, out ti); + + + + + dx = 0; + dy = 0; + return i; + } + private int MaxOffsetFromSlope(float s) { @@ -916,6 +996,11 @@ namespace CodeWalker.Project.Panels } private bool CanPolyIncludeNext(ref Plane vplane, float plthresh, int i, int dir, out int ni) { + if ((i < 0) || (i >= Vertices.Length)) + { + ni = -1; + return false; + } bool ct; switch (dir) { @@ -1005,14 +1090,9 @@ namespace CodeWalker.Project.Panels int ti = i; int qi = i; float slope = maxslope; - //int diry = (maxslope > 0) ? dirny : dirpy; - //int incy = (maxslope > 0) ? 1 : -1; - int sy = (int)Math.Abs(slope); - bool cgx = CanPolyIncludeNext(ref vpl, plt, i, dirnx, out ti); - if (cgx && (slope >= 0)) //new slope should be >=0 { int dy0 = FindPolyEdgeDist(ref vpl, plt, qi, dirny);