Class storing heightfield and other data for a single fixed size square area of terrain defined by four adjacent BasePoint objects.
More...
#include <HeightMap.h>
|
| HeightMap (int resolution) |
| Construct an empty height map with the given resolution. More...
|
|
int | getResolution () const |
| Accessor for resolution of this segment. More...
|
|
float | get (int x, int z) const |
| Get the height at a relative integer position in the Segment. More...
|
|
void | getHeightAndNormal (float x, float z, float &h, WFMath::Vector< 3 > &normal) const |
| Get an accurate height and normal vector at a given coordinate relative to this segment. More...
|
|
void | getHeight (float x, float z, float &h) const |
|
float | getMax () const |
| Accessor for the maximum height value in this Segment. More...
|
|
float | getMin () const |
| Accessor for the minimum height value in this Segment. More...
|
|
void | fill2d (const BasePoint &p1, const BasePoint &p2, const BasePoint &p3, const BasePoint &p4) |
| Two dimensional midpoint displacement fractal. More...
|
|
void | checkMaxMin (float h) |
| Check a value against m_min and m_max and set one of them if appropriate. More...
|
|
float & | operator() (unsigned int x, unsigned int y, unsigned int channel) |
| Retrieve the data value at a given point. More...
|
|
const float & | operator() (unsigned int x, unsigned int y, unsigned int channel) const |
| Retrieve the data value at a given point. More...
|
|
unsigned int | getSize () const |
| Accessor for the size of segment, m_res + 1. More...
|
|
unsigned int | getChannels () const |
| Accessor for the number of data values per height point. More...
|
|
float * | getData () |
| Accessor for a pointer to buffer containing data values. More...
|
|
const float * | getData () const |
| Accessor for a pointer to buffer containing data values. More...
|
|
void | allocate () |
| Allocate the storage required by the buffer. More...
|
|
bool | isValid () const |
| Determine if this buffer has valid allocated storage. More...
|
|
void | invalidate () |
| De-allocate the storage for this buffer. More...
|
|
|
const unsigned int | m_channels |
| The number of data values per height point. More...
|
|
const unsigned int | m_size |
| The size of segment, m_res + 1. More...
|
|
std::vector< float > | m_data |
| Pointer to buffer containing data values. More...
|
|
Class storing heightfield and other data for a single fixed size square area of terrain defined by four adjacent BasePoint objects.
Definition at line 21 of file HeightMap.h.
Mercator::HeightMap::HeightMap |
( |
int |
resolution | ) |
|
|
explicit |
Construct an empty height map with the given resolution.
Definition at line 104 of file HeightMap.cpp.
Allocate the storage required by the buffer.
Allocate memory based on the size and number of channels required by the buffer.
Definition at line 76 of file Buffer.h.
void Mercator::HeightMap::checkMaxMin |
( |
float |
h | ) |
|
float Mercator::HeightMap::get |
( |
int |
x, |
|
|
int |
z |
|
) |
| const |
|
inline |
Accessor for the number of data values per height point.
Definition at line 58 of file Buffer.h.
Accessor for a pointer to buffer containing data values.
Definition at line 63 of file Buffer.h.
Accessor for a pointer to buffer containing data values.
Definition at line 68 of file Buffer.h.
void Mercator::HeightMap::getHeightAndNormal |
( |
float |
x, |
|
|
float |
z, |
|
|
float & |
h, |
|
|
WFMath::Vector< 3 > & |
normal |
|
) |
| const |
Get an accurate height and normal vector at a given coordinate relative to this segment.
The height and surface normal are determined by finding the four adjacent height points nearest to the coordinate, and interpolating between those height values. The square area defined by the 4 height points is considered as two triangles for the purposes of interpolation to ensure that the calculated height falls on the surface rendered by a 3D graphics engine from the same heightfield data. The line used to divide the area is defined by the gradient z = x, so the first triangle has relative vertex coordinates (0,0) (1,0) (1,1) and the second triangle has vertex coordinates (0,0) (0,1) (1,1).
Definition at line 380 of file HeightMap.cpp.
Referenced by Mercator::Segment::getHeightAndNormal().
float Mercator::HeightMap::getMax |
( |
| ) |
const |
|
inline |
float Mercator::HeightMap::getMin |
( |
| ) |
const |
|
inline |
int Mercator::HeightMap::getResolution |
( |
| ) |
const |
|
inline |
Accessor for resolution of this segment.
Definition at line 35 of file HeightMap.h.
Accessor for the size of segment, m_res + 1.
Definition at line 53 of file Buffer.h.
De-allocate the storage for this buffer.
Free the storage allocate for this buffer.
Definition at line 90 of file Buffer.h.
Determine if this buffer has valid allocated storage.
- Returns
- true if storage is allocated.
Definition at line 83 of file Buffer.h.
float & Mercator::Buffer< float >::operator() |
( |
unsigned int |
x, |
|
|
unsigned int |
y, |
|
|
unsigned int |
channel |
|
) |
| |
|
inlineinherited |
Retrieve the data value at a given point.
Access the data value associated with given point in the segment in a given channel in this buffer.
- Returns
- a reference to the value at the point requested.
Definition at line 36 of file Buffer.h.
const float & Mercator::Buffer< float >::operator() |
( |
unsigned int |
x, |
|
|
unsigned int |
y, |
|
|
unsigned int |
channel |
|
) |
| const |
|
inlineinherited |
Retrieve the data value at a given point.
Return the data value associated with given point in the segment in a given channel in this buffer.
- Returns
- the value at the point requested.
Definition at line 45 of file Buffer.h.
The number of data values per height point.
Definition at line 17 of file Buffer.h.
Pointer to buffer containing data values.
Definition at line 21 of file Buffer.h.
Referenced by fill2d().
The size of segment, m_res + 1.
Definition at line 19 of file Buffer.h.
Referenced by fill2d().
The documentation for this class was generated from the following files: