diff --git a/Make/makedirdefs b/Make/makedirdefs
index 10281c222..2be9cdc41 100644
--- a/Make/makedirdefs
+++ b/Make/makedirdefs
@@ -75,6 +75,7 @@ DEMOS_DIRS = \
osgcube\
osghud\
osgimpostor\
+ osgoccluder\
osgparticle\
osgreflect\
osgscribe\
diff --git a/VisualStudio/Demos/osgoccluder/osgoccluder.dsp b/VisualStudio/Demos/osgoccluder/osgoccluder.dsp
new file mode 100644
index 000000000..ad516b14b
--- /dev/null
+++ b/VisualStudio/Demos/osgoccluder/osgoccluder.dsp
@@ -0,0 +1,190 @@
+# Microsoft Developer Studio Project File - Name="Demo osgoccluder" - Package Owner=<4>
+
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+
+# ** DO NOT EDIT **
+
+
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+
+
+CFG=Demo osgoccluder - Win32 Release
+
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+
+!MESSAGE use the Export Makefile command and run
+
+!MESSAGE
+
+!MESSAGE NMAKE /f "osgoccluder.mak".
+
+!MESSAGE
+
+!MESSAGE You can specify a configuration when running NMAKE
+
+!MESSAGE by defining the macro CFG on the command line. For example:
+
+!MESSAGE
+
+!MESSAGE NMAKE /f "osgoccluder.mak" CFG="Demo osgoccluder - Win32 Release"
+
+!MESSAGE
+
+!MESSAGE Possible choices for configuration are:
+
+!MESSAGE
+
+!MESSAGE "Demo osgoccluder - Win32 Release" (based on "Win32 (x86) Console Application")
+
+!MESSAGE "Demo osgoccluder - Win32 Debug" (based on "Win32 (x86) Console Application")
+
+!MESSAGE
+
+
+
+# Begin Project
+
+# PROP AllowPerConfigDependencies 0
+
+# PROP Scc_ProjName ""
+
+# PROP Scc_LocalPath ""
+
+CPP=cl.exe
+
+RSC=rc.exe
+
+
+
+!IF "$(CFG)" == "Demo osgoccluder - Win32 Release"
+
+
+
+# PROP BASE Use_MFC 0
+
+# PROP BASE Use_Debug_Libraries 0
+
+# PROP BASE Output_Dir "Release"
+
+# PROP BASE Intermediate_Dir "Release"
+
+# PROP BASE Target_Dir ""
+
+# PROP Use_MFC 0
+
+# PROP Use_Debug_Libraries 0
+
+# PROP Output_Dir "Release"
+
+# PROP Intermediate_Dir "Release"
+
+# PROP Ignore_Export_Lib 0
+
+# PROP Target_Dir ""
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+
+# ADD RSC /l 0x809 /d "NDEBUG"
+
+BSC32=bscmake.exe
+
+# ADD BASE BSC32 /nologo
+
+# ADD BSC32 /nologo
+
+LINK32=link.exe
+
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+# ADD LINK32 /nologo /subsystem:console /pdb:none /machine:I386 /out:"../../../bin/osgoccluder.exe" /libpath:"../../../lib"
+
+
+
+!ELSEIF "$(CFG)" == "Demo osgoccluder - Win32 Debug"
+
+
+
+# PROP BASE Use_MFC 0
+
+# PROP BASE Use_Debug_Libraries 1
+
+# PROP BASE Output_Dir "Debug"
+
+# PROP BASE Intermediate_Dir "Debug"
+
+# PROP BASE Target_Dir ""
+
+# PROP Use_MFC 0
+
+# PROP Use_Debug_Libraries 1
+
+# PROP Output_Dir "Debug"
+
+# PROP Intermediate_Dir "Debug"
+
+# PROP Ignore_Export_Lib 0
+
+# PROP Target_Dir ""
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+
+# ADD CPP /nologo /MDd /W3 /Gm /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /FR /YX /FD /c
+
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+
+# ADD RSC /l 0x809 /d "_DEBUG"
+
+BSC32=bscmake.exe
+
+# ADD BASE BSC32 /nologo
+
+# ADD BSC32 /nologo
+
+LINK32=link.exe
+
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+# ADD LINK32 glut32.lib glu32.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../../bin/osgoccluderd.exe" /pdbtype:sept /libpath:"../../../lib"
+
+# SUBTRACT LINK32 /incremental:no
+
+
+
+!ENDIF
+
+
+
+# Begin Target
+
+
+
+# Name "Demo osgoccluder - Win32 Release"
+
+# Name "Demo osgoccluder - Win32 Debug"
+
+# Begin Source File
+
+
+
+SOURCE=..\..\..\src\Demos\osgoccluder\osgoccluder.cpp
+
+# End Source File
+
+# End Target
+
+# Begin Group "Resource Files"
+
+
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+
+# End Group
+
+# End Project
+
diff --git a/VisualStudio/VisualStudio.dsw b/VisualStudio/VisualStudio.dsw
index 13d60d5a7..343a1ff97 100644
--- a/VisualStudio/VisualStudio.dsw
+++ b/VisualStudio/VisualStudio.dsw
@@ -726,6 +726,60 @@ Package=<4>
+Project: "Demo osgoccluder"=.\Demos\osgoccluder\osgoccluder.dsp - Package Owner=<4>
+
+
+
+Package=<5>
+
+{{{
+
+}}}
+
+
+
+Package=<4>
+
+{{{
+
+ Begin Project Dependency
+
+ Project_Dep_Name Core osg
+
+ End Project Dependency
+
+ Begin Project Dependency
+
+ Project_Dep_Name Core osgDB
+
+ End Project Dependency
+
+ Begin Project Dependency
+
+ Project_Dep_Name Core osgGA
+
+ End Project Dependency
+
+ Begin Project Dependency
+
+ Project_Dep_Name Core osgGLUT
+
+ End Project Dependency
+
+ Begin Project Dependency
+
+ Project_Dep_Name Core osgUtil
+
+ End Project Dependency
+
+}}}
+
+
+
+###############################################################################
+
+
+
Project: "Demo osgreflect"=.\Demos\osgreflect\osgreflect.dsp - Package Owner=<4>
diff --git a/doc/demos.html b/doc/demos.html
index 3eb3710c9..0e421e779 100644
--- a/doc/demos.html
+++ b/doc/demos.html
@@ -53,11 +53,19 @@ Unix
export PATH = ${PATH}:/home/myaccount/OpenSceneGraph/bin
export LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/home/myaccount/OpenSceneGraph/lib
-
export OSG_FILE_PATH = /home/myaccount/OpenSceneGraph-Data:C:/OpenSceneGraph-Data/Images:C:/OpenSceneGraph-Data/Fonts
+
export OSG_FILE_PATH = /home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images:/home/myaccount/OpenSceneGraph-Data/Fonts
or
setenv PATH ${PATH}:/home/myaccount/OpenSceneGraph/bin
setenv LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/home/myaccount/OpenSceneGraph/lib
-
setenv OSG_FILE_PATH /home/myaccount/OpenSceneGraph-Data:C:/OpenSceneGraph-Data/Images:C:/OpenSceneGraph-Data/Fonts
+
setenv OSG_FILE_PATH /home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images:/home/myaccount/OpenSceneGraph-Data/Fonts
+
+
+MacOSX:
+
+setenv PATH "${PATH}:${OSGHOME}/lib:${OSGHOME}/lib/osgPlugins"
+
setenv DYLD_LIBRARY_PATH "${OSGHOME}/lib:${OSGHOME}/lib/osgPlugins"
+
setenv OSG_FILE_PATH "/home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images:/home/myaccount/OpenSceneGraph-Data/Fonts"
+
All the demos run on the commandline, most requiring parameters, such as
what file to load, if you are in any doubt just run the application and
it will either run, or provide help on what options it accepts.
diff --git a/include/osg/CullingSet b/include/osg/CullingSet
index 33aea1771..566ccba4e 100644
--- a/include/osg/CullingSet
+++ b/include/osg/CullingSet
@@ -77,6 +77,23 @@ class SG_EXPORT CullingSet : public Referenced
/** Compute the pixel of an bounding sphere.*/
float pixelSize(const BoundingSphere& bs) const { return bs.radius()/(bs.center()*_pixelSizeVector); }
+ inline void disableOccluder(NodePath& nodePath)
+ {
+ for(OccluderList::iterator itr=_occluderList.begin();
+ itr!=_occluderList.end();
+ ++itr)
+ {
+ if (itr->getNodePath()==nodePath)
+ {
+ // we have trapped for the case an occlude potentially occluding itself,
+ // to prevent this we disable the results mask so that no subsequnt
+ // when the next pushCurrentMask calls happens this occluder is switched off.
+ itr->disableResultMasks();
+ }
+ }
+ }
+
+
inline bool isCulled(const BoundingBox& bb)
{
if (_mask&VIEW_FRUSTUM_CULLING)
diff --git a/include/osg/Polytope b/include/osg/Polytope
index 5a3d21519..570add156 100644
--- a/include/osg/Polytope
+++ b/include/osg/Polytope
@@ -25,7 +25,7 @@ class SG_EXPORT Polytope
inline Polytope(const Polytope& cv) :
_maskStack(cv._maskStack),
- _resultsMask(cv._resultsMask),
+ _resultMask(cv._resultMask),
_planeList(cv._planeList) {}
inline Polytope(const PlaneList& pl) : _planeList(pl) {setupMask();}
@@ -38,7 +38,7 @@ class SG_EXPORT Polytope
{
if (&cv==this) return *this;
_maskStack = cv._maskStack;
- _resultsMask = cv._resultsMask;
+ _resultMask = cv._resultMask;
_planeList = cv._planeList;
return *this;
}
@@ -76,26 +76,27 @@ class SG_EXPORT Polytope
inline void setupMask()
{
- _resultsMask = 0;
+ _resultMask = 0;
for(unsigned int i=0;i<_planeList.size();++i)
{
- _resultsMask = (_resultsMask<<1) | 1;
+ _resultMask = (_resultMask<<1) | 1;
}
- _maskStack.back() = _resultsMask;
+ _maskStack.back() = _resultMask;
}
inline ClippingMask& getCurrentMask() { return _maskStack.back(); }
inline ClippingMask getCurrentMask() const { return _maskStack.back(); }
- inline ClippingMask getResultsMask() const
- {
- return _resultsMask;
- }
+ inline void setResultMask(ClippingMask mask) { _resultMask=mask; }
+
+ inline ClippingMask getResultMask() const { return _resultMask; }
+
+
inline void pushCurrentMask()
{
- _maskStack.push_back(_resultsMask);
+ _maskStack.push_back(_resultMask);
}
inline void popCurrentMask()
@@ -128,18 +129,18 @@ class SG_EXPORT Polytope
{
if (!_maskStack.back()) return true;
- _resultsMask = _maskStack.back();
+ _resultMask = _maskStack.back();
ClippingMask selector_mask = 0x1;
for(PlaneList::const_iterator itr=_planeList.begin();
itr!=_planeList.end();
++itr)
{
- if (_resultsMask&selector_mask)
+ if (_resultMask&selector_mask)
{
int res=itr->intersect(bs);
if (res<0) return false; // outside clipping set.
- else if (res>0) _resultsMask ^= selector_mask; // subsequent checks against this plane not required.
+ else if (res>0) _resultMask ^= selector_mask; // subsequent checks against this plane not required.
}
selector_mask <<= 1;
}
@@ -155,18 +156,18 @@ class SG_EXPORT Polytope
{
if (!_maskStack.back()) return true;
- _resultsMask = _maskStack.back();
+ _resultMask = _maskStack.back();
ClippingMask selector_mask = 0x1;
for(PlaneList::const_iterator itr=_planeList.begin();
itr!=_planeList.end();
++itr)
{
- if (_resultsMask&selector_mask)
+ if (_resultMask&selector_mask)
{
int res=itr->intersect(bb);
if (res<0) return false; // outside clipping set.
- else if (res>0) _resultsMask ^= selector_mask; // subsequent checks against this plane not required.
+ else if (res>0) _resultMask ^= selector_mask; // subsequent checks against this plane not required.
}
selector_mask <<= 1;
}
@@ -178,18 +179,18 @@ class SG_EXPORT Polytope
{
if (!_maskStack.back()) return false;
- _resultsMask = _maskStack.back();
+ _resultMask = _maskStack.back();
ClippingMask selector_mask = 0x1;
for(PlaneList::const_iterator itr=_planeList.begin();
itr!=_planeList.end();
++itr)
{
- if (_resultsMask&selector_mask)
+ if (_resultMask&selector_mask)
{
int res=itr->intersect(bs);
if (res<1) return false; // intersects, or is below plane.
- _resultsMask ^= selector_mask; // subsequent checks against this plane not required.
+ _resultMask ^= selector_mask; // subsequent checks against this plane not required.
}
selector_mask <<= 1;
}
@@ -201,18 +202,18 @@ class SG_EXPORT Polytope
{
if (!_maskStack.back()) return false;
- _resultsMask = _maskStack.back();
+ _resultMask = _maskStack.back();
ClippingMask selector_mask = 0x1;
for(PlaneList::const_iterator itr=_planeList.begin();
itr!=_planeList.end();
++itr)
{
- if (_resultsMask&selector_mask)
+ if (_resultMask&selector_mask)
{
int res=itr->intersect(bb);
if (res<1) return false; // intersects, or is below plane.
- _resultsMask ^= selector_mask; // subsequent checks against this plane not required.
+ _resultMask ^= selector_mask; // subsequent checks against this plane not required.
}
selector_mask <<= 1;
}
@@ -239,13 +240,13 @@ class SG_EXPORT Polytope
{
if (!_maskStack.back()) return;
- _resultsMask = _maskStack.back();
+ _resultMask = _maskStack.back();
ClippingMask selector_mask = 0x1;
for(PlaneList::iterator itr=_planeList.begin();
itr!=_planeList.end();
++itr)
{
- if (_resultsMask&selector_mask)
+ if (_resultMask&selector_mask)
{
itr->transformProvidingInverse(matrix);
selector_mask <<= 1;
@@ -257,7 +258,7 @@ class SG_EXPORT Polytope
fast_back_stack _maskStack;
- ClippingMask _resultsMask;
+ ClippingMask _resultMask;
PlaneList _planeList;
};
diff --git a/include/osg/ShadowOccluderVolume b/include/osg/ShadowOccluderVolume
index 469cbee19..7063efad2 100644
--- a/include/osg/ShadowOccluderVolume
+++ b/include/osg/ShadowOccluderVolume
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
namespace osg {
@@ -21,6 +22,7 @@ class SG_EXPORT ShadowOccluderVolume
typedef std::vector HoleList;
ShadowOccluderVolume(const ShadowOccluderVolume& soc):
+ _nodePath(soc._nodePath),
_occluderVolume(soc._occluderVolume),
_holeList(soc._holeList) {}
@@ -28,9 +30,18 @@ class SG_EXPORT ShadowOccluderVolume
ShadowOccluderVolume(const ConvexPlanerOccluder& occluder,Matrix& MVP);
+ inline void disableResultMasks();
+
inline void pushCurrentMask();
inline void popCurrentMask();
+ /** Set the NodePath which describes the which node in the scene graph
+ * that this occluder was attached to.*/
+ inline void setNodePath(NodePath& nodePath) { _nodePath = nodePath; }
+ inline NodePath& getNodePath() { return _nodePath; }
+ inline const NodePath& getNodePath() const { return _nodePath; }
+
+
/** Convert shadow occluder into local coords by multiplying the
* clip space occluder by the ModelViewProjectionMatrix.*/
void set(const ShadowOccluderVolume& soc,Matrix& MVP);
@@ -60,11 +71,23 @@ class SG_EXPORT ShadowOccluderVolume
protected:
-
+
+ NodePath _nodePath;
Polytope _occluderVolume;
HoleList _holeList;
};
+inline void ShadowOccluderVolume::disableResultMasks()
+{
+ _occluderVolume.setResultMask(0);
+ for(HoleList::iterator itr=_holeList.begin();
+ itr!=_holeList.end();
+ ++itr)
+ {
+ itr->setResultMask(0);
+ }
+}
+
inline void ShadowOccluderVolume::pushCurrentMask()
{
_occluderVolume.pushCurrentMask();
diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp
index 6124f22be..4dd2977a1 100644
--- a/src/osgUtil/CullVisitor.cpp
+++ b/src/osgUtil/CullVisitor.cpp
@@ -715,9 +715,11 @@ void CullVisitor::apply(osg::OccluderNode& node)
{
// need to check if occlusion node is in the occluder
// list, if so disable the appropriate ShadowOccluderVolume
+ _modelviewCullingStack.back()->disableOccluder(_nodePath);
std::cout<<"We are in an Occlusion node"<<&node<