osgEarth 2.1.1
Classes | Functions

anonymous_namespace{OverlayDecorator.cpp} Namespace Reference

Classes

class  MyConvexPolyhedron
struct  CoarsePolytopeIntersector

Functions

void getMinMaxExtentInSilhouette (const osg::Vec3d &cam, const osg::Vec3d &look, std::vector< osg::Vec3d > &verts, double &out_eMin, double &out_eMax)
void getMinMaxExtentInSilhouette (const osg::Vec3d &cam, const osg::Vec3d &look, const osg::BoundingBox &bbox, double &out_eMin, double &out_eMax)

Function Documentation

void anonymous_namespace{OverlayDecorator.cpp}::getMinMaxExtentInSilhouette ( const osg::Vec3d &  cam,
const osg::Vec3d &  look,
std::vector< osg::Vec3d > &  verts,
double &  out_eMin,
double &  out_eMax 
)

This method takes a set of verts and finds the nearest and farthest distances from the points to the camera. It does this calculation in the plane defined by the look vector.

IOW, all the test points are "projected" on to the plane defined by the camera point and the look (normal) vector, and then the distances from the camera point to each projected point are tested in order to find the min/max extent.

Definition at line 167 of file OverlayDecorator.cpp.

    {
        double minSqrDist2D = DBL_MAX;
        double maxSqrDist2D = -DBL_MAX;
        osg::Plane plane( look, cam );

        for( std::vector<osg::Vec3d>::iterator i = verts.begin(); i != verts.end(); ++i )
        {
            osg::Vec3d& point = *i;

            // project the vert onto the camera plane:
            double signedDist = plane.distance( point );
            point += (-plane.getNormal() * signedDist);

            // then calculate the 2D distance to the camera:
            double sqrDist2D = (cam-point).length2();
            if ( sqrDist2D > maxSqrDist2D )
                maxSqrDist2D = sqrDist2D;
            if ( sqrDist2D < minSqrDist2D )
                minSqrDist2D = sqrDist2D;
        }

        out_eMin = sqrt( minSqrDist2D );
        out_eMax = sqrt( maxSqrDist2D );
    }

Here is the caller graph for this function:

void anonymous_namespace{OverlayDecorator.cpp}::getMinMaxExtentInSilhouette ( const osg::Vec3d &  cam,
const osg::Vec3d &  look,
const osg::BoundingBox &  bbox,
double &  out_eMin,
double &  out_eMax 
)

Same as the method above, but extracts the verts from a bounding box.

Definition at line 199 of file OverlayDecorator.cpp.

    {
        std::vector<osg::Vec3d> verts(8);
        verts[0].set( bbox.xMin(), bbox.yMin(), bbox.zMin() );
        verts[1].set( bbox.xMin(), bbox.yMin(), bbox.zMax() );
        verts[2].set( bbox.xMin(), bbox.yMax(), bbox.zMin() );
        verts[3].set( bbox.xMin(), bbox.yMax(), bbox.zMax() );
        verts[4].set( bbox.xMax(), bbox.yMin(), bbox.zMin() );
        verts[5].set( bbox.xMax(), bbox.yMin(), bbox.zMax() );
        verts[6].set( bbox.xMax(), bbox.yMax(), bbox.zMin() );
        verts[7].set( bbox.xMax(), bbox.yMax(), bbox.zMax() );
        getMinMaxExtentInSilhouette( cam, look, verts, out_eMin, out_eMax );
    }

Here is the call graph for this function:

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines