##

Heightmap.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_RENDERING_HEIGHTMAP_HH_
#define GAZEBO_RENDERING_HEIGHTMAP_HH_
#include <vector>
#include <string>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/msgs/MessageTypes.hh"
#include "gazebo/rendering/RenderTypes.hh"
#include "gazebo/rendering/ogre_gazebo.h"
#include "gazebo/util/system.hh"
namespace boost
{
namespace filesystem
{
class path;
}
}
namespace Ogre
{
class TerrainGroup;
class Terrain;
}
namespace gazebo
{
namespace common
{
class Image;
}
namespace rendering
{
// Forward declare private data.
class HeightmapPrivate;
class GZ_RENDERING_VISIBLE Heightmap
{
public: explicit Heightmap(ScenePtr _scene);
public: virtual ~Heightmap();
public: void Load();
public: void LoadFromMsg(ConstVisualPtr &_msg);
public: double Height(const double _x, const double _y,
const double _z = 1000) const;
public: bool Flatten(CameraPtr _camera,
const ignition::math::Vector2i &_mousePos,
const double _outsideRadius,
const double _insideRadius,
const double _weight = 0.1);
public: bool Smooth(CameraPtr _camera,
const ignition::math::Vector2i &_mousePos,
const double _outsideRadius,
const double _insideRadius,
const double _weight = 0.1);
public: bool Raise(CameraPtr _camera,
const ignition::math::Vector2i &_mousePos,
const double _outsideRadius,
const double _insideRadius,
const double _weight = 0.1);
public: bool Lower(CameraPtr _camera,
const ignition::math::Vector2i &_mousePos,
const double _outsideRadius,
const double _insideRadius,
const double _weight = 0.1);
public: double AvgHeight(const ignition::math::Vector3d &_pos,
const double _brushSize) const;
public: void SetWireframe(const bool _show);
public: Ogre::TerrainGroup *OgreTerrain() const;
public: common::Image Image() const;
public: Ogre::TerrainGroup::RayResult MouseHit(CameraPtr _camera,
const ignition::math::Vector2i &_mousePos) const;
public: void SplitHeights(const std::vector<float> &_heightmap,
const int _n, std::vector<std::vector<float> > &_v);
public: unsigned int TerrainSubdivisionCount() const;
public: void SetMaterial(const std::string &_materialName);
public: std::string MaterialName() const;
public: void SetLOD(const unsigned int _value);
public: unsigned int LOD() const;
public: void SetSkirtLength(const double _value);
public: double SkirtLength() const;
public: void SetCastShadows(const bool _value);
public: bool CastShadows() const;
private: void CreateMaterial();
private: void ModifyTerrain(Ogre::Vector3 _pos,
const double _outsideRadius, const double _insideRadius,
const double _weight, const std::string &_op);
private: bool InitBlendMaps(Ogre::Terrain *_terrain);
private: void ConfigureTerrainDefaults();
private: void DefineTerrain(const int _x, const int _y);
private: void SetupShadows(const bool _enabled);
private: void UpdateTerrainHash(const std::string &_hash,
const boost::filesystem::path &_terrainDir);
private: bool PrepareTerrain(
const boost::filesystem::path &_terrainDirPath);
private: void SaveHeightmap();
private: std::unique_ptr<HeightmapPrivate> dataPtr;
};
}
}
#endif
gazebo::rendering::Heightmap::OgreTerrain
Ogre::TerrainGroup * OgreTerrain() const
Get a pointer to the OGRE terrain group object.
gazebo::rendering::Heightmap::Load
void Load()
Load the heightmap.
gazebo::rendering::Heightmap::SetMaterial
void SetMaterial(const std::string &_materialName)
Set custom material for the terrain.
Ogre
Definition: JointMaker.hh:39
gazebo::rendering::Heightmap::~Heightmap
virtual ~Heightmap()
Destructor.
gazebo::rendering::Heightmap::MouseHit
Ogre::TerrainGroup::RayResult MouseHit(CameraPtr _camera, const ignition::math::Vector2i &_mousePos) const
Calculate a mouse ray hit on the terrain.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::rendering::Heightmap::LoadFromMsg
void LoadFromMsg(ConstVisualPtr &_msg)
Load the heightmap from a visual message.
gazebo::rendering::Heightmap::Smooth
bool Smooth(CameraPtr _camera, const ignition::math::Vector2i &_mousePos, const double _outsideRadius, const double _insideRadius, const double _weight=0.1)
Smooth the terrain based on a mouse press.
gazebo::rendering::Heightmap
Rendering a terrain using heightmap information.
Definition: Heightmap.hh:62
gazebo::rendering::Heightmap::SetSkirtLength
void SetSkirtLength(const double _value)
Set the skirt length for the heightmap LOD tiles.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::rendering::Heightmap::Heightmap
Heightmap(ScenePtr _scene)
Constructor.
boost
Definition: JointMaker.hh:44
system.hh
gazebo::rendering::Heightmap::Height
double Height(const double _x, const double _y, const double _z=1000) const
Get the height at a location.
gazebo::rendering::Heightmap::Flatten
bool Flatten(CameraPtr _camera, const ignition::math::Vector2i &_mousePos, const double _outsideRadius, const double _insideRadius, const double _weight=0.1)
Flatten the terrain based on a mouse press.
gazebo::common::Image
Encapsulates an image.
Definition: Image.hh:66
gazebo::rendering::Heightmap::SplitHeights
void SplitHeights(const std::vector< float > &_heightmap, const int _n, std::vector< std::vector< float > > &_v)
Split a terrain into subterrains.
gazebo::rendering::ScenePtr
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
RenderTypes.hh
rendering
rendering
Definition: RenderEngine.hh:31
gazebo::rendering::Heightmap::Raise
bool Raise(CameraPtr _camera, const ignition::math::Vector2i &_mousePos, const double _outsideRadius, const double _insideRadius, const double _weight=0.1)
Raise the terrain based on a mouse press.
gazebo::rendering::Heightmap::SetCastShadows
void SetCastShadows(const bool _value)
Set the heightmap terrain to cast shadows.
ogre_gazebo.h
gazebo::rendering::Heightmap::Image
common::Image Image() const
Get the heightmap as an image.
gazebo::rendering::Heightmap::MaterialName
std::string MaterialName() const
Get the custom material name used for the terrain.
gazebo::rendering::Heightmap::AvgHeight
double AvgHeight(const ignition::math::Vector3d &_pos, const double _brushSize) const
Get the average height around a point.
gazebo::rendering::Heightmap::SetWireframe
void SetWireframe(const bool _show)
Set the heightmap to render in wireframe mode.
gazebo::rendering::Heightmap::TerrainSubdivisionCount
unsigned int TerrainSubdivisionCount() const
Get the number of subdivision the terrain will be split into.
gazebo::rendering::Heightmap::SkirtLength
double SkirtLength() const
Get the skirt length of LOD tiles.
gazebo::rendering::Heightmap::CastShadows
bool CastShadows() const
Get whether the heightmap terrain casts shadows.
gazebo::rendering::CameraPtr
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90
gazebo::rendering::Heightmap::Lower
bool Lower(CameraPtr _camera, const ignition::math::Vector2i &_mousePos, const double _outsideRadius, const double _insideRadius, const double _weight=0.1)
Lower the terrain based on a mouse press.
gazebo::rendering::Heightmap::LOD
unsigned int LOD() const
Get the heightmap Level of Detail (LOD) value.
gazebo::rendering::Heightmap::SetLOD
void SetLOD(const unsigned int _value)
Set the Level Of Detail (LOD) for the heightmap.