Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PortalPath.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 
39 #ifndef __PORTAL_PATH_H__
40 #define __PORTAL_PATH_H__
41 
49 #include "mengeCommon.h"
50 #include "Route.h"
51 #include "NavMesh.h"
52 #include "Goals/Goal.h"
53 
54 
55 namespace Menge {
56 
57  // Forward Declaration
58  class NavMeshLocalizer;
59  class PathPlanner;
60  namespace Agents {
61  class BaseAgent;
62  }
63 
70  class PortalPath {
71  public:
80  PortalPath( const Vector2 & startPos, const BFSM::Goal * goal, const PortalRoute * route, float agentRadius );
81 
85  ~PortalPath();
86 
96  void setPreferredDirection( const Agents::BaseAgent * agent, float headingCos, Agents::PrefVelocity & pVel );
97 
107  unsigned int updateLocation( const Agents::BaseAgent * agent, const NavMeshPtr & navMesh, const NavMeshLocalizer * localizer, PathPlanner * planner );
108 
115  unsigned int getNode() const;
116 
122  inline size_t getWayPointCount() const { return _route->getPortalCount(); }
123 
130  Vector2 getWayPoint( size_t i ) const;
131 
137  inline const BFSM::Goal * getGoal() const { return _goal; }
138 
144  inline Vector2 getGoalCentroid() const { return _goal->getCentroid(); }
145 
151  inline unsigned int getEndNode() const { return _route->getEndNode(); }
152 
160  unsigned int getNode( size_t i ) const;
161 
168  inline size_t getCurrentPortal() const { return _currPortal; }
169 
175  inline size_t getPortalCount() const { return _route->getPortalCount(); }
176 
183  inline const WayPortal * getPortal( size_t i ) const { return _route->getPortal( i ); }
184 
195  void setWaypoints( size_t start, size_t end, const Vector2 & p0, const Vector2 & dir );
196 
197  protected:
202 
206  const BFSM::Goal * _goal;
207 
212  size_t _currPortal;
213 
220  void computeCrossing( const Vector2 & startPos, float agentRadius );
221 
226 
231 
242  void replan( const Vector2 & startPos, unsigned int startNode, unsigned int endNode, float minWidth, PathPlanner * planner );
243  };
244 } // namespace Menge
245 #endif // __PORTAL_PATH_H__
Class responsible for tracking agent relatinoships to the navigation mesh: its current location and i...
Definition: NavMeshLocalizer.h:186
void setPreferredDirection(const Agents::BaseAgent *agent, float headingCos, Agents::PrefVelocity &pVel)
Sets the directions in the preferred velocity from the path.
Definition: PortalPath.cpp:69
const PortalRoute * _route
The route to follow.
Definition: PortalPath.h:201
The basic structure defining a way "point" along a path through a navigation mesh. It consists of the navigation mesh edge to pass through and the node one should be in while heading to the edge.
Definition: WayPortal.h:64
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
Vector2 * _headings
The original direction to the way point.
Definition: PortalPath.h:230
unsigned int updateLocation(const Agents::BaseAgent *agent, const NavMeshPtr &navMesh, const NavMeshLocalizer *localizer, PathPlanner *planner)
Updates the location of the agent relative to the nav mesh.
Definition: PortalPath.cpp:141
Defines the goal classes for agent behaviors.
The base, abstract class defining goals.
Definition: Goal.h:110
void replan(const Vector2 &startPos, unsigned int startNode, unsigned int endNode, float minWidth, PathPlanner *planner)
Something has changed and the path has to replan.
Definition: PortalPath.cpp:302
virtual Vector2 getCentroid() const =0
Return the centroid of the goal.
size_t _currPortal
The index of the way portal currently serving as immediate goal. -1 means it's at the end...
Definition: PortalPath.h:212
Vector2 getGoalCentroid() const
Returns the centroid of the goal.
Definition: PortalPath.h:144
const WayPortal * getPortal(size_t i) const
Returns the ith portal.
Definition: PortalPath.h:183
The definition of a basic route through a navigation mesh.
Class for computing paths through a navigation mesh.
Definition: PathPlanner.h:133
PortalPath(const Vector2 &startPos, const BFSM::Goal *goal, const PortalRoute *route, float agentRadius)
Constructor.
Definition: PortalPath.cpp:56
The definition of a route through a navigation mesh from a start to an end node.
Definition: Route.h:60
unsigned int getEndNode() const
Returns the identifier for the destination node on the path.
Definition: PortalPath.h:151
WayPortal * getPortal(size_t i)
Gets the ith portal.
Definition: Route.h:111
unsigned int getNode() const
Reports the node the agent is currently in.
Definition: PortalPath.cpp:278
size_t getPortalCount() const
Reports the number of portals in the path)
Definition: PortalPath.h:175
const BFSM::Goal * getGoal() const
Returns the goal.
Definition: PortalPath.h:137
Vector2 getWayPoint(size_t i) const
Returns the position of the ith way point.
Definition: PortalPath.cpp:317
const BFSM::Goal * _goal
The ultimate goal.
Definition: PortalPath.h:206
void setWaypoints(size_t start, size_t end, const Vector2 &p0, const Vector2 &dir)
Set the waypoints for all of the indicated way portals.
Definition: PortalPath.cpp:337
Vector2 * _waypoints
The sequence of way points. Some way points will be duplicated.
Definition: PortalPath.h:225
The definition of a preferred velocity.
Definition: PrefVelocity.h:68
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
The definition of a path through space comprising of a sequence of portals.
Definition: PortalPath.h:70
void computeCrossing(const Vector2 &startPos, float agentRadius)
Computes the crossing values for each portal.
Definition: PortalPath.cpp:288
~PortalPath()
Destructor.
Definition: PortalPath.cpp:62
Defines the classes which maintain the navigation mesh data.
The namespace that contains the basic simulation mechanisms.
size_t getCurrentPortal() const
Returns the index of the current portal (the portal the agent is currently headed towards...
Definition: PortalPath.h:168
size_t getPortalCount() const
Reports the number of portals on the route.
Definition: Route.h:94
size_t getWayPointCount() const
Reports the number of way points in the path (not including the goal)
Definition: PortalPath.h:122
unsigned int getEndNode() const
Returns the identifier for the destination node on the route.
Definition: Route.h:87