1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGSHADOW_SHADOWEDSCENE
15#define OSGSHADOW_SHADOWEDSCENE 1
17#include <osg/buffered_value>
19#include <osg/Texture2D>
20#include <osg/TexGenNode>
22#include <osgShadow/ShadowTechnique>
23#include <osgShadow/ShadowSettings>
27/** ShadowedScene provides a mechansim for decorating a scene that the needs to have shadows cast upon it.*/
28class OSGSHADOW_EXPORT ShadowedScene : public osg::Group
32 ShadowedScene(ShadowTechnique* st=0);
34 ShadowedScene(const ShadowedScene& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
36 META_Node(osgShadow, ShadowedScene);
38 virtual void traverse(osg::NodeVisitor& nv);
40 void setShadowSettings(ShadowSettings* ss);
41 template<class T> void setShadowSettings(const osg::ref_ptr<T>& ss) { setShadowSettings(ss.get()); }
43 ShadowSettings* getShadowSettings() { return _shadowSettings.get(); }
44 const ShadowSettings* getShadowSettings() const { return _shadowSettings.get(); }
46 void setShadowTechnique(ShadowTechnique* technique);
47 template<class T> void setShadowTechnique(const osg::ref_ptr<T>& ss) { setShadowTechnique(ss.get()); }
49 ShadowTechnique* getShadowTechnique() { return _shadowTechnique.get(); }
50 const ShadowTechnique* getShadowTechnique() const { return _shadowTechnique.get(); }
52 /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
53 void cleanSceneGraph();
55 /** Dirty any cache data structures held in the attached ShadowTechnqiue.*/
58 /** Resize any per context GLObject buffers to specified size. */
59 virtual void resizeGLObjectBuffers(unsigned int maxSize);
61 /** If State is non-zero, this function releases any associated OpenGL objects for
62 * the specified graphics context. Otherwise, releases OpenGL objects
63 * for all graphics contexts. */
64 virtual void releaseGLObjects(osg::State* = 0) const;
68 /** deprecated, moved to ShadowSettings.*/
69 void setReceivesShadowTraversalMask(unsigned int mask) { if (_shadowSettings.valid()) _shadowSettings->setReceivesShadowTraversalMask(mask); }
70 /** deprecated, moved to ShadowSettings.*/
71 unsigned int getReceivesShadowTraversalMask() const { return _shadowSettings.valid() ? _shadowSettings->getReceivesShadowTraversalMask() : 0xffffffff; }
73 /** deprecated, moved to ShadowSettings.*/
74 void setCastsShadowTraversalMask(unsigned int mask) { if (_shadowSettings.valid()) _shadowSettings->setCastsShadowTraversalMask(mask); }
75 /** deprecated, moved to ShadowSettings.*/
76 unsigned int getCastsShadowTraversalMask() const { return _shadowSettings.valid() ? _shadowSettings->getCastsShadowTraversalMask() : 0xffffffff; }
80 virtual ~ShadowedScene();
82 osg::ref_ptr<ShadowSettings> _shadowSettings;
83 osg::ref_ptr<ShadowTechnique> _shadowTechnique;