Further work on osgShadow::ShadowTechnique API

This commit is contained in:
Robert Osfield 2007-02-08 19:34:38 +00:00
parent 95befaf1ed
commit c2665963bb
6 changed files with 69 additions and 4 deletions

View File

@ -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;

View File

@ -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();
};

View File

@ -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();

View File

@ -30,6 +30,10 @@ ShadowTechnique::ShadowTechnique(const ShadowTechnique& copy, const osg::CopyOp&
{
}
ShadowTechnique::~ShadowTechnique()
{
}
void ShadowTechnique::init()
{
osg::notify(osg::NOTICE)<<className()<<"::init() not implemened yet"<<std::endl;
@ -49,6 +53,11 @@ void ShadowTechnique::cull(osg::NodeVisitor& nv)
_shadowedScene->osg::Group::traverse(nv);
}
void ShadowTechnique::cleanSceneGraph()
{
osg::notify(osg::NOTICE)<<className()<<"::cleanSceneGraph()) not implemened yet."<<std::endl;
}
void ShadowTechnique::traverse(osg::NodeVisitor& nv)
{
if (!_shadowedScene) return;

View File

@ -12,16 +12,46 @@
*/
#include <osgShadow/ShadowVolume>
#include <osgShadow/ShadowedScene>
#include <osg/Notify>
using namespace osgShadow;
ShadowVolume::ShadowVolume()
{
osg::notify(osg::NOTICE)<<"Warning: osgShadow::ShadowVolume technique not implemented yet."<<std::endl;
osg::notify(osg::NOTICE)<<"Warning: osgShadow::ShadowVolume technique in development."<<std::endl;
}
ShadowVolume::ShadowVolume(const ShadowVolume& copy, const osg::CopyOp& copyop):
ShadowTechnique(copy,copyop)
{
}
ShadowVolume::~ShadowVolume()
{
}
void ShadowVolume::init()
{
osg::notify(osg::NOTICE)<<className()<<"::init() not implemened yet, but almost"<<std::endl;
_dirty = false;
}
void ShadowVolume::update(osg::NodeVisitor& nv)
{
osg::notify(osg::NOTICE)<<className()<<"::update(osg::NodeVisitor&) not implemened yet, but almost."<<std::endl;
_shadowedScene->osg::Group::traverse(nv);
}
void ShadowVolume::cull(osg::NodeVisitor& nv)
{
osg::notify(osg::NOTICE)<<className()<<"::cull(osg::NodeVisitor&) not implemened yet, but almost."<<std::endl;
_shadowedScene->osg::Group::traverse(nv);
}
void ShadowVolume::cleanSceneGraph()
{
osg::notify(osg::NOTICE)<<className()<<"::cleanSceneGraph()) not implemened yet, but almost."<<std::endl;
}

View File

@ -53,7 +53,11 @@ void ShadowedScene::setShadowTechnique(ShadowTechnique* technique)
{
if (_shadowTechnique == technique) return;
if (_shadowTechnique.valid()) _shadowTechnique->_shadowedScene = 0;
if (_shadowTechnique.valid())
{
_shadowTechnique->cleanSceneGraph();
_shadowTechnique->_shadowedScene = 0;
}
_shadowTechnique = technique;