Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

BVolume Class Reference

A bounding volume. More...

Inheritance diagram for BVolume:

AABox BSphere List of all members.

Public Types

enum  Intersection {
  inside = 1,
  outside = -1,
  partial = 0
}

Public Methods

virtual ~BVolume ()=0
 Destructor.

virtual bool isMAX () const=0
 Gets the MAX flag.

virtual void setMAX ()=0
 Sets the MAX flag.

virtual Intersection intersectFrustum (const VrmlFrustum &frustum) const=0
 Intersect this bvolume with a frustum.

virtual void extend (const BVolume &b)=0
 Extend this bvolume to enclose the given bvolume.

virtual void extend (const float p[3])=0
 Extend this bvolume to enclose the given point.

virtual void extend (const AABox &b)=0
 Extend this bvolume to enclose the given box.

virtual void extend (const BSphere &b)=0
 Extend this bvolume to enclose the given sphere.

virtual void enclose (const float *p, int n)=0
 Enclose the given set of points.

virtual void orthoTransform (const VrmlMatrix &M)=0
 Transform this bounding volume using an orthogonal transfom.

virtual void transform (const VrmlMatrix &M)=0
 Transform this bounding volume using an affine transfom.


Detailed Description

A bounding volume.

All the geometry in a scene maintains a bounding volume to help speed up rendering and picking. Although currently we're just using spheres, the plan is to eventually use tighter bounds like axis aligned boxes around nodes that are expected to be static. That probably means boxes for geometry and spheres for grouping nodes.

See also:
Node::render

BSphere

AABox


Member Enumeration Documentation

enum Intersection
 

Enumeration values:
inside  Results of an intersection; indicates that the tested volume is entirely inside the target volume.

outside  Results of an intersection; indicates that the tested volume is entirely outside the target volume.

partial  Results of an intersection; indicates that the tested volume intersects with the target volume.


Constructor & Destructor Documentation

~BVolume   [pure virtual]
 

Destructor.


Member Function Documentation

void enclose const float *    p,
int    n
[pure virtual]
 

Enclose the given set of points.

This resets the volume from any previous values.

Parameters:
p array of floats, each set of 3 represents a point
n number of points (not number of floats!)

void extend const BSphere   b [pure virtual]
 

Extend this bvolume to enclose the given sphere.

Parameters:
b a bounding sphere

void extend const AABox   b [pure virtual]
 

Extend this bvolume to enclose the given box.

Parameters:
b an axis-aligned box

Implemented in BSphere.

void extend const float    p[3] [pure virtual]
 

Extend this bvolume to enclose the given point.

Parameters:
p a point

void extend const BVolume &    b [pure virtual]
 

Extend this bvolume to enclose the given bvolume.

This is tricky, because C++ doesn't provide us a way to figure out exactly what sort of bvolume we have been passed, yet we have to know in order to do the appropriate math. What we really need is double dispatch but C++ does not provide it.

What the implementation will probably do is use the toBSphere and toAABox methods to test for the actual type of the parameter, and redispatch to extend(sphere) or extend(box). Alternatively, we could use the double dispatch pattern as described in the Gang of Four patterns book.

We need this because nodes like Group don't know until runtime exactly what sort of bounding volumes their children will have. Group could test using toBSphere and toAABox, but it's better to centralize ugly stuff like that.

Parameters:
b a bounding volume of unknown type

BVolume::Intersection intersectFrustum const VrmlFrustum   frustum const [pure virtual]
 

Intersect this bvolume with a frustum.

The test assumes that the frustum is in the canonical looking-down-negative-z orientation, so the bounding volume is going to have to be transformed into the frustum's space. (Alternatives include transforming the frustum into the bvolume's space, or transforming both of them into the projection space. Lots of tradeoffs involved, but transforming the bvolume is probably the simplest approach overall.)

Parameters:
frustum the frustum.
Returns:
inside, outside, or partial.
See also:
BVolume::transform

BVolume::orthoTransform

Implemented in AABox.

bool isMAX   const [pure virtual]
 

Gets the MAX flag.

The convention is that nodes that should be rendered unconditionally set a MAX bvolume, ensuring that the branch they are on does not get pruned during culling. Stuff like the picking code needs a way to differentiate this from just a really big bounding volume, or an unset bounding volume.

Returns:
the max flag
See also:
setMax

void orthoTransform const VrmlMatrix   M [pure virtual]
 

Transform this bounding volume using an orthogonal transfom.

Orthogonal transformations preserve angles. They include translation, rotation, and uniform scaling. It turns out to be so easy to transform bounding spheres by orthogonal transformations that it's worth special casing. The caller is responsible for assuring that the transformation is in fact orthogonal, otherwise the results are undefined. If in doubt, call transform instead and take the speed hit.

Parameters:
M orthonormal transformation matrix in VrmlMatrix format
See also:
MathUtils

void setMAX   [pure virtual]
 

Sets the MAX flag.

See also:
isMAX

void transform const VrmlMatrix   M [pure virtual]
 

Transform this bounding volume using an affine transfom.

Affine transformations can include nonuniform scaling. It is much messier to deal with them, but VRML allows nonuniform scaling, so we have to handle it. Note that since all orthogonal transforms are affine, it's safe to always call this routine instead of orthoTransform, but it's likely to be slower. The results are undefined if this routine is called with a non-affine argument. Note that VRML Transform nodes only allow affine transformations, so unless you're doing something tricky this routine should always be safe.

Parameters:
M affine transformation matrix in VrmlMatrix format
See also:
MathUtils