Menge Plugin Examples
A Collection of Example Plugins for the Menge Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
HeightField.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 __HEIGHTFIELD_H__
40 #define __HEIGHTFIELD_H__
41 
47 #include "TerrainConfig.h"
48 #include "Resource.h"
49 #include "graphCommon.h"
50 #include <string>
51 
52 using namespace Menge;
53 
54 namespace Terrain {
59  class EXPORT_API HeightField : public Resource {
60  public:
66  HeightField( const std::string & fileName );
67 
68  protected:
72  ~HeightField();
73 
74  public:
91  bool initialize( const std::string & imgName, float cellSize, float vertScale, float xpos, float zpos, float smoothParam=0.f );
92 
98  virtual const std::string & getLabel() const { return LABEL; }
99 
112  static Resource * load( const std::string & fileName );
113 
118  void computeNormals();
119 
129  float getHeightAt( float x, float y ) const;
130 
140  Vector3 getNormalAt( float x, float y ) const;
141 
150  float getHeightAtCell( int x, int y ) const;
151 
160  Vector3 getNormalAtCell( int x, int y ) const;
161 
167  int getW() const { return _W; }
168 
174  int getH() const { return _H; }
175 
181  float getCellSize() const { return _cellSize; }
182 
188  float getCornerX() const { return _xpos; }
189 
195  float getCornerY() const { return _ypos; }
196 
201  static const std::string LABEL;
202 
203  protected:
210  void smoothElevation( float smooth );
211 
215  float _cellSize;
216 
220  int _W;
221 
225  int _H;
226 
230  float **_heightMap;
231 
235  Vector3 **_normalMap;
236 
240  float _xpos;
241 
245  float _ypos;
246  };
247 
252 
260 HeightFieldPtr loadHeightField( const std::string & fileName ) throw ( ResourceException );
261 } // namespace Terrain
262 #endif
float _xpos
The x-position of the minimum corner of the heightfield.
Definition: HeightField.h:240
Configures the shared library aspect of the includes.
int _H
The number of cells in the height (z) direction.
Definition: HeightField.h:225
float getCellSize() const
Returns the cellSize of the height field.
Definition: HeightField.h:181
int getH() const
Return the number of cells in the height direction of the field.
Definition: HeightField.h:174
HeightFieldPtr loadHeightField(const std::string &fileName)
Loads the height field of the given name.
Definition: HeightField.cpp:416
ResourcePtr< HeightField > HeightFieldPtr
The definition of the managed pointer for HeightField data.
Definition: HeightField.h:251
Vector3 ** _normalMap
The data for the normals of the height field.
Definition: HeightField.h:235
float _ypos
The y-position of the minimum corner of the heightfield.
Definition: HeightField.h:245
static const std::string LABEL
The unique label for this data type to be used with resource management.
Definition: HeightField.h:201
int _W
The number of cells in the width (x) direction.
Definition: HeightField.h:220
float ** _heightMap
The data for the height field.
Definition: HeightField.h:230
float getCornerY() const
Returns the y-position of the mininum corner of the grid.
Definition: HeightField.h:195
float getCornerX() const
Returns the x-position of the mininum corner of the grid.
Definition: HeightField.h:188
float _cellSize
The size of a cell in the heightfield (in world coordinates)
Definition: HeightField.h:215
int getW() const
Return the number of cells in the width direction of the field.
Definition: HeightField.h:167
A heightfield. A uniform discretization of space which supports queries on height and normal of field...
Definition: HeightField.h:59
virtual const std::string & getLabel() const
Returns a unique resource label to be used to identify different resource types which use the same un...
Definition: HeightField.h:98
The namespace containing the height field resource and Menge elements which use the height field...
Definition: ElevationHeightField.cpp:44