osgEarth 2.1.1
Public Member Functions | Public Attributes

GeodeticManifold Class Reference

Inheritance diagram for GeodeticManifold:
Collaboration diagram for GeodeticManifold:

List of all members.

Public Member Functions

 GeodeticManifold ()
void seed (Level maxLevel)
void cull (osgUtil::CullVisitor *cv)
void initialize (MeshManager *mesh)
osg::Vec3d midpoint (const osg::Vec3d &mapCoord0, const osg::Vec3d &mapCoord1) const
osg::BoundingSphere initialBound () const
MeshNode createNode (const osg::Vec3d &manifoldCoord) const
osg::Vec3d p (double x, double y, double z)

Public Attributes

osg::BoundingSphere _bs
osg::ref_ptr< const Profile_profile
osg::ref_ptr< const
osg::EllipsoidModel > 
_ellipsoid
osg::ref_ptr< Diamond_vd [6]
osg::ref_ptr< Diamond_fd [4]
osg::ref_ptr< Diamond_ed [8]

Detailed Description

The top-level diamond layout for a round earth

Definition at line 29 of file GeodeticManifold.


Constructor & Destructor Documentation

GeodeticManifold::GeodeticManifold ( )

Definition at line 24 of file GeodeticManifold.cpp.

{
    _profile = osgEarth::Registry::instance()->getGlobalGeodeticProfile();
    _ellipsoid = _profile->getSRS()->getGeographicSRS()->getEllipsoid();
}

Here is the call graph for this function:


Member Function Documentation

MeshNode GeodeticManifold::createNode ( const osg::Vec3d &  manifoldCoord) const [virtual]

creates a mesh node for a coordinate in manifold profile

Implements Manifold.

Definition at line 214 of file GeodeticManifold.cpp.

{
    MeshNode node;

    node._manifoldCoord = manCoord;

    node._geodeticCoord.set( 
        osg::DegreesToRadians(manCoord.x()), osg::DegreesToRadians(manCoord.y()), manCoord.z() );

    osg::Vec3d temp;
    _ellipsoid->convertLatLongHeightToXYZ(
        node._geodeticCoord.y(), node._geodeticCoord.x(), node._geodeticCoord.z(),
        temp.x(), temp.y(), temp.z() );

    node._vertex = temp;

    node._normal = _ellipsoid->computeLocalUpVector(
        temp.x(), temp.y(), temp.z() );

    return node;
}
void GeodeticManifold::cull ( osgUtil::CullVisitor *  cv) [virtual]

apply culling to the manifold.

Implements Manifold.

Definition at line 252 of file GeodeticManifold.cpp.

{
    for( unsigned short e=0; e<8; ++e )
    {
        _ed[e]->cull( cv );
    }
}
osg::BoundingSphere GeodeticManifold::initialBound ( ) const [virtual]

calculates the initial bound for the manifold.

Implements Manifold.

Definition at line 237 of file GeodeticManifold.cpp.

{
    return osg::BoundingSphere( osg::Vec3d(0,0,0), _ellipsoid->getRadiusEquator() * 1.2 );
}
void GeodeticManifold::initialize ( MeshManager mesh) [virtual]

builds the base manifold mesh.

Implements Manifold.

Definition at line 31 of file GeodeticManifold.cpp.

{
    mesh->_minGeomLevel = 1;
    mesh->_minActiveLevel = 3;

    // Construct the "vertex diamonds".
    _vd[0] = new Diamond(mesh, TileKey(), 0, "vd0"); // north pole 1
    _vd[0]->setCoord( -90, 90, 0 );

    _vd[1] = new Diamond(mesh, TileKey(), 0, "vd1"); // north pole 2
    _vd[1]->setCoord( 90, 90, 0 );

    _vd[2] = new Diamond(mesh, TileKey(), 0, "vd2"); // south pole 1
    _vd[2]->setCoord( -90, -90, 0 );

    _vd[3] = new Diamond(mesh, TileKey(), 0, "vd3"); // south pole 2
    _vd[3]->setCoord( 90, -90, 0 );

    _vd[4] = new Diamond(mesh, TileKey(), 0, "vd4");
    _vd[4]->setCoord( -180, 0, 0 );

    _vd[5] = new Diamond(mesh, TileKey(), 0, "vd5");
    _vd[5]->setCoord( 0, 0, 0 );

    // The 4 "face diamonds":
    _fd[0] = new Diamond(mesh, TileKey(), 0, "fd0");
    _fd[0]->setCoord( -90, 0, 0 );
    _fd[0]->_a[GDPARENT] = _vd[0].get();
    _fd[0]->_a[QUADTREE] = _vd[2].get();
    _fd[0]->_a[PARENT_L] = _vd[4].get();
    _fd[0]->_a[PARENT_R] = _vd[5].get();

    _fd[1] = new Diamond(mesh, TileKey(), 0, "fd1");
    _fd[1]->setCoord( 90, 0, 0 );
    _fd[1]->_a[GDPARENT] = _vd[3].get();
    _fd[1]->_a[QUADTREE] = _vd[1].get();
    _fd[1]->_a[PARENT_L] = _vd[4].get();
    _fd[1]->_a[PARENT_R] = _vd[5].get();

    _fd[2] = new Diamond(mesh, TileKey(), 0, "fd2"); // virtual north pole diamond
    _fd[2]->setCoord( 0, 90, 0 );
    _fd[2]->_a[GDPARENT] = _vd[0].get();
    _fd[2]->_a[QUADTREE] = _vd[1].get();
    _fd[2]->_a[PARENT_L] = _vd[5].get();
    _fd[2]->_a[PARENT_R] = _vd[4].get();

    _fd[3] = new Diamond(mesh, TileKey(), 0, "fd3"); // virtual south pole diamond
    _fd[3]->setCoord( 0, -90, 0 );
    _fd[3]->_a[GDPARENT] = _vd[3].get();
    _fd[3]->_a[QUADTREE] = _vd[2].get();
    _fd[3]->_a[PARENT_L] = _vd[5].get();
    _fd[3]->_a[PARENT_R] = _vd[4].get();

    // the 8 "edge diamonds" (first with geometry)
    _ed[0] = new Diamond(mesh, TileKey(1,0,0,_profile.get()), 1, "ed0");
    _ed[0]->setCoord( -135, 45, 0 );
    _ed[0]->_a[GDPARENT] = _vd[0].get();
    _ed[0]->_a[QUADTREE] = _vd[4].get();
    _ed[0]->_a[PARENT_L] = _fd[2].get();
    _ed[0]->_a[PARENT_R] = _fd[0].get();
    _ed[0]->_orientation = 0;

    _ed[1] = new Diamond(mesh, TileKey(1,1,0,_profile.get()), 1, "ed1");
    _ed[1]->setCoord( -45, 45, 0 );
    _ed[1]->_a[GDPARENT] = _vd[0].get();
    _ed[1]->_a[QUADTREE] = _vd[5].get();
    _ed[1]->_a[PARENT_L] = _fd[0].get();
    _ed[1]->_a[PARENT_R] = _fd[2].get();
    _ed[1]->_orientation = 2;

    _ed[2] = new Diamond(mesh, TileKey(1,0,1,_profile.get()), 1, "ed2");
    _ed[2]->setCoord( -135, -45, 0 );
    _ed[2]->_a[GDPARENT] = _vd[2].get();
    _ed[2]->_a[QUADTREE] = _vd[4].get();
    _ed[2]->_a[PARENT_L] = _fd[0].get();
    _ed[2]->_a[PARENT_R] = _fd[3].get();
    _ed[2]->_orientation = 6;

    _ed[3] = new Diamond(mesh, TileKey(1,1,1,_profile.get()), 1, "ed3");
    _ed[3]->setCoord( -45, -45, 0 );
    _ed[3]->_a[GDPARENT] = _vd[2].get();
    _ed[3]->_a[QUADTREE] = _vd[5].get();
    _ed[3]->_a[PARENT_L] = _fd[3].get();
    _ed[3]->_a[PARENT_R] = _fd[0].get();
    _ed[3]->_orientation = 4;

    _ed[4] = new Diamond(mesh, TileKey(1,2,0,_profile.get()), 1, "ed4");
    _ed[4]->setCoord( 45, 45, 0 );
    _ed[4]->_a[GDPARENT] = _vd[1].get();
    _ed[4]->_a[QUADTREE] = _vd[5].get();
    _ed[4]->_a[PARENT_L] = _fd[2].get();
    _ed[4]->_a[PARENT_R] = _fd[1].get();
    _ed[4]->_orientation = 0;
    
    _ed[5] = new Diamond(mesh, TileKey(1,3,0,_profile.get()), 1, "ed5");
    _ed[5]->setCoord( 135, 45, 0 );
    _ed[5]->_a[GDPARENT] = _vd[1].get();
    _ed[5]->_a[QUADTREE] = _vd[4].get();
    _ed[5]->_a[PARENT_L] = _fd[1].get();
    _ed[5]->_a[PARENT_R] = _fd[2].get();
    _ed[5]->_orientation = 2;

    _ed[6] = new Diamond(mesh, TileKey(1,2,1,_profile.get()), 1, "ed6");
    _ed[6]->setCoord( 45, -45, 0 );
    _ed[6]->_a[GDPARENT] = _vd[3].get();
    _ed[6]->_a[QUADTREE] = _vd[5].get();
    _ed[6]->_a[PARENT_L] = _fd[1].get();
    _ed[6]->_a[PARENT_R] = _fd[3].get();
    _ed[6]->_orientation = 6;

    _ed[7] = new Diamond(mesh, TileKey(1,3,1,_profile.get()), 1, "ed7");
    _ed[7]->setCoord( 135, -45, 0 );
    _ed[7]->_a[GDPARENT] = _vd[3].get();
    _ed[7]->_a[QUADTREE] = _vd[4].get();
    _ed[7]->_a[PARENT_L] = _fd[3].get();
    _ed[7]->_a[PARENT_R] = _fd[1].get();
    _ed[7]->_orientation = 7;

    // set child pointers:
    _fd[0]->setChild( 0, _ed[3].get() );
    _fd[0]->setChild( 1, _ed[1].get() );
    _fd[0]->setChild( 2, _ed[0].get() );
    _fd[0]->setChild( 3, _ed[2].get() );

    _fd[1]->setChild( 0, _ed[4].get() );
    _fd[1]->setChild( 1, _ed[6].get() );
    _fd[1]->setChild( 2, _ed[7].get() );
    _fd[1]->setChild( 3, _ed[5].get() );

    _fd[2]->setChild( 0, _ed[5].get() );
    _fd[2]->setChild( 1, _ed[0].get() );
    _fd[2]->setChild( 2, _ed[1].get() );
    _fd[2]->setChild( 3, _ed[4].get() );

    _fd[3]->setChild( 0, _ed[2].get() );
    _fd[3]->setChild( 1, _ed[7].get() );
    _fd[3]->setChild( 2, _ed[6].get() );
    _fd[3]->setChild( 3, _ed[3].get() );
    

    // seed the bouding spheres of the manifold diamonds:
    for( unsigned short f=0; f<4; ++f )
        _fd[f]->activate();

    for( unsigned short e=0; e<8; ++e )
        _ed[e]->activate();

    // generate Level 3 (the first renderable quadtree decendants).
    seed( 3 );

    // hopefully, that's it!
}

Here is the call graph for this function:

osg::Vec3d GeodeticManifold::midpoint ( const osg::Vec3d &  mapCoord0,
const osg::Vec3d &  mapCoord1 
) const [virtual]

calculates the midpoint between two map coodinates

Implements Manifold.

Definition at line 198 of file GeodeticManifold.cpp.

{
    //TODO account for date line crossing
    return (p0+p1)*0.5;
}
osg::Vec3d GeodeticManifold::p ( double  x,
double  y,
double  z 
)
void GeodeticManifold::seed ( Level  maxLevel)

generate children up to the specified level

Definition at line 243 of file GeodeticManifold.cpp.

{
    for( unsigned short e=0; e<8; ++e )
    {
        _ed[e]->seed( maxLevel );
    }
}

Here is the caller graph for this function:


Member Data Documentation

osg::BoundingSphere GeodeticManifold::_bs

Definition at line 56 of file GeodeticManifold.

osg::ref_ptr<Diamond> GeodeticManifold::_ed[8]

Definition at line 61 of file GeodeticManifold.

osg::ref_ptr<const osg::EllipsoidModel> GeodeticManifold::_ellipsoid

Definition at line 58 of file GeodeticManifold.

osg::ref_ptr<Diamond> GeodeticManifold::_fd[4]

Definition at line 60 of file GeodeticManifold.

osg::ref_ptr<const Profile> GeodeticManifold::_profile

Definition at line 57 of file GeodeticManifold.

osg::ref_ptr<Diamond> GeodeticManifold::_vd[6]

Definition at line 59 of file GeodeticManifold.


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