Home | Download | Screen shots | Discussion | Documentation | Links |
---|
Inheritance diagram for BVolume:
Public Types | |
enum | Intersection { inside = 1, outside = -1, partial = 0 } |
Public Methods | |
virtual | ~BVolume ()=0 |
Destructor. | |
virtual bool | isMAX () const=0 |
Gets the MAX flag. | |
virtual void | setMAX ()=0 |
Sets the MAX flag. | |
virtual Intersection | intersectFrustum (const VrmlFrustum &frustum) const=0 |
Intersect this bvolume with a frustum. | |
virtual void | extend (const BVolume &b)=0 |
Extend this bvolume to enclose the given bvolume. | |
virtual void | extend (const float p[3])=0 |
Extend this bvolume to enclose the given point. | |
virtual void | extend (const AABox &b)=0 |
Extend this bvolume to enclose the given box. | |
virtual void | extend (const BSphere &b)=0 |
Extend this bvolume to enclose the given sphere. | |
virtual void | enclose (const float *p, int n)=0 |
Enclose the given set of points. | |
virtual void | orthoTransform (const VrmlMatrix &M)=0 |
Transform this bounding volume using an orthogonal transfom. | |
virtual void | transform (const VrmlMatrix &M)=0 |
Transform this bounding volume using an affine transfom. |
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.
|
|
Destructor.
|
|
Enclose the given set of points. This resets the volume from any previous values.
|
|
Extend this bvolume to enclose the given sphere.
|
|
Extend this bvolume to enclose the given box.
Implemented in BSphere. |
|
Extend this bvolume to enclose the given point.
|
|
Extend this bvolume to enclose the given bvolume. This is tricky, because C++ doesn't provide us a way to figure out exactly what sort of bvolume we have been passed, yet we have to know in order to do the appropriate math. What we really need is double dispatch but C++ does not provide it. What the implementation will probably do is use the toBSphere and toAABox methods to test for the actual type of the parameter, and redispatch to extend(sphere) or extend(box). Alternatively, we could use the double dispatch pattern as described in the Gang of Four patterns book. We need this because nodes like Group don't know until runtime exactly what sort of bounding volumes their children will have. Group could test using toBSphere and toAABox, but it's better to centralize ugly stuff like that.
|
|
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 AABox. |
|
Gets the MAX flag. The convention is that nodes that should be rendered unconditionally set a MAX bvolume, 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.
|
|
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
|
|
Sets the MAX flag.
|
|
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
|