Home | Download | Screen shots | Discussion | Documentation |
---|
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.
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. |
openvrml::bounding_volume::~bounding_volume | ( | ) | [pure virtual] |
Destructor.
void openvrml::bounding_volume::maximize | ( | ) | [pure virtual] |
Maximize the bounding volume.
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.
true
if the bounding voume is maximized; false
otherwise.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.)
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
.
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
.
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
.
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.
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.
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.
M | orthonormal transformation matrix in mat4f format |
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.
M | affine transformation matrix. |
Implemented in openvrml::bounding_sphere, and openvrml::axis_aligned_bounding_box.