| 1 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield |
|---|
| 2 | * |
|---|
| 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. |
|---|
| 7 | * |
|---|
| 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. |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | #ifndef OSGSHADOW_SHADOWVOLUME |
|---|
| 15 | #define OSGSHADOW_SHADOWVOLUME 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/Camera> |
|---|
| 18 | #include <osg/Light> |
|---|
| 19 | #include <osg/Geode> |
|---|
| 20 | |
|---|
| 21 | #include <osgShadow/ShadowTechnique> |
|---|
| 22 | #include <osgShadow/OccluderGeometry> |
|---|
| 23 | |
|---|
| 24 | namespace osgShadow { |
|---|
| 25 | |
|---|
| 26 | /** ShadowedTexture provides an implementation of shadow textures.*/ |
|---|
| 27 | class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique |
|---|
| 28 | { |
|---|
| 29 | public : |
|---|
| 30 | ShadowVolume(); |
|---|
| 31 | |
|---|
| 32 | ShadowVolume(const ShadowVolume& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); |
|---|
| 33 | |
|---|
| 34 | META_Object(osgShadow, ShadowVolume); |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | void setDrawMode(osgShadow::ShadowVolumeGeometry::DrawMode drawMode); |
|---|
| 38 | osgShadow::ShadowVolumeGeometry::DrawMode getDrawMode() const { return _drawMode; } |
|---|
| 39 | |
|---|
| 40 | void setDynamicShadowVolumes(bool dynamicShadowVolumes); |
|---|
| 41 | bool getDynamicShadowVolumes() const { return _dynamicShadowVolumes; } |
|---|
| 42 | |
|---|
| 43 | /** initialize the ShadowedScene and local cached data structures.*/ |
|---|
| 44 | virtual void init(); |
|---|
| 45 | |
|---|
| 46 | /** run the update traversal of the ShadowedScene and update any loca chached data structures.*/ |
|---|
| 47 | virtual void update(osg::NodeVisitor& nv); |
|---|
| 48 | |
|---|
| 49 | /** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/ |
|---|
| 50 | virtual void cull(osgUtil::CullVisitor& cv); |
|---|
| 51 | |
|---|
| 52 | /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/ |
|---|
| 53 | virtual void cleanSceneGraph(); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | protected : |
|---|
| 57 | |
|---|
| 58 | virtual ~ShadowVolume(); |
|---|
| 59 | |
|---|
| 60 | osgShadow::ShadowVolumeGeometry::DrawMode _drawMode; |
|---|
| 61 | bool _dynamicShadowVolumes; |
|---|
| 62 | |
|---|
| 63 | osg::ref_ptr<osgShadow::OccluderGeometry> _occluder; |
|---|
| 64 | |
|---|
| 65 | OpenThreads::Mutex _shadowVolumeMutex; |
|---|
| 66 | osg::ref_ptr<osgShadow::ShadowVolumeGeometry> _shadowVolume; |
|---|
| 67 | |
|---|
| 68 | osg::Vec4 _lightpos; |
|---|
| 69 | |
|---|
| 70 | osg::ref_ptr<osg::Light> _ambientLight; |
|---|
| 71 | osg::ref_ptr<osg::Light> _diffuseLight; |
|---|
| 72 | |
|---|
| 73 | osg::ref_ptr<osg::StateSet> _ss1; |
|---|
| 74 | osg::ref_ptr<osg::StateSet> _mainShadowStateSet; |
|---|
| 75 | osg::ref_ptr<osg::StateSet> _shadowVolumeStateSet; |
|---|
| 76 | osg::ref_ptr<osg::StateSet> _shadowedSceneStateSet; |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | }; |
|---|
| 80 | |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | #endif |
|---|