Recast Navigation
Navigation-mesh Toolset for Games
Loading...
Searching...
No Matches
NavMeshTesterTool.h
Go to the documentation of this file.
1//
2// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3//
4// This software is provided 'as-is', without any express or implied
5// warranty. In no event will the authors be held liable for any damages
6// arising from the use of this software.
7// Permission is granted to anyone to use this software for any purpose,
8// including commercial applications, and to alter it and redistribute it
9// freely, subject to the following restrictions:
10// 1. The origin of this software must not be misrepresented; you must not
11// claim that you wrote the original software. If you use this software
12// in a product, an acknowledgment in the product documentation would be
13// appreciated but is not required.
14// 2. Altered source versions must be plainly marked as such, and must not be
15// misrepresented as being the original software.
16// 3. This notice may not be removed or altered from any source distribution.
17//
18
19#ifndef NAVMESHTESTERTOOL_H
20#define NAVMESHTESTERTOOL_H
21
22#include "Sample.h"
23#include "DetourNavMesh.h"
24#include "DetourNavMeshQuery.h"
25
27{
28 Sample* m_sample;
29
30 dtNavMesh* m_navMesh;
31 dtNavMeshQuery* m_navQuery;
32
33 dtQueryFilter m_filter;
34
35 dtStatus m_pathFindStatus;
36
37 enum ToolMode
38 {
39 TOOLMODE_PATHFIND_FOLLOW,
40 TOOLMODE_PATHFIND_STRAIGHT,
41 TOOLMODE_PATHFIND_SLICED,
42 TOOLMODE_RAYCAST,
43 TOOLMODE_DISTANCE_TO_WALL,
44 TOOLMODE_FIND_POLYS_IN_CIRCLE,
45 TOOLMODE_FIND_POLYS_IN_SHAPE,
46 TOOLMODE_FIND_LOCAL_NEIGHBOURHOOD
47 };
48
49 ToolMode m_toolMode;
50
51 int m_straightPathOptions;
52
53 static const int MAX_POLYS = 256;
54 static const int MAX_SMOOTH = 2048;
55
56 dtPolyRef m_startRef;
57 dtPolyRef m_endRef;
58 dtPolyRef m_polys[MAX_POLYS];
59 dtPolyRef m_parent[MAX_POLYS];
60 int m_npolys;
61 float m_straightPath[MAX_POLYS*3];
62 unsigned char m_straightPathFlags[MAX_POLYS];
63 dtPolyRef m_straightPathPolys[MAX_POLYS];
64 int m_nstraightPath;
65 float m_polyPickExt[3];
66 float m_smoothPath[MAX_SMOOTH*3];
67 int m_nsmoothPath;
68 float m_queryPoly[4*3];
69
70 static const int MAX_RAND_POINTS = 64;
71 float m_randPoints[MAX_RAND_POINTS*3];
72 int m_nrandPoints;
73 bool m_randPointsInCircle;
74
75 float m_spos[3];
76 float m_epos[3];
77 float m_hitPos[3];
78 float m_hitNormal[3];
79 bool m_hitResult;
80 float m_distanceToWall;
81 float m_neighbourhoodRadius;
82 float m_randomRadius;
83 bool m_sposSet;
84 bool m_eposSet;
85
86 int m_pathIterNum;
87 dtPolyRef m_pathIterPolys[MAX_POLYS];
88 int m_pathIterPolyCount;
89 float m_prevIterPos[3], m_iterPos[3], m_steerPos[3], m_targetPos[3];
90
91 static const int MAX_STEER_POINTS = 10;
92 float m_steerPoints[MAX_STEER_POINTS*3];
93 int m_steerPointCount;
94
95public:
97
98 virtual int type() { return TOOL_NAVMESH_TESTER; }
99 virtual void init(Sample* sample);
100 virtual void reset();
101 virtual void handleMenu();
102 virtual void handleClick(const float* s, const float* p, bool shift);
103 virtual void handleToggle();
104 virtual void handleStep();
105 virtual void handleUpdate(const float dt);
106 virtual void handleRender();
107 virtual void handleRenderOverlay(double* proj, double* model, int* view);
108
109 void recalc();
110 void drawAgent(const float* pos, float r, float h, float c, const unsigned int col);
111};
112
113#endif // NAVMESHTESTERTOOL_H
114
unsigned int dtStatus
Definition DetourStatus.h:22
@ TOOL_NAVMESH_TESTER
Definition Sample.h:33
Definition NavMeshTesterTool.h:27
virtual void reset()
Definition NavMeshTesterTool.cpp:622
virtual void handleUpdate(const float dt)
Definition NavMeshTesterTool.cpp:592
virtual int type()
Definition NavMeshTesterTool.h:98
virtual void handleToggle()
Definition NavMeshTesterTool.cpp:441
virtual void handleStep()
Definition NavMeshTesterTool.cpp:437
virtual void handleMenu()
Definition NavMeshTesterTool.cpp:226
virtual void init(Sample *sample)
Definition NavMeshTesterTool.cpp:204
void drawAgent(const float *pos, float r, float h, float c, const unsigned int col)
Definition NavMeshTesterTool.cpp:1353
virtual void handleRenderOverlay(double *proj, double *model, int *view)
Definition NavMeshTesterTool.cpp:1332
void recalc()
Definition NavMeshTesterTool.cpp:635
virtual void handleClick(const float *s, const float *p, bool shift)
Definition NavMeshTesterTool.cpp:422
virtual void handleRender()
Definition NavMeshTesterTool.cpp:996
NavMeshTesterTool()
Definition NavMeshTesterTool.cpp:171
Definition Sample.h:100
Provides the ability to perform pathfinding related queries against a navigation mesh.
Definition DetourNavMeshQuery.h:166
A navigation mesh based on tiles of convex polygons.
Definition DetourNavMesh.h:339
Defines polygon filtering and traversal costs for navigation mesh query operations.
Definition DetourNavMeshQuery.h:36
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition DetourNavMesh.h:48
Definition Sample.h:76