vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TerrainProperties.h
Go to the documentation of this file.
1 
11 #ifndef VRECKO_NATURE_TERRAIN_TERRAINPROPERTIES_H
12 #define VRECKO_NATURE_TERRAIN_TERRAINPROPERTIES_H
13 
14 #include <vrecko/ReaderWriter.h>
15 #include <osg/Vec2>
16 
17 #include "Enumerations.h"
18 
19 namespace APNature
20 {
21  static class TerrainProperties
22  {
23  protected:
24 
25  // Common attributes
26  // =================
27  static TerrainAlignment _alignmentX, _alignmentY;
28 
29  static osg::Vec2f _fieldSize;
30  static float _heightMin, _heightMax;
31 
32  static int _segmentSize;
33  static int _resolutionX, _resolutionY;
34 
35  static DataSourceType _dataSourceType;
36 
37  public:
38 
39  // Common methods
40  // ##############
41 
45  static inline TerrainAlignment AlignmentX() { return _alignmentX; }
46  static inline void AlignmentX(TerrainAlignment alignmentX) { _alignmentX = alignmentX; }
47 
51  static inline TerrainAlignment AlignmentY() { return _alignmentY; }
52  static inline void AlignmentY(TerrainAlignment alignmentY) { _alignmentY = alignmentY; }
53 
57  static inline osg::Vec2f FieldSize() { return _fieldSize; }
58  static void FieldSize(osg::Vec2f fieldSize);
59 
67  static void HeightRange(float heightMin, float heightMax);
68 
69  static inline float HeightMin() { return _heightMin; }
70  static inline float HeightMax() { return _heightMax; }
71 
77  static inline int SegmentSize() { return _segmentSize; }
78  static inline void SegmentSize(int segmentSize) { _segmentSize = (segmentSize >= 2 ? segmentSize : 2); }
79 
83  static inline int ResolutionX() { return _resolutionX; }
84  static inline void ResolutionX(int resolutionX) { _resolutionX = (resolutionX >= 1 ? resolutionX : 1); }
85 
89  static inline int ResolutionY() { return _resolutionY; }
90  static inline void ResolutionY(int resolutionY) { _resolutionY = (resolutionY >= 1 ? resolutionY : 1); }
91 
92  // DataSource-related methods
93  // ##########################
94 
98  static inline DataSourceType SourceType() { return _dataSourceType; }
99  static inline void SourceType(DataSourceType dataSourceType) { _dataSourceType = dataSourceType; }
100 
101 
102  // Derived properties
103  // ##################
104 
108  static inline int VerticesX() { return _segmentSize * _resolutionX; }
112  static inline int VerticesY() { return _segmentSize * _resolutionY; }
113 
117  static inline float SizeX() { return (VerticesX() - 1) * _fieldSize.x(); }
121  static inline float SizeY() { return (VerticesY() - 1) * _fieldSize.y(); }
122 
123 
124  // Methods
125  // #######
126 
131  static void LoadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node);
132 
137  static void LoadDataSourceNodeParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *parameters);
138 
139  protected:
140 
146  static TerrainAlignment ParseAlignmentString(const std::string& input);
147 
148  } TerrainProperties;
149 
150 }
151 
152 #endif