Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

# openvrml::bounding_volume Class Reference

A bounding volume. More...

`#include <openvrml/bounding_volume.h>`

Inheritance diagram for openvrml::bounding_volume:
[legend]

List of all members.

## 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

enum openvrml::bounding_volume::intersection

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]` | frustum | the 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]` | p | a 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]` | bv | a 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]` | points | points.

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]` | M | orthonormal 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]` | M | affine transformation matrix.

void openvrml::bounding_volume::do_maximize | ( |  | ) | `[private, pure virtual]`

Called by `bounding_volume::maximize`.

See also:
  maximize

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

bool openvrml::bounding_volume::do_maximized | ( |  | ) | const`[private, pure virtual]`

Called by `bounding_volume::maximized`.

Returns:
  `true` if the bounding voume is maximized; `false` otherwise.

See also:
  openvrml::bounding_volume::maximized

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

openvrml::bounding_volume::intersection openvrml::bounding_volume::do_intersect_frustum | ( | const openvrml::frustum & | frustum | ) | const`[private, pure virtual]`

Called by `bounding_volume::intersect_frustum`.

Parameters:

  `[in]` | frustum | the frustum.

Returns:
  inside, outside, or partial.

See also:
  openvrml::bounding_volume::transform
  openvrml::bounding_volume::ortho_transform

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

void openvrml::bounding_volume::do_extend | ( | const vec3f & | p | ) | `[private, pure virtual]`

Extend the bounding volume to enclose `p`.

Parameters:

  `[in]` | p | a point

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

void openvrml::bounding_volume::do_extend | ( | const axis_aligned_bounding_box & | bbox | ) | `[private, pure virtual]`

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

Parameters:

  `[in]` | bbox | an axis-aligned bounding box.

Implemented in openvrml::bounding_sphere.

void openvrml::bounding_volume::do_extend | ( | const bounding_sphere & | b | ) | `[private, pure virtual]`

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

Parameters:

  `[in]` | b | a bounding sphere

Implemented in openvrml::axis_aligned_bounding_box.

void openvrml::bounding_volume::do_enclose | ( | const std::vector< vec3f > & | points | ) | `[private, pure virtual]`

Called by `bounding_volume::enclose`.

Parameters:

  `[in]` | points | points.

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

void openvrml::bounding_volume::do_ortho_transform | ( | const mat4f & | M | ) | `[private, pure virtual]`

Called by `bounding_volume::ortho_transform`.

Parameters:

  `[in]` | M | orthonormal transformation matrix in mat4f format

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

void openvrml::bounding_volume::do_transform | ( | const mat4f & | M | ) | `[private, pure virtual]`

Called by `bounding_volume::transform`.

Parameters:

  `[in]` | M | affine transformation matrix.

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