C3DMesh::BuildOctree

Top  Previous  Next

Syntax:

 

BuildOctree(int  maxPoly, int  depth)

 

Purpose:

Builds an octree for the mesh.

 

Parameters:

maxPoly - Maximum triangle count for each node.

depth - The maximum depth of the tree.

 

Returned value(s):

None

 

Application:

if Mesh3.Load3DS(s, GETSTARTPATH + "park.3ds",FALSE)
    mesh3.BuildOctree(500,4)
    'initialize the collision system for this mesh
    mesh3.InitCollision(FALSE)
endif

 

Class Hierarchy

C3DObject

-------C3DMesh

 

Additional Info:

An octree separates a mesh into equally sized blocks of eight. Each block will be further separated depending on the maxPoly and depth settings. Using octrees speeds up rendering of a scene by only drawing parts of the mesh that are currently in view of the camera. The original data is unchanged and multiple index buffers are used to render the correct parts of the mesh.

 

Octrees work best on large objects ( > 1000 polys)  with a depth level of 5 or less.  The larger the tree the more time it will take to determine which parts are visible. BuildOctree has no effect on landscape or skinned mesh objects.

 

Once an octree is built it will be used automatically when drawing the mesh. No further interaction is required.

 

See Also: