osg::BoundingBox Class Reference

General purpose axis-aligned bounding box class for enclosing objects/vertices. More...

List of all members.

Public Types

typedef Vec3d vec_type
typedef double value_type

Public Member Functions

 BoundingBox ()
 Creates an uninitialized bounding box.
 BoundingBox (value_type xmin, value_type ymin, value_type zmin, value_type xmax, value_type ymax, value_type zmax)
 Creates a bounding box initialized to the given extents.
 BoundingBox (const vec_type &min, const vec_type &max)
 Creates a bounding box initialized to the given extents.
void init ()
 Clear the bounding box.
bool valid () const
 Returns true if the bounding box extents are valid, false otherwise.
void set (value_type xmin, value_type ymin, value_type zmin, value_type xmax, value_type ymax, value_type zmax)
 Sets the bounding box extents.
void set (const vec_type &min, const vec_type &max)
 Sets the bounding box extents.
value_typexMin ()
value_type xMin () const
value_typeyMin ()
value_type yMin () const
value_typezMin ()
value_type zMin () const
value_typexMax ()
value_type xMax () const
value_typeyMax ()
value_type yMax () const
value_typezMax ()
value_type zMax () const
const vec_type center () const
 Calculates and returns the bounding box center.
value_type radius () const
 Calculates and returns the bounding box radius.
value_type radius2 () const
 Calculates and returns the squared length of the bounding box radius.
const vec_type corner (unsigned int pos) const
 Returns a specific corner of the bounding box.
void expandBy (const vec_type &v)
 Expands the bounding box to include the given coordinate.
void expandBy (value_type x, value_type y, value_type z)
 Expands the bounding box to include the given coordinate.
void expandBy (const BoundingBox &bb)
 Expands this bounding box to include the given bounding box.
void expandBy (const BoundingSphere &sh)
 Expands this bounding box to include the given sphere.
BoundingBox intersect (const BoundingBox &bb) const
 Returns the intersection of this bounding box and the specified bounding box.
bool intersects (const BoundingBox &bb) const
 Return true if this bounding box intersects the specified bounding box.
bool contains (const vec_type &v) const
 Returns true if this bounding box contains the specified coordinate.

Public Attributes

vec_type _min
 Minimum extent.
vec_type _max
 Maximum extent.


Detailed Description

General purpose axis-aligned bounding box class for enclosing objects/vertices.

Bounds leaf objects in a scene such as osg::Drawable objects. Used for frustum culling etc.


Member Typedef Documentation


Constructor & Destructor Documentation

osg::BoundingBox::BoundingBox (  )  [inline]

Creates an uninitialized bounding box.

osg::BoundingBox::BoundingBox ( value_type  xmin,
value_type  ymin,
value_type  zmin,
value_type  xmax,
value_type  ymax,
value_type  zmax 
) [inline]

Creates a bounding box initialized to the given extents.

osg::BoundingBox::BoundingBox ( const vec_type min,
const vec_type max 
) [inline]

Creates a bounding box initialized to the given extents.


Member Function Documentation

void osg::BoundingBox::init (  )  [inline]

Clear the bounding box.

Erases existing minimum and maximum extents.

bool osg::BoundingBox::valid (  )  const [inline]

Returns true if the bounding box extents are valid, false otherwise.

Referenced by osg::CullStack::isCulled().

void osg::BoundingBox::set ( value_type  xmin,
value_type  ymin,
value_type  zmin,
value_type  xmax,
value_type  ymax,
value_type  zmax 
) [inline]

Sets the bounding box extents.

void osg::BoundingBox::set ( const vec_type min,
const vec_type max 
) [inline]

Sets the bounding box extents.

value_type& osg::BoundingBox::xMin (  )  [inline]

value_type osg::BoundingBox::xMin (  )  const [inline]

value_type& osg::BoundingBox::yMin (  )  [inline]

value_type osg::BoundingBox::yMin (  )  const [inline]

value_type& osg::BoundingBox::zMin (  )  [inline]

value_type osg::BoundingBox::zMin (  )  const [inline]

value_type& osg::BoundingBox::xMax (  )  [inline]

value_type osg::BoundingBox::xMax (  )  const [inline]

value_type& osg::BoundingBox::yMax (  )  [inline]

value_type osg::BoundingBox::yMax (  )  const [inline]

value_type& osg::BoundingBox::zMax (  )  [inline]

value_type osg::BoundingBox::zMax (  )  const [inline]

const vec_type osg::BoundingBox::center (  )  const [inline]

Calculates and returns the bounding box center.

value_type osg::BoundingBox::radius (  )  const [inline]

Calculates and returns the bounding box radius.

value_type osg::BoundingBox::radius2 (  )  const [inline]

Calculates and returns the squared length of the bounding box radius.

Note, radius2() is faster to calculate than radius().

const vec_type osg::BoundingBox::corner ( unsigned int  pos  )  const [inline]

Returns a specific corner of the bounding box.

pos specifies the corner as a number between 0 and 7. Each bit selects an axis, X, Y, or Z from least- to most-significant. Unset bits select the minimum value for that axis, and set bits select the maximum.

Referenced by osg::Plane::intersect().

void osg::BoundingBox::expandBy ( const vec_type v  )  [inline]

Expands the bounding box to include the given coordinate.

If the box is uninitialized, set its min and max extents to v.

References osg::Vec3d::x(), osg::Vec3d::y(), and osg::Vec3d::z().

void osg::BoundingBox::expandBy ( value_type  x,
value_type  y,
value_type  z 
) [inline]

Expands the bounding box to include the given coordinate.

If the box is uninitialized, set its min and max extents to Vec3(x,y,z).

void osg::BoundingBox::expandBy ( const BoundingBox bb  ) 

Expands this bounding box to include the given bounding box.

If this box is uninitialized, set it equal to bb.

void osg::BoundingBox::expandBy ( const BoundingSphere sh  ) 

Expands this bounding box to include the given sphere.

If this box is uninitialized, set it to include sh.

BoundingBox osg::BoundingBox::intersect ( const BoundingBox bb  )  const [inline]

Returns the intersection of this bounding box and the specified bounding box.

References osg::maximum(), osg::minimum(), xMax(), xMin(), yMax(), yMin(), zMax(), and zMin().

bool osg::BoundingBox::intersects ( const BoundingBox bb  )  const [inline]

Return true if this bounding box intersects the specified bounding box.

References osg::maximum(), osg::minimum(), xMax(), xMin(), yMax(), yMin(), zMax(), and zMin().

bool osg::BoundingBox::contains ( const vec_type v  )  const [inline]

Returns true if this bounding box contains the specified coordinate.

References osg::Vec3d::x(), osg::Vec3d::y(), and osg::Vec3d::z().


Member Data Documentation

Minimum extent.

(Smallest X, Y, and Z values of all coordinates.)

Maximum extent.

(Greatest X, Y, and Z values of all coordinates.)


The documentation for this class was generated from the following file:

Generated at Thu Aug 14 04:59:46 2008 for the OpenSceneGraph by doxygen 1.5.6.