openscenegraph
VolumeScene
Go to the documentation of this file.
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
14#ifndef OSGVOLUMESCENE
15#define OSGVOLUMESCENE 1
16
17#include <osg/Group>
18#include <osg/Texture2D>
19#include <osgUtil/CullVisitor>
20
21#include <osgVolume/VolumeTile>
22
23namespace osgVolume {
24
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
27{
28 public:
29
30 VolumeScene();
31
32 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
33 VolumeScene(const VolumeScene&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
34
35 META_Node(osgVolume, VolumeScene);
36
37 virtual void traverse(osg::NodeVisitor& nv);
38
39 TileData* tileVisited(osgUtil::CullVisitor* cv, VolumeTile* tile);
40 TileData* getTileData(osgUtil::CullVisitor* cv, VolumeTile* tile);
41
42 protected:
43
44 virtual ~VolumeScene();
45
46 typedef std::map< VolumeTile*, osg::ref_ptr<TileData> > Tiles;
47
48 class ViewData : public osg::Referenced
49 {
50 public:
51 ViewData();
52
53 void clearTiles();
54 void visitTile(VolumeTile* tile);
55
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;
64
65 Tiles _tiles;
66
67 protected:
68 virtual ~ViewData() {}
69 };
70
71 typedef std::map< osgUtil::CullVisitor*, osg::ref_ptr<ViewData> > ViewDataMap;
72 OpenThreads::Mutex _viewDataMapMutex;
73 ViewDataMap _viewDataMap;
74};
75
76}
77
78#endif