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.
14#ifndef OSGVOLUME_VOLUMETECHNIQUE
15#define OSGVOLUME_VOLUMETECHNIQUE 1
19#include <osgUtil/UpdateVisitor>
20#include <osgUtil/CullVisitor>
22#include <osgVolume/Export>
28/** Container for render to texture objects used when doing multi-pass volume rendering techniques.*/
29struct TileData : public osg::Referenced
31 TileData() : active(false) {}
33 virtual void update(osgUtil::CullVisitor* cv) = 0;
37 osg::NodePath nodePath;
38 osg::ref_ptr<osg::RefMatrix> projectionMatrix;
39 osg::ref_ptr<osg::RefMatrix> modelviewMatrix;
41 osg::ref_ptr<osg::StateSet> stateset;
45class OSGVOLUME_EXPORT VolumeTechnique : public osg::Object
51 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
52 VolumeTechnique(const VolumeTechnique&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
54 META_Object(osgVolume, VolumeTechnique);
56 VolumeTile* getVolumeTile() { return _volumeTile; }
57 const VolumeTile* getVolumeTile() const { return _volumeTile; }
61 virtual void update(osgUtil::UpdateVisitor* nv);
63 virtual bool isMoving(osgUtil::CullVisitor* nv);
65 virtual void cull(osgUtil::CullVisitor* nv);
67 /** Clean scene graph from any terrain technique specific nodes.*/
68 virtual void cleanSceneGraph();
70 /** Traverse the terrain subgraph.*/
71 virtual void traverse(osg::NodeVisitor& nv);
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; }
79 void setDirty(bool dirty);
81 virtual ~VolumeTechnique();
83 friend class osgVolume::VolumeTile;
85 VolumeTile* _volumeTile;
87 typedef std::map<osgUtil::CullVisitor::Identifier*, osg::Matrix> ModelViewMatrixMap;
88 OpenThreads::Mutex _mutex;
89 ModelViewMatrixMap _modelViewMatrixMap;