대충 이런 느낌?

This commit is contained in:
ikpil 2023-03-16 01:12:03 +09:00
parent 704d1558de
commit be1a4915ec
2 changed files with 117 additions and 113 deletions

View File

@ -16,24 +16,26 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
using System.Numerics;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Demo.UI; using DotRecast.Recast.Demo.UI;
using ImGuiNET;
using Silk.NET.Windowing; using Silk.NET.Windowing;
namespace DotRecast.Recast.Demo.Settings; namespace DotRecast.Recast.Demo.Settings;
public class RcSettingsView : IRcView { public class RcSettingsView : IRcView
{
private float cellSize = 0.3f;
private float cellHeight = 0.2f;
private readonly float[] cellSize = new[] { 0.3f }; private float agentHeight = 2.0f;
private readonly float[] cellHeight = new[] { 0.2f }; private float agentRadius = 0.6f;
private float agentMaxClimb = 0.9f;
private float agentMaxSlope = 45f;
private readonly float[] agentHeight = new[] { 2f }; private int minRegionSize = 8;
private readonly float[] agentRadius = new[] { 0.6f }; private int mergedRegionSize = 20;
private readonly float[] agentMaxClimb = new[] { 0.9f };
private readonly float[] agentMaxSlope = new[] { 45f };
private readonly int[] minRegionSize = new[] { 8 };
private readonly int[] mergedRegionSize = new[] { 20 };
private PartitionType partitioning = PartitionType.WATERSHED; private PartitionType partitioning = PartitionType.WATERSHED;
@ -65,68 +67,44 @@ public class RcSettingsView : IRcView {
private bool meshInputTrigerred; private bool meshInputTrigerred;
private bool navMeshInputTrigerred; private bool navMeshInputTrigerred;
public bool render(IWindow i, int x, int y, int width, int height, int mouseX, int mouseY) { public bool render(IWindow i, int x, int y, int width, int height, int mouseX, int mouseY)
{
ImGui.Begin("Properties");
renderInternal(i, x, y, width, height, mouseX, mouseY);
ImGui.End();
return true;
}
public bool renderInternal(IWindow i, int x, int y, int width, int height, int mouseX, int mouseY)
{
bool mouseInside = false; bool mouseInside = false;
// nk_rgb(255, 255, 255, white); ImGui.Text("Input Mesh");
// nk_rgba(0, 0, 0, 192, background); ImGui.Separator();
// nk_rgba(255, 0, 0, 0, transparent); ImGui.Button("Load Source Geom...");
// try (MemoryStack stack = stackPush()) { ImGui.Text($"Verts: {voxels[0]} Tris: {voxels[1]}");
// ctx.style().text().color().set(white); ImGui.NewLine();
// ctx.style().option().text_normal().set(white);
// ctx.style().property().label_normal().set(white); ImGui.Text("Rasterization");
// ctx.style().window().background().set(background); ImGui.Separator();
// NkStyleItem styleItem = NkStyleItem.mallocStack(stack);
// nk_style_item_color(background, styleItem); ImGui.SliderFloat("Cell Size", ref cellSize, 0.01f, 1f, $"{cellSize}");
// ctx.style().window().fixed_background().set(styleItem); ImGui.SliderFloat("Cell Height", ref cellHeight, 0.01f, 1f, $"{cellHeight}");
// nk_style_item_color(white, styleItem); ImGui.Text($"Voxels {voxels[0]} x {voxels[1]}");
// ctx.style().option().cursor_hover().set(styleItem); ImGui.NewLine();
// ctx.style().option().cursor_normal().set(styleItem);
// nk_style_item_color(transparent, styleItem); ImGui.Text("Agent");
// ctx.style().tab().node_minimize_button().normal().set(styleItem); ImGui.Separator();
// ctx.style().tab().node_minimize_button().active().set(styleItem); ImGui.SliderFloat("Height", ref agentHeight, 5f, 0.1f, $"{agentHeight}");
// ctx.style().tab().node_maximize_button().normal().set(styleItem); ImGui.SliderFloat("Radius", ref agentRadius, 5f, 0.1f, $"{agentRadius}");
// ctx.style().tab().node_maximize_button().active().set(styleItem); ImGui.SliderFloat("Max Climb", ref agentMaxClimb, 5f, 0.1f, $"{agentMaxClimb}");
// } ImGui.SliderFloat("Max Slope", ref agentMaxSlope, 90f, 1f, $"{agentMaxSlope}");
// try (MemoryStack stack = stackPush()) { ImGui.NewLine();
// NkRect rect = NkRect.mallocStack(stack);
// if (nk_begin(ctx, "Properties", nk_rect(width - 255, 5, 250, height - 10, rect), ImGui.Text("Region");
// NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_TITLE)) { ImGui.Separator();
// ImGui.SliderInt("Min Region Size", ref minRegionSize, 1, 150);
// nk_layout_row_dynamic(ctx, 18, 1); ImGui.SliderInt("Merged Region Size", ref mergedRegionSize, 1, 150);
// nk_label(ctx, "Input Mesh", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1);
// meshInputTrigerred = nk_button_text(ctx, "Load Source Geom...");
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, string.format("Verts: %d Tris: %d", 0, 0), NK_TEXT_ALIGN_RIGHT);
//
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Rasterization", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Cell Size", 0.1f, cellSize, 1f, 0.01f, 0.01f);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Cell Height", 0.1f, cellHeight, 1f, 0.01f, 0.01f);
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, string.format("Voxels %d x %d", voxels[0], voxels[1]), NK_TEXT_ALIGN_RIGHT);
//
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Agent", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Height", 0.1f, agentHeight, 5f, 0.1f, 0.1f);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Radius", 0.0f, agentRadius, 5f, 0.1f, 0.1f);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Climb", 0.1f, agentMaxClimb, 5f, 0.1f, 0.1f);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_float(ctx, "Max Slope", 0f, agentMaxSlope, 90f, 1f, 1f);
//
// nk_layout_row_dynamic(ctx, 3, 1);
// nk_spacing(ctx, 1);
// nk_layout_row_dynamic(ctx, 18, 1);
// nk_label(ctx, "Region", NK_TEXT_ALIGN_LEFT);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_int(ctx, "Min Region Size", 0, minRegionSize, 150, 1, 1f);
// nk_layout_row_dynamic(ctx, 20, 1);
// nk_property_int(ctx, "Merged Region Size", 0, mergedRegionSize, 150, 1, 1f);
// //
// nk_layout_row_dynamic(ctx, 3, 1); // nk_layout_row_dynamic(ctx, 3, 1);
// nk_spacing(ctx, 1); // nk_spacing(ctx, 1);
@ -208,118 +186,145 @@ public class RcSettingsView : IRcView {
return mouseInside; return mouseInside;
} }
public float getCellSize() { public float getCellSize()
return cellSize[0]; {
return cellSize;
} }
public float getCellHeight() { public float getCellHeight()
return cellHeight[0]; {
return cellHeight;
} }
public float getAgentHeight() { public float getAgentHeight()
return agentHeight[0]; {
return agentHeight;
} }
public float getAgentRadius() { public float getAgentRadius()
return agentRadius[0]; {
return agentRadius;
} }
public float getAgentMaxClimb() { public float getAgentMaxClimb()
return agentMaxClimb[0]; {
return agentMaxClimb;
} }
public float getAgentMaxSlope() { public float getAgentMaxSlope()
return agentMaxSlope[0]; {
return agentMaxSlope;
} }
public int getMinRegionSize() { public int getMinRegionSize()
return minRegionSize[0]; {
return minRegionSize;
} }
public int getMergedRegionSize() { public int getMergedRegionSize()
return mergedRegionSize[0]; {
return mergedRegionSize;
} }
public PartitionType getPartitioning() { public PartitionType getPartitioning()
{
return partitioning; return partitioning;
} }
public bool isBuildTriggered() { public bool isBuildTriggered()
{
return buildTriggered; return buildTriggered;
} }
public bool isFilterLowHangingObstacles() { public bool isFilterLowHangingObstacles()
{
return filterLowHangingObstacles; return filterLowHangingObstacles;
} }
public bool isFilterLedgeSpans() { public bool isFilterLedgeSpans()
{
return filterLedgeSpans; return filterLedgeSpans;
} }
public bool isFilterWalkableLowHeightSpans() { public bool isFilterWalkableLowHeightSpans()
{
return filterWalkableLowHeightSpans; return filterWalkableLowHeightSpans;
} }
public void setBuildTime(long buildTime) { public void setBuildTime(long buildTime)
{
this.buildTime = buildTime; this.buildTime = buildTime;
} }
public DrawMode getDrawMode() { public DrawMode getDrawMode()
{
return drawMode; return drawMode;
} }
public float getEdgeMaxLen() { public float getEdgeMaxLen()
{
return edgeMaxLen[0]; return edgeMaxLen[0];
} }
public float getEdgeMaxError() { public float getEdgeMaxError()
{
return edgeMaxError[0]; return edgeMaxError[0];
} }
public int getVertsPerPoly() { public int getVertsPerPoly()
{
return vertsPerPoly[0]; return vertsPerPoly[0];
} }
public float getDetailSampleDist() { public float getDetailSampleDist()
{
return detailSampleDist[0]; return detailSampleDist[0];
} }
public float getDetailSampleMaxError() { public float getDetailSampleMaxError()
{
return detailSampleMaxError[0]; return detailSampleMaxError[0];
} }
public void setVoxels(int[] voxels) { public void setVoxels(int[] voxels)
{
this.voxels[0] = voxels[0]; this.voxels[0] = voxels[0];
this.voxels[1] = voxels[1]; this.voxels[1] = voxels[1];
} }
public bool isTiled() { public bool isTiled()
{
return tiled; return tiled;
} }
public int getTileSize() { public int getTileSize()
{
return tileSize[0]; return tileSize[0];
} }
public void setTiles(int[] tiles) { public void setTiles(int[] tiles)
{
this.tiles[0] = tiles[0]; this.tiles[0] = tiles[0];
this.tiles[1] = tiles[1]; this.tiles[1] = tiles[1];
} }
public void setMaxTiles(int maxTiles) { public void setMaxTiles(int maxTiles)
{
this.maxTiles = maxTiles; this.maxTiles = maxTiles;
} }
public void setMaxPolys(int maxPolys) { public void setMaxPolys(int maxPolys)
{
this.maxPolys = maxPolys; this.maxPolys = maxPolys;
} }
public bool isMeshInputTrigerred() { public bool isMeshInputTrigerred()
{
return meshInputTrigerred; return meshInputTrigerred;
} }
public bool isNavMeshInputTrigerred() { public bool isNavMeshInputTrigerred()
{
return navMeshInputTrigerred; return navMeshInputTrigerred;
} }
} }

View File

@ -141,7 +141,6 @@ public class RcViewSystem {
} }
public bool render(IWindow ctx, int x, int y, int width, int height, int mouseX, int mouseY) { public bool render(IWindow ctx, int x, int y, int width, int height, int mouseX, int mouseY) {
ImGui.ShowDemoWindow();
mouseOverUI = false; mouseOverUI = false;
foreach (IRcView m in _views) { foreach (IRcView m in _views) {
mouseOverUI = m.render(ctx, x, y, width, height, mouseX, mouseY) | mouseOverUI; mouseOverUI = m.render(ctx, x, y, width, height, mouseX, mouseY) | mouseOverUI;