osgEarth 2.1.1
|
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 OSGEARTH_MODEL_FEATURE_STENCIL_STENCIL_UTILS_H 00020 #define OSGEARTH_MODEL_FEATURE_STENCIL_STENCIL_UTILS_H 1 00021 00022 #include <osg/Node> 00023 #include <osg/Geode> 00024 #include <osg/Group> 00025 #include <osgEarthFeatures/Geometry> 00026 #include <osgEarthFeatures/Filter> 00027 #include <osgEarthFeatures/Styling> 00028 00029 using namespace osgEarth::Features; 00030 00031 struct StencilUtils 00032 { 00033 static osg::Node* createGeometryPass( 00034 osg::Node* geometry, 00035 int& ref_renderBin ); 00036 00037 static osg::Node* createMaskPass( 00038 const osg::Vec4ub& color, 00039 int& ref_renderBin ); 00040 00041 static osg::Geode* createVolume( 00042 Geometry* geom, 00043 double offset, 00044 double height, 00045 const FilterContext& context ); 00046 }; 00047 00048 class StencilVolumeNode : public osg::Group 00049 { 00050 public: 00051 StencilVolumeNode(); 00052 StencilVolumeNode( const StencilVolumeNode& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL ); 00053 00054 META_Node(osgEarth::Features,StencilVolumeNode); 00055 00056 // sets the render bins and returns the next available bin. 00057 int setBaseRenderBin( int bin ); 00058 00059 // sets the render color 00060 void setColor( const osg::Vec4f& color ); 00061 00062 // adds volume geometry to the node 00063 void addVolumes( osg::Node* node ); 00064 00065 protected: 00066 void init(); 00067 00068 osg::Group* _stencilGroup1; 00069 osg::Group* _stencilGroup2; 00070 osg::Group* _maskGroup; 00071 osg::Vec4Array* _maskColorArray; 00072 }; 00073 00074 00075 #endif // OSGEARTH_MODEL_FEATURE_STENCIL_STENCIL_UTILS_H