Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AABB or Axis Aligned Bounding Box is a very simple and fast object for testing intersection/containment of two 3D regions.</p> <p>As you suggest, you are calculating a min and max x,y,z for the two regions you want to compare, for example, the region that describes a frustum and the region that describes a mesh. It is axis aligned because the subsequent cube has edges parallel with each of the axis of the coordinate system. Obviously this can be slightly inaccurate (false positives of intersection/containment, but never false negatives), and so once you filter your list with the AABB test, you might consider performing a more accurate test for the remaining meshes.</p> <p>You test for intersection/containment as follows:</p> <p>F = AABB of frustum</p> <p>M = AABB of mesh</p> <pre><code>bool is_mesh_in_frustum(const AABB&amp; F, const AABB&amp; M) { if( F.min.x &gt; M.max.x || M.min.x &gt; F.max.x || F.min.y &gt; M.max.y || M.min.y &gt; F.max.y || F.min.z &gt; M.max.z || M.min.z &gt; F.max.z ) { return false; } return true; } </code></pre> <p>You can also look up algorithms for bounding spheres, oriented bounding box (OBB), and other types of bounding volumes. Depending on how many meshes you are rendering, you may or may not need a more accurate method.</p> <p>To create an AABB in the first place, you could simply walk the vertices of the mesh and record the minimum/maximum x and y and z values you encounter.</p> <p>Also consider, if the meshes dont deform, then the bounding box in the meshes coordinate space are going to be static, so you can calculate the AABB for all the meshes as soon as you have the vertex data.</p> <p>Then you just have to make sure you transform the precalculated AABB min and max vertices into the frustum coordinate space before you do the test each render pass.</p> <p>EDIT (for comment):</p> <p>The AABB can provide false positives because it is at best the exact shape of the region you are bounding, but is more typically larger than the region you are bounding.</p> <p>Consider a sphere, if you use AABB, its like putting a basket ball into a box, you have all these gaps at the corners of the box where the ball cant reach.</p> <p>Or in the case of a frustum where the frustum angles inwards towards the camera, the AABB for it will simply continue straight along the axis towards the camera, effectively bounding a region larger than the camera can see.</p> <p>This is a source of inaccuracy, but it should never result in you culling an object that is even slightly inside the frustum, so at worst you will still be drawing some meshes that are close to the camera but still outside the frustum.</p> <p>You can rectify this by first doing a AABB test, and producing a smaller list of meshes that return true and then performing a more accurate test on that smaller list with a more accurate bounding volume for the frustum and/or meshes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload