Added new osg::OccluderNode which subclasses from osg::Group, and will

provide hooks for adding ConvexPlanerOccluders to the scene.
This commit is contained in:
Robert Osfield
2002-06-05 09:39:04 +00:00
parent 4d2dbdafac
commit 5feba17410
9 changed files with 103 additions and 15 deletions

View File

@@ -277,6 +277,10 @@ SOURCE=..\..\src\osg\Object.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osg\OccluderNode.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osg\Point.cpp
# End Source File
# Begin Source File
@@ -577,6 +581,10 @@ SOURCE=..\..\Include\Osg\Object
# End Source File
# Begin Source File
SOURCE=..\..\Include\Osg\OccluderNode
# End Source File
# Begin Source File
SOURCE=..\..\Include\Osg\Plane
# End Source File
# Begin Source File

View File

@@ -8,7 +8,6 @@
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/Drawable>
#include <osg/ConvexPlanerOccluder>
namespace osg {
@@ -109,17 +108,6 @@ class SG_EXPORT Geode : public Node
/** compile OpenGL Display List for each geoset.*/
void compileDrawables(State& state);
/** Attach a ConvexPlanerOccluder to a Geode.*/
void setOccluder(ConvexPlanerOccluder* occluder) { _occluder = occluder; }
/** Get the ConvexPlanerOccluder* attached to a Geode. */
ConvexPlanerOccluder* getOccluder() { return _occluder.get(); }
/** Get the const ConvexPlanerOccluder* attached to a Geode.*/
const ConvexPlanerOccluder* getOccluder() const { return _occluder.get(); }
protected:
virtual ~Geode();
@@ -127,7 +115,6 @@ class SG_EXPORT Geode : public Node
virtual const bool computeBound() const;
DrawableList _drawables;
ref_ptr<ConvexPlanerOccluder> _occluder;
};

View File

@@ -22,6 +22,7 @@ class LOD;
class Switch;
class Impostor;
class EarthSky;
class OccluderNode;
/** Visitor for type safe operations on osg::Node's.
Based on GOF's Visitor pattern. The NodeVisitor
@@ -179,6 +180,7 @@ class SG_EXPORT NodeVisitor : public Referenced
virtual void apply(LOD& node) { apply((Group&)node); }
virtual void apply(Impostor& node) { apply((LOD&)node); }
virtual void apply(EarthSky& node) { apply((Group&)node); }
virtual void apply(OccluderNode& node) { apply((Group&)node); }
protected:

49
include/osg/OccluderNode Normal file
View File

@@ -0,0 +1,49 @@
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSG_OCCLUDERNODE
#define OSG_OCCLUDERNODE 1
#include <osg/Group>
#include <osg/ConvexPlanerOccluder>
namespace osg {
/** OccluderNode is a Group node which allows OccluderNodeing between children.
Typical uses would be for objects which might need to be rendered
differently at different times, for instance a OccluderNode could be used
to represent the different states of a traffic light.
*/
class SG_EXPORT OccluderNode : public Group
{
public :
OccluderNode();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
OccluderNode(const OccluderNode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Node(OccluderNode);
/** Attach a ConvexPlanerOccluder to an OccluderNode.*/
void setOccluder(ConvexPlanerOccluder* occluder) { _occluder = occluder; }
/** Get the ConvexPlanerOccluder* attached to a OccluderNode. */
ConvexPlanerOccluder* getOccluder() { return _occluder.get(); }
/** Get the const ConvexPlanerOccluder* attached to a OccluderNode.*/
const ConvexPlanerOccluder* getOccluder() const { return _occluder.get(); }
protected :
virtual ~OccluderNode() {}
ref_ptr<ConvexPlanerOccluder> _occluder;
};
}
#endif

View File

@@ -78,6 +78,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
virtual void apply(osg::Switch& node);
virtual void apply(osg::LOD& node);
virtual void apply(osg::EarthSky& node);
virtual void apply(osg::OccluderNode& node);
virtual void apply(osg::Impostor& node);
void setEarthSky(const osg::EarthSky* earthSky) { _earthSky = earthSky; }

View File

@@ -20,8 +20,6 @@ Geode::Geode(const Geode& geode,const CopyOp& copyop):
Drawable* drawable = copyop(itr->get());
if (drawable) addDrawable(drawable);
}
_occluder = dynamic_cast<ConvexPlanerOccluder*>(copyop(geode.getOccluder()));
}
Geode::~Geode()

View File

@@ -48,6 +48,7 @@ CXXFILES =\
NodeVisitor.cpp\
Notify.cpp\
Object.cpp\
OccluderNode.cpp\
Point.cpp\
PolygonMode.cpp\
PolygonOffset.cpp\

13
src/osg/OccluderNode.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include <osg/OccluderNode>
using namespace osg;
OccluderNode::OccluderNode()
{
}
OccluderNode::OccluderNode(const OccluderNode& node,const CopyOp& copyop):
Group(node,copyop),
_occluder(dynamic_cast<ConvexPlanerOccluder*>(copyop(node._occluder.get())))
{
}

View File

@@ -5,6 +5,7 @@
#include <osg/Billboard>
#include <osg/LightSource>
#include <osg/ClipNode>
#include <osg/OccluderNode>
#include <osg/Notify>
#include <osg/TexEnv>
#include <osg/AlphaFunc>
@@ -710,6 +711,34 @@ void CullVisitor::apply(osg::EarthSky& node)
}
void CullVisitor::apply(osg::OccluderNode& node)
{
// need to check if occlusion node is in the occluder
// list, if so disable the appropriate ShadowOccluderVolume
std::cout<<"We are in an Occlusion node"<<&node<<std::endl;
if (isCulled(node)) return;
// push the culling mode.
pushCurrentMask();
// push the node's state.
StateSet* node_state = node.getStateSet();
if (node_state) pushStateSet(node_state);
handle_cull_callbacks_and_traverse(node);
// pop the node's state off the render graph stack.
if (node_state) popStateSet();
// pop the culling mode.
popCurrentMask();
}
void CullVisitor::apply(Impostor& node)
{