| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef INPUTGEOM_H |
| 20 |
#define INPUTGEOM_H |
| 21 |
|
| 22 |
#include "ChunkyTriMesh.h" |
| 23 |
#include "MeshLoaderObj.h" |
| 24 |
|
| 25 |
static const int MAX_CONVEXVOL_PTS = 12; |
| 26 |
struct ConvexVolume |
| 27 |
{ |
| 28 |
float verts[MAX_CONVEXVOL_PTS*3]; |
| 29 |
float hmin, hmax; |
| 30 |
int nverts; |
| 31 |
int area; |
| 32 |
}; |
| 33 |
|
| 34 |
struct BuildSettings |
| 35 |
{ |
| 36 |
|
| 37 |
float cellSize; |
| 38 |
|
| 39 |
float cellHeight; |
| 40 |
|
| 41 |
float agentHeight; |
| 42 |
|
| 43 |
float agentRadius; |
| 44 |
|
| 45 |
float agentMaxClimb; |
| 46 |
|
| 47 |
float agentMaxSlope; |
| 48 |
|
| 49 |
|
| 50 |
float regionMinSize; |
| 51 |
|
| 52 |
|
| 53 |
float regionMergeSize; |
| 54 |
|
| 55 |
float edgeMaxLen; |
| 56 |
|
| 57 |
float edgeMaxError; |
| 58 |
float vertsPerPoly; |
| 59 |
|
| 60 |
float detailSampleDist; |
| 61 |
|
| 62 |
float detailSampleMaxError; |
| 63 |
|
| 64 |
int partitionType; |
| 65 |
|
| 66 |
float navMeshBMin[3]; |
| 67 |
float navMeshBMax[3]; |
| 68 |
|
| 69 |
float tileSize; |
| 70 |
}; |
| 71 |
|
| 72 |
class InputGeom |
| 73 |
{ |
| 74 |
rcChunkyTriMesh* m_chunkyMesh; |
| 75 |
rcMeshLoaderObj* m_mesh; |
| 76 |
float m_meshBMin[3], m_meshBMax[3]; |
| 77 |
BuildSettings m_buildSettings; |
| 78 |
bool m_hasBuildSettings; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
static const int MAX_OFFMESH_CONNECTIONS = 256; |
| 83 |
float m_offMeshConVerts[MAX_OFFMESH_CONNECTIONS*3*2]; |
| 84 |
float m_offMeshConRads[MAX_OFFMESH_CONNECTIONS]; |
| 85 |
unsigned char m_offMeshConDirs[MAX_OFFMESH_CONNECTIONS]; |
| 86 |
unsigned char m_offMeshConAreas[MAX_OFFMESH_CONNECTIONS]; |
| 87 |
unsigned short m_offMeshConFlags[MAX_OFFMESH_CONNECTIONS]; |
| 88 |
unsigned int m_offMeshConId[MAX_OFFMESH_CONNECTIONS]; |
| 89 |
int m_offMeshConCount; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
static const int MAX_VOLUMES = 256; |
| 95 |
ConvexVolume m_volumes[MAX_VOLUMES]; |
| 96 |
int m_volumeCount; |
| 97 |
|
| 98 |
|
| 99 |
bool loadMesh(class rcContext* ctx, const std::string& filepath); |
| 100 |
bool loadGeomSet(class rcContext* ctx, const std::string& filepath); |
| 101 |
public: |
| 102 |
InputGeom(); |
| 103 |
~InputGeom(); |
| 104 |
|
| 105 |
|
| 106 |
bool load(class rcContext* ctx, const std::string& filepath); |
| 107 |
bool saveGeomSet(const BuildSettings* settings); |
| 108 |
|
| 109 |
|
| 110 |
const rcMeshLoaderObj* getMesh() const { return m_mesh; } |
| 111 |
const float* getMeshBoundsMin() const { return m_meshBMin; } |
| 112 |
const float* getMeshBoundsMax() const { return m_meshBMax; } |
| 113 |
const float* getNavMeshBoundsMin() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMin : m_meshBMin; } |
| 114 |
const float* getNavMeshBoundsMax() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMax : m_meshBMax; } |
| 115 |
const rcChunkyTriMesh* getChunkyMesh() const { return m_chunkyMesh; } |
| 116 |
const BuildSettings* getBuildSettings() const { return m_hasBuildSettings ? &m_buildSettings : 0; } |
| 117 |
bool raycastMesh(float* src, float* dst, float& tmin); |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
int getOffMeshConnectionCount() const { return m_offMeshConCount; } |
| 122 |
const float* getOffMeshConnectionVerts() const { return m_offMeshConVerts; } |
| 123 |
const float* getOffMeshConnectionRads() const { return m_offMeshConRads; } |
| 124 |
const unsigned char* getOffMeshConnectionDirs() const { return m_offMeshConDirs; } |
| 125 |
const unsigned char* getOffMeshConnectionAreas() const { return m_offMeshConAreas; } |
| 126 |
const unsigned short* getOffMeshConnectionFlags() const { return m_offMeshConFlags; } |
| 127 |
const unsigned int* getOffMeshConnectionId() const { return m_offMeshConId; } |
| 128 |
void addOffMeshConnection(const float* spos, const float* epos, const float rad, |
| 129 |
unsigned char bidir, unsigned char area, unsigned short flags); |
| 130 |
void deleteOffMeshConnection(int i); |
| 131 |
void drawOffMeshConnections(struct duDebugDraw* dd, bool hilight = false); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
int getConvexVolumeCount() const { return m_volumeCount; } |
| 137 |
const ConvexVolume* getConvexVolumes() const { return m_volumes; } |
| 138 |
void addConvexVolume(const float* verts, const int nverts, |
| 139 |
const float minh, const float maxh, unsigned char area); |
| 140 |
void deleteConvexVolume(int i); |
| 141 |
void drawConvexVolumes(struct duDebugDraw* dd, bool hilight = false); |
| 142 |
|
| 143 |
|
| 144 |
private: |
| 145 |
|
| 146 |
InputGeom(const InputGeom&); |
| 147 |
InputGeom& operator=(const InputGeom&); |
| 148 |
}; |
| 149 |
|
| 150 |
#endif |