| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef NAVMESHTESTERTOOL_H |
| 20 |
#define NAVMESHTESTERTOOL_H |
| 21 |
|
| 22 |
#include "Sample.h" |
| 23 |
#include "DetourNavMesh.h" |
| 24 |
#include "DetourNavMeshQuery.h" |
| 25 |
|
| 26 |
class NavMeshTesterTool : public SampleTool |
| 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 |
|
| 95 |
public: |
| 96 |
NavMeshTesterTool(); |
| 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 |
| 114 |
|