Added support for reading and writing OccluderNode's to the .osg file format.

This commit is contained in:
Robert Osfield
2002-06-19 16:06:03 +00:00
parent b12e36cede
commit 77e1fb7f80
8 changed files with 230 additions and 10 deletions

View File

@@ -57,6 +57,11 @@ class SG_EXPORT BoundingBox
return _max.x()>=_min.x();
}
inline const bool valid() const
{
return _max.x()>=_min.x();
}
inline void set (float xmin,float ymin,float zmin,
float xmax,float ymax,float zmax)
{

View File

@@ -10,6 +10,8 @@
namespace osg {
class BoundingBox;
/** General purpose bounding sphere class for enclosing nodes/objects/vertices.
Used to bound internal osg::Node's in the scene,
to assist in view frustum culling etc. Similar in function to BoundingBox
@@ -40,6 +42,10 @@ class SG_EXPORT BoundingSphere
false if the bounding sphere is effectively unset.*/
inline const bool isValid() const { return _radius>=0.0f; }
/** return true if the bounding sphere contains valid values,
false if the bounding sphere is effectively unset.*/
inline const bool valid() const { return _radius>=0.0f; }
/** set bounding sphere.*/
inline void set(const Vec3& center,float radius)
{
@@ -86,6 +92,17 @@ class SG_EXPORT BoundingSphere
If this sphere is empty then move the centrer to v and set radius to 0. */
void expandRadiusBy(const BoundingSphere& sh);
/** If incomming box is outwith the sphere expand to ecompass incomming box.
calculates the combination of movement of center and radius which
minimizes the radius increase. If this boz is empty then
move the centrer to v and set radius to 0.*/
void expandBy(const BoundingBox& bb);
/** If incomming box is outwith the sphere expand radius to ecompass incomming box.
Unlike update, does not move the center, just increasing the radius.
If this sphere is empty then move the centrer to v and set radius to 0. */
void expandRadiusBy(const BoundingBox& bb);
/** return true is vertex v is within the sphere.*/
inline const bool contains(const Vec3& v) const
{

View File

@@ -6,7 +6,7 @@
#define OSG_CONVEXPLANEROCCLUDER 1
#include <osg/ConvexPlanerPolygon>
#include <osg/Referenced>
#include <osg/Object>
namespace osg {
@@ -14,14 +14,18 @@ class OccluderVolume;
/** A class for representing convex clipping volumes made up.
* When adding planes, their normals should point inwards (into the volume) */
class SG_EXPORT ConvexPlanerOccluder : public Referenced
class SG_EXPORT ConvexPlanerOccluder : public Object
{
public:
inline ConvexPlanerOccluder() {}
ConvexPlanerOccluder():Object() {}
ConvexPlanerOccluder(const ConvexPlanerOccluder& cpo,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Object(cpo,copyop),
_occluder(cpo._occluder),
_holeList(cpo._holeList) {}
META_Object(osg,ConvexPlanerOccluder)
void setOccluder(const ConvexPlanerPolygon& cpp) { _occluder = cpp; }
@@ -47,9 +51,7 @@ class SG_EXPORT ConvexPlanerOccluder : public Referenced
protected:
float _area;
Vec3 _center;
Vec3 _normal;
~ConvexPlanerOccluder() {}
ConvexPlanerPolygon _occluder;
HoleList _holeList;

View File

@@ -41,6 +41,9 @@ class SG_EXPORT OccluderNode : public Group
virtual ~OccluderNode() {}
/** Override's Group's computeBound.*/
virtual const bool computeBound() const;
ref_ptr<ConvexPlanerOccluder> _occluder;
};