openvrml::bounding_volume Class Reference

Inheritance diagram for openvrml::bounding_volume:
[legend]

List of all members.


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

bounding_sphere

axis_aligned_bounding_box


Public Types

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

Public Member Functions

virtual ~bounding_volume ()=0
 Destructor.
virtual void maximize ()=0
 Maximize the bounding volume.
virtual bool maximized () const =0
 Indicates whether the bounding volume is maximized.
virtual intersection intersect_frustum (const openvrml::frustum &frustum) const =0
 Intersect this bvolume with a frustum.
virtual void extend (const bounding_volume &bv)=0
 Extend the bounding_volume to enclose bv.
virtual void extend (const vec3f &p)=0
 Extend the bounding volume to enclose p.
virtual void extend (const axis_aligned_bounding_box &bbox)=0
 Extend the bounding volume to enclose bbox.
virtual void extend (const bounding_sphere &bs)=0
 Extend this bvolume to enclose the given sphere.
virtual void enclose (const std::vector< vec3f > &points)=0
 Enclose the given set of points.
virtual void ortho_transform (const mat4f &M)=0
 Transform this bounding volume using an orthogonal transfom.
virtual void transform (const mat4f &M)=0
 Transform this bounding volume using an affine transfom.

Member Enumeration Documentation

Enumerator:
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

openvrml::bounding_volume::~bounding_volume (  )  [pure virtual]

Destructor.


Member Function Documentation

void openvrml::bounding_volume::maximize (  )  [pure virtual]

Maximize the bounding volume.

See also:
maximized

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

bool openvrml::bounding_volume::maximized (  )  const [pure virtual]

Indicates whether the bounding volume is maximized.

The convention is that nodes that should be rendered unconditionally set a maximum bounding volume, 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:
true if the bounding voume is maximized; false otherwise.
See also:
maximize

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

bounding_volume::intersection openvrml::bounding_volume::intersect_frustum ( const openvrml::frustum 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:
bounding_volume::transform

bounding_volume::ortho_transform

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::extend ( const bounding_volume bv  )  [pure virtual]

Extend the bounding_volume to enclose bv.

Parameters:
bv a bounding volume.

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::extend ( const vec3f p  )  [pure virtual]

Extend the bounding volume to enclose p.

Parameters:
p a point

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::extend ( const axis_aligned_bounding_box bbox  )  [pure virtual]

Extend the bounding volume to enclose bbox.

Parameters:
bbox an axis-aligned bounding box.

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::extend ( const bounding_sphere b  )  [pure virtual]

Extend this bvolume to enclose the given sphere.

Parameters:
b a bounding sphere

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::enclose ( const std::vector< vec3f > &  points  )  [pure virtual]

Enclose the given set of points.

This resets the volume from any previous values.

Parameters:
points points.

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::ortho_transform ( const mat4f 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 mat4f format
See also:
MathUtils

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::transform ( const mat4f 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 ortho_transform, 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.

Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.