osgEarth 2.1.1
Classes | Functions | Variables

anonymous_namespace{SkyNode.cpp} Namespace Reference

Classes

struct  DoNotIncludeInNearFarComputationCallback
struct  OverrideNearFarValuesCallback
struct  AddCallbackToDrawablesVisitor
struct  Sun

Functions

osg::Geometry * s_makeEllipsoidGeometry (const osg::EllipsoidModel *ellipsoid, double outerRadius)
osg::Geometry * s_makeDiscGeometry (double radius)
double getJulianDate (int year, int month, int date)

Variables

static const double TWO_PI = (2.0*osg::PI)
static const double JD2000 = 2451545.0
static char s_atmosphereVertexSource [] = "} \n"
static char s_atmosphereFragmentSource [] = "} \n"
static char s_sunVertexSource [] = "} \n"
static char s_sunFragmentSource [] = "} \n"
static const char s_starVertexSource [] = "} \n"
static const char s_starFragmentSource [] = "} \n"

Function Documentation

double anonymous_namespace{SkyNode.cpp}::getJulianDate ( int  year,
int  month,
int  date 
)

Definition at line 262 of file SkyNode.cpp.

    {
        if ( month <= 2 )
        {
            month += 12;
            year -= 1;
        }

        int A = int(year/100);
        int B = 2-A+(A/4);
        int C = int(365.25*(year+4716));
        int D = int(30.6001*(month+1));
        return B + C + D + date - 1524.5;
    }

Here is the caller graph for this function:

osg::Geometry* anonymous_namespace{SkyNode.cpp}::s_makeDiscGeometry ( double  radius)

Definition at line 205 of file SkyNode.cpp.

    {
        int segments = 48;
        float deltaAngle = 360.0/(float)segments;

        osg::Geometry* geom = new osg::Geometry();

        //geom->setUseVertexBufferObjects( true );
        geom->setUseDisplayList( false );

        osg::Vec3Array* verts = new osg::Vec3Array();
        verts->reserve( 1 + segments );
        geom->setVertexArray( verts );

        osg::DrawElementsUShort* el = new osg::DrawElementsUShort( GL_TRIANGLES );
        el->reserve( 1 + 2*segments );
        geom->addPrimitiveSet( el );

        verts->push_back( osg::Vec3(0,0,0) ); // center point

        for( int i=0; i<segments; ++i )
        {
            double angle = osg::DegreesToRadians( deltaAngle * (float)i );
            double x = radius * cos( angle );
            double y = radius * sin( angle );
            verts->push_back( osg::Vec3(x, y, 0.0) );

            int i_plus_1 = i < segments-1? i+1 : 0;
            el->push_back( 0 );
            el->push_back( 1 + i_plus_1 );
            el->push_back( 1 + i );
        }

        return geom;
    }

Here is the caller graph for this function:

osg::Geometry* anonymous_namespace{SkyNode.cpp}::s_makeEllipsoidGeometry ( const osg::EllipsoidModel *  ellipsoid,
double  outerRadius 
)

Definition at line 154 of file SkyNode.cpp.

    {
        double hae = outerRadius - ellipsoid->getRadiusEquator();

        osg::Geometry* geom = new osg::Geometry();

        //geom->setUseVertexBufferObjects( true );
        geom->setUseDisplayList( false );

        int latSegments = 100;
        int lonSegments = 2 * latSegments;

        double segmentSize = 180.0/(double)latSegments; // degrees

        osg::Vec3Array* verts = new osg::Vec3Array();
        verts->reserve( latSegments * lonSegments );

        osg::DrawElementsUShort* el = new osg::DrawElementsUShort( GL_TRIANGLES );
        el->reserve( latSegments * lonSegments * 6 );

        for( int y = 0; y <= latSegments; ++y )
        {
            double lat = -90.0 + segmentSize * (double)y;
            for( int x = 0; x < lonSegments; ++x )
            {
                double lon = -180.0 + segmentSize * (double)x;
                double gx, gy, gz;
                ellipsoid->convertLatLongHeightToXYZ( osg::DegreesToRadians(lat), osg::DegreesToRadians(lon), hae, gx, gy, gz );
                verts->push_back( osg::Vec3(gx, gy, gz) );

                if ( y < latSegments )
                {
                    int x_plus_1 = x < lonSegments-1 ? x+1 : 0;
                    int y_plus_1 = y+1;
                    el->push_back( y*lonSegments + x );
                    el->push_back( y*lonSegments + x_plus_1 );
                    el->push_back( y_plus_1*lonSegments + x );
                    el->push_back( y*lonSegments + x_plus_1 );
                    el->push_back( y_plus_1*lonSegments + x_plus_1 );
                    el->push_back( y_plus_1*lonSegments + x );
                }
            }
        }

        geom->setVertexArray( verts );
        geom->addPrimitiveSet( el );

        return geom;
    }

Here is the caller graph for this function:


Variable Documentation

const double anonymous_namespace{SkyNode.cpp}::JD2000 = 2451545.0 [static]

Definition at line 254 of file SkyNode.cpp.

char anonymous_namespace{SkyNode.cpp}::s_atmosphereFragmentSource[] = "} \n" [static]

Definition at line 500 of file SkyNode.cpp.

char anonymous_namespace{SkyNode.cpp}::s_atmosphereVertexSource[] = "} \n" [static]

Definition at line 357 of file SkyNode.cpp.

const char anonymous_namespace{SkyNode.cpp}::s_starFragmentSource[] = "} \n" [static]

Definition at line 574 of file SkyNode.cpp.

const char anonymous_namespace{SkyNode.cpp}::s_starVertexSource[] = "} \n" [static]

Definition at line 566 of file SkyNode.cpp.

char anonymous_namespace{SkyNode.cpp}::s_sunFragmentSource[] = "} \n" [static]

Definition at line 542 of file SkyNode.cpp.

char anonymous_namespace{SkyNode.cpp}::s_sunVertexSource[] = "} \n" [static]

Definition at line 530 of file SkyNode.cpp.

const double anonymous_namespace{SkyNode.cpp}::TWO_PI = (2.0*osg::PI) [static]

Definition at line 253 of file SkyNode.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines