osgEarth 2.1.1
Public Member Functions | Private Attributes

osgEarth::CubeFaceLocator Class Reference

Inheritance diagram for osgEarth::CubeFaceLocator:
Collaboration diagram for osgEarth::CubeFaceLocator:

List of all members.

Public Member Functions

 CubeFaceLocator (unsigned int face)
bool convertLocalToModel (const osg::Vec3d &local, osg::Vec3d &world) const
bool convertModelToLocal (const osg::Vec3d &world, osg::Vec3d &local) const

Private Attributes

unsigned int _face

Detailed Description

osgTerrain locator for positioning data on the terrain using a cube-face coordinate system.

Definition at line 91 of file Cube.


Constructor & Destructor Documentation

CubeFaceLocator::CubeFaceLocator ( unsigned int  face)

Definition at line 296 of file Cube.cpp.

                                                 :
_face(face)
{
    //NOP
}

Member Function Documentation

bool CubeFaceLocator::convertLocalToModel ( const osg::Vec3d &  local,
osg::Vec3d &  world 
) const

Definition at line 304 of file Cube.cpp.

{
#if ((OPENSCENEGRAPH_MAJOR_VERSION <= 2) && (OPENSCENEGRAPH_MINOR_VERSION < 8))
    // OSG 2.7 bug workaround: bug fix in Locator submitted by GW
    const_cast<CubeFaceLocator*>(this)->_inverse.invert( _transform );
#endif

    if ( _coordinateSystemType == GEOCENTRIC )
    {
        //Convert the NDC coordinate into face space
        osg::Vec3d faceCoord = local * _transform;

        double lat_deg, lon_deg;
        CubeUtils::faceCoordsToLatLon( faceCoord.x(), faceCoord.y(), _face, lat_deg, lon_deg );

        //OE_NOTICE << "LatLon=" << latLon <<  std::endl;

        // convert to geocentric:
        _ellipsoidModel->convertLatLongHeightToXYZ(
            osg::DegreesToRadians( lat_deg ),
            osg::DegreesToRadians( lon_deg ),
            local.z(),
            world.x(), world.y(), world.z() );

        return true;
    }    
    return true;
}

Here is the call graph for this function:

bool CubeFaceLocator::convertModelToLocal ( const osg::Vec3d &  world,
osg::Vec3d &  local 
) const [virtual]

Reimplemented from osgEarth::GeoLocator.

Definition at line 335 of file Cube.cpp.

{
#if ((OPENSCENEGRAPH_MAJOR_VERSION <= 2) && (OPENSCENEGRAPH_MINOR_VERSION < 8))
    // OSG 2.7 bug workaround: bug fix in Locator submitted by GW
    const_cast<CubeFaceLocator*>(this)->_inverse.invert( _transform );
#endif

    switch(_coordinateSystemType)
    {
    case(GEOCENTRIC):
        {         
            double longitude, latitude, height;

            _ellipsoidModel->convertXYZToLatLongHeight(world.x(), world.y(), world.z(), latitude, longitude, height );

            int face=-1;
            double x, y;

            double lat_deg = osg::RadiansToDegrees(latitude);
            double lon_deg = osg::RadiansToDegrees(longitude);

            bool success = CubeUtils::latLonToFaceCoords( lat_deg, lon_deg, x, y, face, _face );

            if (!success)
            {
                OE_NOTICE << LC << "Couldn't convert to face coords " << std::endl;
            }
            if (face != _face)
            {
                OE_NOTICE << LC
                    << "Face should be " << _face << " but is " << face
                    << ", lat = " << lat_deg
                    << ", lon = " << lon_deg
                    << std::endl;
            }

            local = osg::Vec3d( x, y, height ) * _inverse;
            return true;
        }


    case(GEOGRAPHIC):
    case(PROJECTED):
        // Neither of these is supported for this locator..
        {        
            local = world * _inverse;
            return true;      
        }
    }    

    return false;
}

Here is the call graph for this function:


Member Data Documentation

unsigned int osgEarth::CubeFaceLocator::_face [private]

Definition at line 105 of file Cube.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines