##

Heightmap Class Reference
Rendering

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 | CastShadows () const
| Get whether the heightmap terrain casts shadows. 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...
unsigned int | LOD () const
| Get the heightmap Level of Detail (LOD) value. 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 | SetCastShadows (const bool _value)
| Set the heightmap terrain to cast shadows. More...
void | SetLOD (const unsigned int _value)
| Set the Level Of Detail (LOD) for the heightmap. More...
void | SetMaterial (const std::string &_materialName)
| Set custom material for the terrain. More...
void | SetSkirtLength (const double _value)
| Set the skirt length for the heightmap LOD tiles. More...
void | SetWireframe (const bool _show)
| Set the heightmap to render in wireframe mode. More...
double | SkirtLength () const
| Get the skirt length of LOD tiles. 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()

Heightmap | ( | ScenePtr | _scene | ) |

explicit

Constructor.

Parameters

  [in] | _scene | Pointer to the scene that will contain the heightmap

## ~Heightmap()

virtual ~Heightmap | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## AvgHeight()

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

Get the average height around a point.

Parameters

  [in] | _pos | Position in world coordinates.
  [in] | _brushSize | Controls the radius of effect.

## CastShadows()

bool CastShadows | ( |  | ) | const

Get whether the heightmap terrain casts shadows.

Returns
  True if the heightmap terrain casts shadows

## 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.

Parameters

  [in] | _camera | Camera associated with the mouse press.
  [in] | _mousePos | Position of the mouse in viewport coordinates.
  [in] | _outsideRadius | Controls the radius of effect.
  [in] | _insideRadius | Controls the size of the radius with the maximum effect (value between 0 and 1).
  [in] | _weight | Controls modification magnitude.

Returns
  True if the terrain was modified

## Height()

double Height | ( | const double | _x,
|  | const double | _y,
|  | const double | _z = `1000`
| ) |  | const

Get the height at a location.

Parameters

  [in] | _x | X location
  [in] | _y | Y location
  [in] | _z | Z location

Returns
  The height at the specified location

## Image()

common::Image Image | ( |  | ) | const

Get the heightmap as an image.

Returns
  An image that contains the terrain data.

## Load()

void Load | ( |  | ) |

Load the heightmap.

## LoadFromMsg()

void LoadFromMsg | ( | ConstVisualPtr & | _msg | ) |

Load the heightmap from a visual message.

Parameters

  [in] | _msg | The visual message containing heightmap info

## LOD()

unsigned int LOD | ( |  | ) | const

Get the heightmap Level of Detail (LOD) value.

Returns
  Value used to compute LOD.

## 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.

Parameters

  [in] | _camera | Camera associated with the mouse press.
  [in] | _mousePos | Position of the mouse in viewport coordinates.
  [in] | _outsideRadius | Controls the radius of effect.
  [in] | _insideRadius | Controls the size of the radius with the maximum effect (value between 0 and 1).
  [in] | _weight | Controls modification magnitude.

Returns
  True if the terrain was modified

## MaterialName()

std::string MaterialName | ( |  | ) | const

Get the custom material name used for the terrain.

Returns
  Custom material name.

## MouseHit()

Ogre::TerrainGroup::RayResult MouseHit | ( | CameraPtr | _camera,
|  | const ignition::math::Vector2i & | _mousePos
| ) |  | const

Calculate a mouse ray hit on the terrain.

Parameters

  [in] | _camera | Camera associated with the mouse press.
  [in] | _mousePos | Position of the mouse in viewport coordinates.

Returns
  The result of the mouse ray hit.

## OgreTerrain()

Ogre::TerrainGroup* OgreTerrain | ( |  | ) | const

Get a pointer to the OGRE terrain group object.

Returns
  Pointer to the OGRE terrain.

## 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.

Parameters

  [in] | _camera | Camera associated with the mouse press.
  [in] | _mousePos | Position of the mouse in viewport coordinates.
  [in] | _outsideRadius | Controls the radius of effect.
  [in] | _insideRadius | Controls the size of the radius with the maximum effect (value between 0 and 1).
  [in] | _weight | Controls modification magnitude.

Returns
  True if the terrain was modified

## SetCastShadows()

void SetCastShadows | ( | const bool | _value | ) |

Set the heightmap terrain to cast shadows.

Parameters

  [in] | _value | True to cast shadows, false to not cast shadows.

## SetLOD()

void SetLOD | ( | const unsigned int | _value | ) |

Set the Level Of Detail (LOD) for the heightmap.

Parameters

  [in] | _value | A render-engine specific value used to compute LOD. In Ogre, this is the max pixel error that should be allowed when rendering the heightmap. Default is 0, i.e. LOD is disabled. Note: enabling LOD means that the rendering engine will be allowed to morph mesh vertices, resulting in a simplified visual that may be different from the collision.

## SetMaterial()

void SetMaterial | ( | const std::string & | _materialName | ) |

Set custom material for the terrain.

Parameters

  [in] | _materialName | Name of the material

## SetSkirtLength()

void SetSkirtLength | ( | const double | _value | ) |

Set the skirt length for the heightmap LOD tiles.

Parameters

  [in] | _value | LOD tile skirts hide potential gaps between tiles of different detail levels.

## SetWireframe()

void SetWireframe | ( | const bool | _show | ) |

Set the heightmap to render in wireframe mode.

Parameters

  [in] | _show | True to render wireframe, false to render solid.

## SkirtLength()

double SkirtLength | ( |  | ) | const

Get the skirt length of LOD tiles.

Returns
  Skirt length of LOD tiles

## 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.

Parameters

  [in] | _camera | Camera associated with the mouse press.
  [in] | _mousePos | Position of the mouse in viewport coordinates.
  [in] | _outsideRadius | Controls the radius of effect.
  [in] | _insideRadius | Controls the size of the radius with the maximum effect (value between 0 and 1).
  [in] | _weight | Controls modification magnitude.

Returns
  True if the terrain was modified

## SplitHeights()

void SplitHeights | ( | const std::vector< float > & | _heightmap,
|  | const int | _n,
|  | std::vector< std::vector< float > > & | _v
| ) |  |

Split a terrain into subterrains.

Parameters

  [in] | _heightmap | Source vector of floats with the heights.
  [in] | _n | Number of subterrains.
  [out] | _v | Destination vector with the subterrains.

## TerrainSubdivisionCount()

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:

- Heightmap.hh