osgEarth 2.1.1
|
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 |
osgTerrain locator for positioning data on the terrain using a cube-face coordinate system.
CubeFaceLocator::CubeFaceLocator | ( | unsigned int | face | ) |
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; }
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; }
unsigned int osgEarth::CubeFaceLocator::_face [private] |