osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/StencilVolumeNode

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2009 Pelican Ventures, Inc.
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 #ifndef OSGEARTHFEATURES_STENCIL_VOLUME_NODE_H
00020 #define OSGEARTHFEATURES_STENCIL_VOLUME_NODE_H 1
00021 
00022 #include <osgEarthFeatures/Common>
00023 #include <osgEarthFeatures/Filter>
00024 #include <osgEarthFeatures/Geometry>
00025 #include <osgEarth/MaskNode>
00026 #include <osg/Group>
00027 #include <osg/Vec4>
00028 
00029 namespace osgEarth { namespace Features 
00030 {
00031     class OSGEARTHFEATURES_EXPORT StencilVolumeNode : public osgEarth::MaskNode
00032     {
00033     public:
00047         StencilVolumeNode(
00048             bool preRenderChildrenToDepthBuffer =false,
00049             bool inverted =false );
00050 
00051         StencilVolumeNode( const StencilVolumeNode& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL );
00052 
00053         META_Node(osgEarth::Features,StencilVolumeNode);
00054         
00055         virtual void traverse( osg::NodeVisitor& nv );
00056 
00057     public: // props
00058 
00059         // sets the render bins and returns the next available bin.
00060         int setBaseRenderBin( int bin );
00061 
00062         // adds stenciling volume geometry
00063         void addVolumes( osg::Node* node );
00064 
00065         // adds the node to draw once the stencil is in place.
00066         //void setChild( osg::Node* node );
00067 
00068     public: //osg::Group overrides
00069 
00070         virtual bool addChild( Node *child );
00071         virtual bool insertChild( unsigned int index, Node *child );
00072         virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
00073         virtual bool replaceChild( Node *origChild, Node* newChild );
00074         virtual bool setChild( unsigned  int i, Node* node );
00075         virtual osg::BoundingSphere computeBound() const;
00076 
00077     protected:
00078         void init();
00079 
00080         osg::ref_ptr<osg::Group> _root;
00081         osg::Group* _stencilGroup1;
00082         osg::Group* _stencilGroup2;
00083         osg::Group* _depthPass;
00084         osg::Group* _renderPass;
00085         bool _inverted;
00086         bool _preRenderChildrenToDepthBuffer;
00087     };
00088 
00089 
00090     class OSGEARTHFEATURES_EXPORT StencilVolumeFactory
00091     {
00092     public:
00093         static osg::Geode* createVolume(
00094             Geometry*            geom,
00095             double               offset,
00096             double               height,
00097             const FilterContext& context );
00098     };
00099 
00100 } } // namespace osgEarth::Features
00101 
00102 #endif // OSGEARTHFEATURES_STENCIL_VOLUME_NODE_H
00103 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines