120 likes | 162 Views
Octrees. Purposes. Collision Detection Only need to check against objects within the node containing the object being calculated Occlusion Culling If a node has a visible object then all children nodes are also visible Ray Tracing. Purpose continued. Spatial Indexing
E N D
Purposes • Collision Detection • Only need to check against objects within the node containing the object being calculated • Occlusion Culling • If a node has a visible object then all children nodes are also visible • Ray Tracing
Purpose continued • Spatial Indexing • Can split data into different nodes based on how similar the data is to the data within each node • Octree colour quantization • Can convert a 24bit RGB image to paletted 8bit by limiting the depth of each octant and averaging any colors that would go deeper than the limit with the deepest nodes color • Realtime Shadows
BSP Trees • Binary Space Partitioning • Used for Occlusion Culling
Quadtree • A node either has 4 children or none • For example, the below quadtree has a rule that no more than 3 dots can exist in a square.
Quadtree • Landscape example:
Quadtree continued struct quad { int x,y; // position of center node top_left,top_right; node bottom_left,bottom_right; // Other data here };
Octree • Like a Quadtree except 3D • Splits into 8 subsections (octants)
Octree continued struct node { int x,y,z; // position of center node nodeList[8]; // Other data here };
Regular vs Loose • Each octant overlaps its’ siblings by a factor of .5 • Anything half the size of a parent node will fit completely inside a child node
Ogre • Ogre uses Octree as one of the generic scene managers • mRoot->createSceneManager (ST_GENERIC); • Octree Scene Manager • Uses an octree to split the scene and performs well for most scenes, except those which are reliant on heavy occlusion. • Pros: • A simple and generic solution, works well for most scenes • Can use the StaticGeometry class to accelerate large chunks of immovable geometry • Cons: • No specific acceleration for particular scene structures • Heavily occluded scenes will need a more specialised solution