Show
Ignore:
Timestamp:
02/27/07 22:12:48 (7 years ago)
Author:
robert
Message:

Moved include/osgTerrain/DataSet/.cpp, gdal plugin and osgdem out into the VirtualPlaneBuilder? project.

Updated examples to remove DataSet?/GDAL dependency.

Updated wrappers

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgfadetext/osgfadetext.cpp

    r5923 r6283  
    1515#include <osgText/FadeText> 
    1616 
    17 #include <osgTerrain/DataSet> 
    18  
    1917#include <osgSim/OverlayNode> 
    2018#include <osgSim/SphereSegment> 
     
    2422#include <iostream> 
    2523 
    26 class MyGraphicsContext { 
    27     public: 
    28         MyGraphicsContext() 
    29         { 
    30             osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; 
    31             traits->x = 0; 
    32             traits->y = 0; 
    33             traits->width = 1; 
    34             traits->height = 1; 
    35             traits->windowDecoration = false; 
    36             traits->doubleBuffer = false; 
    37             traits->sharedContext = 0; 
    38             traits->pbuffer = true; 
    39  
    40             _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
    41  
    42             if (!_gc) 
    43             { 
    44                 osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl; 
    45                  
    46                 traits->pbuffer = false; 
    47                 _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
    48             } 
    49  
    50             if (_gc.valid())  
    51              
    52              
    53             { 
    54                 _gc->realize(); 
    55                 _gc->makeCurrent(); 
    56                 std::cout<<"Realized window"<<std::endl; 
    57             } 
    58         } 
    59          
    60         bool valid() const { return _gc.valid() && _gc->isRealized(); } 
    61          
    62     private: 
    63         osg::ref_ptr<osg::GraphicsContext> _gc; 
    64 }; 
    65  
    6624osg::Node* createEarth() 
    6725{ 
    68     osg::ref_ptr<osg::Node> scene; 
     26    osg::TessellationHints* hints = new osg::TessellationHints; 
     27    hints->setDetailRatio(5.0f); 
     28 
    6929     
    70     { 
    71         std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg"); 
    72  
    73         // make osgTerrain::DataSet quieter.. 
    74         osgTerrain::DataSet::setNotifyOffset(1); 
    75  
    76         osg::ref_ptr<osgTerrain::DataSet> dataSet = new osgTerrain::DataSet; 
    77  
    78         // register the source imagery 
    79         { 
    80             osgTerrain::DataSet::Source* source = new osgTerrain::DataSet::Source(osgTerrain::DataSet::Source::IMAGE, filename); 
    81  
    82             source->setCoordinateSystemPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS); 
    83             source->setCoordinateSystem(osgTerrain::DataSet::coordinateSystemStringToWTK("WGS84")); 
    84  
    85             source->setGeoTransformPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS_BUT_SCALE_BY_FILE_RESOLUTION); 
    86             source->setGeoTransformFromRange(-180.0, 180.0, -90.0, 90.0); 
    87  
    88             dataSet->addSource(source); 
    89         } 
    90  
    91         // set up destination database paramters. 
    92         dataSet->setDatabaseType(osgTerrain::DataSet::LOD_DATABASE); 
    93         dataSet->setConvertFromGeographicToGeocentric(true); 
    94         dataSet->setDestinationName("test.osg"); 
    95  
    96         // load the source data and record sizes. 
    97         dataSet->loadSources(); 
    98  
    99         MyGraphicsContext context; 
    100         dataSet->createDestination(30); 
    101  
    102         if (dataSet->getDatabaseType()==osgTerrain::DataSet::LOD_DATABASE) dataSet->buildDestination(); 
    103         else dataSet->writeDestination(); 
    104          
    105         scene = dataSet->getDestinationRootNode(); 
    106          
    107         // now we must get rid of all the old OpenGL objects before we start using the scene graph again  
    108         // otherwise it'll end up in an inconsistent state. 
    109         scene->releaseGLObjects(dataSet->getState()); 
    110         osg::Texture::flushAllDeletedTextureObjects(0); 
    111         osg::Drawable::flushAllDeletedDisplayLists(0); 
    112     } 
    113          
    114     return scene.release(); 
     30    osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0,0.0,0.0), osg::WGS_84_RADIUS_POLAR), hints); 
     31     
     32    osg::Geode* geode = new osg::Geode; 
     33    geode->addDrawable(sd); 
     34     
     35    std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg"); 
     36    geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile(filename))); 
     37     
     38    osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode; 
     39    csn->setEllipsoidModel(new osg::EllipsoidModel()); 
     40    csn->addChild(geode); 
     41     
     42    return csn; 
    11543     
    11644}