Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 608 for code/branches/FICN/src


Ignore:
Timestamp:
Dec 18, 2007, 2:23:12 AM (17 years ago)
Author:
landauf
Message:

added SpaceShip class

Location:
code/branches/FICN/src/orxonox
Files:
2 added
5 edited

Legend:

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

    r594 r608  
    2828    objects/Entity.cc
    2929    objects/Camera.cc
    30     objects/SpaceshipSteeringObject.cc
     30#    objects/SpaceshipSteeringObject.cc
    3131    objects/Model.cc
    3232    objects/Mesh.cc
    3333    objects/BaseEntity.cc
     34    objects/SpaceShip.cc
     35    objects/NPC.cc
    3436  )
    3537ELSE(WIN32)
  • code/branches/FICN/src/orxonox/objects/CMakeLists.txt

    r602 r608  
    1313  Entity.cc
    1414  Camera.cc
    15   SpaceshipSteeringObject.cc
     15#  SpaceshipSteeringObject.cc
    1616  Model.cc
    1717  Mesh.cc
     18  SpaceShip.cc
    1819  NPC.cc
    1920)
  • code/branches/FICN/src/orxonox/objects/Camera.cc

    r560 r608  
    5959                std::string node = xmlElem->Attribute("node");
    6060
    61                     Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->getChild(node);
     61                    Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
    6262                    sceneNode->attachObject((Ogre::MovableObject*)cam);
    6363
  • code/branches/FICN/src/orxonox/orxonox.cc

    r605 r608  
    6161#include "../audio/AudioManager.h"
    6262
    63 #include "spaceship_steering.h"
    64 
    65 #include "particle/ParticleInterface.h"
    66 
    6763#include "hud/HUD.h"
    6864
     
    8480
    8581   // put this in seperate Class or solve the problem in another fashion
    86   class OrxListener : public FrameListener, public OIS::MouseListener
     82  class OrxListener : public FrameListener
    8783  {
    8884    public:
    89       OrxListener(OIS::Keyboard *keyboard, OIS::Mouse *mouse, audio::AudioManager*  auMan, SpaceshipSteering* steering, gameMode mode)
    90       : mKeyboard(keyboard), mMouse(mouse)
     85      OrxListener(OIS::Keyboard *keyboard, audio::AudioManager*  auMan, gameMode mode)
    9186      {
    92 
    93 
     87        mKeyboard = keyboard;
    9488        mode_=mode;
    95         speed = 250;
    96         loop = 100;
    97         rotate = 10;
    98         mouseX = 0;
    99         mouseY = 0;
    100         maxMouseX = 0;
    101         minMouseX = 0;
    102         moved = false;
    103 
    104         steering_ = steering;
    105 
    106         steering_->brakeRotate(rotate*10);
    107         steering_->brakeLoop(loop);
    108 
    109 
    110         mMouse->setEventCallback(this);
    11189        auMan_ = auMan;
    11290      }
     91
    11392      bool frameStarted(const FrameEvent& evt)
    11493      {
    115 
    11694        auMan_->update();
    11795
    118         mKeyboard->capture();
    119         mMouse->capture();
    120         if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    121           steering_->moveForward(speed);
    122         else
    123           steering_->moveForward(0);
    124         if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    125           steering_->brakeForward(speed);
    126         else
    127           steering_->brakeForward(speed/10);
    128         if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    129           steering_->loopRight(loop);
    130         else
    131           steering_->loopRight(0);
    132         if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    133           steering_->loopLeft(loop);
    134         else
    135           steering_->loopLeft(0);
    136 
    137         if(moved) {
    138           if (mouseY<=0)
    139             steering_->rotateUp(-mouseY*rotate);
    140           if (mouseY>0)
    141             steering_->rotateDown(mouseY*rotate);
    142           if (mouseX>0)
    143             steering_->rotateRight(mouseX*rotate);
    144           if (mouseX<=0)
    145             steering_->rotateLeft(-mouseX*rotate);
    146           mouseY = 0;
    147           mouseX = 0;
    148           moved = false;
    149         }
    150         else {
    151           steering_->rotateUp(0);
    152           steering_->rotateDown(0);
    153           steering_->rotateRight(0);
    154           steering_->rotateLeft(0);
    155         }
    156 
    157                 steering_->tick(evt.timeSinceLastFrame);
    158 
    159 
    160 
    161 //      scenemanager->spacehip->tick(evt.timesincelastframe);
    162         //if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
    163           //cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl;
    16496        if(mode_==PRESENTATION)
    165           server_g->tick(evt.timeSinceLastFrame);
     97          server_g->tick(evt.timeSinceLastFrame);
    16698        else if(mode_==CLIENT)
    16799          client_g->tick(evt.timeSinceLastFrame);
     100
    168101        usleep(10);
     102
     103        mKeyboard->capture();
    169104        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
    170105      }
    171106
    172       bool mouseMoved(const OIS::MouseEvent &e)
    173       {
    174         mouseX += e.state.X.rel;
    175         mouseY += e.state.Y.rel;
    176         if(mouseX>maxMouseX) maxMouseX = mouseX;
    177         if(mouseX<minMouseX) minMouseX = mouseX;
    178         //cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
    179         moved = true;
    180         return true;
    181       }
    182 
    183       bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
    184       bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
    185 
    186107    private:
    187108      gameMode mode_;
    188       float speed;
    189       float rotate;
    190       float loop;
    191       float mouseY;
    192       float mouseX;
    193       float maxMouseX;
    194       float minMouseX;
    195       bool moved;
    196109      OIS::Keyboard *mKeyboard;
    197       OIS::Mouse *mMouse;
    198110      audio::AudioManager*  auMan_;
    199       SpaceshipSteering* steering_;
    200111  };
     112
    201113  // init static singleton reference of Orxonox
    202114  Orxonox* Orxonox::singletonRef_ = NULL;
     
    207119  Orxonox::Orxonox()
    208120  {
    209     ogre_ = new GraphicsEngine();
    210     dataPath_ = "";
     121    this->ogre_ = new GraphicsEngine();
     122    this->dataPath_ = "";
     123    this->loader_ = 0;
     124    this->auMan_ = 0;
     125    this->singletonRef_ = 0;
     126    this->keyboard_ = 0;
     127    this->mouse_ = 0;
     128    this->inputManager_ = 0;
     129    this->frameListener_ = 0;
     130    this->root_ = 0;
    211131  }
    212132
     
    240160    ar.checkArgument("ip", serverIp_, false);
    241161    if(ar.errorHandling()) die();
    242 
    243162    if(mode == std::string("server"))
    244163    {
     
    343262    createRenderWindow();
    344263    initializeResourceGroups();
     264    setupInputSystem();
     265    Factory::createClassHierarchy();
    345266    createScene();
    346267    setupScene();
    347     setupInputSystem();
    348     Factory::createClassHierarchy();
    349268    createFrameListener();
    350269    try{
     
    472391  void Orxonox::setupScene()
    473392  {
    474     SceneManager *mgr = ogre_->getSceneManager();
    475 
    476 
    477     SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");
     393//    SceneManager *mgr = ogre_->getSceneManager();
     394
     395
     396//    SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");
    478397//     SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
    479398
    480 
    481     steering_ = new SpaceshipSteering(500, 200, 200, 200);
    482     steering_->addNode(node);
    483399
    484400/*
     
    489405    e->addToSceneNode(node);
    490406*/
    491 
    492     particle::ParticleInterface *w = new particle::ParticleInterface(mgr,"schuss","Orxonox/schuss");
    493     w->particleSystem_->setParameter("local_space","true");
    494     w->newEmitter();
    495     w->setDirection(Vector3(0,0,1));
    496     w->setPositionOfEmitter(0, Vector3(10,10,0));
    497     w->setPositionOfEmitter(1, Vector3(-10,10,0));
    498     w->addToSceneNode(node);
    499 
    500     particle::ParticleInterface *tt = new particle::ParticleInterface(mgr,"twinthruster","Orxonox/engineglow");
    501     tt->particleSystem_->setParameter("local_space","true");
    502     tt->newEmitter();
    503     tt->setDirection(Vector3(0,0,-1));
    504     tt->setPositionOfEmitter(0, Vector3(20,-1,-15));
    505     tt->setPositionOfEmitter(1, Vector3(-20,-1,-15));
    506     tt->addToSceneNode(node);
    507 
    508407  }
    509408
     
    542441
    543442    //if(mode_!=CLIENT) // just a hack ------- remove this in future
    544       frameListener_ = new OrxListener(keyboard_, mouse_, auMan_, steering_, mode_);
     443      frameListener_ = new OrxListener(keyboard_, auMan_, mode_);
    545444    ogre_->getRoot()->addFrameListener(frameListener_);
    546445  }
  • code/branches/FICN/src/orxonox/orxonox.h

    r599 r608  
    1010//#include <OgreSingleton.h>
    1111#include <OgreSceneManager.h>
    12 
    1312#include <OIS/OIS.h>
    1413
     
    2928    PRESENTATION
    3029  };
    31  
     30
    3231  class OrxListener;
    3332
     
    4241      inline SceneManager* getSceneManager() { return ogre_->getSceneManager(); };
    4342      inline GraphicsEngine* getOgrePointer() { return ogre_; };
    44       inline SpaceshipSteering* getSteeringPointer() { return steering_; };
    4543      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
     44      inline OIS::Keyboard* getKeyboard() { return this->keyboard_; }
     45      inline OIS::Mouse* getMouse() { return this->mouse_; }
     46
    4647    private:
    4748      Orxonox();
     
    6364      void createFrameListener();
    6465      void startRenderLoop();
     66
    6567    private:
    66 
    6768      GraphicsEngine*       ogre_;      //!< our dearest graphics engine <3
    6869      std::string           dataPath_;  //!< path to data
    6970      loader::LevelLoader*  loader_;    //!< level loader builds the scene
    7071      audio::AudioManager*  auMan_;     //!< audio manager
    71       SpaceshipSteering*        steering_;
    7272      static Orxonox*       singletonRef_;
    7373      OIS::Keyboard*        keyboard_;
     
    7676      OrxListener*          frameListener_;
    7777      Ogre::Root*           root_;
    78      
     78
    7979      // this is used to identify the mode (server/client/...) we're in
    8080      gameMode              mode_;
Note: See TracChangeset for help on using the changeset viewer.