1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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.
15#define OSGVOLUMESCENE 1
18#include <osg/Texture2D>
19#include <osgUtil/CullVisitor>
21#include <osgVolume/VolumeTile>
25/** 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.*/
26class OSGVOLUME_EXPORT VolumeScene : public osg::Group
32 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
33 VolumeScene(const VolumeScene&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
35 META_Node(osgVolume, VolumeScene);
37 virtual void traverse(osg::NodeVisitor& nv);
39 TileData* tileVisited(osgUtil::CullVisitor* cv, VolumeTile* tile);
40 TileData* getTileData(osgUtil::CullVisitor* cv, VolumeTile* tile);
44 virtual ~VolumeScene();
46 typedef std::map< VolumeTile*, osg::ref_ptr<TileData> > Tiles;
48 class ViewData : public osg::Referenced
54 void visitTile(VolumeTile* tile);
56 osg::ref_ptr<osg::Texture2D> _depthTexture;
57 osg::ref_ptr<osg::Texture2D> _colorTexture;
58 osg::ref_ptr<osg::Camera> _rttCamera;
59 osg::ref_ptr<osg::Node> _backdropSubgraph;
60 osg::ref_ptr<osg::Geometry> _geometry;
61 osg::ref_ptr<osg::Vec3Array> _vertices;
62 osg::ref_ptr<osg::StateSet> _stateset;
63 osg::ref_ptr<osg::Uniform> _viewportDimensionsUniform;
68 virtual ~ViewData() {}
71 typedef std::map< osgUtil::CullVisitor*, osg::ref_ptr<ViewData> > ViewDataMap;
72 OpenThreads::Mutex _viewDataMapMutex;
73 ViewDataMap _viewDataMap;