Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Protected Attributes | List of all members
vtHeightFieldGrid3d Class Referenceabstract

#include <HeightField.h>

Inheritance diagram for vtHeightFieldGrid3d:
vtHeightField3d vtHeightField vtDynTerrainGeom vtElevationGrid BruteTerrain DemeterTerrain SMTerrain SRTerrain TVTerrain

Public Member Functions

void Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight, int cols, int rows)
 
virtual void SetEarthExtents (const DRECT &ext)
 
bool CastRayToSurface (const FPoint3 &point, const FPoint3 &dir, FPoint3 &result) const
 
bool LineOfSight (const FPoint3 &point1, const FPoint3 &point2) const
 
DPoint2 GetSpacing () const
 
FPoint2 GetWorldSpacing () const
 
void GetDimensions (int &nColumns, int &nRows) const
 
int NumColumns ()
 
int NumRows ()
 
void EarthToGrid (const DPoint2 &epos, IPoint2 &ipos)
 
void WorldToGrid (const FPoint3 &pos, IPoint2 &ipos)
 
float GetInterpolatedElevation (double findex_x, double findex_y) const
 
int FindNumUnknown ()
 
virtual float GetElevation (int iX, int iZ, bool bTrue=false) const =0
 
virtual void GetWorldLocation (int i, int j, FPoint3 &loc, bool bTrue=false) const =0
 
bool ColorDibFromElevation (vtBitmapBase *pBM, const ColorMap *cmap, int iGranularity, const RGBAi &nodata, bool progress_callback(int)=NULL)
 
bool ColorDibFromTable (vtBitmapBase *pBM, std::vector< RGBi > &table, float fMin, float fMax, const RGBAi &nodata, bool progress_callback(int)=NULL)
 
void ShadeDibFromElevation (vtBitmapBase *pBM, const FPoint3 &light_dir, float fLightFactor, float fAmbient=0.1f, float fGamma=1.0f, bool bTrue=false, bool progress_callback(int)=NULL)
 
void ShadeQuick (vtBitmapBase *pBM, float light_factor, bool bTrue=false, bool progress_callback(int)=NULL)
 
void ShadowCastDib (vtBitmapBase *pBM, const FPoint3 &ight_dir, float fLightFactor, float fAmbient, bool progress_callback(int)=NULL)
 
- Public Member Functions inherited from vtHeightField3d
void Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight)
 
virtual bool FindAltitudeAtPoint (const FPoint3 &p3, float &fAltitude, bool bTrue=false, int iCultureFlags=0, FPoint3 *vNormal=NULL) const =0
 
int PointIsAboveTerrain (const FPoint3 &p) const
 
bool ConvertEarthToSurfacePoint (const DPoint2 &epos, FPoint3 &p3, int iCultureFlags=0, bool bTrue=false)
 
bool ContainsWorldPoint (float x, float z)
 
void GetCenter (FPoint3 &center)
 
void SetCulture (CultureExtension *ext)
 
- Public Member Functions inherited from vtHeightField
void Initialize (const DRECT &extents, float fMinHeight, float fMaxHeight)
 
virtual bool FindAltitudeOnEarth (const DPoint2 &p, float &fAltitude, bool bTrue=false) const =0
 
bool ContainsEarthPoint (const DPoint2 &p, bool bInclusive=false) const
 
DRECTGetEarthExtents ()
 
const DRECTGetEarthExtents () const
 
void GetHeightExtents (float &fMinHeight, float &fMaxHeight) const
 

Protected Attributes

int m_iColumns
 
int m_iRows
 
float m_fXStep
 
float m_fZStep
 
double m_dXStep
 
double m_dYStep
 
- Protected Attributes inherited from vtHeightField3d
float m_fDiagonalLength
 
CultureExtensionm_pCulture
 
- Protected Attributes inherited from vtHeightField
float m_fMinHeight
 
float m_fMaxHeight
 
DRECT m_EarthExtents
 

Additional Inherited Members

- Public Attributes inherited from vtHeightField3d
FRECT m_WorldExtents
 
vtLocalConversion m_Conversion
 
- Protected Member Functions inherited from vtHeightField3d
void UpdateWorldExtents ()
 

Detailed Description

This class extends vtHeightField3d with the knowledge of operating on a regular grid of elevation values.

Member Function Documentation

bool vtHeightFieldGrid3d::CastRayToSurface ( const FPoint3 point,
const FPoint3 dir,
FPoint3 result 
) const
virtual

Tests a ray against a heightfield grid.

Note: This algorithm is not guaranteed to give absolutely correct results, but it is reasonably fast and efficient. It checks a series of points along the ray against the terrain. When a pair of points (segment) is found to straddle the terrain, it refines the segment in a binary fashion.

Since the length of the test is proportional to a single grid element, there is a small chance that it will give results that are off by a small distance (less than 1 grid element)

Returns
true if hit terrain. The resulting point of intersection is placed in the 'result' argument.

Implements vtHeightField3d.

bool vtHeightFieldGrid3d::ColorDibFromElevation ( vtBitmapBase pBM,
const ColorMap cmap,
int  iGranularity,
const RGBAi nodata,
bool   progress_callbackint = NULL 
)

Use the height data in the grid to fill a bitmap with colors.

Parameters
pBMThe bitmap to be colored.
cmapThe mapping of elevation values to colors.
iGranularityThe smoothness of the mapping, expressed as the size of the internal mapping table. 2000 is a generally good value.
nodataThe color to use for NODATA areas, where there are no elevation values.
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
Returns
true if any invalid elevation values were encountered.
bool vtHeightFieldGrid3d::ColorDibFromTable ( vtBitmapBase pBM,
std::vector< RGBi > &  table,
float  fMin,
float  fMax,
const RGBAi nodata,
bool   progress_callbackint = NULL 
)

Use the height data in the grid and a colormap fill a bitmap with colors. Any undefined heixels in the source will be fill with red (255,0,0).

Parameters
pBMThe bitmap to be colored.
tableThe table of colors.
fMin,fMaxThe range of valid elevation values expect in the input.
nodataThe color to use for NODATA areas, where there are no elevation values.
progress_callbackIf supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
Returns
true if any invalid elevation values were encountered.
void vtHeightFieldGrid3d::EarthToGrid ( const DPoint2 epos,
IPoint2 ipos 
)

Convert a point from earth coordinates to the integer coordinates of the grid.

int vtHeightFieldGrid3d::FindNumUnknown ( )

Count the number of unknown (invalid) heixels in this grid.

void vtHeightFieldGrid3d::GetDimensions ( int &  nColumns,
int &  nRows 
) const

Get the grid size of the grid. The values are placed into the arguments by reference.

Parameters
nColumnsThe number of columns (east-west)
nRowsTHe number of rows (north-south)
float vtHeightFieldGrid3d::GetInterpolatedElevation ( double  findex_x,
double  findex_y 
) const

Get the interpolated height of the grid at a specific grid coordinate, where the coordinates can be non-integer; the result is interpolated between the source heixels when possible (i.e. not at the edge)

Parameters
findex_xFloating point index, from 0 to width in heixels.
findex_yFloating point index, from 0 to height in heixels.
DPoint2 vtHeightFieldGrid3d::GetSpacing ( ) const

Get the grid spacing, the width of each column and row.

bool vtHeightFieldGrid3d::LineOfSight ( const FPoint3 point1,
const FPoint3 point2 
) const
Returns
true if a line of sight exists between point1 and point2.
void vtHeightFieldGrid3d::SetEarthExtents ( const DRECT ext)
virtual

Set the geographic extents of the grid.

Reimplemented from vtHeightField3d.

void vtHeightFieldGrid3d::ShadeDibFromElevation ( vtBitmapBase pBM,
const FPoint3 light_dir,
float  fLightFactor,
float  fAmbient = 0.1f,
float  fGamma = 1.0f,
bool  bTrue = false,
bool   progress_callbackint = NULL 
)

Perform simple shading of a bitmap, based on this grid's elevation values. Lighting is computing using the dot product of the surface normal with the light direction. This is often called "dot-product lighting".

Parameters
pBMThe bitmap to shade.
light_dirDirection vector of the light.
fLightFactorValue from 0 (no shading) to 1 (full shading)
fAmbientAmbient light values from 0 to 1, a typical value is 0.1.
fGammaGamma values from 0 to 1, values less than 1 boost the brightness curve.
bTrueIf true, use the real elevation values, ignoring vertical exaggeration.
progress_callbackIf supplied, will be called with values from 0 to 100.
void vtHeightFieldGrid3d::ShadeQuick ( vtBitmapBase pBM,
float  fLightFactor,
bool  bTrue = false,
bool   progress_callbackint = NULL 
)

Quickly produce a shading-like effect by scanning over the bitmap once, using the east-west slope to produce lightening/darkening. The bitmap must be the same size as the elevation grid, or a power of 2 smaller.

void vtHeightFieldGrid3d::ShadowCastDib ( vtBitmapBase pBM,
const FPoint3 light_dir,
float  fLightFactor,
float  fAmbient,
bool   progress_callbackint = NULL 
)

ShadowCastDib - method to create shadows over the terrain based on the angle of the sun.

Parameters
pBMAn interface to the bitmap to be shaded.
light_dirThe direction of the light, in world coordinates, coming down toward the terrain. For example, (-1,-1,0) is pointing down where the sun would be at 9AM on the equator. Despite this example, light_dir should be normalized to unit length.
fLightFactorAmount of shading, from 0 to 1. A value of 0 means no lighting, 1 means full lighting.
fAmbientAmount of ambient light, from 0 to 1. A typical value is 0.1.
progress_callbackOptional callback for progress notification.
void vtHeightFieldGrid3d::WorldToGrid ( const FPoint3 pos,
IPoint2 ipos 
)

Convert a point from world coordinates to the integer coordinates of the grid.


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