Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GoalOBB.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_OBB_H__
45 #define __GOAL_OBB_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 {
63  class MENGE_API OBBGoal : public Goal {
64  public:
68  OBBGoal();
69 
76  virtual float squaredDistance( const Vector2 & pt ) const;
77 
91  virtual void setDirections( const Vector2 & q, float r, Agents::PrefVelocity & directions ) const;
92 
108  virtual Vector2 getTargetPoint( const Vector2 & q, float r ) const;
109 
113  virtual Vector2 getCentroid() const;
114 
121  inline void setPivot( float x, float y ) { _pivot.set( x, y ); }
122 
128  inline void setPivot( const Vector2 & p ) { _pivot.set( p ); }
129 
136  inline void setSize( float w, float h ) { _size.set( w, h ); }
137 
143  inline void setSize( const Vector2 & size ) { _size.set( size ); }
144 
150  void setRotation( float angle );
151 
152  protected:
156  virtual void drawGLGeometry() const;
157 
162 
167 
174 
181  };
182 
186  class MENGE_API OBBGoalFactory : public GoalFactory {
187  public:
191  OBBGoalFactory();
192 
201  virtual const char * name() const { return "OBB"; }
202 
210  virtual const char * description() const {
211  return "An agent goal consisting of an oriented bounding box in two-dimensional space";
212  };
213 
214  protected:
220  Goal * instance() const { return new OBBGoal(); }
221 
234  virtual bool setFromXML( Goal * goal, TiXmlElement * node, const std::string & behaveFldr ) const;
235 
239  size_t _xID;
240 
244  size_t _yID;
245 
249  size_t _wID;
250 
254  size_t _hID;
255 
259  size_t _aID;
260  };
261  } // namespace BFSM
262 } // namespace Menge
263 
264 #endif // __GOAL_OBB_H__
virtual const char * description() const
A description of the goal.
Definition: GoalOBB.h:210
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.
void setSize(float w, float h)
Set the AABB's size.
Definition: GoalOBB.h:136
Vector2 _rot0
The first column of the rotation matrix A point, p, can be rotated to the box's orientation as: Vecto...
Definition: GoalOBB.h:173
Defines the goal classes for agent behaviors.
The base, abstract class defining goals.
Definition: Goal.h:110
Vector2 _rot1
The second column of the rotation matrix A point, p, can be rotated to the box's orientation as: Vect...
Definition: GoalOBB.h:180
virtual const char * name() const
The name of the goal type.
Definition: GoalOBB.h:201
size_t _yID
The identifier for the "y" float attribute.
Definition: GoalOBB.h:244
size_t _wID
The identifier for the "width" float attribute.
Definition: GoalOBB.h:249
Factory for the OBBGoal.
Definition: GoalOBB.h:186
Vector2 _size
The size of the box region beyond the minimum point.
Definition: GoalOBB.h:166
size_t _hID
The identifier for the "height" float attribute.
Definition: GoalOBB.h:254
void setPivot(const Vector2 &p)
Set the OBB's pivot point.
Definition: GoalOBB.h:128
The namespace contains the Behavior Finite State Machine (BFSM) definition.
Collection of convenient pre-compiler information for fsm definitions.
An oriented bounding box goal region with uniform probability.
Definition: GoalOBB.h:63
void setSize(const Vector2 &size)
Set the AABB's size.
Definition: GoalOBB.h:143
The definition of a preferred velocity.
Definition: PrefVelocity.h:68
void setPivot(float x, float y)
Set the OBB's pivot point.
Definition: GoalOBB.h:121
Goal * instance() const
Create an instance of this class's goal.
Definition: GoalOBB.h:220
size_t _aID
The identifier for the "angle" float attribute.
Definition: GoalOBB.h:259
size_t _xID
The identifier for the "x" float attribute.
Definition: GoalOBB.h:239
Vector2 _pivot
The minimum point in the box region.
Definition: GoalOBB.h:161
The factory for parsing xml data and instantiating goals.