Changeset 3532 for OpenSceneGraph/trunk/examples/osgplanets/osgplanets.cpp
- Timestamp:
- 10/25/04 20:23:42 (9 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgplanets/osgplanets.cpp
r3522 r3532 7 7 #include <osg/Geode> 8 8 #include <osg/ShapeDrawable> 9 #include <osg/Texture2D> 10 9 11 10 12 #include <osgUtil/Optimizer> … … 87 89 88 90 89 osg::Geode* createPlanet( double radius, std::string name, osg::Vec4 color)91 osg::Geode* createPlanet( double radius, const std::string& name, const osg::Vec4& color , const std::string& textureName ) 90 92 { 91 93 // create a cube shape … … 94 96 // create a container that makes the sphere drawable 95 97 osg::ShapeDrawable *sPlanetSphere = new osg::ShapeDrawable( planetSphere ); 96 98 97 99 // set the object color 98 100 sPlanetSphere->setColor( color ); 101 102 if( !textureName.empty() ) 103 { 104 osg::Image* image = osgDB::readImageFile( textureName ); 105 if ( image ) 106 { 107 sPlanetSphere->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D( image ), osg::StateAttribute::ON ); 108 109 // reset the object color to white to allow the texture to set the colour. 110 sPlanetSphere->setColor( osg::Vec4(1.0f,1.0f,1.0f,1.0f) ); 111 } 112 } 113 99 114 100 115 // create a geode object to as a container for our drawable sphere object … … 107 122 return( geodePlanet ); 108 123 }// end createPlanet 109 124 //--radiusSun 5.0 --radiusEarth 2.0 --RorbitEarth 10.0 --RorbitMoon 2.0 --radiusMoon 0.5 --tiltEarth 18.0 --rotateSpeedEarth 1.0 125 //--rotateSpeedMoon 1.0 --rotateSpeedEarthAndMoon 1.0 110 126 111 127 class SolarSystem … … 123 139 double _rotateSpeedMoon; 124 140 125 SolarSystem( 126 double _radiusSun = 20.0, 127 double _radiusEarth = 10.0, 128 double _RorbitEarth = 100.0, 129 double _tiltEarth = 5.0, 130 double _rotateSpeedEarthAndMoon = 5.0, 131 double _rotateSpeedEarth = 5.0, 132 double _radiusMoon = 2.0, 133 double _RorbitMoon = 20.0, 134 double _rotateSpeedMoon = 5.0 ) 135 {} 141 SolarSystem() 142 { 143 _radiusSun = 5.0; 144 _radiusEarth = 2.0; 145 _RorbitEarth = 10.0; 146 _tiltEarth = 18.0; 147 _rotateSpeedEarthAndMoon = 1.0; 148 _rotateSpeedEarth = 1.0; 149 _radiusMoon = 0.5; 150 _RorbitMoon = 2.0; 151 _rotateSpeedMoon = 1.0; 152 } 136 153 137 154 osg::Group* built() … … 141 158 142 159 // create the sun 143 osg::Node* sun = createPlanet( _radiusSun, "Sun", osg::Vec4( 1.0f, 1.0f, 0.5f, 1.0f) );160 osg::Node* sun = createPlanet( _radiusSun, "Sun", osg::Vec4( 1.0f, 1.0f, 0.5f, 1.0f), "" ); 144 161 145 162 // stick sun right under root, no transformations for the sun … … 151 168 152 169 // create earth and moon 153 osg::Node* earth = createPlanet( _radiusEarth, "Earth", osg::Vec4( 0.0f, 0.0f, 1.0f, 1.0f) );154 osg::Node* moon = createPlanet( _radiusMoon, "Moon", osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f) );170 osg::Node* earth = createPlanet( _radiusEarth, "Earth", osg::Vec4( 0.0f, 0.0f, 1.0f, 1.0f), "Images/land_shallow_topo_2048.jpg" ); 171 osg::Node* moon = createPlanet( _radiusMoon, "Moon", osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f), "Images/moon256128.TGA" ); 155 172 156 173 // create transformations for the earthMoonGroup … … 233 250 while (arguments.read("--rotateSpeedMoon",solarSystem._rotateSpeedMoon)) { } 234 251 235 236 // solarSystem.printParameters(); 252 solarSystem.printParameters(); 237 253 238 254 // if user request help write it out to cout.
