forked from bit/DotRecastNetSim
Preparing for integration as ViewSystem
This commit is contained in:
parent
85e74dad92
commit
540845cff3
|
@ -49,13 +49,13 @@ public class NavMeshRenderer {
|
|||
DemoInputGeomProvider geom = sample.getInputGeom();
|
||||
IList<RecastBuilderResult> rcBuilderResults = sample.getRecastResults();
|
||||
NavMesh navMesh = sample.getNavMesh();
|
||||
SettingsUI settingsUI = sample.getSettingsUI();
|
||||
RcSettingsView rcSettingsView = sample.getSettingsUI();
|
||||
debugDraw.fog(true);
|
||||
debugDraw.depthMask(true);
|
||||
DrawMode drawMode = settingsUI.getDrawMode();
|
||||
DrawMode drawMode = rcSettingsView.getDrawMode();
|
||||
|
||||
float texScale = 1.0f / (settingsUI.getCellSize() * 10.0f);
|
||||
float m_agentMaxSlope = settingsUI.getAgentMaxSlope();
|
||||
float texScale = 1.0f / (rcSettingsView.getCellSize() * 10.0f);
|
||||
float m_agentMaxSlope = rcSettingsView.getAgentMaxSlope();
|
||||
|
||||
if (drawMode != DrawMode.DRAWMODE_NAVMESH_TRANS) {
|
||||
// Draw mesh
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
namespace DotRecast.Recast.Demo;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var demo = new RecastDemo();
|
||||
demo.start();
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ namespace DotRecast.Recast.Demo;
|
|||
public class RecastDemo : MouseListener
|
||||
{
|
||||
private readonly ILogger logger = Log.ForContext<RecastDemo>();
|
||||
private NuklearUI nuklearUI;
|
||||
private RcViewSystem _viewSys;
|
||||
private IWindow window;
|
||||
private IInputContext _input;
|
||||
private ImGuiController _imgui;
|
||||
|
@ -95,7 +95,7 @@ public class RecastDemo : MouseListener
|
|||
private bool markerPositionSet;
|
||||
private readonly float[] markerPosition = new float[3];
|
||||
private ToolsUI toolsUI;
|
||||
private SettingsUI settingsUI;
|
||||
private RcSettingsView _rcSettingsView;
|
||||
private long prevFrameTime;
|
||||
|
||||
public RecastDemo()
|
||||
|
@ -378,7 +378,7 @@ public class RecastDemo : MouseListener
|
|||
window.CreateInput();
|
||||
|
||||
|
||||
settingsUI = new SettingsUI();
|
||||
_rcSettingsView = new RcSettingsView();
|
||||
toolsUI = new ToolsUI(
|
||||
new TestNavmeshTool(),
|
||||
new OffMeshConnectionTool(),
|
||||
|
@ -387,7 +387,7 @@ public class RecastDemo : MouseListener
|
|||
new JumpLinkBuilderTool(),
|
||||
new DynamicUpdateTool());
|
||||
|
||||
nuklearUI = new NuklearUI(window, _input, settingsUI, toolsUI);
|
||||
_viewSys = new RcViewSystem(window, _input, _rcSettingsView, toolsUI);
|
||||
|
||||
DemoInputGeomProvider geom = loadInputMesh(Loader.ToBytes("nav_test.obj"));
|
||||
//sample = new Sample(geom, ImmutableArray<RecastBuilderResult>.Empty, null, settingsUI, dd);
|
||||
|
@ -410,9 +410,9 @@ public class RecastDemo : MouseListener
|
|||
// settingsUI.setMaxPolys(tileNavMeshBuilder.getMaxPolysPerTile(sample.getInputGeom(), settingsUI.getCellSize(), settingsUI.getTileSize()));
|
||||
// }
|
||||
|
||||
nuklearUI.inputBegin();
|
||||
_viewSys.inputBegin();
|
||||
window.DoEvents();
|
||||
nuklearUI.inputEnd(window);
|
||||
_viewSys.inputEnd(window);
|
||||
|
||||
long time = Stopwatch.GetTimestamp() / 1000;
|
||||
//float dt = (time - prevFrameTime) / 1000000.0f;
|
||||
|
@ -446,7 +446,7 @@ public class RecastDemo : MouseListener
|
|||
|
||||
//mouseOverMenu = nuklearUI.layout(window, 0, 0, width, height, (int)mousePos[0], (int)mousePos[1]);
|
||||
|
||||
if (settingsUI.isMeshInputTrigerred())
|
||||
if (_rcSettingsView.isMeshInputTrigerred())
|
||||
{
|
||||
// aFilterPatterns.put(stack.UTF8("*.obj"));
|
||||
// aFilterPatterns.flip();
|
||||
|
@ -460,7 +460,7 @@ public class RecastDemo : MouseListener
|
|||
// }
|
||||
// }
|
||||
}
|
||||
else if (settingsUI.isNavMeshInputTrigerred())
|
||||
else if (_rcSettingsView.isNavMeshInputTrigerred())
|
||||
{
|
||||
// try (MemoryStack stack = stackPush()) {
|
||||
// PointerBuffer aFilterPatterns = stack.mallocPointer(4);
|
||||
|
@ -664,9 +664,8 @@ public class RecastDemo : MouseListener
|
|||
private unsafe void OnWindowOnRender(double dt)
|
||||
{
|
||||
_gl.Clear(ClearBufferMask.ColorBufferBit);
|
||||
// Render GUI
|
||||
//mouseOverMenu = nuklearUI.layout(window, 0, 0, width, height, (int)mousePos[0], (int)mousePos[1]);
|
||||
//nuklearUI.render();
|
||||
|
||||
mouseOverMenu = _viewSys.render(window, 0, 0, width, height, (int)mousePos[0], (int)mousePos[1]);
|
||||
ImGui.Button("hello");
|
||||
ImGui.Button("world");
|
||||
|
||||
|
@ -674,13 +673,7 @@ public class RecastDemo : MouseListener
|
|||
}
|
||||
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var demo = new RecastDemo();
|
||||
demo.start();
|
||||
}
|
||||
|
||||
private static void ErrorCallback(Silk.NET.GLFW.ErrorCode code, string message)
|
||||
private void ErrorCallback(Silk.NET.GLFW.ErrorCode code, string message)
|
||||
{
|
||||
Console.WriteLine($"GLFW error [{code}]: {message}");
|
||||
}
|
||||
|
|
|
@ -30,16 +30,16 @@ public class Sample {
|
|||
private DemoInputGeomProvider inputGeom;
|
||||
private NavMesh navMesh;
|
||||
private NavMeshQuery navMeshQuery;
|
||||
private readonly SettingsUI settingsUI;
|
||||
private readonly RcSettingsView _rcSettingsView;
|
||||
private IList<RecastBuilderResult> recastResults;
|
||||
private bool changed;
|
||||
|
||||
public Sample(DemoInputGeomProvider inputGeom, IList<RecastBuilderResult> recastResults, NavMesh navMesh,
|
||||
SettingsUI settingsUI, RecastDebugDraw debugDraw) {
|
||||
RcSettingsView rcSettingsView, RecastDebugDraw debugDraw) {
|
||||
this.inputGeom = inputGeom;
|
||||
this.recastResults = recastResults;
|
||||
this.navMesh = navMesh;
|
||||
this.settingsUI = settingsUI;
|
||||
this._rcSettingsView = rcSettingsView;
|
||||
setQuery(navMesh);
|
||||
changed = true;
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ public class Sample {
|
|||
return navMesh;
|
||||
}
|
||||
|
||||
public SettingsUI getSettingsUI() {
|
||||
return settingsUI;
|
||||
public RcSettingsView getSettingsUI() {
|
||||
return _rcSettingsView;
|
||||
}
|
||||
|
||||
public NavMeshQuery getNavMeshQuery() {
|
||||
|
|
|
@ -16,16 +16,13 @@ freely, subject to the following restrictions:
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using DotRecast.Recast.Demo.Draw;
|
||||
using DotRecast.Recast.Demo.UI;
|
||||
using ImGuiNET;
|
||||
using Silk.NET.OpenGL.Extensions.ImGui;
|
||||
using Silk.NET.Windowing;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Settings;
|
||||
|
||||
public class SettingsUI : NuklearUIModule {
|
||||
public class RcSettingsView : IRcView {
|
||||
|
||||
private readonly float[] cellSize = new[] { 0.3f };
|
||||
private readonly float[] cellHeight = new[] { 0.2f };
|
||||
|
@ -68,7 +65,7 @@ public class SettingsUI : NuklearUIModule {
|
|||
private bool meshInputTrigerred;
|
||||
private bool navMeshInputTrigerred;
|
||||
|
||||
public bool layout(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) {
|
||||
bool mouseInside = false;
|
||||
// nk_rgb(255, 255, 255, white);
|
||||
// nk_rgba(0, 0, 0, 192, background);
|
||||
|
@ -212,43 +209,35 @@ public class SettingsUI : NuklearUIModule {
|
|||
}
|
||||
|
||||
public float getCellSize() {
|
||||
//return cellSize[0];
|
||||
return 0;
|
||||
return cellSize[0];
|
||||
}
|
||||
|
||||
public float getCellHeight() {
|
||||
//return cellHeight[0];
|
||||
return 0;
|
||||
return cellHeight[0];
|
||||
}
|
||||
|
||||
public float getAgentHeight() {
|
||||
//return agentHeight[0];
|
||||
return 0;
|
||||
return agentHeight[0];
|
||||
}
|
||||
|
||||
public float getAgentRadius() {
|
||||
//return agentRadius[0];
|
||||
return 0;
|
||||
return agentRadius[0];
|
||||
}
|
||||
|
||||
public float getAgentMaxClimb() {
|
||||
//return agentMaxClimb[0];
|
||||
return 0;
|
||||
return agentMaxClimb[0];
|
||||
}
|
||||
|
||||
public float getAgentMaxSlope() {
|
||||
//return agentMaxSlope[0];
|
||||
return 0;
|
||||
return agentMaxSlope[0];
|
||||
}
|
||||
|
||||
public int getMinRegionSize() {
|
||||
//return minRegionSize[0];
|
||||
return 0;
|
||||
return minRegionSize[0];
|
||||
}
|
||||
|
||||
public int getMergedRegionSize() {
|
||||
//return mergedRegionSize[0];
|
||||
return 0;
|
||||
return mergedRegionSize[0];
|
||||
}
|
||||
|
||||
public PartitionType getPartitioning() {
|
|
@ -23,7 +23,7 @@ using Silk.NET.Windowing;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class ToolsUI : NuklearUIModule {
|
||||
public class ToolsUI : IRcView {
|
||||
|
||||
//private readonly NkColor white = NkColor.create();
|
||||
private Tool currentTool;
|
||||
|
@ -34,7 +34,7 @@ public class ToolsUI : NuklearUIModule {
|
|||
this.tools = tools;
|
||||
}
|
||||
|
||||
public bool layout(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) {
|
||||
bool mouseInside = false;
|
||||
// nk_rgb(255, 255, 255, white);
|
||||
// try (MemoryStack stack = stackPush()) {
|
||||
|
|
|
@ -20,10 +20,7 @@ using Silk.NET.Windowing;
|
|||
|
||||
namespace DotRecast.Recast.Demo.UI;
|
||||
|
||||
public interface IRcView {
|
||||
|
||||
|
||||
public interface NuklearUIModule {
|
||||
|
||||
bool layout(IWindow ctx, int x, int y, int width, int height, int mouseX, int mouseY);
|
||||
|
||||
bool render(IWindow ctx, int x, int y, int width, int height, int mouseX, int mouseY);
|
||||
}
|
|
@ -33,7 +33,7 @@ public class NuklearGL {
|
|||
private static readonly int FONT_BITMAP_H = 1024;
|
||||
private static readonly int FONT_HEIGHT = 15;
|
||||
|
||||
private readonly NuklearUI context;
|
||||
private readonly RcViewSystem context;
|
||||
// private readonly NkDrawNullTexture null_texture = NkDrawNullTexture.create();
|
||||
// private readonly NkBuffer cmds = NkBuffer.create();
|
||||
// private readonly NkUserFont default_font;
|
||||
|
@ -45,7 +45,7 @@ public class NuklearGL {
|
|||
private readonly int vao;
|
||||
//private readonly Buffer vertexLayout;
|
||||
|
||||
public NuklearGL(NuklearUI context) {
|
||||
public NuklearGL(RcViewSystem context) {
|
||||
this.context = context;
|
||||
// nk_buffer_init(cmds, context.allocator, BUFFER_INITIAL_SIZE);
|
||||
// vertexLayout = NkDrawVertexLayoutElement.create(4)//
|
||||
|
|
|
@ -18,23 +18,22 @@ freely, subject to the following restrictions:
|
|||
|
||||
using Silk.NET.Input;
|
||||
using Silk.NET.OpenGL;
|
||||
using Silk.NET.OpenGL.Extensions.ImGui;
|
||||
using Silk.NET.Windowing;
|
||||
|
||||
namespace DotRecast.Recast.Demo.UI;
|
||||
|
||||
public class NuklearUI {
|
||||
public class RcViewSystem {
|
||||
|
||||
// readonly NkAllocator allocator;
|
||||
private readonly IWindow _window;
|
||||
private readonly GL _gl;
|
||||
// readonly NkColor background;
|
||||
// readonly NkColor white;
|
||||
private readonly NuklearUIModule[] _modules;
|
||||
private readonly IRcView[] _views;
|
||||
private readonly NuklearGL glContext;
|
||||
private bool mouseOverUI;
|
||||
|
||||
public NuklearUI(IWindow window, IInputContext input, params NuklearUIModule[] modules)
|
||||
public RcViewSystem(IWindow window, IInputContext input, params IRcView[] views)
|
||||
{
|
||||
var mouse = new Mouse(input);
|
||||
_window = window;
|
||||
|
@ -58,7 +57,7 @@ public class NuklearUI {
|
|||
// setupClipboard(window);
|
||||
// glfwSetCharCallback(window, (w, codepoint) => nk_input_unicode(ctx, codepoint));
|
||||
// glContext = new NuklearGL(this);
|
||||
_modules = modules;
|
||||
_views = views;
|
||||
}
|
||||
|
||||
private void setupMouse(Mouse mouse) {
|
||||
|
@ -140,10 +139,10 @@ public class NuklearUI {
|
|||
// nk_input_end(ctx);
|
||||
}
|
||||
|
||||
public bool layout(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) {
|
||||
mouseOverUI = false;
|
||||
foreach (NuklearUIModule m in _modules) {
|
||||
mouseOverUI = m.layout(ctx, x, y, width, height, mouseX, mouseY) | mouseOverUI;
|
||||
foreach (IRcView m in _views) {
|
||||
mouseOverUI = m.render(ctx, x, y, width, height, mouseX, mouseY) | mouseOverUI;
|
||||
}
|
||||
return mouseOverUI;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
[Window][Debug##Default]
|
||||
Pos=280,129
|
||||
Size=400,400
|
||||
Collapsed=0
|
||||
|
Loading…
Reference in New Issue