1 #ifndef __SkyDome_H__ 2 #define __SkyDome_H__ 3 4 #include "SdkSample.h" 5 6 using namespace Ogre; 7 using namespace OgreBites; 8 9 class _OgreSampleClassExport Sample_SkyDome : public SdkSample 10 { 11 public: 12 Sample_SkyDome()13 Sample_SkyDome() 14 { 15 mInfo["Title"] = "Sky Dome"; 16 mInfo["Description"] = "Shows how to use skydomes (fixed-distance domes used for backgrounds)."; 17 mInfo["Thumbnail"] = "thumb_skydome.png"; 18 mInfo["Category"] = "Environment"; 19 } 20 sliderMoved(Slider * slider)21 void sliderMoved(Slider* slider) 22 { 23 // use the values from the sliders to update the skydome properties 24 mSceneMgr->setSkyDome(true, "Examples/CloudySky", mCurvatureSlider->getValue(), mTilingSlider->getValue()); 25 } 26 27 protected: 28 setupContent()29 void setupContent() 30 { 31 // setup some basic lighting for our scene 32 mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3)); 33 mSceneMgr->createLight()->setPosition(20, 80, 50); 34 35 // set our camera to orbit around the origin and show cursor 36 mCameraMan->setStyle(CS_ORBIT); 37 mCameraMan->setYawPitchDist(Degree(0), Degree(0), 250); 38 mTrayMgr->showCursor(); 39 40 // create a floor mesh resource 41 MeshManager::getSingleton().createPlane("floor", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 42 Plane(Vector3::UNIT_Y, -30), 1000, 1000, 10, 10, true, 1, 8, 8, Vector3::UNIT_Z); 43 44 // create a floor entity, give it a material, and place it at the origin 45 Entity* floor = mSceneMgr->createEntity("Floor", "floor"); 46 floor->setMaterialName("Examples/BumpyMetal"); 47 mSceneMgr->getRootSceneNode()->attachObject(floor); 48 49 // create an ogre head entity and place it at the origin 50 mSceneMgr->getRootSceneNode()->attachObject(mSceneMgr->createEntity("Head", "ogrehead.mesh")); 51 52 // create slider bars to control the dome curvature and texture tiling 53 mCurvatureSlider = mTrayMgr->createThickSlider(TL_TOPLEFT, "Curvature", "Dome Curvature", 200, 60, 0, 50, 11); 54 mTilingSlider = mTrayMgr->createThickSlider(TL_TOPLEFT, "Tiling", "Dome Tiling", 200, 60, 1, 20, 191); 55 56 /* Here, we set default values for our sliders. We do not need to setup a skydome here, because when 57 slider values change, the sliderMoved callback is invoked, and we setup the skydome with the appropriate 58 values in there. See its definition above. */ 59 mCurvatureSlider->setValue(10); 60 mTilingSlider->setValue(8); 61 } 62 cleanupContent()63 void cleanupContent() 64 { 65 MeshManager::getSingleton().remove("floor"); 66 } 67 68 Slider* mCurvatureSlider; 69 Slider* mTilingSlider; 70 }; 71 72 #endif 73