Menge
Modular Pedestrian Simulation Framework for Research and Development
|
The class for defining a navigation mesh. A decomposition of the free space into a connected mesh of convex (or near convex) polygons used for global planning in planar or non-planar environments. More...
#include <NavMesh.h>
Public Member Functions | |
NavMesh (const std::string &name) | |
Constructor. More... | |
void | clear () |
Clears the navigation mesh - removes edges and nodes. | |
virtual const std::string & | getLabel () const |
Returns a unique resource label to be used to identify different resource types which use the same underlying file data. | |
size_t | getVertexCount () const |
Reports the number of vertices in the navigation mesh. More... | |
size_t | getNodeCount () const |
Reports the number of nodes in the navigation mesh. More... | |
NavMeshNode & | getNode (unsigned int i) |
Returns a reference to the ith node. More... | |
const NavMeshNode & | getNode (unsigned int i) const |
Returns a const reference to the ith node. More... | |
size_t | getEdgeCount () const |
Reports the number of edges in the navigation mesh. More... | |
NavMeshEdge & | getEdge (unsigned int i) |
Returns a reference to the ith edge. More... | |
const NavMeshEdge & | getEdge (unsigned int i) const |
Returns a const reference to the ith edge. More... | |
size_t | getObstacleCount () const |
Returns the number of obstacles connected to this node. More... | |
NavMeshObstacle & | getObstacle (unsigned int i) |
Returns a reference to the ith obstacle. More... | |
const NavMeshObstacle & | getObstacle (unsigned int i) const |
Returns a const reference to the ith obstacle. More... | |
Vector2 * | getVertices () |
Returns a pointer to the array of vertices. More... | |
const Vector2 * | getVertices () const |
Returns a const pointer to the array of vertices. More... | |
float | getElevation (unsigned int nodeID, const Vector2 &p) const |
Computes the elevation at a particular point based on the given node's geometry. More... | |
Vector2 | getGradient (unsigned int nodeID, const Vector2 &p) const |
Computes the gradient at a particular point based on the given node's geometry. More... | |
void | setVertexCount (size_t count) |
Allocates memory for the given number of vertices. All previous vertices will be deleted. More... | |
void | setVertex (unsigned int i, float x, float y) |
Sets the value of the ith vertex. More... | |
void | setNodeCount (size_t count) |
Allocates memory for the given number of nodes. All previous nodes will be deleted. More... | |
void | setEdgeCount (size_t count) |
Allocates memory for the given number of edges. All previous edges will be deleted. More... | |
void | setObstacleCount (size_t count) |
Allocates memory for the given number of obstacles. All previous obstacles will be delete.d. More... | |
bool | finalize () |
After initializing the navigation mesh's components this function needs to be called to make the mesh functional. | |
bool | addGroup (const std::string &grpName, size_t grpSize) |
Adds a group of polygons to the navigation mesh. More... | |
std::vector < Agents::ObstacleVertexList > | getObstacles () |
Gets the navigation mesh's obstacles for the simulator. More... | |
Public Member Functions inherited from Menge::Resource | |
Resource (const std::string &fileName) | |
Constructor. More... | |
void | destroy () |
This supplants the destructor. More... | |
const std::string & | getName () const |
Return the file name for this resource. More... | |
int | incRef () |
Increment references to the managed data. More... | |
int | decRef () |
Decrement references to the managed data. More... | |
bool | isUnreferenced () const |
Reports if the data is referenced. More... | |
Static Public Member Functions | |
static Resource * | load (const std::string &fileName) |
Parses a navigation mesh definition and returns a pointer to it. More... | |
Static Public Attributes | |
static const std::string | LABEL |
The unique label for this data type to be used with resource management. | |
Protected Member Functions | |
~NavMesh () | |
Destructor. | |
Protected Member Functions inherited from Menge::Resource | |
virtual | ~Resource () |
Virtual destructor. | |
Protected Attributes | |
size_t | _vCount |
The number of vertices. | |
Vector2 * | _vertices |
An array containing all vertices. | |
size_t | _nCount |
The number of nodes (aka polygons in the mesh). | |
NavMeshNode * | _nodes |
An array containing all nodes. | |
size_t | _eCount |
The number of edges (aka portals or shared edges between polygons). | |
NavMeshEdge * | _edges |
An array containing all edges. | |
size_t | _obstCount |
The number of obstacles in the scene. | |
NavMeshObstacle * | _obstacles |
An array of obstacles. | |
std::map< const std::string, NMNodeGroup > | _nodeGroups |
The mapping from node group name to an instance of a NMNodeGroup. | |
Protected Attributes inherited from Menge::Resource | |
const std::string | _fileName |
The file which contains the resource's data. | |
int | _refCount |
The number of data wrappers using this managed data. | |
SimpleLock | _lock |
Simple lock to handle reference counts safely. | |
Friends | |
class | NavMeshFactory |
class | PathPlanner |
The class for defining a navigation mesh. A decomposition of the free space into a connected mesh of convex (or near convex) polygons used for global planning in planar or non-planar environments.
It represents the minimum data required to do path planning. The navigation mesh is represented in 2.5D. The boundaries of mesh's polygons are only defined on the ground plane. The nodes themselves include a definition of the polygon's plane off the plane. Likewise, the vertices all lie on the plane.
Menge::NavMesh::NavMesh | ( | const std::string & | name | ) |
Constructor.
name | The name of the underlying navigation mesh. |
bool Menge::NavMesh::addGroup | ( | const std::string & | grpName, |
size_t | grpSize | ||
) |
Adds a group of polygons to the navigation mesh.
The group name must be unique from all other group names in the navigation mesh. The number of polygons in the group extends the number of reported nodes in the mesh (see NavMesh::getNodeCount). Even if the nodes are not yet defined at this point, they are allocated and considered viable.
grpName | The name of the group. |
grpSize | The number of nodes in the group. |
NavMeshEdge & Menge::NavMesh::getEdge | ( | unsigned int | i | ) |
Returns a reference to the ith edge.
i | The index of the desired edge. The validitity of the index is only tested in debug build. |
const NavMeshEdge & Menge::NavMesh::getEdge | ( | unsigned int | i | ) | const |
Returns a const reference to the ith edge.
i | The index of the desired edge. The validitity of the index is only tested in debug build. |
|
inline |
Reports the number of edges in the navigation mesh.
float Menge::NavMesh::getElevation | ( | unsigned int | nodeID, |
const Vector2 & | p | ||
) | const |
Computes the elevation at a particular point based on the given node's geometry.
nodeID | The node to use in computing elevation. |
p | The point to evaluate the elevation for. |
Computes the gradient at a particular point based on the given node's geometry.
nodeID | The node to use in computing gradient. |
p | The point to evaluate the gradient for. |
NavMeshNode & Menge::NavMesh::getNode | ( | unsigned int | i | ) |
Returns a reference to the ith node.
i | The index of the desired node. The validitity of the index is only tested in debug build. |
const NavMeshNode & Menge::NavMesh::getNode | ( | unsigned int | i | ) | const |
Returns a const reference to the ith node.
i | The index of the desired node. The validitity of the index is only tested in debug build. |
|
inline |
Reports the number of nodes in the navigation mesh.
NavMeshObstacle & Menge::NavMesh::getObstacle | ( | unsigned int | i | ) |
Returns a reference to the ith obstacle.
i | The index of the desired obstacle. The validity of the index is only tested in debug build. |
const NavMeshObstacle & Menge::NavMesh::getObstacle | ( | unsigned int | i | ) | const |
Returns a const reference to the ith obstacle.
i | The index of the desired obstacle. The validity of the index is only tested in debug build. |
|
inline |
Returns the number of obstacles connected to this node.
std::vector< Agents::ObstacleVertexList > Menge::NavMesh::getObstacles | ( | ) |
Gets the navigation mesh's obstacles for the simulator.
|
inline |
Reports the number of vertices in the navigation mesh.
|
inline |
Returns a pointer to the array of vertices.
|
inline |
Returns a const pointer to the array of vertices.
|
static |
Parses a navigation mesh definition and returns a pointer to it.
This function works in conjunction with the ResourceManager. That is why it returns a pointer, not to a NavMesh, but to a Resource. The ResourceManager uses it to load and instantiate VectorField instances.
fileName | The path to the file containing the NavMesh definition. |
void Menge::NavMesh::setEdgeCount | ( | size_t | count | ) |
Allocates memory for the given number of edges. All previous edges will be deleted.
count | The number of edges. |
void Menge::NavMesh::setNodeCount | ( | size_t | count | ) |
Allocates memory for the given number of nodes. All previous nodes will be deleted.
count | The number of nodes. |
void Menge::NavMesh::setObstacleCount | ( | size_t | count | ) |
Allocates memory for the given number of obstacles. All previous obstacles will be delete.d.
count | The number of obstacles. |
void Menge::NavMesh::setVertex | ( | unsigned int | i, |
float | x, | ||
float | y | ||
) |
Sets the value of the ith vertex.
i | The index of the vertex. Validity of the index is only tested in the debug build. |
x | The x-value of the vertex. |
y | The y-value of the vertex. |
void Menge::NavMesh::setVertexCount | ( | size_t | count | ) |
Allocates memory for the given number of vertices. All previous vertices will be deleted.
count | The number of vertices. |