ShadowTexture 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef OSGSHADOW_SHADOWETEXTURE
  14. #define OSGSHADOW_SHADOWETEXTURE 1
  15. #include <osg/Camera>
  16. #include <osg/Material>
  17. #include <osgShadow/ShadowTechnique>
  18. namespace osgShadow {
  19. /** ShadowedTexture provides an implementation of shadow textures.*/
  20. class OSGSHADOW_EXPORT ShadowTexture : public ShadowTechnique
  21. {
  22. public :
  23. ShadowTexture();
  24. ShadowTexture(const ShadowTexture& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  25. META_Object(osgShadow, ShadowTexture);
  26. /** Set the texture unit that the shadow texture will be applied on.*/
  27. void setTextureUnit(unsigned int unit);
  28. /** Get the texture unit that the shadow texture will be applied on.*/
  29. unsigned int getTextureUnit() const { return _textureUnit; }
  30. /** initialize the ShadowedScene and local cached data structures.*/
  31. virtual void init();
  32. /** run the update traversal of the ShadowedScene and update any loca chached data structures.*/
  33. virtual void update(osg::NodeVisitor& nv);
  34. /** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/
  35. virtual void cull(osgUtil::CullVisitor& cv);
  36. /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
  37. virtual void cleanSceneGraph();
  38. /** Resize any per context GLObject buffers to specified size. */
  39. virtual void resizeGLObjectBuffers(unsigned int maxSize);
  40. /** If State is non-zero, this function releases any associated OpenGL objects for
  41. * the specified graphics context. Otherwise, releases OpenGL objects
  42. * for all graphics contexts. */
  43. virtual void releaseGLObjects(osg::State* = 0) const;
  44. protected :
  45. virtual ~ShadowTexture() {}
  46. osg::ref_ptr<osg::Camera> _camera;
  47. osg::ref_ptr<osg::TexGen> _texgen;
  48. osg::ref_ptr<osg::Texture2D> _texture;
  49. osg::ref_ptr<osg::StateSet> _stateset;
  50. osg::ref_ptr<osg::Material> _material;
  51. unsigned int _textureUnit;
  52. };
  53. }
  54. #endif