/usr/include/osgEarthAnnotation/AnnotationUtils is in libosgearth-dev 2.7.0+dfsg-2+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_ANNOTATION_ANNOTATION_UTILS_H
#define OSGEARTH_ANNOTATION_ANNOTATION_UTILS_H 1
#include <osgEarthAnnotation/Common>
#include <osgEarthSymbology/TextSymbol>
#include <osgEarthSymbology/Style>
#include <osg/AutoTransform>
#include <osg/CullStack>
#include <osg/Drawable>
#include <osg/Geometry>
#include <osgText/TextBase>
#include <osgUtil/CullVisitor>
namespace osgEarth { namespace Annotation
{
using namespace osgEarth;
using namespace osgEarth::Symbology;
/**
* Internal tools used by the annotation library.
*/
struct OSGEARTHANNO_EXPORT AnnotationUtils
{
static const std::string& UNIFORM_HIGHLIGHT();
static const std::string& UNIFORM_IS_TEXT();
static const std::string& UNIFORM_FADE();
static const std::string& PROGRAM_NAME();
/**
* Convert a symbology encoding enum to an osgText enum
*/
static osgText::String::Encoding convertTextSymbolEncoding(const TextSymbol::Encoding encoding);
/**
* Creates a drawable representing a symbolized text label in
* pixel space.
*/
static osg::Drawable* createTextDrawable(
const std::string& text,
const TextSymbol* symbol,
const osg::Vec3& positionOffset );
/**
* Creates the basic geometry to draw an image texture-mapped to
* a quad in pixel space.
*/
static osg::Geometry* createImageGeometry(
osg::Image* image,
const osg::Vec2s& pixelOffsets,
unsigned textureUnit,
double heading,
double scale );
/**
* Creates a fading uniform that the decluttering engine can use
* to adjust the alpha of annotation drawables.
*/
static osg::Uniform* createFadeUniform();
/**
* Creates a boolean uniform used to indicate a hightlighted state.
*/
static osg::Uniform* createHighlightUniform();
/**
* Builds a graph on top of the specified that that implements a 2-pass
* rendering scheme for self-occluding or self-intersecting geometies that
* would not otherwise properly blend. The scheme renders the back faces
* first, followed by the front faces, ensuring proper blending.
*/
static osg::Node* installTwoPassAlpha( osg::Node* );
/**
* Checks whether using a style will require transparency blending.
*/
static bool styleRequiresAlphaBlending( const Style& style );
/**
* Internal - A customized AutoTransform used by the OrthoNode to
* support intersections that are compatible with the decluttering engine
*/
struct OrthoNodeAutoTransform : public osg::AutoTransform
{
/** override */
virtual void accept(osg::NodeVisitor& nv);
bool okToIntersect() const { return !_firstTimeToInitEyePoint; }
};
// some geometry creation utilities
static osg::Drawable* create2DQuad( const osg::BoundingBox& box, float padding, const osg::Vec4& color );
static osg::Drawable* create2DOutline( const osg::BoundingBox& box, float padding, const osg::Vec4& color );
static osg::Node* createFullScreenQuad( const osg::Vec4& color );
/**
* Builds a sphere geometry.
* @param r Radius
* @param color Color
* @param maxAngle Maximum angle between verts (controls tessellation)
*/
static osg::Node* createSphere( float r, const osg::Vec4& color, float maxAngle =15.0f );
/**
* Builds a hemisphere geometry.
* @param r Radius
* @param color Color
* @param maxAngle Maximum angle between verts (controls tessellation)
*/
static osg::Node* createHemisphere( float r, const osg::Vec4& color, float maxAngle =15.0f );
/**
* Builds the geometry for an ellipsoid.
*/
static osg::Geometry* createEllipsoidGeometry(
float xr, float yr, float zr, const osg::Vec4& color, float maxAngle =10.0f,
float minLat =-90.0, float maxLat=90.0, float minLon=-180.0, float maxLon=180.0);
static osg::Node* createEllipsoid(
float xr, float yr, float zr, const osg::Vec4& color, float maxAngle =10.0f,
float minLat =-90.0, float maxLat=90.0, float minLon=-180.0, float maxLon=180.0);
struct AltitudePolicy
{
AltitudePolicy() : draping(false), sceneClamping(false), gpuClamping(false) { }
bool draping;
bool sceneClamping;
bool gpuClamping;
};
static void getAltitudePolicy( const Style& style, AltitudePolicy& b );
private:
AnnotationUtils() { }
};
/**
* A bounding sphere calculator that forces the center point
* to (0,0,0) and adjusts the radius accordingly. This forces the bounding
* center to the "control point" of the annotation - useful for culling.
*/
class ControlPointCallback : public osg::Node::ComputeBoundingSphereCallback
{
public:
osg::BoundingSphere computeBound(const osg::Node& node) const
{
osg::BoundingSphere nodebs = node.computeBound();
return osg::BoundingSphere(osg::Vec3(0,0,0), nodebs.center().length() + nodebs.radius());
}
};
} } // namespace osgEarth::Annotation
#endif //OSGEARTH_ANNOTATION_ANNOTATION_UTILS_H
|