Menge Plugin Examples
A Collection of Example Plugins for the Menge Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
VelModHeightField.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 
43 #ifndef __VELMOD_HEIGHT_FIELD_H__
44 #define __VELMOD_HEIGHT_FIELD_H__
45 
46 // Resources
47 #include "HeightField.h"
48 
49 // Menge Base
52 
53 //forward declarations
54 class TiXmlElement;
55 
56 namespace Menge {
57  namespace Agents {
58  class BaseAgent;
59  }
60 }
61 
62 using namespace Menge;
63 
64 namespace Terrain {
65 
66  //forward declare Factory
67  class HeightFieldModifierFactory;
68 
86  class EXPORT_API HeightFieldModifier : public BFSM::VelModifier {
87  public:
88 
93 
100 
106  void setHeightField( HeightFieldPtr hfPtr ) { _field = hfPtr; }
107 
113  BFSM::VelModifier* copy() const;
114 
122  void adaptPrefVelocity(const Agents::BaseAgent * agent, Agents::PrefVelocity & pVel );
123 
124  /*
125  * identify the factory helper
126  */
127  friend class HeightFieldModifierFactory;
128 
129  protected:
130 
135 
139  float _turnWeight;
140 
145 
150 
151  };
152 
153 
155 
159  class EXPORT_API HeightFieldModifierFactory : public BFSM::VelModFactory {
160  public:
167 
176  virtual const char * name() const { return "height_field"; }
177 
185  virtual const char * description() const {
186  return "Pushes the agent's preferred velocity away from the gradient of a height field";
187  };
188 
189  protected:
200  BFSM::VelModifier * instance() const { return new HeightFieldModifier(); }
201 
220  virtual bool setFromXML( BFSM::VelModifier * modifier, TiXmlElement * node, const std::string & behaveFldr ) const;
221 
225  size_t _fileNameID;
226 
230  size_t _turnID;
231 
235  size_t _uphillID;
236 
240  size_t _downhillID;
241 
242 
243 
244 
245  };
246 };
247 #endif
Definition of a height field based on a uniform discretization of space.
float _upHillScale
The uphill scale factor.
Definition: VelModHeightField.h:144
size_t _fileNameID
The identifier for the "file_name" string attribute.
Definition: VelModHeightField.h:225
size_t _downhillID
The identifier for the "down_hill_scale" float attribute.
Definition: VelModHeightField.h:240
virtual const char * description() const
A description of the modifier.
Definition: VelModHeightField.h:185
virtual const char * name() const
The name of the modifier.
Definition: VelModHeightField.h:176
size_t _turnID
The identifier for the "dir_weight" float attribute.
Definition: VelModHeightField.h:230
void setHeightField(HeightFieldPtr hfPtr)
Sets the height field for this velocity modifier object to use.
Definition: VelModHeightField.h:106
HeightFieldPtr _field
The height field used to query elevation and gradient.
Definition: VelModHeightField.h:134
size_t _uphillID
The identifier for the "up_hill_scale" float attribute.
Definition: VelModHeightField.h:235
Factory for the HeightFieldModifier.
Definition: VelModHeightField.h:159
BFSM::VelModifier * instance() const
Create an instance of this class's modifier.
Definition: VelModHeightField.h:200
float _turnWeight
The weighting factor for how the gradient effects direction.
Definition: VelModHeightField.h:139
float _downHillScale
The downhill scale factor.
Definition: VelModHeightField.h:149
Modify the preferred velocity based on a height field.
Definition: VelModHeightField.h:86
The namespace containing the height field resource and Menge elements which use the height field...
Definition: ElevationHeightField.cpp:44