Stonehenge in a box

Stonehenge in a box. A model of Stonehenge contained in an axially aligned bounding box.

RHTgrAABB

The RHTgrAABB class implements an axially aligned bounding box which calculates the position and extents, in world space, of the box that defines the bounds of the items contained within it. RHTgrAABB also provides methods for determining bounding box intersection, and bisection.

Download

RHTgrAABB is included in the RHTgrCamera package and is available individually below.

rhtgraabb_win32.zip
rhtgraabb_sunOS_32.tar.gz

 

Calling Sequence

oAABB = OBJ_NEW('RHTgrAABB', [oModel], [, COLOR=index or RGB vector] [, DOUBLE{Get, Set}={0 | 1}], [, /SHOWBOUNDS {Get, Set}])

Keywords

color

Set this keyword to a 3 element vector specifying the color of the bounding box.

Default: [128,128,128]

double

Set this keyword to store and return the bounding box position and extents in double precision.

Default: 0.

showBounds

Set this keyword to make the bounds of the bounding box visible when drawn.

Default: 0.

Methods

This object inherits methods from it's superclass, IDLgrModel, and adds or modifies the following methods:

Add

This procedure method adds a model (or models) to the bounding box. You can only add IDLgrModels or children of IDLgrModel. You cannot add children of IDLgrGraphic a.k.a. graphics "atoms". Care should be taken when constructing the object hierarchy being added to the bounding box. Extraneous instances of IDLgrModel in the object hierarchy will slow the calculation of the bounding box. After adding the new model(s) the bounding box updates it's position and extents properties.

oOrbOne = OBJ_NEW('orb', POS=[-10,0,0])
oOrbTwo = OBJ_NEW('orb', POS=[0,0,5])
oAABB = OBJ_NEW('RHTgrAABB')
oAABB -> Add, [oOrbOne, oOrbTwo]

Bisect

This function method bisects the bounding box about the specified axis and location and returns two structures [left, right] containing information about the objects in the bisected halves. If an object spans the bisecting axis it will appear in both the left and right structures. The returned data structures have the following form:

left = {position:[0.,0.,0.], $
        extents:[0.,0.,0.], $
        models:OBJARR(), $
        nModels:0L $
       }
right = {position:[0.,0.,0.], $
         extents:[0.,0.,0.], $
         models:OBJARR(), $
         nModels:0L $
        }
where position is the position (center) of the left or right bounding box created by the bisection, extents is the extents of this bounding box, and models contains an array of object references specifying the models contained within the box. Nmodels contains a long representing the number of models contained within the bounding box. Set the AXIS argument to 0,1, or 2 to specify bisection along the X, Y, or Z axis respectively. Set the LOCATION argument to specify where on the axis to cut the bounding box. Set the DUPLICATES keyword to return a 2xn array containing the index values of left.models and right.models respectivly that span the bisecting axis. This method is under construction.

leftRight = oAABB -> Bisect(0, 5.0)

GetAABB

This procedure method updates the position and extents properties and optionally returns this data to the caller. This procedure method must be called if any of the objects contained in the bounding box have changed (models have been manipulated, vertices changed, coordinate conversions altered). Set the ALL keyword to return positions and extents for all models that have been added to the bounding box.

oAABB -> GetAABB, POSITION=pos, EXTENTS=ext

Intersects

This function method tests the intersection between this bounding box and another. The other bounding box can be either a valid reference to another instance of RHTgrAABB or it can be provided via the POSITION and EXTENTS keywords. You must provide either a reference to a second RHTgrAABB object or both the POSITION and EXTENTS keywords. The function returns TRUE (1) if the two bounding boxes intersect and FALSE (0) if they do not.

OrbThree = OBJ_NEW('orb', POS=[-1,1,2], $
    RADIUS=2.0)
oAABBTwo = OBJ_NEW('RHTgrAABB')
oAABBTwo -> Add, oOrbThree

intersect = oAABB -> Intersects, oAABBTwo

;   Or alternatively:
intersect = oAABB -> POSITION=[-1,1,2], $
    EXTENTS=[2,2,2]

Remove

This procedure method removes a model from the bounding box. Set the ALL keyword to remove all models contained within the bounding box. After removing the model(s) the bounding box updates it's position and extents properties.

oAABB -> Remove, oOrbOne

IDL @ the FAR Lab

IDL Code

RHTgrCamera

RHTgrAABB

RHTgrQuaternion

directInput.dlm

Miscellaneous

Using jEdit with IDL

CODEC Comparison

IDL Links

About