osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthUtil/ClampCallback

Go to the documentation of this file.
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 
00020 #ifndef OSGEARTHUTIL_CLAMPCALLBACK
00021 #define OSGEARTHUTIL_CLAMPCALLBACK
00022 
00023 #include <osg/NodeCallback>
00024 #include <osg/CoordinateSystemNode>
00025 
00026 
00027 #include <osgEarth/FindNode>
00028 #include <osgEarth/MapNode>
00029 
00030 #include <osgEarthUtil/Common>
00031 
00032 namespace osgEarth { namespace Util
00033 {       
00034 
00040         class OSGEARTHUTIL_EXPORT ClampCallback : public osg::NodeCallback
00041         {
00042         public:
00049         ClampCallback(osg::Node* terrainNode = NULL);
00050 
00054         void setTerrainNode(osg::Node* terrainNode);
00055 
00059         osg::Node* getTerrainNode() const { return _terrainNode.get(); }
00060 
00064         double getOffset() const { return _offset;}
00065 
00069         void setOffset(double offset);
00070 
00074         void setIntersectionMask(unsigned int intersectionMask);
00075 
00079         unsigned int getIntersectionMask() const;
00080 
00081                 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
00082 
00083         private:
00084 
00085         bool clamp(const osg::Vec3d& pos, osg::Vec3d& out) const;
00086         bool clampGeometry(osg::Geometry* geom, const osg::Matrixd& localToWorld, const osg::Matrixd& worldToLocal) const;
00087 
00088         unsigned int _intersectionMask;
00089 
00090         osg::observer_ptr<osg::CoordinateSystemNode> _csn;
00091 
00092         osg::ref_ptr< osg::Node > _terrainNode;
00093 
00094         int _lastCulledFrame;
00095 
00096         double _offset;
00097 
00098 
00099         };
00100 
00101 } } // namespace osgEarth::Util
00102 
00103 #endif //OSGEARTHUTIL_CLAMPCALLBACK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines