osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthUtil/ObjectPlacer

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 #ifndef OSGEARTHUTIL_OBJECT_PLACER
00020 #define OSGEARTHUTIL_OBJECT_PLACER
00021 
00022 #include <osgEarthUtil/Common>
00023 #include <osgEarth/MapNode>
00024 #include <osg/Node>
00025 #include <osg/Matrix>
00026 #include <osgUtil/IntersectionVisitor>
00027 
00028 namespace osgEarth { namespace Util
00029 {
00034     class OSGEARTHUTIL_EXPORT ObjectPlacer
00035     {
00036     public:
00052         ObjectPlacer(
00053             osg::Node* terrain,
00054             int  traversalMask =~0,
00055             bool clamp        =false,
00056             int  maxLevel     =20);
00057 
00073         bool createPlacerMatrix(
00074             double lat_degrees,
00075             double lon_degrees,
00076             double height,
00077             osg::Matrixd& out_result ) const;
00078 
00093         osg::Node* placeNode(
00094             osg::Node* node,
00095             double lat_degrees,
00096             double lon_degrees,
00097             double height ) const;
00098 
00099     private:
00100         osg::ref_ptr<osgEarth::MapNode> _mapNode;
00101         osg::ref_ptr<osg::CoordinateSystemNode> _csn;
00102         osg::ref_ptr<osgUtil::IntersectionVisitor::ReadCallback> _readCallback;
00103         int _traversalMask;
00104         bool _clamp;
00105 
00106         bool clampGeocentric(osg::CoordinateSystemNode* csn, double lat_rad, double lon_rad, osg::Vec3d& out) const;
00107         bool clampProjected(osg::CoordinateSystemNode* csn, double x, double y, osg::Vec3d& out) const;
00108     };
00109 
00110 } } // namespace osgEarth::Util
00111 
00112 #endif // OSGEARTHUTIL_OBJECT_PLACER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines