lilith3d::TerrainMesh Class Reference

#include <terrainmesh.h>

List of all members.


Detailed Description

Perhaps the largest class in Lilith, the TerrainMesh is the highly optimized terrain drawing class. It supports advanced culling, level of detain, and other functions. It is automatically created by the Lilith engine.


Public Member Functions

void LoadHeightMap (const char *filename)
void RandomHeightMap (U32 seed)
int IntersectRay (const grinliz::Vector3F &point, const grinliz::Vector3F &dir, grinliz::Vector3F *intersect, void **state)
float CalcHeight (float x, float y, grinliz::Vector3F *at=0, bool *inWater=0)
void PointToPoly (float x, float y, int vind[], grinliz::Vector3F vertex[], bool *passable)
float Height (int x, int y)
void StartHeightChange ()
void SetHeight (int x, int y, float height)
 Set the terrain height. Can only be called between StartHeightChange() and EndHeightChange().
void SetHeightDelta (int x, int y, float delta)
 Set the height as an offset. Can only be called between StartHeightChange() and EndHeightChange().
void SetHeightFiltered (int x, int y, float height)
void EndHeightChange (bool callListeners=true)
 End the height change sequence, and notify the listeners.
void LockHeight (const grinliz::Rectangle2I &bounds)
void UnLockHeight (const grinliz::Rectangle2I &bounds)
 Unlocks a height change zones.
std::vector< grinliz::Vector2F > * FindPath (float startX, float startY, float endX, float endY)
std::vector< grinliz::Vector2F > * FindPath (const LilithObject &start, const LilithObject &end)
bool CanPlaceBuilding (int x, int y, const StaticResource *meshResource, grinliz::Rectangle2I *outVertexBounds)
BuildingMeshCreateBuilding (int x, int y, const StaticResource *meshResource)


Member Function Documentation

void lilith3d::TerrainMesh::LoadHeightMap ( const char *  filename  ) 

Loads a height map from a bitmap. The bitmap must be at least the vertex size of the terrain.

void lilith3d::TerrainMesh::RandomHeightMap ( U32  seed  ) 

Create a random height map.

int lilith3d::TerrainMesh::IntersectRay ( const grinliz::Vector3F &  point,
const grinliz::Vector3F &  dir,
grinliz::Vector3F *  intersect,
void **  state 
)

Intersects a ray with the terrain mesh.

Parameters:
point Point of origin of the ray.
dir Direction of the ray
intersect Out: the intersection point with the terrain
state Internal use. Pass null.
Returns:
INTERSECT or REJECT

float lilith3d::TerrainMesh::CalcHeight ( float  x,
float  y,
grinliz::Vector3F *  at = 0,
bool *  inWater = 0 
)

Accurately computes the height at the given x,y. Moderately expensive. InWater reflects whether the ray hit the water, in which case "at" will reflect the underwater hit.

Returns the height value of the hit.

void lilith3d::TerrainMesh::PointToPoly ( float  x,
float  y,
int  vind[],
grinliz::Vector3F  vertex[],
bool *  passable 
) [inline]

From a point, retrieve the triangle information it is in. This is the standard and correct poly lookup routine, and accounts for all rounding errors. The "intersect" routines are approximations from a round off perspective.

CalcHeight is a derivitive of PointToPoly and gives consistent results.

float lilith3d::TerrainMesh::Height ( int  x,
int  y 
) [inline]

Return the heightmap at a vertex position. Not necessarity the height drawn - only CalcHeight() can return that.

void lilith3d::TerrainMesh::StartHeightChange (  )  [inline]

Call to start a terrain height change.

void lilith3d::TerrainMesh::SetHeightFiltered ( int  x,
int  y,
float  height 
)

Set the terrain height. Can only be called between StartHeightChange() and EndHeightChange(). This version distributes the set over 9 vertices.

void lilith3d::TerrainMesh::LockHeight ( const grinliz::Rectangle2I &  bounds  ) 

Locks a rectangle to prevent it from height changing. Call "UnLock" with the exact same bounds to remove. The engine will correctly account for overlapping bounds.

std::vector< grinliz::Vector2F >* lilith3d::TerrainMesh::FindPath ( float  startX,
float  startY,
float  endX,
float  endY 
)

Finds a path between 2 points, returned as a vector of points. This is an expensive call - especially of no path exists.* Lots of pathing should be spread out over multiple frames.

std::vector< grinliz::Vector2F >* lilith3d::TerrainMesh::FindPath ( const LilithObject start,
const LilithObject end 
)

Finds a path between 2 objects, returned as a vector of points. This is an expensive call - especially of no path exists.* Lots of pathing should be spread out over multiple frames.

bool lilith3d::TerrainMesh::CanPlaceBuilding ( int  x,
int  y,
const StaticResource meshResource,
grinliz::Rectangle2I *  outVertexBounds 
)

Queries whether a building can be placed at the given x,y. Will return 'true' if it can, and the (possibly slightly modified) position where the building will go.

BuildingMesh* lilith3d::TerrainMesh::CreateBuilding ( int  x,
int  y,
const StaticResource meshResource 
)

A building mesh can not be new'd. It is created by this factory method. Buildings can fail to be created for many reasons, and this method will ofter return null. CanPlaceBuilding() can pre-establish success, as well.


The documentation for this class was generated from the following file:
Generated on Fri Mar 23 19:36:28 2007 for Lilith3D by  doxygen 1.5.1-p1