Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ElevationNavMesh.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
47 #ifndef __ELEVATION_NAV_MESH_H__
48 #define __ELEVATION_NAV_MESH_H__
49 
50 // Resources
51 #include "NavMesh.h"
52 #include "NavMeshLocalizer.h"
53 
54 // Menge Base
55 #include "mengeCommon.h"
56 #include "Elevations/Elevation.h"
58 
59 // STL
60 #include <string>
61 
62 namespace Menge {
63 
64  // forward declaration
65  namespace BFSM {
66  class Task;
67  }
68 
69  namespace Agents {
70 
74  class MENGE_API NavMeshElevation : public Elevation {
75  public:
81 
89  virtual float getElevation( const Vector2 & point ) const;
90 
97  virtual float getElevation( const BaseAgent * agent ) const;
98 
106  virtual Vector2 getGradient( const Vector2 & point ) const;
107 
114  virtual Vector2 getGradient( const BaseAgent * agent ) const;
115 
121  void setNavMesh( const NavMeshPtr & nm ) { _navMesh = nm; }
122 
128  void setNavMeshLocalizer( const NavMeshLocalizerPtr & nml ) { _localizer = nml; }
129 
137  virtual BFSM::Task * getTask();
138 
139  protected:
144 
150  };
151 
153 
157  class MENGE_API NavMeshElevationFactory : public ElevationFactory {
158  public:
163 
172  virtual const char * name() const { return "nav_mesh"; }
173 
181  virtual const char * description() const {
182  return "Provides elevation based on location on a navigation mesh.";
183  };
184 
185  protected:
196  Elevation * instance() const { return new NavMeshElevation(); }
197 
216  virtual bool setFromXML( Elevation * e, TiXmlElement * node, const std::string & specFldr ) const;
217 
221  size_t _fileNameID;
222  };
223  } // namespace Agents
224 } // namespace Menge
225 #endif // __ELEVATION_NAV_MESH_H__
226 
Factory for the NavMeshElevation.
Definition: ElevationNavMesh.h:157
virtual const char * name() const
The name of the elevation.
Definition: ElevationNavMesh.h:172
size_t _fileNameID
The identifier for the "file_name" string attribute.
Definition: ElevationNavMesh.h:221
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
NavMeshLocalizerPtr _localizer
The localizer for identifying where the agents are in the navigation mesh.
Definition: ElevationNavMesh.h:149
Data structure responsible for knowing where on the navigation mesh each agent is located...
void setNavMesh(const NavMeshPtr &nm)
Sets the navigation mesh pointer.
Definition: ElevationNavMesh.h:121
NavMeshPtr _navMesh
The navigation mesh used to query elevation and gradient.
Definition: ElevationNavMesh.h:143
A class for parsing the xml description of an action and instantiating particular instances...
Definition: ElevationFactory.h:59
Elevation * instance() const
Create an instance of this class's elevation implementation.
Definition: ElevationNavMesh.h:196
The definition of the elevation element. This approximately allows for agents to be simulated on non-...
The namespace contains the Behavior Finite State Machine (BFSM) definition.
virtual const char * description() const
A description of the elevation.
Definition: ElevationNavMesh.h:181
The base class for determining an agent's elevation.
Definition: Elevation.h:107
void setNavMeshLocalizer(const NavMeshLocalizerPtr &nml)
Sets the navigation mesh localizer pointer.
Definition: ElevationNavMesh.h:128
Interface for basic FSM task.
Definition: Task.h:110
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
Elevation definition based on a navigation mesh.
Definition: ElevationNavMesh.h:74
The factory for parsing xml data and instantiating elevation implementations.
Defines the classes which maintain the navigation mesh data.
The namespace that contains the basic simulation mechanisms.