osgEarth 2.1.1
|
00001 /* -*-c++-*- */ 00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph 00003 * Copyright 2008-2010 Pelican Mapping 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 OSGEARTHSYMBOLOGY_STENCIL_VOLUME_NODE_H 00020 #define OSGEARTHSYMBOLOGY_STENCIL_VOLUME_NODE_H 1 00021 00022 #include <osgEarthSymbology/Common> 00023 #include <osgEarthSymbology/Geometry> 00024 #include <osgEarth/MaskNode> 00025 #include <osgEarth/ThreadingUtils> 00026 #include <osg/Group> 00027 #include <osg/Vec4> 00028 #include <queue> 00029 00030 namespace osgEarth { namespace Symbology 00031 { 00032 class OSGEARTHSYMBOLOGY_EXPORT StencilVolumeNode : public osgEarth::MaskNode 00033 { 00034 public: 00048 StencilVolumeNode( 00049 bool preRenderChildrenToDepthBuffer =false, 00050 bool inverted =false ); 00051 00055 StencilVolumeNode( const StencilVolumeNode& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL ); 00056 00057 META_Node(osgEarth::Symbology,StencilVolumeNode); 00058 00059 //override 00060 virtual void traverse( osg::NodeVisitor& nv ); 00061 00062 public: // props 00063 00064 // sets the render bins and returns the next available bin. 00065 int setBaseRenderBin( int bin ); 00066 00067 // adds stenciling volume geometry (safely during the next update traversal, if necessary) 00068 void addVolumes( osg::Node* node, bool onNextUpdate =true ); 00069 00070 public: // utilties 00071 00076 static osg::Node* createFullScreenQuad( const osg::Vec4f& color ); 00077 00078 00079 public: //osg::Group overrides 00080 00081 virtual bool addChild( Node *child ); 00082 virtual bool insertChild( unsigned int index, Node *child ); 00083 virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove); 00084 virtual bool replaceChild( Node *origChild, Node* newChild ); 00085 virtual bool setChild( unsigned int i, Node* node ); 00086 virtual osg::BoundingSphere computeBound() const; 00087 00088 protected: 00089 void init(); 00090 00091 osg::ref_ptr<osg::Group> _root; 00092 osg::Group* _stencilGroup1; 00093 osg::Group* _stencilGroup2; 00094 osg::Group* _depthPass; 00095 osg::Group* _renderPass; 00096 bool _inverted; 00097 bool _preRenderChildrenToDepthBuffer; 00098 00099 Threading::Mutex _addVolumesMutex; 00100 std::queue< osg::ref_ptr<osg::Node> > _volumesToAdd; 00101 void addQueuedVolumes(); 00102 }; 00103 00104 00105 } } // namespace osgEarth::Symbology 00106 00107 #endif // OSGEARTHSYMBOLOGY_STENCIL_VOLUME_NODE_H 00108