vtdata library
|
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 |
const DPoint2 & | GetSpacing () const |
const FPoint2 & | GetWorldSpacing () const |
void | GetDimensions (int &nColumns, int &nRows) const |
const IPoint2 & | GetDimensions () const |
int | NumColumns () const |
int | NumRows () const |
void | EarthToGrid (const DPoint2 &epos, IPoint2 &ipos) |
void | WorldToGrid (const FPoint3 &pos, IPoint2 &ipos) |
float | GetInterpolatedElevation (double findex_x, double findex_y, bool bTrue=false) 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, ColorMap *cmap, int iGranularity, const RGBAi &nodata, bool progress_callback(int)=NULL) const |
bool | ColorDibFromTable (vtBitmapBase *pBM, const ColorMap *color_map, const RGBAi &nodata, bool progress_callback(int)=NULL) const |
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) const |
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) const |
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) const |
bool | ContainsWorldPoint (float x, float z) const |
void | GetCenter (FPoint3 ¢er) const |
void | SetCulture (CultureExtension *ext) |
float | LineOnSurface (const DLine2 &line, float fSpacing, float fOffset, bool bInterp, bool bCurve, bool bTrue, FLine3 &output) |
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 |
DRECT & | GetEarthExtents () |
const DRECT & | GetEarthExtents () const |
void | GetHeightExtents (float &fMinHeight, float &fMaxHeight) const |
Protected Attributes | |
IPoint2 | m_iSize |
FPoint2 | m_fStep |
DPoint2 | m_dStep |
Protected Attributes inherited from vtHeightField3d | |
float | m_fDiagonalLength |
CultureExtension * | m_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 |
LocalCS | m_LocalCS |
Protected Member Functions inherited from vtHeightField3d | |
void | UpdateWorldExtents () |
This class extends vtHeightField3d with the knowledge of operating on a regular grid of elevation values.
|
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)
Implements vtHeightField3d.
bool vtHeightFieldGrid3d::ColorDibFromElevation | ( | vtBitmapBase * | pBM, |
ColorMap * | cmap, | ||
int | iGranularity, | ||
const RGBAi & | nodata, | ||
bool | progress_callbackint = NULL |
||
) | const |
Use the height data in the grid to fill a bitmap with colors.
pBM | The bitmap to be colored. |
cmap | The mapping of elevation values to colors. |
iGranularity | The smoothness of the mapping, expressed as the size of the internal mapping table. 2000 is a generally good value. |
nodata | The color to use for NODATA areas, where there are no elevation values. |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
bool vtHeightFieldGrid3d::ColorDibFromTable | ( | vtBitmapBase * | pBM, |
const ColorMap * | color_map, | ||
const RGBAi & | nodata, | ||
bool | progress_callbackint = NULL |
||
) | const |
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).
pBM | The bitmap to be colored. |
color_map | A ColorMap which has already had GenerateColorTable() called. |
nodata | The color to use for NODATA areas, where there are no elevation values. |
progress_callback | If supplied, this function will be called back with a value of 0 to 100 as the operation progresses. |
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.
nColumns | The number of columns (east-west) |
nRows | THe number of rows (north-south) |
float vtHeightFieldGrid3d::GetInterpolatedElevation | ( | double | findex_x, |
double | findex_y, | ||
bool | bTrue = false |
||
) | 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)
findex_x | Floating point index, from 0 to width in heixels. |
findex_y | Floating point index, from 0 to height in heixels. |
bTrue | Use the true elevation, ignoring any scaling/exaggeration. |
|
inline |
Get the grid spacing, the width of each column and row.
|
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 |
||
) | const |
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".
pBM | The bitmap to shade. |
light_dir | Direction vector of the light. |
fLightFactor | Value from 0 (no shading) to 1 (full shading) |
fAmbient | Ambient light values from 0 to 1, a typical value is 0.1. |
fGamma | Gamma values from 0 to 1, values less than 1 boost the brightness curve. |
bTrue | If true, use the real elevation values, ignoring vertical exaggeration. |
progress_callback | If 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 |
||
) | const |
ShadowCastDib - method to create shadows over the terrain based on the angle of the sun.
pBM | An interface to the bitmap to be shaded. |
light_dir | The 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. |
fLightFactor | Amount of shading, from 0 to 1. A value of 0 means no lighting, 1 means full lighting. |
fAmbient | Amount of ambient light, from 0 to 1. A typical value is 0.1. |
progress_callback | Optional callback for progress notification. |