Changeset 3688 for OpenSceneGraph/trunk/examples/osgplanets/osgplanets.cpp
- Timestamp:
- 11/22/04 14:58:57 (9 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgplanets/osgplanets.cpp
r3667 r3688 134 134 int numSamples = 1000; 135 135 float yaw = 0.0f; 136 float yaw_delta = 2.0f*osg::PI/((float)numSamples-1.0f);136 float yaw_delta = -2.0f*osg::PI/((float)numSamples-1.0f); 137 137 float roll = osg::inDegrees(30.0f); 138 138 … … 174 174 double _RorbitJupiter; 175 175 176 double _rotateSpeedSun; 176 177 double _rotateSpeedMercury; 177 178 double _rotateSpeedVenus; … … 194 195 std::string _mapJupiter; 195 196 197 double _rotateSpeedFactor; 198 double _RorbitFactor; 199 double _radiusFactor; 200 196 201 SolarSystem() 197 202 { 198 _radiusSpace = 300.0;199 _radiusSun = 3.5;200 _radiusMercury = 0. 7;201 _radiusVenus = 1.2;202 _radiusEarth = 2.0;203 _radiusMoon = 0. 5;204 _radiusMars = 1.8;205 _radiusJupiter = 1.8;203 _radiusSpace = 500.0; 204 _radiusSun = 109.0; 205 _radiusMercury = 0.38; 206 _radiusVenus = 0.95; 207 _radiusEarth = 1.0; 208 _radiusMoon = 0.1; 209 _radiusMars = 0.53; 210 _radiusJupiter = 5.0; 206 211 207 212 _RorbitMercury = 11.7; 208 213 _RorbitVenus = 21.6; 209 214 _RorbitEarth = 30.0; 210 _RorbitMoon = 2.0;215 _RorbitMoon = 1.0; 211 216 _RorbitMars = 45.0; 212 217 _RorbitJupiter = 156.0; 213 218 214 _rotateSpeedMercury = 1.1; 215 _rotateSpeedVenus = 1.3; 216 _rotateSpeedEarthAndMoon = 1.0; 217 _rotateSpeedEarth = 1.0; 218 _rotateSpeedMoon = 1.2; 219 _rotateSpeedMars = 1.2; 220 _rotateSpeedJupiter = 1.2; 221 222 _tiltEarth = 18.0; // degrees 219 // orbital period in days 220 _rotateSpeedSun = 0.0; // should be 11.97; // 30.5 average 221 _rotateSpeedMercury = 4.15; // 87.96 222 _rotateSpeedVenus = 1.62; // 224.70 223 _rotateSpeedEarthAndMoon = 1.0; // 365.25 224 _rotateSpeedEarth = 1.0; // 225 _rotateSpeedMoon = 0.95; // 226 _rotateSpeedMars = 0.53; // 686.98 227 _rotateSpeedJupiter = 0.08; // 4332.71 228 229 _tiltEarth = 23.45; // degrees 223 230 224 231 _mapSpace = "Images/spacemap2.jpg"; … … 231 238 _mapMars = "SolarSystem/mars256128.jpg"; 232 239 _mapJupiter = "SolarSystem/jupiter256128.jpg"; 240 241 _rotateSpeedFactor = 0.5; 242 _RorbitFactor = 15.0; 243 _radiusFactor = 10.0; 233 244 } 234 245 … … 241 252 osg::Group* createSunLight(); 242 253 254 void rotateSpeedCorrection() 255 { 256 _rotateSpeedSun *= _rotateSpeedFactor; 257 _rotateSpeedMercury *= _rotateSpeedFactor; 258 _rotateSpeedVenus *= _rotateSpeedFactor; 259 _rotateSpeedEarthAndMoon *= _rotateSpeedFactor; 260 _rotateSpeedEarth *= _rotateSpeedFactor; 261 _rotateSpeedMoon *= _rotateSpeedFactor; 262 _rotateSpeedMars *= _rotateSpeedFactor; 263 _rotateSpeedJupiter *= _rotateSpeedFactor; 264 265 std::cout << "rotateSpeed corrected by factor " << _rotateSpeedFactor << std::endl; 266 } 267 268 void RorbitCorrection() 269 { 270 _RorbitMercury *= _RorbitFactor; 271 _RorbitVenus *= _RorbitFactor; 272 _RorbitEarth *= _RorbitFactor; 273 _RorbitMoon *= _RorbitFactor; 274 _RorbitMars *= _RorbitFactor; 275 _RorbitJupiter *= _RorbitFactor; 276 277 std::cout << "Rorbits corrected by factor " << _RorbitFactor << std::endl; 278 } 279 280 void radiusCorrection() 281 { 282 _radiusSpace *= _radiusFactor; 283 //_radiusSun *= _radiusFactor; 284 _radiusMercury *= _radiusFactor; 285 _radiusVenus *= _radiusFactor; 286 _radiusEarth *= _radiusFactor; 287 _radiusMoon *= _radiusFactor; 288 _radiusMars *= _radiusFactor; 289 _radiusJupiter *= _radiusFactor; 290 291 std::cout << "Radius corrected by factor " << _radiusFactor << std::endl; 292 } 243 293 void printParameters(); 244 294 … … 475 525 std::cout << "radiusSpace(" << _radiusSpace << ")" << std::endl; 476 526 std::cout << "radiusSun(" << _radiusSun << ")" << std::endl; 527 std::cout << "radiusMercury(" << _radiusMercury << ")" << std::endl; 528 std::cout << "radiusVenus(" << _radiusVenus << ")" << std::endl; 477 529 std::cout << "radiusEarth(" << _radiusEarth << ")" << std::endl; 478 530 std::cout << "radiusMoon(" << _radiusMoon << ")" << std::endl; 479 531 std::cout << "radiusMars(" << _radiusMars << ")" << std::endl; 532 std::cout << "radiusJupiter(" << _radiusJupiter << ")" << std::endl; 533 534 std::cout << "RorbitMercury(" << _RorbitMercury << ")" << std::endl; 535 std::cout << "RorbitVenus(" << _RorbitVenus << ")" << std::endl; 480 536 std::cout << "RorbitEarth(" << _RorbitEarth << ")" << std::endl; 481 537 std::cout << "RorbitMoon(" << _RorbitMoon << ")" << std::endl; 482 538 std::cout << "RorbitMars(" << _RorbitMars << ")" << std::endl; 539 std::cout << "RorbitJupiter(" << _RorbitJupiter << ")" << std::endl; 540 541 std::cout << "rotateSpeedMercury(" << _rotateSpeedMercury << ")" << std::endl; 542 std::cout << "rotateSpeedVenus(" << _rotateSpeedVenus << ")" << std::endl; 483 543 std::cout << "rotateSpeedEarthAndMoon(" << _rotateSpeedEarthAndMoon << ")" << std::endl; 484 544 std::cout << "rotateSpeedEarth(" << _rotateSpeedEarth << ")" << std::endl; 485 545 std::cout << "rotateSpeedMoon(" << _rotateSpeedMoon << ")" << std::endl; 546 std::cout << "rotateSpeedMars(" << _rotateSpeedMars << ")" << std::endl; 547 std::cout << "rotateSpeedJupiter(" << _rotateSpeedJupiter << ")" << std::endl; 548 486 549 std::cout << "tiltEarth(" << _tiltEarth << ")" << std::endl; 487 550 488 std::cout << "mapSpace(" << _radiusSpace << ")" << std::endl; 489 std::cout << "mapEarth(" << _radiusSpace << ")" << std::endl; 490 std::cout << "mapEarthNight(" << _radiusSpace << ")" << std::endl; 491 std::cout << "mapMoon(" << _radiusSpace << ")" << std::endl; 551 std::cout << "mapSpace(" << _mapSpace << ")" << std::endl; 552 std::cout << "mapSun(" << _mapSun << ")" << std::endl; 553 std::cout << "mapMercury(" << _mapMercury << ")" << std::endl; 554 std::cout << "mapVenus(" << _mapVenus << ")" << std::endl; 555 std::cout << "mapEarth(" << _mapEarth << ")" << std::endl; 556 std::cout << "mapEarthNight(" << _mapEarthNight << ")" << std::endl; 557 std::cout << "mapMoon(" << _mapMoon << ")" << std::endl; 558 std::cout << "mapMars(" << _mapMars << ")" << std::endl; 559 std::cout << "mapJupiter(" << _mapJupiter << ")" << std::endl; 560 561 std::cout << "rotateSpeedFactor(" << _rotateSpeedFactor << ")" << std::endl; 562 std::cout << "RorbitFactor(" << _RorbitFactor << ")" << std::endl; 563 std::cout << "radiusFactor(" << _radiusFactor << ")" << std::endl; 492 564 } 493 565 … … 517 589 while (arguments.read("--radiusSpace",solarSystem._radiusSpace)) { } 518 590 while (arguments.read("--radiusSun",solarSystem._radiusSun)) { } 591 while (arguments.read("--radiusMercury",solarSystem._radiusMercury)) { } 592 while (arguments.read("--radiusVenus",solarSystem._radiusVenus)) { } 519 593 while (arguments.read("--radiusEarth",solarSystem._radiusEarth)) { } 520 594 while (arguments.read("--radiusMoon",solarSystem._radiusMoon)) { } 595 while (arguments.read("--radiusMars",solarSystem._radiusMars)) { } 596 while (arguments.read("--radiusJupiter",solarSystem._radiusJupiter)) { } 521 597 522 598 while (arguments.read("--RorbitEarth",solarSystem._RorbitEarth)) { } … … 532 608 while (arguments.read("--mapEarthNight",solarSystem._mapEarthNight)) { } 533 609 while (arguments.read("--mapMoon",solarSystem._mapMoon)) { } 610 611 while (arguments.read("--rotateSpeedFactor",solarSystem._rotateSpeedFactor)) { } 612 while (arguments.read("--RorbitFactor",solarSystem._RorbitFactor)) { } 613 while (arguments.read("--radiusFactor",solarSystem._radiusFactor)) { } 614 615 solarSystem.rotateSpeedCorrection(); 616 solarSystem.RorbitCorrection(); 617 solarSystem.radiusCorrection(); 534 618 535 619 std::string writeFileName; … … 570 654 571 655 572 solarSystem.printParameters();656 // solarSystem.printParameters(); 573 657 574 658 // if user request help write it out to cout. … … 576 660 { 577 661 std::cout << "setup the following arguments: " << std::endl; 578 std::cout << "--radiusSpace: double" << std::endl; 579 std::cout << "--radiusSun: double" << std::endl; 580 std::cout << "--radiusEarth: double" << std::endl; 581 std::cout << "--radiusMoon: double" << std::endl; 582 583 std::cout << "--RorbitEarth: double" << std::endl; 584 std::cout << "--RorbitMoon: double" << std::endl; 585 586 std::cout << "--rotateSpeedEarthAndMoon: double" << std::endl; 587 std::cout << "--rotateSpeedEarth: double" << std::endl; 588 std::cout << "--rotateSpeedMoon: double" << std::endl; 589 std::cout << "--tiltEarth: double" << std::endl; 590 591 std::cout << "--mapSpace: string" << std::endl; 592 std::cout << "--mapEarth: string" << std::endl; 593 std::cout << "--mapEarthNight: string" << std::endl; 594 std::cout << "--mapMoon: string" << std::endl; 662 std::cout << "\t--radiusSpace: double" << std::endl; 663 std::cout << "\t--radiusSun: double" << std::endl; 664 std::cout << "\t--radiusMercury: double" << std::endl; 665 std::cout << "\t--radiusVenus: double" << std::endl; 666 std::cout << "\t--radiusEarth: double" << std::endl; 667 std::cout << "\t--radiusMoon: double" << std::endl; 668 std::cout << "\t--radiusMars: double" << std::endl; 669 std::cout << "\t--radiusJupiter: double" << std::endl; 670 671 std::cout << "\t--RorbitMercury: double" << std::endl; 672 std::cout << "\t--RorbitVenus: double" << std::endl; 673 std::cout << "\t--RorbitEarth: double" << std::endl; 674 std::cout << "\t--RorbitMoon: double" << std::endl; 675 std::cout << "\t--RorbitMars: double" << std::endl; 676 std::cout << "\t--RorbitJupiter: double" << std::endl; 677 678 std::cout << "\t--rotateSpeedMercury: double" << std::endl; 679 std::cout << "\t--rotateSpeedVenus: double" << std::endl; 680 std::cout << "\t--rotateSpeedEarthAndMoon: double" << std::endl; 681 std::cout << "\t--rotateSpeedEarth: double" << std::endl; 682 std::cout << "\t--rotateSpeedMoon: double" << std::endl; 683 std::cout << "\t--rotateSpeedMars: double" << std::endl; 684 std::cout << "\t--rotateSpeedJupiter: double" << std::endl; 685 686 std::cout << "\t--tiltEarth: double" << std::endl; 687 688 std::cout << "\t--mapSpace: string" << std::endl; 689 std::cout << "\t--mapSun: string" << std::endl; 690 std::cout << "\t--mapMercury: string" << std::endl; 691 std::cout << "\t--mapVenus: string" << std::endl; 692 std::cout << "\t--mapEarth: string" << std::endl; 693 std::cout << "\t--mapEarthNight: string" << std::endl; 694 std::cout << "\t--mapMoon: string" << std::endl; 695 std::cout << "\t--mapMars: string" << std::endl; 696 std::cout << "\t--mapJupiter: string" << std::endl; 697 698 std::cout << "\t--rotateSpeedFactor: string" << std::endl; 699 std::cout << "\t--RorbitFactor: string" << std::endl; 700 std::cout << "\t--radiusFactor: string" << std::endl; 595 701 596 702 return 1; … … 627 733 sunBillboard->setMode(osg::Billboard::POINT_ROT_EYE); 628 734 sunBillboard->addDrawable( 629 createSquare(osg::Vec3(- 5.0f,0.0f,-5.0f),osg::Vec3(10.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,10.0f),createBillboardImage( osg::Vec4( 1.0, 1.0, 0, 1.0f), 64, 1.0) ),735 createSquare(osg::Vec3(-150.0f,0.0f,-150.0f),osg::Vec3(300.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,300.0f),createBillboardImage( osg::Vec4( 1.0, 1.0, 0, 1.0f), 64, 1.0) ), 630 736 osg::Vec3(0.0f,0.0f,0.0f)); 631 737 632 738 sunLight->addChild( sunBillboard ); 739 633 740 634 741 // stick sun right under root, no transformations for the sun … … 648 755 // create transformations for the earthMoonGroup 649 756 osg::MatrixTransform* aroundSunRotationEarthMoonGroup = solarSystem.createRotation( solarSystem._RorbitEarth, solarSystem._rotateSpeedEarthAndMoon ); 650 osg::MatrixTransform* earthMoonGroupPosition = solarSystem.createTranslationAndTilt( solarSystem._RorbitEarth, solarSystem._tiltEarth ); 757 // osg::MatrixTransform* earthMoonGroupPosition = solarSystem.createTranslationAndTilt( solarSystem._RorbitEarth, solarSystem._tiltEarth ); 758 osg::MatrixTransform* earthMoonGroupPosition = solarSystem.createTranslationAndTilt( solarSystem._RorbitEarth, 0.0 ); 651 759 652 760 … … 654 762 osg::Group* earthMoonGroup = new osg::Group; 655 763 656 657 764 //transformation to rotate the earth around itself 658 765 osg::MatrixTransform* earthAroundItselfRotation = solarSystem.createRotation ( 0.0, solarSystem._rotateSpeedEarth ); … … 660 767 //transformations for the moon 661 768 osg::MatrixTransform* moonAroundEarthRotation = solarSystem.createRotation( solarSystem._RorbitMoon, solarSystem._rotateSpeedMoon ); 662 osg::MatrixTransform* moonTranslation = solarSystem.createTranslationAndTilt( solarSystem._RorbitMoon, 0.0 f);769 osg::MatrixTransform* moonTranslation = solarSystem.createTranslationAndTilt( solarSystem._RorbitMoon, 0.0 ); 663 770 664 771 … … 668 775 669 776 earthAroundItselfRotation->addChild( earth ); 670 671 777 earthMoonGroup->addChild( earthAroundItselfRotation ); 672 778 673 779 earthMoonGroupPosition->addChild( earthMoonGroup ); 674 780
