Changeset 159 for code/branches/main_reto_vs05/src/orxonox_scene.cc
- Timestamp:
- Nov 3, 2007, 11:06:43 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto_vs05/src/orxonox_scene.cc
r157 r159 26 26 */ 27 27 28 /** 29 * The orxonox scene includes everything running in the background like terrain, 30 * static figures, dangling lamp, etc. 31 */ 32 33 28 34 #include "orxonox_scene.h" 29 35 30 36 31 OrxonoxScene::OrxonoxScene(SceneManager *mSceneMgr) : mSceneMgr(mSceneMgr) 37 /** 38 * Empty Consructor except the initialiser list. 39 * @param sceneMgr The Scene Manager. 40 */ 41 OrxonoxScene::OrxonoxScene(SceneManager *sceneMgr) : sceneMgr_(sceneMgr) 32 42 { 33 43 } 34 44 35 45 /** 46 * Empty Destructor. 47 */ 36 48 OrxonoxScene::~OrxonoxScene() 37 49 { 38 50 } 39 51 40 52 /** 53 * Ogre initialisation method. 54 * This function is called by the Run Manager to load the neccessary recources 55 * and to create the scene. 56 * @return False if failed. 57 */ 41 58 bool OrxonoxScene::initialise() 42 59 { … … 44 61 loadResources(); 45 62 46 distance = 0;47 radius = 100;63 distance_ = 0; 64 radius_ = 100; 48 65 49 66 createScene(); … … 53 70 54 71 55 // method where you can perform resource group loading 56 // Must at least do 57 // ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 58 void OrxonoxScene::loadResources(void) 72 /** 73 * Resource loader. 74 * Currently, this method loads everything! TODO: If done this ugly, it should 75 * at least be in the Run Manager. 76 */ 77 void OrxonoxScene::loadResources() 59 78 { 60 79 // Initialise, parse scripts etc … … 63 82 64 83 65 // Currently just a test scene with an ogre head an a surrounding light 66 void OrxonoxScene::createScene(void) 84 /** 85 * Scene creation. 86 * Currently just a test scene with an ogre head an a surrounding light. 87 */ 88 void OrxonoxScene::createScene() 67 89 { 68 mSceneMgr->setAmbientLight(ColourValue(0.3,0.3,0.3));90 sceneMgr_->setAmbientLight(ColourValue(0.3,0.3,0.3)); 69 91 70 92 //create first entity 71 Entity *head = mSceneMgr->createEntity("head", "ogrehead.mesh");93 Entity *head = sceneMgr_->createEntity("head", "ogrehead.mesh"); 72 94 73 95 //create a scene node to attach the head to 74 SceneNode *node = mSceneMgr->getRootSceneNode()96 SceneNode *node = sceneMgr_->getRootSceneNode() 75 97 ->createChildSceneNode("OgreHeadNode", Vector3(0,0,0)); 76 98 //attach the ogre head … … 78 100 79 101 // set up skybox 80 mSceneMgr->setSkyBox(true, "Examples/SceneSkyBox2");102 sceneMgr_->setSkyBox(true, "Examples/SceneSkyBox2"); 81 103 82 // set up one mLightsource83 mLight = mSceneMgr->createLight("Light1");84 mLight->setType(Light::LT_POINT);85 mLight->setPosition(Vector3(0, 0, 0));86 mLight->setDiffuseColour(1.0, 1.0, 1.0);87 mLight->setSpecularColour(1.0, 1.0, 1.0);104 // set up one light_ source 105 light_ = sceneMgr_->createLight("Light1"); 106 light_->setType(Light::LT_POINT); 107 light_->setPosition(Vector3(0, 0, 0)); 108 light_->setDiffuseColour(1.0, 1.0, 1.0); 109 light_->setSpecularColour(1.0, 1.0, 1.0); 88 110 89 111 //create billboard 90 bbs = mSceneMgr->createBillboardSet("bb", 1);91 bbs ->createBillboard(Vector3::ZERO, ColourValue(1.0, 1.0, 1.0));92 bbs ->setMaterialName("Examples/Flare");112 bbs_ = sceneMgr_->createBillboardSet("bb", 1); 113 bbs_->createBillboard(Vector3::ZERO, ColourValue(1.0, 1.0, 1.0)); 114 bbs_->setMaterialName("Examples/Flare"); 93 115 94 lightNode = mSceneMgr->getRootSceneNode()95 ->createChildSceneNode(" LightNode", Vector3(0, 100, 0));116 lightNode_ = sceneMgr_->getRootSceneNode() 117 ->createChildSceneNode("lightNode_", Vector3(0, 100, 0)); 96 118 97 lightNode ->attachObject(bbs);98 lightNode ->attachObject(mLight);119 lightNode_->attachObject(bbs_); 120 lightNode_->attachObject(light_); 99 121 } 100 122 101 123 102 // compute something between frames if neccessary 103 void OrxonoxScene::tick(unsigned long time, float deltaTime) 124 /** 125 * Compute something between frames if neccessary. 126 * @param time Absolute time. 127 * @param deltaTime Relative time. 128 * @return Return true to continue rendering. 129 */ 130 bool OrxonoxScene::tick(unsigned long time, Real deltaTime) 104 131 { 105 floatt = time/1000.0;132 Real t = time/1000.0; 106 133 107 lightNode ->setPosition(radius*sin(5*t), radius*cos(5*t), sin(1*t)*distance);134 lightNode_->setPosition(radius_*sin(5*t), radius_*cos(5*t), sin(1*t)*distance_); 108 135 109 mLight->setDiffuseColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));110 mLight->setSpecularColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));136 light_->setDiffuseColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2)); 137 light_->setSpecularColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2)); 111 138 112 bbs ->getBillboard(0)->setColour(ColourValue(sin(1*t),139 bbs_->getBillboard(0)->setColour(ColourValue(sin(1*t), 113 140 sin(1*t + 2.09), sin(1*t + 2.09*2))); 141 142 return true; 114 143 }
Note: See TracChangeset
for help on using the changeset viewer.