From c2665963bbb11889b2bec12818aa8ffd47fadc90 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 8 Feb 2007 19:34:38 +0000 Subject: [PATCH] Further work on osgShadow::ShadowTechnique API --- include/osgShadow/ShadowTechnique | 9 ++++++++- include/osgShadow/ShadowVolume | 14 +++++++++++++- include/osgShadow/ShadowedScene | 3 +++ src/osgShadow/ShadowTechnique.cpp | 9 +++++++++ src/osgShadow/ShadowVolume.cpp | 32 ++++++++++++++++++++++++++++++- src/osgShadow/ShadowedScene.cpp | 6 +++++- 6 files changed, 69 insertions(+), 4 deletions(-) diff --git a/include/osgShadow/ShadowTechnique b/include/osgShadow/ShadowTechnique index e60fad867..acb9d469e 100644 --- a/include/osgShadow/ShadowTechnique +++ b/include/osgShadow/ShadowTechnique @@ -38,19 +38,26 @@ class OSGSHADOW_EXPORT ShadowTechnique : public osg::Object ShadowedScene* getShadowedScene() { return _shadowedScene; } + /** initialize the ShadowedScene and local cached data structures.*/ virtual void init(); + /** run the update traversal of the ShadowedScene and update any loca chached data structures.*/ virtual void update(osg::NodeVisitor& nv); + /** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/ virtual void cull(osg::NodeVisitor& nv); + /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/ + virtual void cleanSceneGraph(); + virtual void traverse(osg::NodeVisitor& nv); + /** Dirty so that cached data structurese are updated.*/ virtual void dirty() { _dirty = true; } protected : - virtual ~ShadowTechnique() {} + virtual ~ShadowTechnique(); friend class ShadowedScene; diff --git a/include/osgShadow/ShadowVolume b/include/osgShadow/ShadowVolume index b4ef900bd..c64b9e88f 100644 --- a/include/osgShadow/ShadowVolume +++ b/include/osgShadow/ShadowVolume @@ -30,9 +30,21 @@ class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique META_Object(osgShadow, ShadowVolume); + /** initialize the ShadowedScene and local cached data structures.*/ + virtual void init(); + + /** run the update traversal of the ShadowedScene and update any loca chached data structures.*/ + virtual void update(osg::NodeVisitor& nv); + + /** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/ + virtual void cull(osg::NodeVisitor& nv); + + /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/ + virtual void cleanSceneGraph(); + protected : - virtual ~ShadowVolume() {} + virtual ~ShadowVolume(); }; diff --git a/include/osgShadow/ShadowedScene b/include/osgShadow/ShadowedScene index 8ab5867a6..0cb146d5b 100644 --- a/include/osgShadow/ShadowedScene +++ b/include/osgShadow/ShadowedScene @@ -46,6 +46,9 @@ class OSGSHADOW_EXPORT ShadowedScene : public osg::Group ShadowTechnique* getShadowTechnique() { return _shadowTechnique.get(); } const ShadowTechnique* getShadowTechnique() const { return _shadowTechnique.get(); } + /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/ + void cleanSceneGraph(); + /** Dirty any cache data structures held in the attached ShadowTechnqiue.*/ void dirty(); diff --git a/src/osgShadow/ShadowTechnique.cpp b/src/osgShadow/ShadowTechnique.cpp index fd934539e..1155aa3ef 100644 --- a/src/osgShadow/ShadowTechnique.cpp +++ b/src/osgShadow/ShadowTechnique.cpp @@ -30,6 +30,10 @@ ShadowTechnique::ShadowTechnique(const ShadowTechnique& copy, const osg::CopyOp& { } +ShadowTechnique::~ShadowTechnique() +{ +} + void ShadowTechnique::init() { osg::notify(osg::NOTICE)<osg::Group::traverse(nv); } +void ShadowTechnique::cleanSceneGraph() +{ + osg::notify(osg::NOTICE)< +#include #include using namespace osgShadow; ShadowVolume::ShadowVolume() { - osg::notify(osg::NOTICE)<<"Warning: osgShadow::ShadowVolume technique not implemented yet."<osg::Group::traverse(nv); +} + +void ShadowVolume::cull(osg::NodeVisitor& nv) +{ + osg::notify(osg::NOTICE)<osg::Group::traverse(nv); +} + +void ShadowVolume::cleanSceneGraph() +{ + osg::notify(osg::NOTICE)<_shadowedScene = 0; + if (_shadowTechnique.valid()) + { + _shadowTechnique->cleanSceneGraph(); + _shadowTechnique->_shadowedScene = 0; + } _shadowTechnique = technique;