Heightmap Class Reference

Rendering a terrain using heightmap information. More...

#include <rendering/rendering.hh>

Public Member Functions

 Heightmap (ScenePtr _scene)
 Constructor. More...
 
virtual ~Heightmap ()
 Destructor. More...
 
double AvgHeight (const ignition::math::Vector3d &_pos, const double _brushSize) const
 Get the average height around a point. More...
 
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. More...
 
double Height (const double _x, const double _y, const double _z=1000) const
 Get the height at a location. More...
 
common::Image Image () const
 Get the heightmap as an image. More...
 
void Load ()
 Load the heightmap. More...
 
void LoadFromMsg (ConstVisualPtr &_msg)
 Load the heightmap from a visual message. More...
 
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. More...
 
std::string MaterialName () const
 Get the custom material name used for the terrain. More...
 
Ogre::TerrainGroup::RayResult MouseHit (CameraPtr _camera, const ignition::math::Vector2i &_mousePos) const
 Calculate a mouse ray hit on the terrain. More...
 
Ogre::TerrainGroup * OgreTerrain () const
 Get a pointer to the OGRE terrain group object. More...
 
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. More...
 
void SetMaterial (const std::string &_materialName)
 Set custom material for the terrain. More...
 
void SetWireframe (const bool _show)
 Set the heightmap to render in wireframe mode. More...
 
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. More...
 
void SplitHeights (const std::vector< float > &_heightmap, const int _n, std::vector< std::vector< float > > &_v)
 Split a terrain into subterrains. More...
 
unsigned int TerrainSubdivisionCount () const
 Get the number of subdivision the terrain will be split into. More...
 

Detailed Description

Rendering a terrain using heightmap information.

Constructor & Destructor Documentation

Heightmap ( ScenePtr  _scene)
explicit

Constructor.

Parameters
[in]_scenePointer to the scene that will contain the heightmap
virtual ~Heightmap ( )
virtual

Destructor.

Member Function Documentation

double AvgHeight ( const ignition::math::Vector3d &  _pos,
const double  _brushSize 
) const

Get the average height around a point.

Parameters
[in]_posPosition in world coordinates.
[in]_brushSizeControls the radius of effect.
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.

Parameters
[in]_cameraCamera associated with the mouse press.
[in]_mousePosPosition of the mouse in viewport coordinates.
[in]_outsideRadiusControls the radius of effect.
[in]_insideRadiusControls the size of the radius with the maximum effect (value between 0 and 1).
[in]_weightControls modification magnitude.
Returns
True if the terrain was modified
double Height ( const double  _x,
const double  _y,
const double  _z = 1000 
) const

Get the height at a location.

Parameters
[in]_xX location
[in]_yY location
[in]_zZ location
Returns
The height at the specified location
common::Image Image ( ) const

Get the heightmap as an image.

Returns
An image that contains the terrain data.
void Load ( )

Load the heightmap.

void LoadFromMsg ( ConstVisualPtr &  _msg)

Load the heightmap from a visual message.

Parameters
[in]_msgThe visual message containing heightmap info
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.

Parameters
[in]_cameraCamera associated with the mouse press.
[in]_mousePosPosition of the mouse in viewport coordinates.
[in]_outsideRadiusControls the radius of effect.
[in]_insideRadiusControls the size of the radius with the maximum effect (value between 0 and 1).
[in]_weightControls modification magnitude.
Returns
True if the terrain was modified
std::string MaterialName ( ) const

Get the custom material name used for the terrain.

Returns
Custom material name.
Ogre::TerrainGroup::RayResult MouseHit ( CameraPtr  _camera,
const ignition::math::Vector2i &  _mousePos 
) const

Calculate a mouse ray hit on the terrain.

Parameters
[in]_cameraCamera associated with the mouse press.
[in]_mousePosPosition of the mouse in viewport coordinates.
Returns
The result of the mouse ray hit.
Ogre::TerrainGroup* OgreTerrain ( ) const

Get a pointer to the OGRE terrain group object.

Returns
Pointer to the OGRE terrain.
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.

Parameters
[in]_cameraCamera associated with the mouse press.
[in]_mousePosPosition of the mouse in viewport coordinates.
[in]_outsideRadiusControls the radius of effect.
[in]_insideRadiusControls the size of the radius with the maximum effect (value between 0 and 1).
[in]_weightControls modification magnitude.
Returns
True if the terrain was modified
void SetMaterial ( const std::string &  _materialName)

Set custom material for the terrain.

Parameters
[in]_materialNameName of the material
void SetWireframe ( const bool  _show)

Set the heightmap to render in wireframe mode.

Parameters
[in]_showTrue to render wireframe, false to render solid.
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.

Parameters
[in]_cameraCamera associated with the mouse press.
[in]_mousePosPosition of the mouse in viewport coordinates.
[in]_outsideRadiusControls the radius of effect.
[in]_insideRadiusControls the size of the radius with the maximum effect (value between 0 and 1).
[in]_weightControls modification magnitude.
Returns
True if the terrain was modified
void SplitHeights ( const std::vector< float > &  _heightmap,
const int  _n,
std::vector< std::vector< float > > &  _v 
)

Split a terrain into subterrains.

Parameters
[in]_heightmapSource vector of floats with the heights.
[in]_nNumber of subterrains.
[out]_vDestination vector with the subterrains.
unsigned int TerrainSubdivisionCount ( ) const

Get the number of subdivision the terrain will be split into.

Returns
Number of terrain subdivisions

The documentation for this class was generated from the following file: