net.java.dev.joode.util
Class AABBSet

java.lang.Object
  extended by net.java.dev.joode.util.AABBSet

public class AABBSet
extends java.lang.Object

Represents a collection of axis-aligned bounding boxes (AABBs).

The goal of this class is to find intersections between a set of AABBs and rays, another AABB, or another set of AABBs.

The class uses a few different techniques for finding intersections between sets of AABBs. For small sets, a brute-force technique -- testing all pairs of AABBs -- is used. Otherwise, the boxes of each set are first sorted according to their min and max X and Z coordinates.

This implementation is derived from GIMPACT, a software library for geometry processing and collision detection.

Author:
Art Pope

Nested Class Summary
static class AABBSet.ElementPair
          Indexes a pair of AABBs in the collection.
 
Constructor Summary
AABBSet(int length)
          Constructs an AABBSet for a specified number of bounding boxes.
 
Method Summary
 java.util.Collection<AABBSet.ElementPair> findIntersections(AABBSet set2)
          Finds all intersections between this elements of this AABBSet and those of another.
 AABB3f getGlobalBounds()
          Gets an AABB bounding the entire collection.
 void setBounds(int i, Point3f p0, Point3f p1, Point3f p2)
          Sets an AABB to the bounds about 3 points.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AABBSet

public AABBSet(int length)
Constructs an AABBSet for a specified number of bounding boxes.

Method Detail

setBounds

public void setBounds(int i,
                      Point3f p0,
                      Point3f p1,
                      Point3f p2)
Sets an AABB to the bounds about 3 points.


getGlobalBounds

public AABB3f getGlobalBounds()
Gets an AABB bounding the entire collection.

Returns:
an AABB bounding the entire collection. The AABB still "belongs to" to this AABBSet; make a copy of it if you wish to modify it.

findIntersections

public java.util.Collection<AABBSet.ElementPair> findIntersections(AABBSet set2)
Finds all intersections between this elements of this AABBSet and those of another. This method uses brute-force search if both sets are small, and otherwise sorts them.

Parameters:
set2 - the other AABBSet
Returns:
a list of AABBSet#ElementPair objects, each containing the index of a box in this AABBSet (AABBSet#ElementPair#index1) and an intersecting box in the other AABBSet (AABBSet#ElementPair#index2).