forked from mirror/DotRecast
prepare model <- vm or ctrl <- view
This commit is contained in:
parent
474ca92c1c
commit
fc553e2753
|
@ -304,4 +304,4 @@ public class NavMeshRenderer
|
|||
|
||||
debugDraw.DepthMask(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -602,7 +602,7 @@ public class RecastDemo
|
|||
}
|
||||
|
||||
RcVec3f rayDir = RcVec3f.Of(rayEnd.x - rayStart.x, rayEnd.y - rayStart.y, rayEnd.z - rayStart.z);
|
||||
Tool rayTool = toolsUI.GetTool();
|
||||
ITool rayTool = toolsUI.GetTool();
|
||||
rayDir.Normalize();
|
||||
if (rayTool != null)
|
||||
{
|
||||
|
@ -727,7 +727,7 @@ public class RecastDemo
|
|||
|
||||
dd.Fog(camr * 0.1f, camr * 1.25f);
|
||||
renderer.Render(sample);
|
||||
Tool tool = toolsUI.GetTool();
|
||||
ITool tool = toolsUI.GetTool();
|
||||
if (tool != null)
|
||||
{
|
||||
tool.HandleRender(renderer);
|
||||
|
|
|
@ -30,7 +30,7 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class ConvexVolumeTool : Tool
|
||||
public class ConvexVolumeTool : ITool
|
||||
{
|
||||
private Sample sample;
|
||||
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
||||
|
@ -41,12 +41,12 @@ public class ConvexVolumeTool : Tool
|
|||
private readonly List<float> pts = new();
|
||||
private readonly List<int> hull = new();
|
||||
|
||||
public override void SetSample(Sample m_sample)
|
||||
public void SetSample(Sample m_sample)
|
||||
{
|
||||
sample = m_sample;
|
||||
}
|
||||
|
||||
public override void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
{
|
||||
DemoInputGeomProvider geom = sample.GetInputGeom();
|
||||
if (geom == null)
|
||||
|
@ -139,7 +139,7 @@ public class ConvexVolumeTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override void HandleRender(NavMeshRenderer renderer)
|
||||
public void HandleRender(NavMeshRenderer renderer)
|
||||
{
|
||||
RecastDebugDraw dd = renderer.GetDebugDraw();
|
||||
// Find height extent of the shape.
|
||||
|
@ -182,7 +182,7 @@ public class ConvexVolumeTool : Tool
|
|||
dd.End();
|
||||
}
|
||||
|
||||
public override void Layout()
|
||||
public void Layout()
|
||||
{
|
||||
ImGui.SliderFloat("Shape Height", ref boxHeight, 0.1f, 20f, "%.1f");
|
||||
ImGui.SliderFloat("Shape Descent", ref boxDescent, 0.1f, 20f, "%.1f");
|
||||
|
@ -224,13 +224,19 @@ public class ConvexVolumeTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
public string GetName()
|
||||
{
|
||||
return "Create Convex Volumes";
|
||||
}
|
||||
|
||||
public override void HandleUpdate(float dt)
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class CrowdTool : Tool
|
||||
public class CrowdTool : ITool
|
||||
{
|
||||
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
||||
private Sample sample;
|
||||
|
@ -56,7 +56,7 @@ public class CrowdTool : Tool
|
|||
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
||||
}
|
||||
|
||||
public override void SetSample(Sample psample)
|
||||
public void SetSample(Sample psample)
|
||||
{
|
||||
if (sample != psample)
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ public class CrowdTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
{
|
||||
if (m_mode == CrowdToolMode.PROFILING)
|
||||
{
|
||||
|
@ -313,7 +313,7 @@ public class CrowdTool : Tool
|
|||
return vel.Scale(speed);
|
||||
}
|
||||
|
||||
public override void HandleRender(NavMeshRenderer renderer)
|
||||
public void HandleRender(NavMeshRenderer renderer)
|
||||
{
|
||||
if (m_mode == CrowdToolMode.PROFILING)
|
||||
{
|
||||
|
@ -620,7 +620,7 @@ public class CrowdTool : Tool
|
|||
dd.DepthMask(true);
|
||||
}
|
||||
|
||||
public override void HandleUpdate(float dt)
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
UpdateTick(dt);
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ public class CrowdTool : Tool
|
|||
m_agentDebug.agent = agent;
|
||||
}
|
||||
|
||||
public override void Layout()
|
||||
public void Layout()
|
||||
{
|
||||
ImGui.Text($"Crowd Tool Mode");
|
||||
ImGui.Separator();
|
||||
|
@ -794,8 +794,14 @@ public class CrowdTool : Tool
|
|||
return updateFlags;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
public string GetName()
|
||||
{
|
||||
return "Crowd";
|
||||
}
|
||||
|
||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,7 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class DynamicUpdateTool : Tool
|
||||
public class DynamicUpdateTool : ITool
|
||||
{
|
||||
private Sample sample;
|
||||
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
||||
|
@ -92,12 +92,12 @@ public class DynamicUpdateTool : Tool
|
|||
convexGeom = DemoObjImporter.Load(Loader.ToBytes("convex.obj"));
|
||||
}
|
||||
|
||||
public override void SetSample(Sample sample)
|
||||
public void SetSample(Sample sample)
|
||||
{
|
||||
this.sample = sample;
|
||||
}
|
||||
|
||||
public override void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
{
|
||||
if (mode == DynamicUpdateToolMode.COLLIDERS)
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ public class DynamicUpdateTool : Tool
|
|||
}
|
||||
|
||||
|
||||
public override void HandleClickRay(RcVec3f start, RcVec3f dir, bool shift)
|
||||
public void HandleClickRay(RcVec3f start, RcVec3f dir, bool shift)
|
||||
{
|
||||
if (mode == DynamicUpdateToolMode.COLLIDERS)
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ public class DynamicUpdateTool : Tool
|
|||
return disc >= 0.0f;
|
||||
}
|
||||
|
||||
public override void HandleRender(NavMeshRenderer renderer)
|
||||
public void HandleRender(NavMeshRenderer renderer)
|
||||
{
|
||||
if (mode == DynamicUpdateToolMode.COLLIDERS)
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ public class DynamicUpdateTool : Tool
|
|||
dd.DepthMask(true);
|
||||
}
|
||||
|
||||
public override void HandleUpdate(float dt)
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
if (dynaMesh != null)
|
||||
{
|
||||
|
@ -477,7 +477,7 @@ public class DynamicUpdateTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override void Layout()
|
||||
public void Layout()
|
||||
{
|
||||
ImGui.Text($"Dynamic Update Tool Modes");
|
||||
ImGui.Separator();
|
||||
|
@ -744,7 +744,7 @@ public class DynamicUpdateTool : Tool
|
|||
filterWalkableLowHeightSpans = dynaMesh.config.filterWalkableLowHeightSpans;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
public string GetName()
|
||||
{
|
||||
return "Dynamic Updates";
|
||||
}
|
||||
|
|
|
@ -23,21 +23,18 @@ using DotRecast.Recast.Demo.Draw;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public abstract class Tool
|
||||
public interface ITool
|
||||
{
|
||||
public abstract string GetName();
|
||||
public abstract void Layout();
|
||||
string GetName();
|
||||
void Layout();
|
||||
|
||||
public abstract void SetSample(Sample m_sample);
|
||||
void SetSample(Sample m_sample);
|
||||
|
||||
public abstract void HandleClick(RcVec3f s, RcVec3f p, bool shift);
|
||||
void HandleClick(RcVec3f s, RcVec3f p, bool shift);
|
||||
|
||||
public abstract void HandleRender(NavMeshRenderer renderer);
|
||||
void HandleRender(NavMeshRenderer renderer);
|
||||
|
||||
public abstract void HandleUpdate(float dt);
|
||||
void HandleUpdate(float dt);
|
||||
|
||||
public virtual void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift);
|
||||
}
|
|
@ -29,7 +29,7 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class JumpLinkBuilderTool : Tool
|
||||
public class JumpLinkBuilderTool : ITool
|
||||
{
|
||||
private readonly List<JumpLink> links = new();
|
||||
private Sample sample;
|
||||
|
@ -37,17 +37,17 @@ public class JumpLinkBuilderTool : Tool
|
|||
private readonly int selEdge = -1;
|
||||
private readonly JumpLinkBuilderToolParams option = new JumpLinkBuilderToolParams();
|
||||
|
||||
public override void SetSample(Sample sample)
|
||||
public void SetSample(Sample sample)
|
||||
{
|
||||
this.sample = sample;
|
||||
annotationBuilder = null;
|
||||
}
|
||||
|
||||
public override void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
{
|
||||
}
|
||||
|
||||
public override void HandleRender(NavMeshRenderer renderer)
|
||||
public void HandleRender(NavMeshRenderer renderer)
|
||||
{
|
||||
int col0 = DuLerpCol(DuRGBA(32, 255, 96, 255), DuRGBA(255, 255, 255, 255), 200);
|
||||
int col1 = DuRGBA(32, 255, 96, 255);
|
||||
|
@ -318,11 +318,11 @@ public class JumpLinkBuilderTool : Tool
|
|||
{
|
||||
}
|
||||
|
||||
public override void HandleUpdate(float dt)
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Layout()
|
||||
public void Layout()
|
||||
{
|
||||
if (0 >= sample.GetRecastResults().Count)
|
||||
return;
|
||||
|
@ -442,8 +442,12 @@ public class JumpLinkBuilderTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
public string GetName()
|
||||
{
|
||||
return "Annotation Builder";
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -28,19 +28,19 @@ using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class OffMeshConnectionTool : Tool
|
||||
public class OffMeshConnectionTool : ITool
|
||||
{
|
||||
private Sample sample;
|
||||
private bool hitPosSet;
|
||||
private RcVec3f hitPos;
|
||||
private int bidir;
|
||||
|
||||
public override void SetSample(Sample m_sample)
|
||||
public void SetSample(Sample m_sample)
|
||||
{
|
||||
sample = m_sample;
|
||||
}
|
||||
|
||||
public override void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
{
|
||||
DemoInputGeomProvider geom = sample.GetInputGeom();
|
||||
if (geom == null)
|
||||
|
@ -87,7 +87,7 @@ public class OffMeshConnectionTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override void HandleRender(NavMeshRenderer renderer)
|
||||
public void HandleRender(NavMeshRenderer renderer)
|
||||
{
|
||||
if (sample == null)
|
||||
{
|
||||
|
@ -109,19 +109,25 @@ public class OffMeshConnectionTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override void Layout()
|
||||
public void Layout()
|
||||
{
|
||||
ImGui.RadioButton("One Way", ref bidir, 0);
|
||||
ImGui.RadioButton("Bidirectional", ref bidir, 1);
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
public string GetName()
|
||||
{
|
||||
return "Create Off-Mesh Links";
|
||||
}
|
||||
|
||||
public override void HandleUpdate(float dt)
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
|
|||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class TestNavmeshTool : Tool
|
||||
public class TestNavmeshTool : ITool
|
||||
{
|
||||
private const int MAX_POLYS = 256;
|
||||
private const int MAX_SMOOTH = 2048;
|
||||
|
@ -54,12 +54,12 @@ public class TestNavmeshTool : Tool
|
|||
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 1f, 1f, 1f, 2f, 1.5f });
|
||||
}
|
||||
|
||||
public override void SetSample(Sample m_sample)
|
||||
public void SetSample(Sample m_sample)
|
||||
{
|
||||
this.m_sample = m_sample;
|
||||
}
|
||||
|
||||
public override void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||
{
|
||||
if (shift)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ public class TestNavmeshTool : Tool
|
|||
Recalc();
|
||||
}
|
||||
|
||||
public override void Layout()
|
||||
public void Layout()
|
||||
{
|
||||
var previousToolMode = m_toolMode;
|
||||
int previousStraightPathOptions = m_straightPathOptions;
|
||||
|
@ -153,7 +153,7 @@ public class TestNavmeshTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
public string GetName()
|
||||
{
|
||||
return "Test Navmesh";
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ public class TestNavmeshTool : Tool
|
|||
}
|
||||
}
|
||||
|
||||
public override void HandleRender(NavMeshRenderer renderer)
|
||||
public void HandleRender(NavMeshRenderer renderer)
|
||||
{
|
||||
if (m_sample == null)
|
||||
{
|
||||
|
@ -973,7 +973,7 @@ public class TestNavmeshTool : Tool
|
|||
return center;
|
||||
}
|
||||
|
||||
public override void HandleUpdate(float dt)
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
if (m_toolMode == TestNavmeshToolMode.PATHFIND_SLICED)
|
||||
|
@ -1017,4 +1017,8 @@ public class TestNavmeshTool : Tool
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -30,20 +30,19 @@ public class ToolsView : IRcView
|
|||
{
|
||||
//private readonly NkColor white = NkColor.Create();
|
||||
private int _currentToolIdx = 0;
|
||||
private Tool currentTool;
|
||||
private ITool currentTool;
|
||||
private bool enabled;
|
||||
private readonly Tool[] tools;
|
||||
|
||||
public ToolsView(params Tool[] tools)
|
||||
{
|
||||
this.tools = tools;
|
||||
}
|
||||
|
||||
private readonly ITool[] tools;
|
||||
private bool _mouseInside;
|
||||
public bool IsMouseInside() => _mouseInside;
|
||||
|
||||
private RecastDemoCanvas _canvas;
|
||||
|
||||
public ToolsView(params ITool[] tools)
|
||||
{
|
||||
this.tools = tools;
|
||||
}
|
||||
|
||||
public void Bind(RecastDemoCanvas canvas)
|
||||
{
|
||||
_canvas = canvas;
|
||||
|
@ -51,7 +50,6 @@ public class ToolsView : IRcView
|
|||
|
||||
public void Update(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Draw(double dt)
|
||||
|
@ -89,7 +87,7 @@ public class ToolsView : IRcView
|
|||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Tool GetTool()
|
||||
public ITool GetTool()
|
||||
{
|
||||
return currentTool;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue