The Nebula Device 3: Math::bbox Class Reference

The Nebula Device 3

Math::bbox Class Reference

#include <bbox.h>


Detailed Description

Nebula's bounding box class.

Todo:
: UNTESTED!
(C) 2004 RadonLabs GmbH

Public Types

enum  
 clip codes

Public Member Functions

 bbox ()
 constructor 1
 bbox (const point &center, const vector &extents)
 constructor 3
 bbox (const matrix44 &m)
 construct bounding box from matrix44
point center () const
 get center of box
vector extents () const
 get extents of box
vector size () const
 get size of box
scalar diagonal_size () const
 get diagonal size of box
void set (const matrix44 &m)
 set from matrix44
void set (const point &center, const vector &extents)
 set from center point and extents
void begin_extend ()
 begin extending the box
void extend (const point &p)
 extend the box
void extend (const bbox &box)
 extend the box
void end_extend ()
 this resets the bounding box size to zero if no extend() method was called after begin_extend()
void transform (const matrix44 &m)
 transform bounding box
bool intersects (const bbox &box) const
 check for intersection with axis aligned bounding box
bool contains (const bbox &box) const
 check if this box completely contains the parameter box
bool contains (const point &p) const
 return true if this box contains the position
ClipStatus::Type clipstatus (const bbox &other) const
 check for intersection with other bounding box
ClipStatus::Type clipstatus (const matrix44 &viewProjection) const
 check for intersection with projection volume
matrix44 to_matrix44 () const
 create a matrix which transforms a unit cube to this bounding box
point corner_point (int index) const
 return one of the 8 corner points
void get_clipplanes (const matrix44 &viewProjection, Util::Array< plane > &outPlanes) const
 return side planes in clip space

Member Function Documentation

void Math::bbox::set ( const matrix44 m  )  [inline]

set from matrix44

Construct a bounding box around a 4x4 matrix. The translational part defines the center point, and the x,y,z vectors of the matrix define the extents.

void Math::bbox::end_extend (  )  [inline]

this resets the bounding box size to zero if no extend() method was called after begin_extend()

This just checks whether the extend() method has actually been called after begin_extend() and just sets vmin and vmax to the null vector if it hasn't.

void Math::bbox::transform ( const matrix44 m  )  [inline]

transform bounding box

Transforms this axis aligned bounding by the 4x4 matrix. This bounding box must be axis aligned with the matrix, the resulting bounding will be axis aligned in the matrix' "destination" space.

E.g. if you have a bounding box in model space 'modelBox', and a 'modelView' matrix, the operation

modelBox.transform(modelView)

would transform the bounding box into view space.

bool Math::bbox::intersects ( const bbox box  )  const [inline]

check for intersection with axis aligned bounding box

Check for intersection of 2 axis aligned bounding boxes. The bounding boxes must live in the same coordinate space.

bool Math::bbox::contains ( const bbox box  )  const [inline]

check if this box completely contains the parameter box

Check if the parameter bounding box is completely contained in this bounding box.

bool Math::bbox::contains ( const point p  )  const [inline]

return true if this box contains the position

Check if position is inside bounding box.

ClipStatus::Type Math::bbox::clipstatus ( const bbox other  )  const

check for intersection with other bounding box

Return box/box clip status.

ClipStatus::Type Math::bbox::clipstatus ( const matrix44 viewProjection  )  const

check for intersection with projection volume

Check for intersection with a view volume defined by a view-projection matrix.

matrix44 Math::bbox::to_matrix44 (  )  const [inline]

create a matrix which transforms a unit cube to this bounding box

Create a transform matrix which would transform a unit cube to this bounding box.

point Math::bbox::corner_point ( int  index  )  const

return one of the 8 corner points

Returns one of the 8 corners of the bounding box.

void Math::bbox::get_clipplanes ( const matrix44 viewProj,
Util::Array< plane > &  outPlanes 
) const

return side planes in clip space

Get the bounding box's side planes in clip space.