diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index 725f4dfbd..e8bf13f7f 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -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 diff --git a/include/osg/Geode b/include/osg/Geode index 2f21bcb5c..b62aaa8dc 100644 --- a/include/osg/Geode +++ b/include/osg/Geode @@ -8,7 +8,6 @@ #include #include #include -#include 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 _occluder; }; diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index 401b95b4f..39b1225a0 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -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: diff --git a/include/osg/OccluderNode b/include/osg/OccluderNode new file mode 100644 index 000000000..280ae258e --- /dev/null +++ b/include/osg/OccluderNode @@ -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 +#include + +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 _occluder; +}; + +} + +#endif diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 71435bb4b..4dd75ea0e 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -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; } diff --git a/src/osg/Geode.cpp b/src/osg/Geode.cpp index a7ccb5d6e..9b892f771 100644 --- a/src/osg/Geode.cpp +++ b/src/osg/Geode.cpp @@ -20,8 +20,6 @@ Geode::Geode(const Geode& geode,const CopyOp& copyop): Drawable* drawable = copyop(itr->get()); if (drawable) addDrawable(drawable); } - - _occluder = dynamic_cast(copyop(geode.getOccluder())); } Geode::~Geode() diff --git a/src/osg/Makefile b/src/osg/Makefile index 3ebcadd8e..0a68b2977 100644 --- a/src/osg/Makefile +++ b/src/osg/Makefile @@ -48,6 +48,7 @@ CXXFILES =\ NodeVisitor.cpp\ Notify.cpp\ Object.cpp\ + OccluderNode.cpp\ Point.cpp\ PolygonMode.cpp\ PolygonOffset.cpp\ diff --git a/src/osg/OccluderNode.cpp b/src/osg/OccluderNode.cpp new file mode 100644 index 000000000..e3935bf5b --- /dev/null +++ b/src/osg/OccluderNode.cpp @@ -0,0 +1,13 @@ +#include + +using namespace osg; + +OccluderNode::OccluderNode() +{ +} + +OccluderNode::OccluderNode(const OccluderNode& node,const CopyOp& copyop): + Group(node,copyop), + _occluder(dynamic_cast(copyop(node._occluder.get()))) +{ +} diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index e0e585321..6124f22be 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -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<