openscenegraph
VolumeTechnique
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 OSGVOLUME_VOLUMETECHNIQUE
15#define OSGVOLUME_VOLUMETECHNIQUE 1
16
17#include <osg/Object>
18
19#include <osgUtil/UpdateVisitor>
20#include <osgUtil/CullVisitor>
21
22#include <osgVolume/Export>
23
24namespace osgVolume {
25
26class VolumeTile;
27
28/** Container for render to texture objects used when doing multi-pass volume rendering techniques.*/
29struct TileData : public osg::Referenced
30{
31 TileData() : active(false) {}
32
33 virtual void update(osgUtil::CullVisitor* cv) = 0;
34
35 bool active;
36
37 osg::NodePath nodePath;
38 osg::ref_ptr<osg::RefMatrix> projectionMatrix;
39 osg::ref_ptr<osg::RefMatrix> modelviewMatrix;
40
41 osg::ref_ptr<osg::StateSet> stateset;
42};
43
44
45class OSGVOLUME_EXPORT VolumeTechnique : public osg::Object
46{
47 public:
48
49 VolumeTechnique();
50
51 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
52 VolumeTechnique(const VolumeTechnique&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
53
54 META_Object(osgVolume, VolumeTechnique);
55
56 VolumeTile* getVolumeTile() { return _volumeTile; }
57 const VolumeTile* getVolumeTile() const { return _volumeTile; }
58
59 virtual void init();
60
61 virtual void update(osgUtil::UpdateVisitor* nv);
62
63 virtual bool isMoving(osgUtil::CullVisitor* nv);
64
65 virtual void cull(osgUtil::CullVisitor* nv);
66
67 /** Clean scene graph from any terrain technique specific nodes.*/
68 virtual void cleanSceneGraph();
69
70 /** Traverse the terrain subgraph.*/
71 virtual void traverse(osg::NodeVisitor& nv);
72
73 /** Called from VolumeScene to create the TileData container when a multi-pass technique is being used.
74 * The TileData container caches any render to texture objects that are required. */
75 virtual TileData* createTileData(osgUtil::CullVisitor* /*cv*/) { return 0; }
76
77 protected:
78
79 void setDirty(bool dirty);
80
81 virtual ~VolumeTechnique();
82
83 friend class osgVolume::VolumeTile;
84
85 VolumeTile* _volumeTile;
86
87 typedef std::map<osgUtil::CullVisitor::Identifier*, osg::Matrix> ModelViewMatrixMap;
88 OpenThreads::Mutex _mutex;
89 ModelViewMatrixMap _modelViewMatrixMap;
90};
91
92}
93
94#endif