Nebula
|
#include <bbox.h>
Nebula's bounding box class.
Public Types | |
enum | { ClipLeft = N_BIT(0) , ClipRight = N_BIT(1) , ClipBottom = N_BIT(2) , ClipTop = N_BIT(3) , ClipNear = N_BIT(4) , ClipFar = N_BIT(5) } |
clip codes More... | |
Public Member Functions | |
bbox () | |
constructor 1 | |
bbox (const point ¢er, const vector &extents) | |
constructor 3 | |
bbox (const mat4 &m) | |
construct bounding box from mat4 | |
point | center () const |
get center of box | |
vector | extents () const |
get extents of box | |
vec3 | size () const |
get size of box | |
scalar | diagonal_size () const |
get diagonal size of box | |
void | set (const mat4 &m) |
set from mat4 | |
void | set (const point ¢er, const vector &extents) |
set from center point and extents | |
void | begin_extend () |
begin extending the box | |
void | extend (const vec3 &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 mat4 &m) |
transform bounding box | |
void | affine_transform (const mat4 &m) |
affine transform bounding box, does not allow for projections | |
bool | intersects (const bbox &box) const |
check for intersection with axis aligned bounding box | |
bool | intersects (const line &ray, float &t) const |
check for intersection with ray. parameter t will be filled with the "time" of intersection along line.m . | |
bool | contains (const bbox &box) const |
check if this box completely contains the parameter box | |
bool | contains (const vec3 &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 mat4 &viewProjection, const bool isOrtho=false) const |
check for intersection with projection volume | |
ClipStatus::Type | clipstatus (const vec4 *x_columns, const vec4 *y_columns, const vec4 *z_columns, const vec4 *w_columns, const bool isOrtho=false) const |
check for intersection with pre-calculated columns | |
mat4 | to_mat4 () 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 mat4 &viewProjection, Util::Array< vec4 > &outPlanes) const |
return side planes in clip space | |
template<typename T > | |
T | as () const |
convert to any type | |
float | area () const |
calculate half-area of the surface of the box. If you need the full area, just multiply by 2. | |
Public Attributes | |
point | pmin |
point | pmax |
|
inline |
constructor 1
|
inline |
affine transform bounding box, does not allow for projections
|
inline |
calculate half-area of the surface of the box. If you need the full area, just multiply by 2.
T Math::bbox::as | ( | ) | const |
convert to any type
|
inline |
begin extending the box
|
inline |
get center of box
ClipStatus::Type Math::bbox::clipstatus | ( | const bbox & | other | ) | const |
check for intersection with other bounding box
Return box/box clip status.
__forceinline ClipStatus::Type Math::bbox::clipstatus | ( | const mat4 & | viewProjection, |
const bool | isOrtho = false ) const |
check for intersection with projection volume
__forceinline ClipStatus::Type Math::bbox::clipstatus | ( | const vec4 * | x_columns, |
const vec4 * | y_columns, | ||
const vec4 * | z_columns, | ||
const vec4 * | w_columns, | ||
const bool | isOrtho = false ) const |
check for intersection with pre-calculated columns
|
inline |
check if this box completely contains the parameter box
Check if the parameter bounding box is completely contained in this bounding box.
|
inline |
return true if this box contains the position
Check if position is inside 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.
|
inline |
get diagonal size of box
|
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.
|
inline |
extend the box
|
inline |
extend the box
|
inline |
get extents of box
void Math::bbox::get_clipplanes | ( | const mat4 & | viewProjection, |
Util::Array< vec4 > & | outPlanes ) const |
return side planes in clip space
Get the bounding box's side planes in clip space.
|
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.
|
inline |
check for intersection with ray. parameter t will be filled with the "time" of intersection along line.m
.
Ray/AABB Slab test from Real-Time Collision Detection by Christer Ericsson Assumes ray is normalized.
|
inline |
set from mat4
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.
set from center point and extents
|
inline |
get size of box
|
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.
|
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.
point Math::bbox::pmax |
point Math::bbox::pmin |