Heightmap.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_RENDERING_HEIGHTMAP_HH_
18 #define _GAZEBO_RENDERING_HEIGHTMAP_HH_
19 
20 #include <vector>
21 #include <string>
22 
23 #include <ignition/math/Vector3.hh>
24 #include <ignition/math/Vector2.hh>
25 
26 #include "gazebo/msgs/MessageTypes.hh"
30 #include "gazebo/util/system.hh"
31 
32 namespace boost
33 {
34  namespace filesystem
35  {
36  class path;
37  }
38 }
39 
40 namespace Ogre
41 {
42  class TerrainGroup;
43  class Terrain;
44 }
45 
46 namespace gazebo
47 {
48  namespace math
49  {
50  class Vector2i;
51  }
52 
53  namespace common
54  {
55  class Image;
56  }
57 
58  namespace rendering
59  {
60  // Forward declare private data.
61  class HeightmapPrivate;
62 
65 
68  class GZ_RENDERING_VISIBLE Heightmap
69  {
72  public: Heightmap(ScenePtr _scene);
73 
75  public: virtual ~Heightmap();
76 
78  public: void Load();
79 
82  public: void LoadFromMsg(ConstVisualPtr &_msg);
83 
90  public: double GetHeight(double _x, double _y, double _z = 1000)
91  GAZEBO_DEPRECATED(7.0);
92 
98  public: double Height(const double _x, const double _y,
99  const double _z = 1000) const;
100 
111  public: bool Flatten(CameraPtr _camera, math::Vector2i _mousePos,
112  double _outsideRadius, double _insideRadius,
113  double _weight = 0.1) GAZEBO_DEPRECATED(7.0);
114 
124  public: bool Flatten(CameraPtr _camera,
125  const ignition::math::Vector2i &_mousePos,
126  const double _outsideRadius,
127  const double _insideRadius,
128  const double _weight = 0.1);
129 
140  public: bool Smooth(CameraPtr _camera, math::Vector2i _mousePos,
141  double _outsideRadius, double _insideRadius,
142  double _weight = 0.1) GAZEBO_DEPRECATED(7.0);
143 
153  public: bool Smooth(CameraPtr _camera,
154  const ignition::math::Vector2i &_mousePos,
155  const double _outsideRadius,
156  const double _insideRadius,
157  const double _weight = 0.1);
158 
169  public: bool Raise(CameraPtr _camera, math::Vector2i _mousePos,
170  double _outsideRadius, double _insideRadius,
171  double _weight = 0.1) GAZEBO_DEPRECATED(7.0);
172 
182  public: bool Raise(CameraPtr _camera,
183  const ignition::math::Vector2i &_mousePos,
184  const double _outsideRadius,
185  const double _insideRadius,
186  const double _weight = 0.1);
187 
198  public: bool Lower(CameraPtr _camera, math::Vector2i _mousePos,
199  double _outsideRadius, double _insideRadius,
200  double _weight = 0.1) GAZEBO_DEPRECATED(7.0);
201 
211  public: bool Lower(CameraPtr _camera,
212  const ignition::math::Vector2i &_mousePos,
213  const double _outsideRadius,
214  const double _insideRadius,
215  const double _weight = 0.1);
216 
221  public: double GetAvgHeight(Ogre::Vector3 _pos, double _brushSize)
222  GAZEBO_DEPRECATED(7.0);
223 
227  public: double AvgHeight(const ignition::math::Vector3d &_pos,
228  const double _brushSize) const;
229 
232  public: void SetWireframe(const bool _show);
233 
237  public: Ogre::TerrainGroup *GetOgreTerrain() const GAZEBO_DEPRECATED(7.0);
238 
241  public: Ogre::TerrainGroup *OgreTerrain() const;
242 
246  public: common::Image GetImage() const GAZEBO_DEPRECATED(7.0);
247 
250  public: common::Image Image() const;
251 
258  public: Ogre::TerrainGroup::RayResult GetMouseHit(CameraPtr _camera,
259  math::Vector2i _mousePos) GAZEBO_DEPRECATED(7.0);
260 
266  public: Ogre::TerrainGroup::RayResult MouseHit(CameraPtr _camera,
267  const ignition::math::Vector2i &_mousePos) const;
268 
273  public: void SplitHeights(const std::vector<float> &_heightmap,
274  const int _n, std::vector<std::vector<float> > &_v);
275 
280  public: unsigned int GetTerrainSubdivisionCount() const
281  GAZEBO_DEPRECATED(7.0);
282 
286  public: unsigned int TerrainSubdivisionCount() const;
287 
295  private: void ModifyTerrain(Ogre::Vector3 _pos,
296  const double _outsideRadius, const double _insideRadius,
297  const double _weight, const std::string &_op);
298 
301  private: bool InitBlendMaps(Ogre::Terrain *_terrain);
302 
304  private: void ConfigureTerrainDefaults();
305 
309  private: void DefineTerrain(const int _x, const int _y);
310 
313  private: void SetupShadows(const bool _enabled);
314 
322  private: void UpdateTerrainHash(const std::string &_hash,
323  const boost::filesystem::path &_terrainDir);
324 
331  private: bool PrepareTerrainPaging(
332  const boost::filesystem::path &_terrainDirPath);
333 
336  private: std::unique_ptr<HeightmapPrivate> dataPtr;
337  };
339  }
340 }
341 #endif
Definition: JointMaker.hh:46
Forward declarations for the common classes.
Definition: Animation.hh:33
Generic integer x, y vector.
Definition: Vector2i.hh:36
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:48
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:80
Rendering a terrain using heightmap information.
Definition: Heightmap.hh:68
Definition: JointMaker.hh:41
Encapsulates an image.
Definition: Image.hh:74
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:88