Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GoalAABB.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 
44 #ifndef __GOAL_AABB_H__
45 #define __GOAL_AABB_H__
46 
47 #include "CoreConfig.h"
48 #include "fsmCommon.h"
49 #include "Goals/Goal.h"
50 #include "Goals/GoalFactory.h"
51 
52 namespace Menge {
53 
54  namespace BFSM {
58  class MENGE_API AABBGoal : public Goal {
59  public:
63  AABBGoal();
64 
71  virtual float squaredDistance( const Vector2 & pt ) const;
72 
86  virtual void setDirections( const Vector2 & q, float r, Agents::PrefVelocity & directions ) const;
87 
103  virtual Vector2 getTargetPoint( const Vector2 & q, float r ) const;
104 
108  virtual Vector2 getCentroid() const;
109 
116  inline void setMinimum( float x, float y ) { _minPt.set( x, y ); }
117 
123  inline void setMinimum( const Vector2 & p ) { _minPt.set( p ); }
124 
131  inline void setMaximum( float x, float y ) { _size.set( Vector2( x, y ) - _minPt ); }
132 
138  inline void setMaximum( const Vector2 & p ) { _size.set( p - _minPt ); }
139 
146  inline void setSize( float w, float h ) { _size.set( w, h ); }
147 
153  inline void setSize( const Vector2 & size ) { _size.set( size ); }
154 
155  protected:
159  virtual void drawGLGeometry() const;
160 
165 
170  };
171 
175  class MENGE_API AABBGoalFactory : public GoalFactory {
176  public:
180  AABBGoalFactory();
181 
190  virtual const char * name() const { return "AABB"; }
191 
199  virtual const char * description() const {
200  return "An agent goal consisting of an axis-aligned bounding box in two-dimensional space";
201  };
202 
203  protected:
209  Goal * instance() const { return new AABBGoal(); }
210 
223  virtual bool setFromXML( Goal * goal, TiXmlElement * node, const std::string & behaveFldr ) const;
224 
228  size_t _minXID;
229 
233  size_t _minYID;
234 
238  size_t _maxXID;
239 
243  size_t _maxYID;
244  };
245  } // namespace BFSM
246 } // namespace Menge
247 #endif // __GOAL_AABB_H__
size_t _maxYID
The identifier for the "max_y" float attribute.
Definition: GoalAABB.h:243
void setMaximum(float x, float y)
Set the AABB's maximum point.
Definition: GoalAABB.h:131
A class for parsing the xml description of a goal and instantiating particular instances.
Definition: GoalFactory.h:62
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
Sets up the proper compiler directives for platform and dll export/import.
virtual const char * name() const
The name of the goal type.
Definition: GoalAABB.h:190
void setSize(const Vector2 &size)
Set the AABB's size.
Definition: GoalAABB.h:153
Vector2 _minPt
The minimum point in the box region.
Definition: GoalAABB.h:164
Defines the goal classes for agent behaviors.
The base, abstract class defining goals.
Definition: Goal.h:110
Vector2 _size
The size of the box region beyond the minimum point.
Definition: GoalAABB.h:169
virtual const char * description() const
A description of the goal.
Definition: GoalAABB.h:199
size_t _minXID
The identifier for the "min_x" float attribute.
Definition: GoalAABB.h:228
Goal * instance() const
Create an instance of this class's goal.
Definition: GoalAABB.h:209
void setMaximum(const Vector2 &p)
Set the AABB's maximum point.
Definition: GoalAABB.h:138
void setSize(float w, float h)
Set the AABB's size.
Definition: GoalAABB.h:146
A axis-aligned bounding box goal region with uniform probability.
Definition: GoalAABB.h:58
The namespace contains the Behavior Finite State Machine (BFSM) definition.
Collection of convenient pre-compiler information for fsm definitions.
void setMinimum(const Vector2 &p)
Set the AABB's minimum point.
Definition: GoalAABB.h:123
The definition of a preferred velocity.
Definition: PrefVelocity.h:68
void setMinimum(float x, float y)
Set the AABB's minimum point.
Definition: GoalAABB.h:116
size_t _maxXID
The identifier for the "max_x" float attribute.
Definition: GoalAABB.h:238
Factory for the AABBGoal.
Definition: GoalAABB.h:175
size_t _minYID
The identifier for the "min_y" float attribute.
Definition: GoalAABB.h:233
The factory for parsing xml data and instantiating goals.