2
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
3
* Copyright 2008-2009 Pelican Ventures, Inc.
6
* osgEarth is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>
19
#ifndef OSGEARTHFEATURES_STENCIL_VOLUME_NODE_H
20
#define OSGEARTHFEATURES_STENCIL_VOLUME_NODE_H 1
22
#include <osgEarthFeatures/Common>
23
#include <osgEarthFeatures/Filter>
24
#include <osgEarthFeatures/Geometry>
25
#include <osgEarth/MaskNode>
29
namespace osgEarth { namespace Features
31
class OSGEARTHFEATURES_EXPORT StencilVolumeNode : public osgEarth::MaskNode
35
* Constructs a stencil masking node.
37
* @param preRenderChildrenToDepthBuffer
38
* Normally, this node will render the stencil volumes first and then
39
* render the children (which will be masked by the stencil). If you need
40
* to pre-render the children to the depth buffer, set this to TRUE. You
41
* need to do this is you are creating a straight render mask.
44
* Inverts the stencil buffer, masking the opposite pixels that would
48
bool preRenderChildrenToDepthBuffer =false,
49
bool inverted =false );
51
StencilVolumeNode( const StencilVolumeNode& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL );
53
META_Node(osgEarth::Features,StencilVolumeNode);
55
virtual void traverse( osg::NodeVisitor& nv );
59
// sets the render bins and returns the next available bin.
60
int setBaseRenderBin( int bin );
62
// adds stenciling volume geometry
63
void addVolumes( osg::Node* node );
65
// adds the node to draw once the stencil is in place.
66
//void setChild( osg::Node* node );
68
public: //osg::Group overrides
70
virtual bool addChild( Node *child );
71
virtual bool insertChild( unsigned int index, Node *child );
72
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
73
virtual bool replaceChild( Node *origChild, Node* newChild );
74
virtual bool setChild( unsigned int i, Node* node );
75
virtual osg::BoundingSphere computeBound() const;
80
osg::ref_ptr<osg::Group> _root;
81
osg::Group* _stencilGroup1;
82
osg::Group* _stencilGroup2;
83
osg::Group* _depthPass;
84
osg::Group* _renderPass;
86
bool _preRenderChildrenToDepthBuffer;
90
class OSGEARTHFEATURES_EXPORT StencilVolumeFactory
93
static osg::Geode* createVolume(
97
const FilterContext& context );
100
} } // namespace osgEarth::Features
102
#endif // OSGEARTHFEATURES_STENCIL_VOLUME_NODE_H