Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2007, 5:00:41 PM (17 years ago)
Author:
rgrieder
Message:
  • added namespace Orxonox to every file
    • removed all the "using namespace Ogre" in the header files
  • cleaned up with the includes: attempt to include as little as possible to reduce compile time.
    • created a header file: orxonox_prerequisites.h
    • used OgrePrerequisites in the header files
    • avoided including "Ogre.h", using separate files instead
  • created empty class: AmmunitionDump
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto_vs05/src/orxonox_scene.cc

    r159 r161  
    2626 */
    2727
    28 /**
    29 * The orxonox scene includes everything running in the background like terrain,
    30 * static figures, dangling lamp, etc.
    31 */
    32 
     28#include "OgreSceneManager.h"
     29#include "OgreSceneNode.h"
     30#include "OgreEntity.h"
     31#include "OgreLight.h"
     32#include "OgreBillboard.h"
     33#include "OgreBillboardSet.h"
     34#include "OgreVector3.h"
    3335
    3436#include "orxonox_scene.h"
    3537
     38namespace Orxonox {
     39  using namespace Ogre;
    3640
    37 /**
    38 * Empty Consructor except the initialiser list.
    39 * @param sceneMgr The Scene Manager.
    40 */
    41 OrxonoxScene::OrxonoxScene(SceneManager *sceneMgr) : sceneMgr_(sceneMgr)
    42 {
    43 }
    44 
    45 /**
    46 * Empty Destructor.
    47 */
    48 OrxonoxScene::~OrxonoxScene()
    49 {
    50 }
    51 
    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 */
    58 bool OrxonoxScene::initialise()
    59 {
    60         // Load resources
    61         loadResources();
    62 
    63         distance_ = 0;
    64         radius_ = 100;
    65 
    66         createScene();
    67 
    68         return true;
    69 }
     41  /**
     42  * The orxonox scene includes everything running in the background like terrain,
     43  * static figures, dangling lamp, etc.
     44  */
    7045
    7146
    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()
    78 {
    79         // Initialise, parse scripts etc
    80         ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    81 }
     47  /**
     48  * Empty Consructor except the initialiser list.
     49  * @param sceneMgr The Scene Manager.
     50  */
     51  OrxonoxScene::OrxonoxScene(SceneManager *sceneMgr) : sceneMgr_(sceneMgr)
     52  {
     53  }
     54
     55  /**
     56  * Empty Destructor.
     57  */
     58  OrxonoxScene::~OrxonoxScene()
     59  {
     60  }
     61
     62  /**
     63  * Ogre initialisation method.
     64  * This function is called by the Run Manager to load the neccessary recources
     65  * and to create the scene.
     66  * @return False if failed.
     67  */
     68  bool OrxonoxScene::initialise()
     69  {
     70          // Load resources
     71          loadResources();
     72
     73          distance_ = 0;
     74          radius_ = 100;
     75
     76          createScene();
     77
     78          return true;
     79  }
    8280
    8381
    84 /**
    85 * Scene creation.
    86 * Currently just a test scene with an ogre head an a surrounding light.
    87 */
    88 void OrxonoxScene::createScene()
    89 {
    90         sceneMgr_->setAmbientLight(ColourValue(0.3,0.3,0.3));
    91 
    92         //create first entity
    93         Entity *head = sceneMgr_->createEntity("head", "ogrehead.mesh");
    94 
    95         //create a scene node to attach the head to
    96         SceneNode *node = sceneMgr_->getRootSceneNode()
    97         ->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
    98         //attach the ogre head
    99         node->attachObject(head);
    100 
    101         // set up skybox
    102         sceneMgr_->setSkyBox(true, "Examples/SceneSkyBox2");
    103 
    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);
    110 
    111         //create billboard
    112         bbs_ = sceneMgr_->createBillboardSet("bb", 1);
    113         bbs_->createBillboard(Vector3::ZERO, ColourValue(1.0, 1.0, 1.0));
    114         bbs_->setMaterialName("Examples/Flare");
    115 
    116         lightNode_ = sceneMgr_->getRootSceneNode()
    117         ->createChildSceneNode("lightNode_", Vector3(0, 100, 0));
    118 
    119         lightNode_->attachObject(bbs_);
    120         lightNode_->attachObject(light_);
    121 }
     82  /**
     83  * Resource loader.
     84  * Currently, this method loads everything! TODO: If done this ugly, it should
     85  * at least be in the Run Manager.
     86  */
     87  void OrxonoxScene::loadResources()
     88  {
     89          // Initialise, parse scripts etc
     90          ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     91  }
    12292
    12393
    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)
    131 {
    132         Real t = time/1000.0;
     94  /**
     95  * Scene creation.
     96  * Currently just a test scene with an ogre head an a surrounding light.
     97  */
     98  void OrxonoxScene::createScene()
     99  {
     100          sceneMgr_->setAmbientLight(ColourValue(0.3,0.3,0.3));
    133101
    134         lightNode_->setPosition(radius_*sin(5*t), radius_*cos(5*t), sin(1*t)*distance_);
    135        
    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));
     102          //create first entity
     103          Entity *head = sceneMgr_->createEntity("head", "ogrehead.mesh");
    138104
    139         bbs_->getBillboard(0)->setColour(ColourValue(sin(1*t),
    140         sin(1*t + 2.09), sin(1*t + 2.09*2)));
    141  
    142   return true;
     105          //create a scene node to attach the head to
     106          SceneNode *node = sceneMgr_->getRootSceneNode()
     107          ->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
     108          //attach the ogre head
     109          node->attachObject(head);
     110
     111          // set up skybox
     112          sceneMgr_->setSkyBox(true, "Examples/SceneSkyBox2");
     113
     114          // set up one light_ source
     115          light_ = sceneMgr_->createLight("Light1");
     116          light_->setType(Light::LT_POINT);
     117          light_->setPosition(Vector3(0, 0, 0));
     118          light_->setDiffuseColour(1.0, 1.0, 1.0);
     119          light_->setSpecularColour(1.0, 1.0, 1.0);
     120
     121          //create billboard
     122          bbs_ = sceneMgr_->createBillboardSet("bb", 1);
     123          bbs_->createBillboard(Vector3::ZERO, ColourValue(1.0, 1.0, 1.0));
     124          bbs_->setMaterialName("Examples/Flare");
     125
     126          lightNode_ = sceneMgr_->getRootSceneNode()
     127          ->createChildSceneNode("lightNode_", Vector3(0, 100, 0));
     128
     129          lightNode_->attachObject(bbs_);
     130          lightNode_->attachObject(light_);
     131  }
     132
     133
     134  /**
     135  * Compute something between frames if neccessary.
     136  * @param time Absolute time.
     137  * @param deltaTime Relative time.
     138  * @return Return true to continue rendering.
     139  */
     140  bool OrxonoxScene::tick(unsigned long time, Real deltaTime)
     141  {
     142          Real t = time/1000.0;
     143
     144          lightNode_->setPosition(radius_*sin(5*t), radius_*cos(5*t), sin(1*t)*distance_);
     145       
     146          light_->setDiffuseColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));
     147          light_->setSpecularColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));
     148
     149          bbs_->getBillboard(0)->setColour(ColourValue(sin(1*t),
     150          sin(1*t + 2.09), sin(1*t + 2.09*2)));
     151   
     152    return true;
     153  }
     154
    143155}
Note: See TracChangeset for help on using the changeset viewer.