| | 14 | //////////////////////////////////////////////////////////////////////////////// |
| | 15 | osg::Node * CreateGlobe( void ) |
| | 16 | { |
| | 17 | // File not found - create textured sphere |
| | 18 | osg::Geode * geode = new osg::Geode; |
| | 19 | osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints; |
| | 20 | hints->setDetailRatio( 0.3 ); |
| | 21 | |
| | 22 | #if 1 |
| | 23 | osg::ref_ptr<osg::ShapeDrawable> shape = new osg::ShapeDrawable |
| | 24 | ( new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 4.0 ), hints.get() ); |
| | 25 | #else |
| | 26 | osg::ref_ptr<osg::ShapeDrawable> shape = new osg::ShapeDrawable |
| | 27 | ( new osg::Box( osg::Vec3(-1.0f, -1.0f, -1.0f), 2.0, 2.0, 2.0 ) ); |
| | 28 | #endif |
| | 29 | |
| | 30 | shape->setColor(osg::Vec4(0.8f, 0.8f, 0.8f, 1.0f)); |
| | 31 | |
| | 32 | geode->addDrawable( shape.get() ); |
| | 33 | |
| | 34 | osg::StateSet * stateSet = new osg::StateSet; |
| | 35 | |
| | 36 | osg::Texture2D * texture = new osg::Texture2D( |
| | 37 | osgDB::readImageFile("Images/land_shallow_topo_2048.jpg") |
| | 38 | ); |
| | 39 | |
| | 40 | osg::Material * material = new osg::Material; |
| | 41 | |
| | 42 | material->setAmbient |
| | 43 | ( osg::Material::FRONT_AND_BACK, osg::Vec4( 0.9, 0.9, 0.9, 1.0 ) ); |
| | 44 | |
| | 45 | material->setDiffuse |
| | 46 | ( osg::Material::FRONT_AND_BACK, osg::Vec4( 0.9, 0.9, 0.9, 1.0 ) ); |
| | 47 | |
| | 48 | #if 1 |
| | 49 | material->setSpecular |
| | 50 | ( osg::Material::FRONT_AND_BACK, osg::Vec4( 0.7, 0.3, 0.3, 1.0 ) ); |
| | 51 | |
| | 52 | material->setShininess( osg::Material::FRONT_AND_BACK, 25 ); |
| | 53 | |
| | 54 | #endif |
| | 55 | |
| | 56 | stateSet->setAttributeAndModes( material ); |
| | 57 | stateSet->setTextureAttributeAndModes( 0,texture, osg::StateAttribute::ON ); |
| | 58 | |
| | 59 | geode->setStateSet( stateSet ); |
| | 60 | return geode; |
| | 61 | } |
| | 62 | //////////////////////////////////////////////////////////////////////////////// |
| 21 | | if (arguments.argc()>1) |
| 22 | | { |
| 23 | | if (!arguments.isOption(1)) filename = arguments[1]; |
| | 71 | osg::Node * model = NULL; |
| | 72 | |
| | 73 | if (arguments.argc()>1 && !arguments.isOption(1) ) { |
| | 74 | std::string filename = arguments[1]; |
| | 75 | model = osgDB::readNodeFile( filename ); |
| | 76 | if ( !model ) { |
| | 77 | osg::notify( osg::NOTICE ) |
| | 78 | << "Error, cannot read " << filename |
| | 79 | << ". Loading default earth model instead." << std::endl; |
| | 80 | } |