Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 462 for code/branches/FICN


Ignore:
Timestamp:
Dec 12, 2007, 12:42:30 PM (17 years ago)
Author:
bknecht
Message:

got my work to compile (it's all hacked together and I dunno if it runs)

  • orxonox.h we got now a real .h file for our main class
  • orxonox.cc this is the all hacked class. We/I have to strip that clean
  • orxonoxOld.cc "You did something wrong, the old implementation was SOO much better"
  • graphicsEngine we should have a wrapper around ogre so we have a real graphics module
  • main.cc created a main again doing all the platform depending stuff in there.. (hope this works)

think that's all…

Location:
code/branches/FICN
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/CMakeLists.txt

    r402 r462  
    4242    SET(Boost_INCLUDE_DIR "/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/include/boost-1_34_1")
    4343  ENDIF(IS_TARDIS)
     44  SET(Boost_INCLUDE_DIR "/usr/include/boost")
    4445
    4546ENDIF (UNIX)
  • code/branches/FICN/src/orxonox/CMakeLists.txt

    r389 r462  
    1414  spaceship_steering.cc
    1515  inertial_node.cc
     16  main.cc
     17  graphicsEngine.cc
    1618)
    1719
     
    2022SET_TARGET_PROPERTIES(../../bin/main PROPERTIES LINK_FLAGS "--no-undefined" )
    2123
    22 TARGET_LINK_LIBRARIES( ../../bin/main 
     24TARGET_LINK_LIBRARIES( ../../bin/main
    2325  ${OGRE_LIBRARIES}
    2426  ${OIS_LIBRARIES}
  • code/branches/FICN/src/orxonox/orxonox.cc

    r459 r462  
    55 *   License notice:
    66 *
    7  *   This program is free software: you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation, either version 3 of the License, or
    10  *   (at your option) any later version.
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
    1111 *
    1212 *   This program is distributed in the hope that it will be useful,
     
    1616 *
    1717 *   You should have received a copy of the GNU General Public License
    18  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2020 *
    2121 *   Author:
     
    2828/**
    2929 @file  orxonox.cc
    30  @brief Orxonox Main File
     30 @brief Orxonox Main Class
    3131 */
     32
     33#include "orxonox.h"
     34#include "graphicsEngine.h"
    3235
    3336//#include <Ogre.h>
     
    4952#include <iostream>
    5053
    51 #include "xml/xmlParser.h"
    52 #include "loader/LevelLoader.h"
    53 #include "audio/AudioManager.h"
     54#include "../xml/xmlParser.h"
     55#include "../loader/LevelLoader.h"
     56#include "../audio/AudioManager.h"
    5457
    5558#include "spaceship_steering.h"
    5659SpaceshipSteering* steering;
    5760
    58 audio::AudioManager* auMan;
    5961
    6062//network stuff
    61 //#include "network/Server.h"
    62 //#include "network/Client.h"
    63 #include "network/NetworkFrameListener.h"
     63#include "../network/Server.h"
     64#include "../network/Client.h"
     65//#include "../network/NetworkFrameListener.h"
    6466
    6567// some tests to see if enet works without includsion
     
    6769//#include <enet/protocol.h>
    6870
    69 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    70 #include <CoreFoundation/CoreFoundation.h>
    71 
    72 // This function will locate the path to our application on OS X,
    73 // unlike windows you can not rely on the curent working directory
    74 // for locating your configuration files and resources.
    75 std::string macBundlePath()
    76 {
    77   char path[1024];
    78   CFBundleRef mainBundle = CFBundleGetMainBundle();
    79   assert(mainBundle);
    80 
    81   CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
    82   assert(mainBundleURL);
    83 
    84   CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
    85   assert(cfStringRef);
    86 
    87   CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
    88 
    89   CFRelease(mainBundleURL);
    90   CFRelease(cfStringRef);
    91 
    92   return std::string(path);
    93 }
    94 #endif
    9571
    9672namespace orxonox
    9773{
    98 
    99 using namespace Ogre;
    100 
    101 class OrxExitListener : public FrameListener, public OIS::MouseListener
    102 {
    103   public:
    104     OrxExitListener(OIS::Keyboard *keyboard, OIS::Mouse *mouse)
    105   : mKeyboard(keyboard), mMouse(mouse)
    106     {
    107       speed = 250;
    108       loop = 100;
    109       rotate = 10;
    110       mouseX = 0;
    111       mouseY = 0;
    112       maxMouseX = 0;
    113       minMouseX = 0;
    114       moved = false;
    115       steering->brakeRotate(rotate*10);
    116       steering->brakeLoop(loop);
    117       mMouse->setEventCallback(this);
    118     }
    119     bool frameStarted(const FrameEvent& evt)
    120     {
    121 
    122         auMan->update();
    123 
    124       mKeyboard->capture();
    125       mMouse->capture();
    126       if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    127         steering->moveForward(speed);
    128       else
    129         steering->moveForward(0);
    130       if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    131         steering->brakeForward(speed);
    132       else
    133         steering->brakeForward(speed/10);
    134       if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    135         steering->loopRight(loop);
    136       else
    137         steering->loopRight(0);
    138       if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    139         steering->loopLeft(loop);
    140       else
    141         steering->loopLeft(0);
    142 
    143       if(moved) {
    144         if (mouseY<0)
    145           steering->rotateUp(-mouseY*rotate);
    146         if (mouseY>0)
    147           steering->rotateDown(mouseY*rotate);
    148         if (mouseX>0)
    149           steering->rotateRight(mouseX*rotate);
    150         if (mouseX<0)
    151           steering->rotateLeft(-mouseX*rotate);
     74  using namespace Ogre;
     75
     76   // put this in seperate Class or solve the problem in another fashion
     77  class OrxListener : public FrameListener, public OIS::MouseListener
     78  {
     79    public:
     80      OrxListener(OIS::Keyboard *keyboard, OIS::Mouse *mouse, audio::AudioManager*  auMan)
     81      : mKeyboard(keyboard), mMouse(mouse)
     82      {
     83        speed = 250;
     84        loop = 100;
     85        rotate = 10;
     86        mouseX = 0;
     87        mouseY = 0;
     88        maxMouseX = 0;
     89        minMouseX = 0;
    15290        moved = false;
     91        steering->brakeRotate(rotate*10);
     92        steering->brakeLoop(loop);
     93        mMouse->setEventCallback(this);
     94        auMan_ = auMan;
    15395      }
    154       else {
    155         steering->rotateUp(0);
    156         steering->rotateDown(0);
    157         steering->rotateRight(0);
    158         steering->rotateLeft(0);
     96      bool frameStarted(const FrameEvent& evt)
     97      {
     98
     99        auMan_->update();
     100
     101        mKeyboard->capture();
     102        mMouse->capture();
     103        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
     104          steering->moveForward(speed);
     105        else
     106          steering->moveForward(0);
     107        if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
     108          steering->brakeForward(speed);
     109        else
     110          steering->brakeForward(speed/10);
     111        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
     112          steering->loopRight(loop);
     113        else
     114          steering->loopRight(0);
     115        if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
     116          steering->loopLeft(loop);
     117        else
     118          steering->loopLeft(0);
     119
     120        if(moved) {
     121          if (mouseY<0)
     122            steering->rotateUp(-mouseY*rotate);
     123          if (mouseY>0)
     124            steering->rotateDown(mouseY*rotate);
     125          if (mouseX>0)
     126            steering->rotateRight(mouseX*rotate);
     127          if (mouseX<0)
     128            steering->rotateLeft(-mouseX*rotate);
     129          moved = false;
     130        }
     131        else {
     132          steering->rotateUp(0);
     133          steering->rotateDown(0);
     134          steering->rotateRight(0);
     135          steering->rotateLeft(0);
     136        }
     137
     138        steering->tick(evt.timeSinceLastFrame);
     139//      scenemanager->spacehip->tick(evt.timesincelastframe);
     140        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
     141          cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl;
     142        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
    159143      }
    160144
    161       steering->tick(evt.timeSinceLastFrame);
    162 //      scenemanager->spacehip->tick(evt.timesincelastframe);
    163       if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
    164         cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl;
    165       return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
    166     }
    167 
    168     bool mouseMoved(const OIS::MouseEvent &e)
    169     {
    170       mouseX = e.state.X.rel;
    171       mouseY = e.state.Y.rel;
    172       if(mouseX>maxMouseX) maxMouseX = mouseX;
    173       if(mouseX<minMouseX) minMouseX = mouseX;
    174       cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
    175       moved = true;
    176       return true;
    177     }
    178 
    179     bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
    180     bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
    181 
    182   private:
    183     float speed;
    184     float rotate;
    185     float loop;
    186     float mouseY;
    187     float mouseX;
    188     float maxMouseX;
    189     float minMouseX;
    190     bool moved;
    191     OIS::Keyboard *mKeyboard;
    192     OIS::Mouse *mMouse;
    193 };
    194 
    195 
    196   class OrxApplication
    197   {
    198     public:
    199       void go()
     145      bool mouseMoved(const OIS::MouseEvent &e)
    200146      {
    201         if(function==0)
    202           standalone();
    203         else if(function==1)
    204           server();
    205         else
    206           client();
     147        mouseX = e.state.X.rel;
     148        mouseY = e.state.Y.rel;
     149        if(mouseX>maxMouseX) maxMouseX = mouseX;
     150        if(mouseX<minMouseX) minMouseX = mouseX;
     151        cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
     152        moved = true;
     153        return true;
    207154      }
    208      
    209       OrxApplication(int func){
    210         function = func;
    211       }
    212       OrxApplication(){
    213         function = 0;
    214       }
    215 
    216       ~OrxApplication()
    217       {
    218         mInputManager->destroyInputObject(mKeyboard);
    219         OIS::InputManager::destroyInputSystem(mInputManager);
    220 
    221 //        delete mRenderer;
    222 //        delete mSystem;
    223 
    224 //         delete mListener;
    225 //         delete mRoot;
    226       }
     155
     156      bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
     157      bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
    227158
    228159    private:
    229       Ogre::Root *mRoot;
     160      float speed;
     161      float rotate;
     162      float loop;
     163      float mouseY;
     164      float mouseX;
     165      float maxMouseX;
     166      float minMouseX;
     167      bool moved;
    230168      OIS::Keyboard *mKeyboard;
    231169      OIS::Mouse *mMouse;
    232       OIS::InputManager *mInputManager;
    233       //CEGUI::OgreCEGUIRenderer *mRenderer;
    234       //CEGUI::System *mSystem;
    235       OrxExitListener *mListener;
    236       int function; // 0 for standalone, 1 for server, 2 for client
    237 
    238       void client()
    239       {
    240        client_g = new network::Client(); // address here
    241         mRoot->addFrameListener(new network::ClientFrameListener());
    242         createRoot();
    243         defineResources();
    244         setupRenderSystem();
    245         createRenderWindow();
    246         initializeResourceGroups();
    247         createScene();
    248         setupScene();
    249         setupInputSystem();
    250 //        setupCEGUI();
    251         createFrameListener();
    252         startRenderLoop();
    253       }
    254       void server()
    255       {
    256         server_g = new network::Server(); // add some settings if wanted
    257         mRoot->addFrameListener(new network::ServerFrameListener());
    258         createRoot();
    259         defineResources();
    260         setupRenderSystem();
    261         createRenderWindow();
    262         initializeResourceGroups();
    263         createScene();
    264         setupScene();
    265         //setupInputSystem();
    266         //setupCEGUI();
    267         //createFrameListener();
    268         //startRenderLoop();
    269       }
    270       void standalone()
    271       {
    272         createRoot();
    273         defineResources();
    274         setupRenderSystem();
    275         createRenderWindow();
    276         initializeResourceGroups();
    277         createScene();
    278         setupScene();
    279         setupInputSystem();
    280         setupCEGUI();
    281         createFrameListener();
    282         startRenderLoop();
    283       }
    284      
    285       void createRoot()
    286       {
    287 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    288         mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg");
    289 #else
    290         mRoot = new Ogre::Root();
    291 #endif
    292       }
    293 
    294       void defineResources()
    295       {
    296         Ogre::String secName, typeName, archName;
    297         Ogre::ConfigFile cf;
    298 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    299         cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
    300 #else
    301         cf.load("resources.cfg");
    302 #endif
    303 
    304         Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    305         while (seci.hasMoreElements())
    306         {
    307           secName = seci.peekNextKey();
    308           Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
    309           Ogre::ConfigFile::SettingsMultiMap::iterator i;
    310           for (i = settings->begin(); i != settings->end(); ++i)
    311           {
    312             typeName = i->first;
    313             archName = i->second;
    314 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    315             Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName);
    316 #else
    317             Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);
    318 #endif
    319           }
    320         }
    321       }
    322 
    323       void setupRenderSystem()
    324       {
    325         if (!mRoot->restoreConfig() && !mRoot->showConfigDialog())
    326           throw Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()");
    327       }
    328 
    329       void createRenderWindow()
    330       {
    331         mRoot->initialise(true, "OrxonoxV2");
    332       }
    333 
    334       void initializeResourceGroups()
    335       {
    336         TextureManager::getSingleton().setDefaultNumMipmaps(5);
    337         ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    338       }
    339 
    340       void createScene(void)
    341       {
    342                                 auMan = new audio::AudioManager();
    343 
    344                                 auMan->ambientAdd("a1");
    345                                 auMan->ambientAdd("a2");
    346                                 auMan->ambientAdd("a3");
    347                                 //auMan->ambientAdd("ambient1");
    348                                 auMan->ambientStart();
    349 
    350       string levelFile = "sp_level_moonstation.oxw";
     170      audio::AudioManager*  auMan_;
     171  };
     172  // init static singleton reference of Orxonox
     173  Orxonox* Orxonox::singletonRef_ = NULL;
     174
     175  /**
     176   * create a new instance of Orxonox
     177   */
     178  Orxonox::Orxonox()
     179  {
     180    ogre_ = new GraphicsEngine();
     181  }
     182
     183  /**
     184   * destruct Orxonox
     185   */
     186  Orxonox::~Orxonox()
     187  {
     188    // nothing to delete as for now
     189  }
     190
     191  /**
     192   * initialization of Orxonox object
     193   * @param argc argument counter
     194   * @param argv list of arguments
     195   * @param path path to config (in home dir or something)
     196   */
     197  void Orxonox::init(int argc, char **argv, std::string path)
     198  {
     199    //TODO: initialization with command line parameters
     200    //TODO: find config file (assuming executable directory)
     201    //TODO: read config file
     202    //TODO: give config file to Ogre
     203    if(argc >=2 && strcmp(argv[1], "server")==0)
     204    {
     205      serverInit(path);
     206    }
     207    else if(argc >=2 && strcmp(argv[1], "client")==0)
     208    {
     209      clientInit(path);
     210    }
     211    standalone(path);
     212  }
     213
     214  /**
     215   * start modules
     216   */
     217  void Orxonox::start()
     218  {
     219    //TODO: start modules
     220    ogre_->startRender();
     221    auMan_ = new audio::AudioManager();
     222    // load this file from config
     223    string levelFile = "sp_level_moonstation.oxw";
     224    loader_ = new loader::LevelLoader(levelFile);
     225    //TODO: run engine
     226  }
     227
     228  /**
     229   * @return singleton object
     230   */
     231  Orxonox* Orxonox::getSingleton()
     232  {
     233    if (!singletonRef_)
     234      singletonRef_ = new Orxonox();
     235    return singletonRef_;
     236  }
     237
     238  /**
     239   * error kills orxonox
     240   */
     241  void Orxonox::die(/* some error code */)
     242  {
     243    //TODO: destroy and destruct everything and print nice error msg
     244  }
     245
     246  void Orxonox::standalone(std::string path)
     247  {
     248    ogre_->setConfigPath(path);
     249    ogre_->setup();
     250    if(!ogre_->load()) die(/* unable to load */);
     251  }
     252
     253  void Orxonox::serverInit(std::string path)
     254  {
     255    ogre_->setConfigPath(path);
     256    ogre_->setup();
     257    //server_g = new network::Server(); // add some settings if wanted
     258    if(!ogre_->load()) die(/* unable to load */);
     259    //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener());
     260    ogre_->startRender();
     261
     262    createScene();
     263    setupScene();
     264  }
     265
     266  void Orxonox::clientInit(std::string path)
     267  {
     268    ogre_->setConfigPath(path);
     269    ogre_->setup();
     270    //client_g = new network::Client(); // address here
     271    if(!ogre_->load()) die(/* unable to load */);
     272    //ogre_->getRoot()->addFrameListener(new network::ClientFrameListener());
     273    ogre_->startRender();
     274
     275    createScene();
     276    setupScene();
     277    setupInputSystem();
     278    createFrameListener();
     279    startRenderLoop();
     280  }
     281
     282  void Orxonox::createScene(void)
     283  {
     284    auMan_ = new audio::AudioManager();
     285
     286    auMan_->ambientAdd("a1");
     287    auMan_->ambientAdd("a2");
     288    auMan_->ambientAdd("a3");
     289                                //auMan->ambientAdd("ambient1");
     290    auMan_->ambientStart();
     291
     292    string levelFile = "sp_level_moonstation.oxw";
    351293//       loader::LevelLoader* loader = new loader::LevelLoader(levelFile);
     294  }
     295
     296
     297  void Orxonox::setupScene()
     298  {
     299    SceneManager *mgr = ogre_->getSceneManager();
     300    Camera *cam = mgr->createCamera("Camera");
     301    cam->setPosition(Vector3(0,0,-250));
     302    cam->lookAt(Vector3(0,0,0));
     303    Viewport *vp = ogre_->getRoot()->getAutoCreatedWindow()->addViewport(cam);
     304
     305
     306    mgr->setAmbientLight(ColourValue(1,1,1));
     307    Entity* head = mgr->createEntity("head", "razor.mesh");
     308    SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
     309    node->attachObject(head);
     310    node->attachObject(cam);
     311    mgr->setSkyBox(true, "Examples/SceneSkyBox2");
     312
     313    Entity* head1 = mgr->createEntity("head1", "ogrehead.mesh");
     314    SceneNode *node1 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode1", Vector3(200,0,0));
     315    node1->attachObject(head1);
     316    Entity* head2 = mgr->createEntity("head2", "ogrehead.mesh");
     317    SceneNode *node2 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode2", Vector3(200,400,-100));
     318    node2->attachObject(head2);
     319    Entity* head3 = mgr->createEntity("head3", "ogrehead.mesh");
     320    SceneNode *node3 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode3", Vector3(0,400,200));
     321    node3->attachObject(head3);
     322    Entity* head4 = mgr->createEntity("head4", "ogrehead.mesh");
     323    SceneNode *node4 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode4", Vector3(-400,-200,600));
     324    node4->attachObject(head4);
     325    Entity* head5 = mgr->createEntity("head5", "ogrehead.mesh");
     326    SceneNode *node5 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode5", Vector3(0,0,-400));
     327    node5->attachObject(head5);
     328
     329    steering = new SpaceshipSteering(500, 200, 200, 200);
     330    steering->addNode(node);
     331
     332  }
     333
     334
     335  void Orxonox::setupInputSystem()
     336  {
     337    size_t windowHnd = 0;
     338    std::ostringstream windowHndStr;
     339    OIS::ParamList pl;
     340    Ogre::RenderWindow *win = ogre_->getRoot()->getAutoCreatedWindow();
     341
     342    win->getCustomAttribute("WINDOW", &windowHnd);
     343    windowHndStr << windowHnd;
     344    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     345    inputManager_ = OIS::InputManager::createInputSystem(pl);
     346
     347    try
     348    {
     349      keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false));
     350      mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true));
    352351    }
    353 
    354 
    355     void setupScene()
     352    catch (const OIS::Exception &e)
    356353    {
    357       SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");
    358       Camera *cam = mgr->createCamera("Camera");
    359       cam->setPosition(Vector3(0,0,-250));
    360       cam->lookAt(Vector3(0,0,0));
    361       Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);
    362 
    363 
    364       mgr->setAmbientLight(ColourValue(1,1,1));
    365       Entity* head = mgr->createEntity("head", "razor.mesh");
    366       SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
    367       node->attachObject(head);
    368       node->attachObject(cam);
    369       mgr->setSkyBox(true, "Examples/SceneSkyBox2");
    370 
    371       Entity* head1 = mgr->createEntity("head1", "ogrehead.mesh");
    372       SceneNode *node1 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode1", Vector3(200,0,0));
    373       node1->attachObject(head1);
    374       Entity* head2 = mgr->createEntity("head2", "ogrehead.mesh");
    375       SceneNode *node2 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode2", Vector3(200,400,-100));
    376       node2->attachObject(head2);
    377       Entity* head3 = mgr->createEntity("head3", "ogrehead.mesh");
    378       SceneNode *node3 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode3", Vector3(0,400,200));
    379       node3->attachObject(head3);
    380       Entity* head4 = mgr->createEntity("head4", "ogrehead.mesh");
    381       SceneNode *node4 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode4", Vector3(-400,-200,600));
    382       node4->attachObject(head4);
    383       Entity* head5 = mgr->createEntity("head5", "ogrehead.mesh");
    384       SceneNode *node5 = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode5", Vector3(0,0,-400));
    385       node5->attachObject(head5);
    386 
    387       steering = new SpaceshipSteering(500, 200, 200, 200);
    388       steering->addNode(node);
    389 
     354      throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");
    390355    }
    391 
    392 
    393       void setupInputSystem()
    394       {
    395         size_t windowHnd = 0;
    396         std::ostringstream windowHndStr;
    397         OIS::ParamList pl;
    398         Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow();
    399 
    400         win->getCustomAttribute("WINDOW", &windowHnd);
    401         windowHndStr << windowHnd;
    402         pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    403         mInputManager = OIS::InputManager::createInputSystem(pl);
    404 
    405         try
    406         {
    407           mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));
    408           mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
    409         }
    410         catch (const OIS::Exception &e)
    411         {
    412           throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");
    413         }
    414       }
    415 
    416 //       void setupCEGUI()
    417 //       {
    418 //         Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager");
    419 //         Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow();
    420 
    421         // CEGUI setup
    422 //        mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr);
    423 //        mSystem = new CEGUI::System(mRenderer);
    424 
    425         // Other CEGUI setup here.
    426 //       }
    427 
    428 
    429     void createFrameListener()
    430     {
    431       mListener = new OrxExitListener(mKeyboard, mMouse);
    432       mRoot->addFrameListener(mListener);
    433     }
    434     void startRenderLoop()
    435     {
    436       mRoot->startRendering();
    437     }
    438   };
     356  }
     357
     358  // we actually want to do this differently...
     359  void Orxonox::createFrameListener()
     360  {
     361    frameListener_ = new OrxListener(keyboard_, mouse_, auMan_);
     362    ogre_->getRoot()->addFrameListener(frameListener_);
     363  }
     364
     365  void Orxonox::startRenderLoop()
     366  {
     367    ogre_->getRoot()->startRendering();
     368  }
    439369}
    440370
    441 using namespace Ogre;
    442 
    443 #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    444 #define WIN32_LEAN_AND_MEAN
    445 #include "windows.h"
    446 
    447              INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
    448 #else
    449              int main(int argc, char **argv)
    450 #endif
    451 {
    452   try
    453   {
    454     if(argc >=2 && strcmp(argv[1], "server")==0){
    455       orxonox::OrxApplication orxonox(1);
    456       orxonox.go();
    457     }
    458     else if(argc >=2 && strcmp(argv[1], "client")==0){
    459       orxonox::OrxApplication orxonox(2);
    460       orxonox.go();
    461     }
    462     else{
    463       orxonox::OrxApplication orxonox(0);
    464       orxonox.go();
    465     }
    466   }
    467   catch(Exception& e)
    468   {
    469 #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    470     MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
    471 #else
    472     fprintf(stderr, "An exception has occurred: %s\n",
    473             e.getFullDescription().c_str());
    474 #endif
    475   }
    476 
    477   return 0;
    478 }
    479 
     371
Note: See TracChangeset for help on using the changeset viewer.