Recast Navigation
Navigation-mesh Toolset for Games
Loading...
Searching...
No Matches
InputGeom.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 INPUTGEOM_H
20#define INPUTGEOM_H
21
22#include "ChunkyTriMesh.h"
23#include "MeshLoaderObj.h"
24
25static const int MAX_CONVEXVOL_PTS = 12;
27{
29 float hmin, hmax;
30 int nverts;
31 int area;
32};
33
35{
36 // Cell size in world units
37 float cellSize;
38 // Cell height in world units
40 // Agent height in world units
42 // Agent radius in world units
44 // Agent max climb in world units
46 // Agent max slope in degrees
48 // Region minimum size in voxels.
49 // regionMinSize = sqrt(regionMinArea)
51 // Region merge size in voxels.
52 // regionMergeSize = sqrt(regionMergeArea)
54 // Edge max length in world units
56 // Edge max error in voxels
59 // Detail sample distance in voxels
61 // Detail sample max error in voxel heights.
63 // Partition type, see SamplePartitionType
65 // Bounds of the area to mesh
66 float navMeshBMin[3];
67 float navMeshBMax[3];
68 // Size of the tiles in voxels
69 float tileSize;
70};
71
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
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;
91
94 static const int MAX_VOLUMES = 256;
95 ConvexVolume m_volumes[MAX_VOLUMES];
96 int m_volumeCount;
98
99 bool loadMesh(class rcContext* ctx, const std::string& filepath);
100 bool loadGeomSet(class rcContext* ctx, const std::string& filepath);
101public:
102 InputGeom();
103 ~InputGeom();
104
105
106 bool load(class rcContext* ctx, const std::string& filepath);
107 bool saveGeomSet(const BuildSettings* settings);
108
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
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);
133
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);
143
144private:
145 // Explicitly disabled copy constructor and copy assignment operator.
146 InputGeom(const InputGeom&);
147 InputGeom& operator=(const InputGeom&);
148};
149
150#endif // INPUTGEOM_H
static const int MAX_CONVEXVOL_PTS
Definition InputGeom.h:25
Definition InputGeom.h:73
bool load(class rcContext *ctx, const std::string &filepath)
Definition InputGeom.cpp:299
void deleteConvexVolume(int i)
Definition InputGeom.cpp:541
int getConvexVolumeCount() const
Definition InputGeom.h:136
const unsigned char * getOffMeshConnectionDirs() const
Definition InputGeom.h:124
const rcMeshLoaderObj * getMesh() const
Method to return static mesh data.
Definition InputGeom.h:110
void addConvexVolume(const float *verts, const int nverts, const float minh, const float maxh, unsigned char area)
Definition InputGeom.cpp:528
const float * getNavMeshBoundsMax() const
Definition InputGeom.h:114
const unsigned char * getOffMeshConnectionAreas() const
Definition InputGeom.h:125
const float * getMeshBoundsMax() const
Definition InputGeom.h:112
const rcChunkyTriMesh * getChunkyMesh() const
Definition InputGeom.h:115
const float * getMeshBoundsMin() const
Definition InputGeom.h:111
void addOffMeshConnection(const float *spos, const float *epos, const float rad, unsigned char bidir, unsigned char area, unsigned short flags)
Definition InputGeom.cpp:469
bool saveGeomSet(const BuildSettings *settings)
Definition InputGeom.cpp:316
const float * getNavMeshBoundsMin() const
Definition InputGeom.h:113
bool raycastMesh(float *src, float *dst, float &tmin)
Definition InputGeom.cpp:424
const unsigned short * getOffMeshConnectionFlags() const
Definition InputGeom.h:126
const float * getOffMeshConnectionRads() const
Definition InputGeom.h:123
const BuildSettings * getBuildSettings() const
Definition InputGeom.h:116
const unsigned int * getOffMeshConnectionId() const
Definition InputGeom.h:127
const float * getOffMeshConnectionVerts() const
Definition InputGeom.h:122
void deleteOffMeshConnection(int i)
Definition InputGeom.cpp:484
int getOffMeshConnectionCount() const
Definition InputGeom.h:121
~InputGeom()
Definition InputGeom.cpp:118
void drawOffMeshConnections(struct duDebugDraw *dd, bool hilight=false)
Definition InputGeom.cpp:497
const ConvexVolume * getConvexVolumes() const
Definition InputGeom.h:137
void drawConvexVolumes(struct duDebugDraw *dd, bool hilight=false)
Definition InputGeom.cpp:547
InputGeom()
Definition InputGeom.cpp:109
Provides an interface for optional logging and performance tracking of the Recast build process.
Definition Recast.h:115
Definition MeshLoaderObj.h:25
Definition InputGeom.h:35
float agentHeight
Definition InputGeom.h:41
float navMeshBMin[3]
Definition InputGeom.h:66
int partitionType
Definition InputGeom.h:64
float regionMinSize
Definition InputGeom.h:50
float agentMaxSlope
Definition InputGeom.h:47
float detailSampleMaxError
Definition InputGeom.h:62
float agentMaxClimb
Definition InputGeom.h:45
float vertsPerPoly
Definition InputGeom.h:58
float edgeMaxError
Definition InputGeom.h:57
float agentRadius
Definition InputGeom.h:43
float cellSize
Definition InputGeom.h:37
float navMeshBMax[3]
Definition InputGeom.h:67
float tileSize
Definition InputGeom.h:69
float detailSampleDist
Definition InputGeom.h:60
float cellHeight
Definition InputGeom.h:39
float edgeMaxLen
Definition InputGeom.h:55
float regionMergeSize
Definition InputGeom.h:53
Definition InputGeom.h:27
float hmax
Definition InputGeom.h:29
float hmin
Definition InputGeom.h:29
float verts[MAX_CONVEXVOL_PTS *3]
Definition InputGeom.h:28
int nverts
Definition InputGeom.h:30
int area
Definition InputGeom.h:31
Abstract debug draw interface.
Definition DebugDraw.h:35
Definition ChunkyTriMesh.h:31