openvrml::bounding_volume Class Reference

A bounding volume. More...

#include <openvrml/bounding_volume.h>

Inheritance diagram for openvrml::bounding_volume:

Public Types

enum  intersection {
  outside = -1,
  partial = 0,
  inside = 1
}
 Indicates the type of intersection. More...

Public Member Functions

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

Private Member Functions

virtual void do_maximize ()=0
 Called by bounding_volume::maximize.
virtual bool do_maximized () const =0
 Called by bounding_volume::maximized.
virtual intersection do_intersect_frustum (const openvrml::frustum &frustum) const =0
 Called by bounding_volume::intersect_frustum
virtual void do_extend (const vec3f &p)=0
 Extend the bounding volume to enclose p.
virtual void do_extend (const axis_aligned_bounding_box &bbox)=0
 Called by bounding_volume::extend(const bounding_volume &).
virtual void do_extend (const bounding_sphere &bs)=0
 Called by bounding_volume::extend(const bounding_volume &).
virtual void do_enclose (const std::vector< vec3f > &points)=0
 Called by bounding_volume::enclose.
virtual void do_ortho_transform (const mat4f &M)=0
 Called by bounding_volume::ortho_transform.
virtual void do_transform (const mat4f &M)=0
 Called by bounding_volume::transform.

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
openvrml::bounding_sphere
openvrml::axis_aligned_bounding_box

Member Enumeration Documentation

Indicates the type of intersection.

Enumerator:
outside 

Indicates that the tested volume is entirely outside the target volume.

partial 

Indicates that the tested volume intersects with the target volume.

inside 

Indicates that the tested volume is entirely inside the target volume.

Constructor & Destructor Documentation

openvrml::bounding_volume::~bounding_volume ( ) throw ()
pure virtual

Destroy.

Member Function Documentation

void openvrml::bounding_volume::maximize ( )

Maximize the bounding volume.

Delegates to bounding_volume::do_maximize.

See Also
maximized
bool openvrml::bounding_volume::maximized ( ) const throw ()

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

Intersect this bounding_volume 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
[in]frustumthe frustum.
Returns
inside, outside, or partial.
See Also
openvrml::bounding_volume::transform
openvrml::bounding_volume::ortho_transform
void openvrml::bounding_volume::extend ( const vec3f p)

Extend the bounding volume to enclose p.

Delegates to bounding_volume::do_extend.

Parameters
[in]pa point
void openvrml::bounding_volume::extend ( const bounding_volume bv)

Extend the bounding_volume to enclose bv.

Delegates to bounding_volume::do_extend(const bounding_sphere &) and bounding_volume::do_extend(const axis_alligned_bounding_box &).

Parameters
[in]bva bounding volume.
void openvrml::bounding_volume::enclose ( const std::vector< vec3f > &  points)

Enclose the given set of points.

This resets the volume from any previous values.

Delegates to bounding_volume::do_enclose.

Parameters
[in]pointspoints.
void openvrml::bounding_volume::ortho_transform ( const mat4f M)

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.

Delegates to bounding_volume::do_ortho_transform.

Parameters
[in]Morthonormal transformation matrix.
void openvrml::bounding_volume::transform ( const mat4f M)

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.

Delegates to bounding_volume::do_transform.

Parameters
[in]Maffine transformation matrix.
void openvrml::bounding_volume::do_maximize ( )
privatepure virtual

Called by bounding_volume::maximize.

See Also
maximize
bool openvrml::bounding_volume::do_maximized ( ) const
privatepure virtual

Called by bounding_volume::maximized.

Returns
true if the bounding voume is maximized; false otherwise.
See Also
openvrml::bounding_volume::maximized
openvrml::bounding_volume::intersection openvrml::bounding_volume::do_intersect_frustum ( const openvrml::frustum frustum) const
privatepure virtual

Called by bounding_volume::intersect_frustum

Parameters
[in]frustumthe frustum.
Returns
inside, outside, or partial.
See Also
openvrml::bounding_volume::transform
openvrml::bounding_volume::ortho_transform
void openvrml::bounding_volume::do_extend ( const vec3f p)
privatepure virtual

Extend the bounding volume to enclose p.

Parameters
[in]pa point
void openvrml::bounding_volume::do_extend ( const axis_aligned_bounding_box bbox)
privatepure virtual

Called by bounding_volume::extend(const bounding_volume &).

Parameters
[in]bboxan axis-aligned bounding box.
void openvrml::bounding_volume::do_extend ( const bounding_sphere b)
privatepure virtual

Called by bounding_volume::extend(const bounding_volume &).

Parameters
[in]ba bounding sphere
void openvrml::bounding_volume::do_enclose ( const std::vector< vec3f > &  points)
privatepure virtual

Called by bounding_volume::enclose.

Parameters
[in]pointspoints.
void openvrml::bounding_volume::do_ortho_transform ( const mat4f M)
privatepure virtual

Called by bounding_volume::ortho_transform.

Parameters
[in]Morthonormal transformation matrix in mat4f format
void openvrml::bounding_volume::do_transform ( const mat4f M)
privatepure virtual

Called by bounding_volume::transform.

Parameters
[in]Maffine transformation matrix.