i6engine  1.0
Terrain.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_TERRAIN_H__
26 #define __I6ENGINE_MODULES_TERRAIN_H__
27 
28 #include <cstdint>
29 #include <string>
30 #include <vector>
31 
33 
34 namespace Ogre {
35  class Image;
36  class Terrain;
37  class TerrainGroup;
38  class TerrainGlobalOptions;
39 } /* namespace Ogre */
40 
41 namespace i6e {
42 namespace modules {
43 
44  class GraphicsManager;
45 
53  public:
60  Terrain(GraphicsManager * manager, const std::string & heightmap, const double size, double inputScale, uint16_t vertices, const std::vector<std::tuple<double, std::string, std::string, double, double>> & layers, int64_t minX, int64_t minY, int64_t maxX, int64_t maxY);
61 
68  Terrain(GraphicsManager * manager, const std::vector<std::vector<double>> & heightdata, const double size, double inputScale, uint16_t vertices, const std::vector<std::tuple<double, std::string, std::string, double, double>> & layers, int64_t minX, int64_t minY, int64_t maxX, int64_t maxY);
69 
74  ~Terrain();
75 
79  void defineTerrainHeightmap(const int64_t x, const int64_t y);
80 
84  void defineTerrainHeightdata(const int64_t x, const int64_t y);
85 
90  void configureTerrainDefaults();
91 
96  void getTerrainImage(const bool flipX, const bool flipY, Ogre::Image & img);
97 
98  void initBlendMaps(Ogre::Terrain * terrain);
99 
104  inline Ogre::TerrainGroup * getTerrainGroup() const { return _mTerrainGroup; }
105 
110  inline Ogre::TerrainGlobalOptions * getTerrainGlobalOptions() const { return _mTerrainGlobals; }
111 
115  void setHeightAtPosition(uint64_t x, uint64_t z, double height);
116 
120  void saveCollisionShape(const std::string & outFile);
121 
122  bool isDirty() const {
123  return _dirty;
124  }
125 
126  void update();
127 
128  private:
132  GraphicsManager * _manager;
133 
137  Ogre::TerrainGroup * _mTerrainGroup;
138 
142  Ogre::TerrainGlobalOptions * _mTerrainGlobals;
143 
147  bool _mTerrainsImported;
148 
152  std::string _heightmap;
153 
157  std::vector<std::vector<double>> _heightdata;
158 
162  double _size;
163 
164  double _inputScale;
165 
166  uint16_t _vertices;
167 
168  std::vector<std::tuple<double, std::string, std::string, double, double>> _layers;
169 
170  int64_t _minX;
171  int64_t _maxX;
172  int64_t _minY;
173  int64_t _maxY;
174 
175  bool _dirty;
176 
180  Terrain(const Terrain &) = delete;
181 
185  const Terrain & operator=(const Terrain &) = delete;
186 
188  };
189 
190 } /* namespace modules */
191 } /* namespace i6e */
192 
193 #endif /* __I6ENGINE_MODULES_TERRAIN_H__ */
194 
#define ISIXE_MODULES_API
#define ASSERT_THREAD_SAFETY_HEADER
Ogre::TerrainGroup * getTerrainGroup() const
Returns a pointer to the TerrainGroup of the graphics library Returns a pointer to the TerrainGroup o...
Definition: Terrain.h:104
Saves all Terrain-specific things.
Definition: Terrain.h:52
Ogre::TerrainGlobalOptions * getTerrainGlobalOptions() const
Returns a pointer to the TerrainGlobalsOptions of the graphics library Returns a pointer to the Terra...
Definition: Terrain.h:110
bool isDirty() const
Definition: Terrain.h:122