#include <ddgbtree.h>
Public Members | |||
ddgTBinTree (ddgTreeIndex i, int dr = 0, int dc = 0, bool mirror = false) | |||
Construct a Bintree mesh. | |||
~ddgTBinTree (void) | |||
Destroy the Bintree mesh. | |||
void | freeChain (void) | ||
Free all the cached nodes in this bintree. | |||
ddgCacheIndex | chain (void) | ||
Free all the cached nodes in this bintree. | |||
unsigned int | visTriangle (void) | ||
Return the number of visible triangles which this bin tree is managing. | |||
void | visTriangle (unsigned int v) | ||
Set the number of visible triangles which this bin tree is managing. | |||
ddgTBinTree* | pNeighbourDiag (void) | ||
Return the neighbouring bin tree. | |||
ddgTBinTree* | pNeighbourTop (void) | ||
Return the neighbouring bin tree. | |||
ddgTBinTree* | pNeighbourLeft (void) | ||
Return the neighbouring bin tree. | |||
void | pNeighbourDiag (ddgTBinTree* t) | ||
Set the neighbouring bin tree. | |||
void | pNeighbourTop (ddgTBinTree* t) | ||
Set the neighbouring bin tree. | |||
void | pNeighbourLeft (ddgTBinTree* t) | ||
Set the neighbouring bin tree. | |||
int | dc (void) | ||
Returns the column offset in the height map. | |||
int | dr (void) | ||
Returns the row offset in the height map. | |||
bool | mirror (void) | ||
Returns true if this is a mirrored mesh. | |||
bool | init (void) | ||
Initialize the bin tree. | |||
void | tcacheId ( ddgTriIndex tindex, ddgCacheIndex ci ) | ||
Set the cache index for a triangle. | |||
ddgCacheIndex | tcacheId ( ddgTriIndex tindex ) | ||
Get the cache index for a triangle. | |||
short | rawHeight ( ddgTriIndex tindex ) | ||
Get the raw height for a triangle. | |||
short | rawMinVal ( ddgTriIndex tindex ) | ||
Get the min height for a triangle block. | |||
short | rawMaxVal ( ddgTriIndex tindex ) | ||
Get the max height for a triangle block. | |||
ddgVisState | vis (void) | ||
Return toplevel visibility state. | |||
ddgVisState | vis (ddgTriIndex tindex) | ||
Return the objects visibility state. | |||
void | vis (ddgTriIndex tindex, ddgVisState v) | ||
Set the objects visibility state. | |||
int | priority (ddgTriIndex tindex) | ||
Return the priority of this triangle. | |||
void | priority (ddgTriIndex tindex, int p) | ||
Set the priority of this triangle. | |||
float | priorityFactor (ddgTriIndex tindex) | ||
Return the priority of this triangle. | |||
void | priorityFactor (ddgTriIndex tindex, float pf) | ||
Set the priority of this triangle. | |||
ddgCacheIndex | qscacheIndex (ddgTriIndex tindex) | ||
Return split cache index if any. | |||
void | qscacheIndex (ddgTriIndex tindex, ddgCacheIndex i) | ||
Set split cache index if any. | |||
ddgCacheIndex | qmcacheIndex (ddgTriIndex tindex) | ||
Return split cache index if any. | |||
void | qmcacheIndex (ddgTriIndex tindex, ddgCacheIndex i) | ||
Set split cache index if any. | |||
float | heightByPos (unsigned int r, unsigned int c) | ||
Return the height of a location on the bintree mesh. | |||
float | treeHeight (unsigned int r, unsigned int c, float dx, float dz) | ||
Get height of mesh at a real location. More... | |||
void | vertex (ddgTriIndex tindex, ddgVector3 *vout) | ||
Get vertex location in world space from the cache, return the cache index if we have it. | |||
void | textureC (unsigned int tindex, ddgVector2 *vout) | ||
Get texture coord data, as a value from 0 to 1 on the bintree. | |||
ddgVisState | visibilityTriangle (ddgTriIndex tvc) | ||
Calculate visibility of a triangle. | |||
bool | visible (ddgTriIndex i) | ||
Is triangle visible (even partially)? | |||
bool | fullyvisible (ddgTriIndex i) | ||
Is triangle fully visible? | |||
void | initTriangle ( unsigned int level, ddgTriIndex va, ddgTriIndex v1, ddgTriIndex v0, ddgTriIndex vc) | ||
Initialize precomputed parameters. More... | |||
void | insertSQ (ddgTriIndex tindex, ddgPriority p, ddgCacheIndex ci, ddgVisState parentVis ) | ||
Split queue operations. | |||
ddgCacheIndex | removeSQ (ddgTriIndex tindex) | ||
Remove triangle tindex. | |||
void | insertMQ (ddgTriIndex tindex, ddgPriority p) | ||
Split queue operations. | |||
void | removeMQ (ddgTriIndex tindex) | ||
void | forceSplit ( ddgTriIndex tindex) | ||
Split a triangle into 2. | |||
void | forceMerge ( ddgTriIndex tindex) | ||
Merge 4 triangles into 2. | |||
void | updateSplit (ddgTriIndex tindex, ddgVisState newVis ) | ||
Recursively update the split info for a triangle which is in the mesh. | |||
void | updateMerge (ddgTriIndex tindex, ddgPriority pr) | ||
Update the merge info for a triangle which is in the mesh. | |||
ddgPriority | priorityCalc (ddgTriIndex tindex, float priorityFactor) | ||
Calculate priority of triangle tindex We assume that we only get called. | |||
unsigned int | index (void) | ||
Return the index in the mesh. | |||
bool | rayTest ( ddgVector3 p1, ddgVector3 p2, ddgTriIndex tindex, int depth = -1 ) | ||
Ray test a line segment to see if it collides with the terrain. More... | |||
Static Public Members | |||
unsigned int | level (ddgTriIndex i) | ||
Return the level of this triangle based on its index. | |||
bool | isRight (ddgTriIndex i) | ||
If this is odd (right) or even(left) child in the tree. | |||
bool | isLeft (ddgTriIndex i) | ||
If this is odd (right) or even(left) child in the tree. | |||
ddgTriIndex | parent (ddgTriIndex i) | ||
Return the parent of this element. | |||
ddgTriIndex | right (ddgTriIndex i) | ||
Return the index of the left child. | |||
ddgTriIndex | left (ddgTriIndex i) | ||
Return the index of the left child. | |||
void | initContext ( ddgContext *context, ddgTBinMesh *mesh ) | ||
Initialize view context called once during initialization. | |||
void | updateContext ( ddgContext *context, ddgTBinMesh *mesh ) | ||
Update view context called each frame. |
The mesh is a hierarchical binary tree of triangles. The structure of this mesh can be precomputed and stored as a large look-up-table. Triangles are organized in the array so they can easily find their parent or children as well as all the triangles of their own generation. This can all be done with index arithmetic (ie. no need for pointers).
float ddgTBinTree::treeHeight (unsigned int r, unsigned int c, float dx, float dz) |
Get height of mesh at a real location.
Coords should be unscaled in x,z direction.
void ddgTBinTree::initTriangle (unsigned int level, ddgTriIndex va, ddgTriIndex v0, ddgTriIndex v1, ddgTriIndex vc) |
Initialize precomputed parameters.
Recusively calculate a convex hull for a triangle. Splitting occurs along this points parent's Passed in are the triangles which carry the points that describe the current triangle. va is immediate parent. v1 and v0 are the sub triangles of va.
bool ddgTBinTree::rayTest (ddgVector3 p1, ddgVector3 p2, ddgTriIndex tindex, int depth = -1) |
Ray test a line segment to see if it collides with the terrain.
A depth of 0 implies testing to the leaf nodes. Returns true and the index of the triangle if a hit occured. Returns false otherwise.