VolumeScene 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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 OSGVOLUMESCENE
  14. #define OSGVOLUMESCENE 1
  15. #include <osg/Group>
  16. #include <osg/Texture2D>
  17. #include <osgUtil/CullVisitor>
  18. #include <osgVolume/VolumeTile>
  19. namespace osgVolume {
  20. /** VolumeScene provides high level support for doing multi-pass rendering of volumes where the main scene to rendered to color and depth textures and then re-rendered for the purposes of volume rendering.*/
  21. class OSGVOLUME_EXPORT VolumeScene : public osg::Group
  22. {
  23. public:
  24. VolumeScene();
  25. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  26. VolumeScene(const VolumeScene&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  27. META_Node(osgVolume, VolumeScene);
  28. virtual void traverse(osg::NodeVisitor& nv);
  29. TileData* tileVisited(osgUtil::CullVisitor* cv, VolumeTile* tile);
  30. TileData* getTileData(osgUtil::CullVisitor* cv, VolumeTile* tile);
  31. protected:
  32. virtual ~VolumeScene();
  33. typedef std::map< VolumeTile*, osg::ref_ptr<TileData> > Tiles;
  34. class ViewData : public osg::Referenced
  35. {
  36. public:
  37. ViewData();
  38. void clearTiles();
  39. void visitTile(VolumeTile* tile);
  40. osg::ref_ptr<osg::Texture2D> _depthTexture;
  41. osg::ref_ptr<osg::Texture2D> _colorTexture;
  42. osg::ref_ptr<osg::Camera> _rttCamera;
  43. osg::ref_ptr<osg::Node> _backdropSubgraph;
  44. osg::ref_ptr<osg::Geometry> _geometry;
  45. osg::ref_ptr<osg::Vec3Array> _vertices;
  46. osg::ref_ptr<osg::StateSet> _stateset;
  47. osg::ref_ptr<osg::Uniform> _viewportDimensionsUniform;
  48. Tiles _tiles;
  49. protected:
  50. virtual ~ViewData() {}
  51. };
  52. typedef std::map< osgUtil::CullVisitor*, osg::ref_ptr<ViewData> > ViewDataMap;
  53. OpenThreads::Mutex _viewDataMapMutex;
  54. ViewDataMap _viewDataMap;
  55. };
  56. }
  57. #endif