Home | Download | Screen shots | Discussion | Documentation |
---|
A bounding volume. More...
#include <openvrml/bounding_volume.h>
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 . |
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.
|
pure virtual |
Destroy.
void openvrml::bounding_volume::maximize | ( | ) |
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.
true
if the bounding voume is maximized; false
otherwise.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.)
[in] | frustum | the frustum. |
void openvrml::bounding_volume::extend | ( | const vec3f & | p | ) |
Extend the bounding volume to enclose p
.
Delegates to bounding_volume::do_extend
.
[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 &)
.
[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
.
[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
.
[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
.
[in] | M | affine transformation matrix. |
|
privatepure virtual |
Called by bounding_volume::maximize
.
|
privatepure virtual |
Called by bounding_volume::maximized
.
true
if the bounding voume is maximized; false
otherwise.
|
privatepure virtual |
Called by bounding_volume::intersect_frustum
[in] | frustum | the frustum. |
|
privatepure virtual |
Extend the bounding volume to enclose p
.
[in] | p | a point |
|
privatepure virtual |
Called by bounding_volume::extend(const bounding_volume &)
.
[in] | bbox | an axis-aligned bounding box. |
|
privatepure virtual |
Called by bounding_volume::extend(const bounding_volume &)
.
[in] | b | a bounding sphere |
|
privatepure virtual |
Called by bounding_volume::enclose
.
[in] | points | points. |
|
privatepure virtual |
Called by bounding_volume::ortho_transform
.
[in] | M | orthonormal transformation matrix in mat4f format |
|
privatepure virtual |
Called by bounding_volume::transform
.
[in] | M | affine transformation matrix. |