Click or drag to resize
AB4D logo

MeshOctTree Class

MeshOctTree class organizes the triangles in 3D space into multiple levels of MeshOctTreeNode objects so that the search of a triangle or check for triangle ray intersection is very efficient. Each MeshOctTreeNode divide its space into 8 child MeshOctTreeNode.
Inheritance Hierarchy
SystemObject
  Ab3d.DirectXMeshOctTree
    Ab3d.DirectXOctTree

Namespace: Ab3d.DirectX
Assembly: Ab3d.DXEngine (in Ab3d.DXEngine.dll) Version: 7.0.8865.1045
Syntax
C#
public class MeshOctTree

The MeshOctTree type exposes the following members.

Constructors
 NameDescription
Public methodMeshOctTree(PositionNormalTexture, Int32, Int32, Single) Creates a new instance of MeshOctTree. The instance is created with a standard vertex buffer format (an array of PositionNormalTexture). If you need to create an MeshOctTree with an array of positions instead, then use the other constructor.
Public methodMeshOctTree(Vector3, Int32, Int32, Single) Creates a new instance of MeshOctTree. The instance is created with an array of positions (array of Vector3 values). If you need to create an MeshOctTree with a standard vertex buffer format (an array of PositionNormalTexture) instead, then use the other constructor.
Public methodMeshOctTree(PositionNormalTexture, Int32, BoundingBox, Int32, Single) Creates a new instance of MeshOctTree. The instance is created with a standard vertex buffer format (an array of PositionNormalTexture). If you need to create an MeshOctTree with an array of positions instead, then use the other constructor.
Public methodMeshOctTree(Vector3, Int32, BoundingBox, Int32, Single) Creates a new instance of MeshOctTree. The instance is created with an array of positions (array of Vector3 values). If you need to create an MeshOctTree with a standard vertex buffer format (an array of PositionNormalTexture) instead, then use the other constructor.
Top
Methods
 NameDescription
Public methodCollectBoundingBoxesInLevel CollectBoundingBoxesInLevel is a diagnostics method and returns a list of bounding boxes from child nodes.
Public methodGetAllHitResults HitTest method executes a ray hit test on this oct tree and returns a list of DXRayHitTestResult with all the hit results sorted from the closest to the farthest. If no triangle is hit, an empty list is returned. To get only the closest hit results call method.
Public methodGetNodesCountInAllLevels GetNodesCountInAllLevels is a diagnostics method and returns the number of child nodes (MeshOctTreeNode objects) in this MeshOctTree.
Public methodGetNodesCountInLevel GetNodesCountInLevel is a diagnostics method and returns the number of nodes (MeshOctTreeNode objects) in the specified node level.
Public methodGetNodeStatistics GetNodeStatistics is a diagnostics method and returns a string that describes the details about this MeshOctTree.
Public methodStatic memberGetTrianglesCountInLevel GetTrianglesCountInLevel is a diagnostics method and returns the number of triangles in the specified node and its child nodes.
Public methodHitTest HitTest method executes a ray hit test on this oct tree and returns a DXRayHitTestResult with the closest triangle in this oct tree that is hit by the specified ray. If not triangle is hit, null is returned. To get all hit results call method.
Top
Fields
 NameDescription
Public fieldExpandChildBoundingBoxes ExpandChildBoundingBoxes is a float that defined how much the bounding boxes of node overlap. By default the value is set to 0.2 - so each bounding box is extended for 20% (but it does not go out of the parent's bounding box). This way the triangles that lay on node borders will be put into the child nodes instead of having them in the parent node (there we need to do a hit test every time).
Public fieldMaxNodeLevel Number of levels used for MeshOctTree - bigger number reduces the number of triangles in each node but increased the MeshOctTree initialization time and used memory. Default value is 4.
Public fieldRootNode Root MeshOctTreeNode
Top
Remarks

MeshOctTree class organizes the triangles in 3D space into multiple levels of MeshOctTreeNode objects so that the search of a triangle or check for triangle ray intersection is very efficient. Each MeshOctTreeNode divide its space into 8 child MeshOctTreeNode.

The number of levels (depth) is defined by the MaxNodeLevel that can be specified with the constructor. Bigger number reduces the number of triangles in each node but increased the MeshOctTree initialization time and used memory.

See Also