Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre/OgreHeightmap.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 
18 #ifndef GZ_RENDERING_OGRE_OGREHEIGHTMAP_HH_
19 #define GZ_RENDERING_OGRE_OGREHEIGHTMAP_HH_
20 
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
28 
29 // Ignoring warning: "non dll-interface class
30 // 'gz::rendering::v5::Heightmap' used as base for dll-interface class"
31 // because `Heightmap` and `BaseHeightmap` are header-only
32 #ifdef _MSC_VER
33  #pragma warning(push)
34  #pragma warning(disable:4275)
35 #endif
36 
37 namespace gz
38 {
39  namespace rendering
40  {
41  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
42  //
43  // Forward declaration
44  class OgreHeightmapPrivate;
45 
47  class GZ_RENDERING_OGRE_VISIBLE OgreHeightmap
48  : public BaseHeightmap<OgreGeometry>
49  {
51  protected: explicit OgreHeightmap(const HeightmapDescriptor &_desc);
52 
54  public: virtual ~OgreHeightmap();
55 
56  // Documentation inherited.
57  public: virtual void Init() override;
58 
59  // Documentation inherited.
60  public: virtual void PreRender() override;
61 
64  public: virtual Ogre::MovableObject *OgreObject() const override;
65 
69  public: virtual MaterialPtr Material() const override;
70 
75  public: virtual void SetMaterial(MaterialPtr _material, bool _unique)
76  override;
77 
80  private: void ConfigureTerrainDefaults();
81 
87  private: bool PrepareTerrain(const std::string &_terrainDirPath);
88 
96  private: void UpdateTerrainHash(const std::string &_hash,
97  const std::string &_terrainDir);
98 
103  private: void SplitHeights(const std::vector<float> &_heightmap,
104  int _n, std::vector<std::vector<float>> &_v);
105 
109  private: void DefineTerrain(int _x, int _y);
110 
115  private: void CreateMaterial();
116 
119  private: bool InitBlendMaps(Ogre::Terrain *_terrain);
120 
123  private: void SetupShadows(bool _enabled);
124 
126  private: friend class OgreScene;
127 
129  private: std::unique_ptr<OgreHeightmapPrivate> dataPtr;
130  };
131  }
132  }
133 }
134 #ifdef _MSC_VER
135  #pragma warning(pop)
136 #endif
137 
138 #endif