Main Page   Class Hierarchy   Compound List   Header Files   Compound Members  

ddgTBinMesh Class Reference

Triangle Bintree mesh shared data.
. More...

#include <ddgtmesh.h>

List of all members.


Public Members

 ddgTBinMesh ( ddgHeightMap *i)
Constructor, pass in the size of the BinTree. More...

 ~ddgTBinMesh (void)
Destroy the Bintree mesh.

bool init ( ddgContext *ctx )
Initialize the mesh.

void initNeighbours ( void )
Initialize the neighbour field of all triangles.

void initVertex ( unsigned int level, ddgTriIndex va, ddgTriIndex v1, ddgTriIndex v0, ddgTriIndex vc)
Initialize the vertex and row/col data of the STri. More...

void incrTriVis (void)
Increment the number of visible triangles.

void decrTriVis (void)
Decrement the number of visible triangles.

unsigned int countTriVis (void)
Return the number of visible triangles.

unsigned int edge (ddgTriIndex i)
Return the edge status of a tri.

ddgTriIndex* indexLUT (void)
Return the index lookup table.

ddgTriIndex v0 (ddgTriIndex i)
Get triangle vertex 0.

ddgTriIndex v1 (ddgTriIndex i)
Get triangle vertex 1.

ddgTCachetcache (void)
Return the cache of active triangles.

bool merge (void)
Return merge queue state.

void merge (bool m)
Set merge queue state.

bool splitRun (void)
Are we doing a split only run.

ddgQCacheqscache (void)
Return the cache of priority queue.

ddgQCacheqmcache (void)
Return the cache of priority queue.

ddgTriIndex lookupIndex ( unsigned short row, unsigned short col )
Look up a triangle index based on a row and column.

ddgHeightMapheightMap (void)
Return a pointer to the height map object.

float wheight (short rh)
Return the raw height converted to world space.

unsigned int minDetail ( void )
Return the required LOD.

void minDetail ( unsigned int d )
Set the required LOD.

unsigned int maxDetail ( void )
Return the required LOD.

void maxDetail ( unsigned int d )
Set the required LOD.

unsigned int absMaxDetail ( void )
Return the absolute maximum number of triangles to support.

void absMaxDetail ( unsigned int d )
Set the absolute maximum number of triangles to support.

unsigned int triNo (void)
Return the number of triangles.

unsigned int leafTriNo (void)
Return the number of triangles.

unsigned int maxLevel ( void )
Return the number of split levels.

bool calculate (ddgContext *ctx)
Calculate the optimal set of triangles for the mesh at current camera pos. More...

void addBinTree ( ddgTBinTree *bt )
Function to add a bintree.

void removeBinTree ( ddgTBinTree *bt )
Function to remove a bintree.

ddgTBinTreegetBinTree ( ddgTreeIndex i)
Return the bintree for a given index.

unsigned int getBinTreeNo (void)
Return the total number of bintrees managed by this mesh.

float farClip (void)
Distant clip range triangles beyond this point are not needed.

float farClipSQ (void)
Squared Distant clip range triangles beyond this point are not needed.

float nearClip (void)
Near clip range triangles beyond this point are not needed.

void farClip (float f)
Distant clip range triangles beyond this point are not needed.

void nearClip (float n)
Near clip range triangles beyond this point are not needed.

bool mapPosToTree (float *x, float *z, ddgTBinTree **bt, unsigned int *r, unsigned int *c)
Input: x,z in mesh coords (note these values are modified). More...

float height (float x, float z)
Get height of mesh at a real location. More...

int absDiffHeight (void)
The difference between the highest point on the mesh and the lowest point.

int absMinHeight (void)
The lowest point on the mesh.

int absMaxHeight (void)
The highest point on the mesh.

ddgBBox3bbox (void)
Return the worldspace bounding box of the mesh.

void triCountIncr (void)
Total number of triangles rendered.

unsigned int triCount (void)
Total number of triangles rendered.

unsigned int priCount (void)
Total number of priorities calculated.

unsigned int insCount (void)
Total number of queue insertions.

unsigned int remCount (void)
Total number of queue removals.

unsigned int movCount (void)
Total number of queue updates.

unsigned int visCount (void)
Total number visibility calculations.

unsigned int balCount (void)
Total number balance calculations for this frame.

ddgMSTristri
Pointer to an array of MTri objects.


Detailed Description

Triangle Bintree mesh shared data.
.

General construction of a BinTree and the indexing of vertices:

The top level triangle consists of vertices (0,3,2), triangle vertices are enumerated counter clock-wise. Va is the top of the triangle, Vc is the new split point or center, V0 is the left coord w.r.t. vc and V1 is the right coord w.r.t. vc. This triangle has 2 children (the Bin in BinTree) which are T0 and T1, (0,1,n+1) and (0,n,1), respectively (the left and the right child with respect to vc).
Each sub triangle can be split again, 1st the left into (1,2,0) and (1,n+1,2) and the right into (1,0,3) and (1,3,n). For the left and right sub triangle, 1 becomes va and 2 becomes vc for the left child and 3 becomes vc for the right child, etc. A triangle is identified by its Vc coordinate since that is unique, Va, V0 and V1 are shared with other triangles. Therefor all information that it stores is associated with Vc. Each sub level in the tree adds twice as many triangles as were present in the previous level. So with each level required storage double That only leaves a problem for the top most triangle which needs to store its left and right children from somwhere. In this implementation, this info is stored at index n and n+1. This scheme allows very fast computation of the indices which represent the parent or children of any given triangle.

 This diagram shows the index numbers, names for the top level triangle
 (va,vc,v0,v1) and to map coordinates of the top level vertices.

        0,0      3     size,0
    (va) 0 +-----+-----+ n (v1)
           |\    |    /
           | \   T1  /
           |  \  |  /
           |   \ | /
           |    \|/
         2 +-T0--+ 1 (vc)
           |    /  
           |   /
           |  /
           | /
           |/
   0,size  + n+1 (v0)
Neighbours:
If the triangles 2 and 3 are split again, their vc vertices will lie halfway between vertices 0 and 1. They will produce 4 children which all share this common vc, however since the triangles (2 and 3) are seperate triangles, the vc point is stored twice, once for 2 and once for 3. To keep the mesh from cracking, if 2 is split, 3 must split also. No T-junctions are allowed. Because of this rule, 2 and 3 are considered neighbours and they form a split diamond. There is no easy way to know which triangle is the neighbour of another, for this reason neigbour indices are precomputed and stored in a table. All other indices are readily available from the given triangle's own index.


Member Function Documentation

ddgTBinMesh::ddgTBinMesh (ddgHeightMap * i)

Constructor, pass in the size of the BinTree.

s = size along one edge of one BinTree. i = image object from which to contruct the mesh.

void ddgTBinMesh::initVertex (unsigned int level, ddgTriIndex va, ddgTriIndex v0, ddgTriIndex v1, ddgTriIndex vc)

Initialize the vertex and row/col data of the STri.

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 ddgTBinMesh::calculate (ddgContext * ctx)

Calculate the optimal set of triangles for the mesh at current camera pos.

returns true if any calculation was performed.

bool ddgTBinMesh::mapPosToTree (float * x, float * z, ddgTBinTree ** bt, unsigned int * r, unsigned int * c)

Input: x,z in mesh coords (note these values are modified).

Output: Bintree which owns this coord. Row/Col of triangle which owns this coord in the bintree. x,z offsets from the triangle origin to the coord. Note for mirrored trees the x,z offsets are relative to the mirrored tree. Return: ddgFailure if input location does not map to a location on the mesh.

float ddgTBinMesh::height (float x, float z)

Get height of mesh at a real location.

Coords should be unscaled in x,z direction. Cannot be called before init.


The documentation for this class was generated from the following files:
Generated at Sun Sep 17 19:27:56 2000 for Digital Dawn Graphics Toolkit by doxygen 0.49-991205 written by Dimitri van Heesch, © 1997-1999