|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions
gameplay::HeightField Class Reference

`#include <HeightField.h>`

Inheritance diagram for gameplay::HeightField:

List of all members.

## Public Member Functions

float * | getArray () const
float | getHeight (float column, float row) const
unsigned int | getRowCount () const
unsigned int | getColumnCount () const

## Static Public Member Functions

static HeightField * | create (unsigned int rows, unsigned int columns)
static HeightField * | createFromImage (const char *path, float heightMin=0, float heightMax=1)
static HeightField * | createFromRAW (const char *path, unsigned int width, unsigned int height, float heightMin=0, float heightMax=1)

## Detailed Description

Defines height data used to store values representing elevation.

Heightfields can be used to construct both Terrain objects as well as PhysicsCollisionShape heightfield defintions, which are used in heightfield rigid body creation. Heightfields can be populated manually, or loaded from images and RAW files.

## Member Function Documentation

static HeightField* gameplay::HeightField::create | ( | unsigned int | rows,
|  | unsigned int | columns
| ) |  | `[static]`

Creates a new HeightField of the given dimensions, with uninitialized height data.

Parameters:

  rows | Number of rows in the height field.
  columns | Number of columns in the height field.

Returns:
  The new HeightField.

static HeightField* gameplay::HeightField::createFromImage | ( | const char * | path,
|  | float | heightMin = `0`,
|  | float | heightMax = `1`
| ) |  | `[static]`

Creates a HeightField from the specified heightfield image.

The specified image path must refer to a valid heightfield image. Supported images are the same as those supported by the Image class (i.e. PNG).

The minHeight and maxHeight parameters provides a mapping from heightfield pixel intensity to height values. The minHeight parameter is mapped to zero intensity pixel, while maxHeight maxHeight is mapped to full intensity pixels.

Parameters:

  path | Path to a heightfield image.
  heightMin | Minimum height value for a zero intensity pixel.
  heightMax | Maximum height value for a full intensity heightfield pixel (must be >= minHeight).

Returns:
  The new HeightField.

static HeightField* gameplay::HeightField::createFromRAW | ( | const char * | path,
|  | unsigned int | width,
|  | unsigned int | height,
|  | float | heightMin = `0`,
|  | float | heightMax = `1`
| ) |  | `[static]`

Creates a HeightField from the specified RAW8 or RAW16 file.

RAW files are header-less files containing intensity values, either in 8-bit (RAW8) or 16-bit (RAW16) format. RAW16 files must have little endian (PC) byte ordering. Since RAW files have no header, you must specify the dimensions of the data in the file. This method automatically determines (based on file size) whether the input file is RAW8 or RAW16. RAW files must have a .raw or .r16 file extension.

RAW files are commonly used in software that produces heightmap images. Using RAW16 is preferred or any 8-bit heightfield source since it allows greater precision, resulting in smoother height transitions.

The minHeight and maxHeight parameters provides a mapping from heightfield pixel intensity to height values. The minHeight parameter is mapped to zero intensity pixel, while maxHeight maxHeight is mapped to full intensity pixels.

Parameters:

  path | Path to the RAW file (must end in a .raw or .r16 file extension).
  width | Width of the RAW data.
  height | Height of the RAW data.
  heightMin | Minimum height value for a zero intensity pixel.
  heightMax | Maximum height value for a full intensity heightfield pixel (must be >= minHeight).

Returns:
  The new HeightField.

float* gameplay::HeightField::getArray | ( |  | ) | const

Returns a pointer to the underlying height array.

The array is packed in row major order, meaning that the data is aligned in rows, from top left to bottom right.

Returns:
  The underlying height array.

unsigned int gameplay::HeightField::getColumnCount | ( |  | ) | const

Returns the number of columns in the heightfield.

Returns:
  The column count.

float gameplay::HeightField::getHeight | ( | float | column,
|  | float | row
| ) |  | const

Returns the height at the specified row and column.

The specified row and column are specified as floating point numbers so that values between points can be specified. In this case, a height value is calculated that is interpolated between neighboring height values.

If the specified point lies outside the heightfield, it is clamped to the boundary of the heightfield.

Parameters:

  column | The column of the height value to query.
  row | The row of the height value to query.

Returns:
  The height value.

unsigned int gameplay::HeightField::getRowCount | ( |  | ) | const

Returns the number of rows in the heightfield.

Returns:
  The number of rows.

All Classes Functions Variables Typedefs Enumerations Enumerator