2
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
3
* Copyright 2008-2010 Pelican Mapping
6
* osgEarth is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>
19
#ifndef OSGEARTHUTIL_OBJECT_PLACER
20
#define OSGEARTHUTIL_OBJECT_PLACER
22
#include <osgEarthUtil/Common>
23
#include <osgEarth/MapNode>
26
#include <osgUtil/IntersectionVisitor>
28
namespace osgEarth { namespace Util
31
* Convenience utilities for placing an object on an osgEarth terrain map
32
* using latitude/longitude coordinates.
34
class OSGEARTHUTIL_EXPORT ObjectPlacer
38
* Constructs a new placer.
41
* The scene graph containing the osgEarth::Map node.
42
* @param traversalMask
43
* Mask to use when intersecting the terrain.
45
* Whether the class should attempt to calculate the placement
46
* position so that it sits exactly on the terrain skin.
47
* Warning: this does not yet work properly for maps that don't
48
* report a maximum resolution (like most of the commercial providers).
50
* Maximum level of detail to which to search for high resolution terrain.
54
int traversalMask =~0,
59
* Creates a double-precision matrix that will transform geometry to the
60
* specified map location. In a geocentric map, the matrix will also rotate
61
* into the tangent plane.
63
* @param lat_degrees, lon_degrees
64
* Location on the map for which to generate a matrix
66
* Height above the terrain (in local units)
68
* Receives the resulting matrix; only valid if the method returns TRUE.
70
* True if the method succesfully created the output matrix; false if not
71
* (e.g., the input location was outside the extents of the terrain map).
73
bool createPlacerMatrix(
77
osg::Matrixd& out_result ) const;
80
* Creates a new node graph that positions the input node at a specified map
81
* location. The resulting node will contain the input node as a child.
84
* Node to position at the specified location
85
* @param lat_degrees, lon_degrees
86
* Position on the map at which to place the node
88
* Height above the terrain (in local units)
90
* A node graph representing the newly placed node. The input node will be
91
* a child in the new graph. NULL if the placement failed for some reason.
97
double height ) const;
100
osg::ref_ptr<osgEarth::MapNode> _mapNode;
101
osg::ref_ptr<osg::CoordinateSystemNode> _csn;
102
osg::ref_ptr<osgUtil::IntersectionVisitor::ReadCallback> _readCallback;
106
bool clampGeocentric(osg::CoordinateSystemNode* csn, double lat_rad, double lon_rad, osg::Vec3d& out) const;
107
bool clampProjected(osg::CoordinateSystemNode* csn, double x, double y, osg::Vec3d& out) const;
110
} } // namespace osgEarth::Util
112
#endif // OSGEARTHUTIL_OBJECT_PLACER