mod_sim::Heightmap Class Reference

Heightmap. More...

#include <mod_sim_terrain_heightmap.hh>

List of all members.

Public Types

typedef uint8 Height

Public Member Functions

 Heightmap (void)
 Heightmap (const InitArgs &initArgs)
 Heightmap (const InitArgs &initArgs, const NoiseArgs &noiseArgs)
 ~Heightmap ()
void SetHeight (const int hmLat, const int hmLon, const Height height)
fp GetHeight (const int hmLat, const int hmLon) const
 
Returns:
Height as fp in range {0.0,..,1.0}. Call GetIdx() to get (lat,lon) tuple.

Heightmap::Height GetHeightDirect (const int hmLat, const int hmLon) const
fp GetHeightScaled (const int hmLat, const int hmLon) const
 
Returns:
Height scaled by mHeightScale {0.0,..,mHeightScale}.

fp GetHeightScaledInterpolated (const fp worldLat, const fp worldLon) const
 
Returns:
Height that is scaled, and is interpolated to mapped position in World Space.

CLASS_METHOD
Heightmap::Height 
GetHeightMedian (void)
fp ScaleHeight (const Height height)
WorldVertex GetPosition (const int hmLat, const int hmLon) const
 Converse of GetIdx(hmLat,hmLon).
uint GetIdx (const int hmLat, const int hmLon) const
 
Returns:
Flat index. GetIdx name consistent with Array2D<>.

SharedPtr< Texture > GetColormapTexture (void) const
TexCoord GetColormapTexCoord (const fp worldLat, const fp worldLon) const
bool IfInsideApprox (const fp worldLat, const fp worldLon) const
Elemoperator[] (uint i)
const Elemoperator[] (uint i) const

Public Attributes

CLASS_CONST uint HEIGHT_INVALID = 0xff
CLASS_CONST uint HEIGHT_LIMIT = 0xfe
CLASS_VAR bool msDisableIfInsideApprox = false

Private Types

typedef Array2D
< Elem, Shared > 
HeightmapArray2D

Private Member Functions

void Init (const InitArgs &initArgs)
void InitRandomNumbers (const InitArgs &initArgs)
void ComputePalette (void)

Private Attributes

CLASS_VAR int msHeightmapWidthMinus1
CLASS_VAR Array2D< fpmsRandomHeight
 random offset
CLASS_VAR Array2D< uintmsRandomColor
 random offset
CLASS_VAR vector< RGBA > msPalette
 for constructing colormap (water,land,snow)
CLASS_VAR WaterTexturemsWaterTexture = NULL
bool mValid
BoxVolume mBoxVolume
 volume this Heightmap occupies in World Space
fp mWidthInWorld
 width of this Heightmap in World coords
fp mHeightScale
 scales height values
fp mHeightScaleHalf
fp mWorldHeightmapRatio
 maps world coords to heightmap coords
fp mHeightmapWorldRatio
 inverse (reciprocal)
HeightmapArray2D mHeightmap
 heightmap values in a 2D array
int mHeightmapWidth
 width in height elements
shptr< Texture > mColormapTexture
 separate from Engine's texture set

Friends

class Terrain
class TileFactory
class TextureTask

Classes

class  Elem
 Element of a heightmap. More...
struct  InitArgs
struct  NoiseArgs
class  TextureTask
class  WaterTexture


Detailed Description

Heightmap.

Heightmap minimizes memory at expense of recomputing. Recomputing the same values is actually faster than storing them because the large size of the heightmap would flood the system's memory.

Heightmap relies on the ability of Array2D to clamp 2D coordinates. That is, if a (lat,lon) is slightly past the edge of the world, it will be clamped at the existing element at the edge.

Invalid heightmaps are cheap to construct and used as flags.


Member Typedef Documentation

typedef uint8 mod_sim::Heightmap::Height

typedef Array2D<Elem,Shared> mod_sim::Heightmap::HeightmapArray2D [private]


Constructor & Destructor Documentation

mod_sim::Heightmap::Heightmap ( void   ) 

ctor/dtor. This is parameterized (independent of globals such as gWorld).

mod_sim::Heightmap::Heightmap ( const InitArgs initArgs  ) 

mod_sim::Heightmap::Heightmap ( const InitArgs initArgs,
const NoiseArgs noiseArgs 
)

Dynamically create a heightmap using Perlin noise.

Parameters:
initArgs 
noiseArgs 

mod_sim::Heightmap::~Heightmap (  ) 


Member Function Documentation

void mod_sim::Heightmap::Init ( const InitArgs initArgs  )  [private]

void mod_sim::Heightmap::InitRandomNumbers ( const InitArgs initArgs  )  [private]

Pre-compute random numbers to be reused at edges of heightmaps in order to make them seamless.

void mod_sim::Heightmap::ComputePalette ( void   )  [private]

Compute palette. Used to be updated for every Heightmap but is pre-computed.

void mod_sim::Heightmap::SetHeight ( const int  hmLat,
const int  hmLon,
const Height  height 
) [inline]

fp mod_sim::Heightmap::GetHeight ( const int  hmLat,
const int  hmLon 
) const [inline]

Returns:
Height as fp in range {0.0,..,1.0}. Call GetIdx() to get (lat,lon) tuple.

Heightmap::Height mod_sim::Heightmap::GetHeightDirect ( const int  hmLat,
const int  hmLon 
) const [inline]

fp mod_sim::Heightmap::GetHeightScaled ( const int  hmLat,
const int  hmLon 
) const [inline]

Returns:
Height scaled by mHeightScale {0.0,..,mHeightScale}.

fp mod_sim::Heightmap::GetHeightScaledInterpolated ( const fp  worldLat,
const fp  worldLon 
) const [inline]

Returns:
Height that is scaled, and is interpolated to mapped position in World Space.

Heightmap::Height mod_sim::Heightmap::GetHeightMedian ( void   ) 

Get an average height value. THIS VALUE MAY CHANGE AS HEIGHTMAPS ARE MADE.

fp mod_sim::Heightmap::ScaleHeight ( const Height  height  )  [inline]

WorldVertex mod_sim::Heightmap::GetPosition ( const int  hmLat,
const int  hmLon 
) const [inline]

Converse of GetIdx(hmLat,hmLon).

uint mod_sim::Heightmap::GetIdx ( const int  hmLat,
const int  hmLon 
) const [inline]

Returns:
Flat index. GetIdx name consistent with Array2D<>.

SharedPtr<Texture> mod_sim::Heightmap::GetColormapTexture ( void   )  const [inline]

TexCoord mod_sim::Heightmap::GetColormapTexCoord ( const fp  worldLat,
const fp  worldLon 
) const [inline]

bool mod_sim::Heightmap::IfInsideApprox ( const fp  worldLat,
const fp  worldLon 
) const

Returns:
True if (worldLat,worldLon) is approximately box volume occupied by Heightmap. Terrain generation normally produces (lat,lon) that are slightly outside a volume. Just try to catch egregious coordinates.

Elem& mod_sim::Heightmap::operator[] ( uint  i  )  [inline]

const Elem& mod_sim::Heightmap::operator[] ( uint  i  )  const [inline]


Friends And Related Function Documentation

friend class Terrain [friend]

friend class TileFactory [friend]

friend class TextureTask [friend]


Member Data Documentation

CLASS_CONST uint mod_sim::Heightmap::HEIGHT_INVALID = 0xff

CLASS_CONST uint mod_sim::Heightmap::HEIGHT_LIMIT = 0xfe

int mod_sim::Heightmap::msHeightmapWidthMinus1 [private]

Array2D< fp > mod_sim::Heightmap::msRandomHeight [private]

random offset

Array2D< uint > mod_sim::Heightmap::msRandomColor [private]

random offset

vector< RGBA > mod_sim::Heightmap::msPalette [private]

for constructing colormap (water,land,snow)

Heightmap::WaterTexture * mod_sim::Heightmap::msWaterTexture = NULL [private]

bool mod_sim::Heightmap::mValid [private]

BoxVolume mod_sim::Heightmap::mBoxVolume [private]

volume this Heightmap occupies in World Space

fp mod_sim::Heightmap::mWidthInWorld [private]

width of this Heightmap in World coords

fp mod_sim::Heightmap::mHeightScale [private]

scales height values

fp mod_sim::Heightmap::mHeightScaleHalf [private]

fp mod_sim::Heightmap::mWorldHeightmapRatio [private]

maps world coords to heightmap coords

fp mod_sim::Heightmap::mHeightmapWorldRatio [private]

inverse (reciprocal)

HeightmapArray2D mod_sim::Heightmap::mHeightmap [private]

heightmap values in a 2D array

int mod_sim::Heightmap::mHeightmapWidth [private]

width in height elements

shptr<Texture> mod_sim::Heightmap::mColormapTexture [private]

separate from Engine's texture set

bool mod_sim::Heightmap::msDisableIfInsideApprox = false


The documentation for this class was generated from the following files: Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:31 2007