All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Heightmap.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
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 /* Desc: Heightmap geometry
18  * Author: Nate Koenig
19  * Date: 12 May 2009
20  */
21 
22 #ifndef _HEIGHTMAP_HH_
23 #define _HEIGHTMAP_HH_
24 
25 #include <string>
26 #include <vector>
27 
28 #include "common/Image.hh"
29 #include "math/Vector3.hh"
30 #include "math/Vector2d.hh"
31 #include "rendering/Scene.hh"
32 
33 namespace Ogre
34 {
35  class TerrainGlobalOptions;
36  class TerrainGroup;
37  class Terrain;
38 }
39 
40 namespace gazebo
41 {
42  namespace rendering
43  {
46 
49  class Heightmap
50  {
53  public: Heightmap(ScenePtr _scene);
54 
56  public: virtual ~Heightmap();
57 
59  public: void Load();
60 
63  public: void LoadFromMsg(ConstVisualPtr &_msg);
64 
70  public: double GetHeight(double _x, double _y, double _z = 1000);
71 
74  private: bool InitBlendMaps(Ogre::Terrain *_terrain);
75 
77  private: void ConfigureTerrainDefaults();
78 
82  private: void DefineTerrain(int _x, int _y);
83 
85  private: ScenePtr scene;
86 
88  private: common::Image heightImage;
89 
91  private: math::Vector3 terrainSize;
92 
94  private: unsigned int imageSize;
95 
97  private: double maxPixel;
98 
100  private: math::Vector3 terrainOrigin;
101 
103  private: Ogre::TerrainGlobalOptions *terrainGlobals;
104 
106  private: Ogre::TerrainGroup *terrainGroup;
107 
109  private: bool terrainsImported;
110 
112  private: std::vector<std::string> diffuseTextures;
113 
115  private: std::vector<std::string> normalTextures;
116 
118  private: std::vector<double> worldSizes;
119 
121  private: std::vector<double> blendHeight;
122 
124  private: std::vector<double> blendFade;
125  };
127  }
128 }
129 #endif