Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 152


Ignore:
Timestamp:
Nov 3, 2007, 6:20:21 PM (13 years ago)
Author:
rgrieder
Message:
  • added a few comments
  • converted RunManager and OrxonoxShip to match the style guide
Location:
code/branches/main_reto
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto/include/orxonox_ship.h

    r146 r152  
    3939{
    4040public:
    41         Vector3 speed;
    42         float thrust, sideThrust, baseThrust;
    43         Vector3 bulletSpeed;
    44 
    4541        OrxonoxShip(SceneManager*, SceneNode*);
    4642        virtual ~OrxonoxShip();
     
    5046        void setThrust(const Real);
    5147        void setSideThrust(const Real);
    52         void setYaw(const Radian);
    53         void setPitch(const Radian);
    54         void setRoll(const Radian);
    55 
    56         Real getThrust();
     48        void turnUpAndDown(const Radian&);
     49        void turnLeftAndRight(const Radian&);
    5750
    5851        Bullet* fire();
     
    6053        bool tick(unsigned long, Real);
    6154
    62         SceneNode *mRootNode;
     55protected:
     56
     57
     58public:
     59
    6360
    6461protected:
    65         SceneManager *mSceneMgr;
    66         Entity *mShip;
     62        SceneManager *SceneMgr_;
     63        SceneNode *RootNode_;
     64        Entity *ShipEntity_;
    6765
    68         int n;
     66        Vector3 currentSpeed_;
     67        float CurrentThrust_;
     68  float CurrentSideThrust_;
     69  float baseThrust_;
     70        int objectCounter_;
     71        Vector3 bulletSpeed_;
    6972
    7073};
  • code/branches/main_reto/include/run_manager.h

    r146 r152  
    3838#include "orxonox_ship.h"
    3939
     40
    4041//Use this define to signify OIS will be used as a DLL
    4142//(so that dll import/export macros are in effect)
     
    5556        virtual ~RunManager();
    5657
    57         virtual bool tick(unsigned long, float);
     58        virtual bool tick(unsigned long, Real);
    5859
    5960protected:
    60         OgreControl  *mOgre;
    61 
    62         SceneManager *mSceneMgr;
    63         RenderWindow* mWindow;
    64 
    65         OrxonoxScene *mScene;
    66         Camera* mCamera;
    67         SceneNode *mShipNode;
    68         OrxonoxShip *mShip;
    69 
    70         bool mStatsOn;
    71 
    72         std::string mDebugText;
    73 
    74         unsigned int mNumScreenShots;
    75         // just to stop toggles flipping too fast
    76         Real mTimeUntilNextToggle ;
    77         TextureFilterOptions mFiltering;
    78         int mAniso;
    79 
    80         int mSceneDetailIndex ;
    81         Overlay* mDebugOverlay;
    82 
    83         //OIS Input devices
    84         OIS::InputManager* mInputManager;
    85         OIS::Mouse*    mMouse;
    86         OIS::Keyboard* mKeyboard;
    87         OIS::JoyStick* mJoy;
    88 
    89         bool leftButtonDown;
    90         Bullet **mBullets;
    91         int mBulletsSize;
    92         int mBulletsPosition;
    93 
    94         // previously elapsed render time
    95         unsigned long mTime;
    96 
    9761        virtual void createCamera(void);
    9862
     
    12185        virtual void showDebugOverlay(bool);
    12286
     87protected:
     88        OgreControl  *ogre_;
     89        SceneManager *sceneMgr_;
     90        RenderWindow *window_;
     91        OrxonoxScene *backgroundScene_;
     92        Camera       *camera_;
     93        OrxonoxShip  *playerShip_;
     94
     95        bool statsOn_;
     96        std::string debugText_;
     97
     98        unsigned int screenShotCounter_;
     99        // just to stop toggles flipping too fast
     100        Real timeUntilNextToggle_;
     101        bool leftButtonDown_;
     102        TextureFilterOptions filtering_;
     103        int aniso_;
     104
     105        int sceneDetailIndex_;
     106        Overlay* debugOverlay_;
     107
     108        //OIS Input devices
     109        OIS::InputManager* inputManager_;
     110        OIS::Mouse*    mouse_;
     111        OIS::Keyboard* keyboard_;
     112        OIS::JoyStick* joystick_;
     113
     114  // Bullet array
     115        Bullet **bullets_;
     116        int bulletsSize_;
     117        int bulletsIndex_;
     118
     119        // previously elapsed render time
     120        unsigned long totalTime_;
     121
    123122};
    124123
  • code/branches/main_reto/src/orxonox_ship.cc

    r147 r152  
    2626 */
    2727
     28/**
     29* Base class for any kind of flyable ship in Orxonox.
     30*
     31* The ship offers steering methods (like left, right, etc.) and translates
     32* them into movement. A ship can also hold more than one weapons (where each
     33* of these can be replaced during the game). This means that a ship can have
     34* many WeaponManagers but only one MunitionManager (independant object that
     35* is referenced in each WeaponManager).
     36* Furthermore a ship in Orxonox is responsible for its visualization, which is
     37* why it receives a pointer to the SceneManager.
     38*/
     39
     40
    2841#include "orxonox_ship.h"
    2942
    3043
     44/**
     45* Standard constructor, that only initalizes a few variables. Some of them
     46* could be made static, since any new ship would be derived from the BaseShip.
     47* Or even better: write config files for each ship so that manipulating
     48* its properties would be even easier.
     49* @param mSceneMgr The current main SceneManager
     50* @param mNode The scene node which the ship will be attached to later.
     51*/
    3152OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode)
    3253            : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)),
     
    3758
    3859
     60/**
     61* Standard destructor.
     62* Doesn't have any work to do yet.
     63*/
    3964OrxonoxShip::~OrxonoxShip()
    4065{
     
    4267
    4368
     69/**
     70* Initialises everything.
     71* Once that ResourceGroups are organised, this method loads them.
     72* It might be an idea to make this function static in order for the
     73* SceneManger to call the initialise method of every needed class (macros..)
     74*/
    4475bool OrxonoxShip::initialise()
    4576{
     
    4980
    5081        // create the "space ship" (currently a fish..)
    51         // TODO: names must be unique!
     82        // TODO: names must be unique! use static variables..
    5283        mShip = mSceneMgr->createEntity("Ship", "fish.mesh");
    5384        SceneNode *fishNode = mRootNode->createChildSceneNode("fishNode");
     
    6091
    6192
     93/**
     94* Gets the ship to accelerate in the current direction.
     95* The value should be between 0 and 1, with one beeing full thrust and 0 none.
     96* @param value Acceleration between 0 and 1
     97*/
    6298void OrxonoxShip::setThrust(const Real value)
    6399{
     
    66102
    67103
     104/**
     105* Gets the ship to accelerate sideways regarding the current direction.
     106* The value should be between 0 and 1, with one beeing full thrust and 0 none.
     107* @param value Acceleration between 0 and 1
     108*/
    68109void OrxonoxShip::setSideThrust(const Real value)
    69110{
     
    71112}
    72113
    73 void OrxonoxShip::setYaw(const Radian value)
     114
     115/**
     116* Rotate the ship along with the camera up and down.
     117* @param angle Pitch value.
     118*/
     119void OrxonoxShip::turnUpAndDown(const Radian &angle)
    74120{
    75         mRootNode->yaw(value);
     121  RootNode_->pitch(angle, Ogre::Node::TransformSpace::TS_LOCAL);
    76122}
    77123
    78 void OrxonoxShip::setPitch(const Radian value)
     124
     125/**
     126* Rotate the ship along with the camera left and right.
     127* @param angle Yaw value.
     128*/
     129void OrxonoxShip::turnLeftAndRight(const Radian &angle)
    79130{
    80         mRootNode->pitch(value);
     131  RootNode_->yaw(angle, Ogre::Node::TransformSpace::TS_PARENT);
    81132}
    82133
    83 void OrxonoxShip::setRoll(const Radian value)
    84 {
    85         mRootNode->roll(value);
    86 }
    87134
    88 Real OrxonoxShip::getThrust()
    89 {
    90         return thrust;
    91 }
    92 
     135/**
     136* Fire a bullet (Entity with SceneNode).
     137* This method creates a new Entity plus a SceneNode. But be sure not make
     138* the new Node a child of RootNode_!
     139*/
    93140Bullet* OrxonoxShip::fire()
    94141{
    95142        // TODO: Names must be unique!
    96         SceneNode *temp = mRootNode->getParentSceneNode()->createChildSceneNode(
    97         "BulletNode" + StringConverter::toString(n));
    98         temp->setOrientation(mRootNode->getOrientation());
    99         temp->setPosition(mRootNode->getPosition());
     143        SceneNode *temp = RootNode_->getParentSceneNode()->createChildSceneNode(
     144        "BulletNode" + StringConverter::toString(objectCounter_));
     145        temp->setOrientation(RootNode_->getOrientation());
     146        temp->setPosition(RootNode_->getPosition());
    100147        temp->setScale(Vector3(1, 1, 1) * 10);
    101148        temp->yaw(Degree(-90));
    102149        return new Bullet(temp, mSceneMgr->createEntity("bullet"
    103         + StringConverter::toString(n++), "Barrel.mesh"), speed
    104         + (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy()
    105         * bulletSpeed);
     150        + StringConverter::toString(objectCounter_++), "Barrel.mesh"), speed
     151        + (RootNode_->getOrientation() * Vector3(0, 0, -1)).normalisedCopy()
     152        * bulletSpeed_);
    106153}
    107154
     155
     156/**
     157* Standard tick() function.
     158* Currently, only the speed is applied according to the thrust values.
     159* @param time Absolute time.
     160* @param deltaTime Relative time.
     161*/
    108162bool OrxonoxShip::tick(unsigned long time, Real deltaTime)
    109163{
    110164  Quaternion quad = mRootNode->getOrientation();
    111165  quad.normalise();
    112   speed += quad * Vector3(0, 0, -1) * thrust * deltaTime;
    113         speed += quad * Vector3(-1, 0,  0) * sideThrust * deltaTime;
     166  speed += quad * Vector3(0, 0, -1) * currentThrust_ * deltaTime;
     167        speed += quad * Vector3(-1, 0,  0) * current_SideThrust_ * deltaTime;
    114168
    115         mRootNode->translate(speed * deltaTime);
     169        RootNode_->translate(currentSpeed_ * deltaTime);
    116170
    117171        return true;
  • code/branches/main_reto/src/run_manager.cc

    r146 r152  
    4848*
    4949*
    50 * @param mOgre The OgreControl object holding the render window and the Root
    51 */
    52 RunManager::RunManager(OgreControl * mOgre, bool bufferedKeys,
    53                        bool bufferedMouse, bool bufferedJoy )
    54                        : mOgre(mOgre), mWindow(mOgre->getRenderWindow()), leftButtonDown(false),
    55                        mStatsOn(true), mNumScreenShots(0), mTimeUntilNextToggle(0),
    56                        mFiltering(TFO_BILINEAR), mAniso(1), mSceneDetailIndex(0),
    57                        mDebugOverlay(0), mInputManager(0), mMouse(0), mKeyboard(0), mJoy(0)
     50* @param ogre_ The OgreControl object holding the render window and the Root
     51*/
     52RunManager::RunManager(OgreControl * ogre)
     53      : ogre_(ogre), window_(ogre->getRenderWindow()), leftButtonDown_(false),
     54      statsOn_(true), screenShotCounter_(0), timeUntilNextToggle_(0),
     55      filtering_(TFO_BILINEAR), aniso_(1), sceneDetailIndex_(0),
     56      debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0)
    5857{
    5958
     
    6160
    6261  // create one new SceneManger
    63   mSceneMgr = mOgre->getRoot()->createSceneManager(ST_GENERIC, "mScene");
     62  sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "backgroundScene_");
    6463
    6564  // background scene (world objects, skybox, lights, etc.)
    66   mScene = new OrxonoxScene(mSceneMgr);
     65  backgroundScene_ = new OrxonoxScene(sceneMgr_);
    6766
    6867  // PLAYER SPACESHIP
    6968
    70   // create a steerable SceneNode (not derived!) object. The idea is that this
    71   // object only receives the mouse and the keyboard input (not specifi keys,
    72   // more like up, down, left, right, roll left, roll right, move down,
    73   // move up). The steering class can then decide how to control the node for
    74   // the spaceship. This gives a certain flexibility.
    75   // It should also be considered, that this class should provide another Node
     69  // Create a space ship object and its SceneNode.
     70  // Some ideas about the steering: The ship should only receive events like
     71  // up, down, left, right, roll left, roll right, move down, move up, etc).
     72  // Multiple interpretations of these commands would make the game more
     73  // but it also makes AI steering more difficult, since for every type of
     74  // steering, new methods have to be written.
     75  // --> clearly define how a space ship can fly (rolling?, conservation of
     76  // impuls?, direct mouse sight steeering?, etc.)
     77  // It should also be considered, that the ship should provide another Node
    7678  // for a camera to be attached (otherwise the spaceship in front of the
    77   // would be very static, never moving at all.
    78   mShipNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("ShipNode",
    79     Vector3(20, 20, 20));
    80 
    81   // Construct a new spaceship and attach it to the node
    82   mShip = new OrxonoxShip(mSceneMgr, mShipNode);
     79  // would be very static, never moving at all).
     80
     81  // Construct a new spaceship and give it the node
     82  playerShip_ = new OrxonoxShip(sceneMgr_, getRootSceneNode()
     83    ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)));
    8384
    8485
     
    8788  // load all resources and create the entities by calling the initialise()
    8889  // methods for each object (don't initialise in the constructor!).
    89   mScene->initialise();
    90   mShip->initialise();
     90  backgroundScene_->initialise();
     91  playerShip_->initialise();
    9192
    9293
     
    109110
    110111  // TODO: Use STL to make life easier. But it works this way too..
    111   mBullets = new Bullet*[10];
    112   mBulletsPosition = 0;
    113   mBulletsSize = 10;
     112  bullets_ = new Bullet*[10];
     113  bulletsIndex_ = 0;
     114  bulletsSize_ = 10;
    114115
    115116
     
    118119  using namespace OIS;
    119120
    120   mDebugOverlay = OverlayManager::getSingleton()
     121  debugOverlay_ = OverlayManager::getSingleton()
    121122    .getByName("Core/DebugOverlay");
    122123
     
    126127  std::ostringstream windowHndStr;
    127128
    128   mWindow->getCustomAttribute("WINDOW", &windowHnd);
     129  window_->getCustomAttribute("WINDOW", &windowHnd);
    129130  windowHndStr << windowHnd;
    130131  pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    131132
    132   mInputManager = InputManager::createInputSystem( pl );
     133  inputManager_ = InputManager::createInputSystem( pl );
    133134
    134135  // Create all devices (We only catch joystick exceptions here,
    135136  // as, most people have Key/Mouse)
    136   mKeyboard = static_cast<Keyboard*>(mInputManager
    137     ->createInputObject( OISKeyboard, bufferedKeys ));
    138   mMouse = static_cast<Mouse*>(mInputManager
    139     ->createInputObject( OISMouse, bufferedMouse ));
     137  keyboard_ = static_cast<Keyboard*>(inputManager_
     138    ->createInputObject( OISKeyboard, false ));
     139  mouse_ = static_cast<Mouse*>(inputManager_
     140    ->createInputObject( OISMouse, false ));
    140141  try {
    141     mJoy = static_cast<JoyStick*>(mInputManager
    142       ->createInputObject( OISJoyStick, bufferedJoy ));
     142    joystick_ = static_cast<JoyStick*>(inputManager_
     143      ->createInputObject( OISJoyStick, false ));
    143144  }
    144145  catch(...) {
    145     mJoy = 0;
     146    joystick_ = 0;
    146147  }
    147148
    148149  //Set initial mouse clipping size
    149   windowResized(mWindow);
     150  windowResized(window_);
    150151
    151152  showDebugOverlay(true);
     
    153154  // REGISTER THIS OBJECT AS A WINDOW EVENT LISTENER IN OGRE
    154155  // It will then receive events liek windowClosed, windowResized, etc.
    155   WindowEventUtilities::addWindowEventListener(mWindow, this);
     156  WindowEventUtilities::addWindowEventListener(window_, this);
    156157}
    157158
     
    164165{
    165166  //Remove ourself as a Window listener
    166   WindowEventUtilities::removeWindowEventListener(mWindow, this);
    167   windowClosed(mWindow);
    168 
    169   if (mScene)
    170     delete mScene;
    171   if (mShip)
    172     delete mShip;
     167  WindowEventUtilities::removeWindowEventListener(window_, this);
     168  windowClosed(window_);
     169
     170  if (backgroundScene_)
     171    delete backgroundScene_;
     172  if (playerShip_)
     173    delete playerShip_;
    173174
    174175  // clean up the bullet list
    175   for (int i = 0; i < mBulletsPosition; i++)
    176     delete mBullets[i];
    177   delete mBullets;
     176  for (int i = 0; i < bulletsIndex_; i++)
     177    delete bullets_[i];
     178  delete bullets_;
    178179}
    179180
     
    193194{
    194195  // synchronize with internal class timer
    195   mTime = time;
     196  totalTime_ = time;
    196197
    197198  // Call tick() for every object
    198199  // This could be done by registering (needs a factory..)
    199   mScene->tick(time, deltaTime);
    200   mShip->tick(time, deltaTime);
     200  backgroundScene_->tick(time, deltaTime);
     201  playerShip_->tick(time, deltaTime);
    201202
    202203
     
    205206
    206207  // update the bullet positions
    207   for (int i = 0; i < mBulletsPosition; i++)
    208   {
    209     mBullets[i]->mNode->translate(mBullets[i]->mSpeed*deltaTime);
    210     mBullets[i]->mNode->yaw(Degree(deltaTime*100));
    211     mBullets[i]->mNode->roll(Degree(deltaTime*300));
     208  for (int i = 0; i < bulletsIndex_; i++)
     209  {
     210    bullets_[i]->mNode->translate(bullets_[i]->mSpeed*deltaTime);
     211    bullets_[i]->mNode->yaw(Degree(deltaTime*100));
     212    bullets_[i]->mNode->roll(Degree(deltaTime*300));
    212213  }
    213214
     
    216217  using namespace OIS;
    217218
    218   if(mWindow->isClosed())       return false;
     219  if(window_->isClosed())       return false;
    219220
    220221  //Need to capture/update each device
    221   mKeyboard->capture();
    222   mMouse->capture();
    223   if( mJoy ) mJoy->capture();
    224 
    225   bool buffJ = (mJoy) ? mJoy->buffered() : true;
     222  keyboard_->capture();
     223  mouse_->capture();
     224  if( joystick_ ) joystick_->capture();
     225
     226  bool buffJ = (joystick_) ? joystick_->buffered() : true;
    226227
    227228  //Check if one of the devices is not buffered
    228   if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ )
     229  if( !mouse_->buffered() || !keyboard_->buffered() || !buffJ )
    229230  {
    230231    // one of the input modes is immediate, so setup what
    231232    // is needed for immediate movement
    232     if (mTimeUntilNextToggle >= 0)
    233       mTimeUntilNextToggle -= deltaTime;
    234   }
    235 
    236   //Check to see which device is not buffered, and handle it
    237   if( !mKeyboard->buffered() )
    238     if( processUnbufferedKeyInput() == false )
     233    if (timeUntilNextToggle_ >= 0)
     234      timeUntilNextToggle_ -= deltaTime;
     235  }
     236
     237  // handle HID devices
     238  if( processUnbufferedKeyInput() == false )
    239239      return false;
    240   if( !mMouse->buffered() )
    241     if( processUnbufferedMouseInput() == false )
     240  if( processUnbufferedMouseInput() == false )
    242241      return false;
    243242
     
    259258  rw->getMetrics(width, height, depth, left, top);
    260259
    261   const OIS::MouseState &ms = mMouse->getMouseState();
     260  const OIS::MouseState &ms = mouse_->getMouseState();
    262261  ms.width = width;
    263262  ms.height = height;
     
    273272{
    274273  //Only close for window that created OIS (the main window in these demos)
    275   if( rw == mWindow )
    276   {
    277     if( mInputManager )
     274  if( rw == window_ )
     275  {
     276    if( inputManager_ )
    278277    {
    279       mInputManager->destroyInputObject( mMouse );
    280       mInputManager->destroyInputObject( mKeyboard );
    281       mInputManager->destroyInputObject( mJoy );
    282 
    283       OIS::InputManager::destroyInputSystem(mInputManager);
    284       mInputManager = 0;
     278      inputManager_->destroyInputObject( mouse_ );
     279      inputManager_->destroyInputObject( keyboard_ );
     280      inputManager_->destroyInputObject( joystick_ );
     281
     282      OIS::InputManager::destroyInputSystem(inputManager_);
     283      inputManager_ = 0;
    285284    }
    286285  }
     
    297296  using namespace OIS;
    298297
    299   if(mKeyboard->isKeyDown(KC_A) || mKeyboard->isKeyDown(KC_LEFT))
    300     mShip->setSideThrust(1);
    301   else if(mKeyboard->isKeyDown(KC_D) || mKeyboard->isKeyDown(KC_RIGHT))
    302     mShip->setSideThrust(-1);
     298  if(keyboard_->isKeyDown(KC_A) || keyboard_->isKeyDown(KC_LEFT))
     299    playerShip_->setSideThrust(1);
     300  else if(keyboard_->isKeyDown(KC_D) || keyboard_->isKeyDown(KC_RIGHT))
     301    playerShip_->setSideThrust(-1);
    303302  else
    304     mShip->setSideThrust(0);
    305 
    306   if(mKeyboard->isKeyDown(KC_UP) || mKeyboard->isKeyDown(KC_W) )
    307     mShip->setThrust(1);
    308   else if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) )
    309     mShip->setThrust(-1);
     303    playerShip_->setSideThrust(0);
     304
     305  if(keyboard_->isKeyDown(KC_UP) || keyboard_->isKeyDown(KC_W) )
     306    playerShip_->setThrust(1);
     307  else if(keyboard_->isKeyDown(KC_DOWN) || keyboard_->isKeyDown(KC_S) )
     308    playerShip_->setThrust(-1);
    310309  else
    311     mShip->setThrust(0);
    312 
    313   if( mKeyboard->isKeyDown(KC_ESCAPE) || mKeyboard->isKeyDown(KC_Q) )
     310    playerShip_->setThrust(0);
     311
     312  if( keyboard_->isKeyDown(KC_ESCAPE) || keyboard_->isKeyDown(KC_Q) )
    314313    return false;
    315314
    316   if( mKeyboard->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0 )
    317   {
    318     mStatsOn = !mStatsOn;
    319     showDebugOverlay(mStatsOn);
    320     mTimeUntilNextToggle = 1;
    321   }
    322 
    323   if( mKeyboard->isKeyDown(KC_T) && mTimeUntilNextToggle <= 0 )
    324   {
    325     switch(mFiltering)
     315  if( keyboard_->isKeyDown(KC_F) && timeUntilNextToggle_ <= 0 )
     316  {
     317    statsOn_ = !statsOn_;
     318    showDebugOverlay(statsOn_);
     319    timeUntilNextToggle_ = 1;
     320  }
     321
     322  if( keyboard_->isKeyDown(KC_T) && timeUntilNextToggle_ <= 0 )
     323  {
     324    switch(filtering_)
    326325    {
    327326    case TFO_BILINEAR:
    328       mFiltering = TFO_TRILINEAR;
    329       mAniso = 1;
     327      filtering_ = TFO_TRILINEAR;
     328      aniso_ = 1;
    330329      break;
    331330    case TFO_TRILINEAR:
    332       mFiltering = TFO_ANISOTROPIC;
    333       mAniso = 8;
     331      filtering_ = TFO_ANISOTROPIC;
     332      aniso_ = 8;
    334333      break;
    335334    case TFO_ANISOTROPIC:
    336       mFiltering = TFO_BILINEAR;
    337       mAniso = 1;
     335      filtering_ = TFO_BILINEAR;
     336      aniso_ = 1;
    338337      break;
    339338    default: break;
    340339    }
    341     MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering);
    342     MaterialManager::getSingleton().setDefaultAnisotropy(mAniso);
    343 
    344     showDebugOverlay(mStatsOn);
    345     mTimeUntilNextToggle = 1;
    346   }
    347 
    348   if(mKeyboard->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0)
     340    MaterialManager::getSingleton().setDefaultTextureFiltering(filtering_);
     341    MaterialManager::getSingleton().setDefaultAnisotropy(aniso_);
     342
     343    showDebugOverlay(statsOn_);
     344    timeUntilNextToggle_ = 1;
     345  }
     346
     347  if(keyboard_->isKeyDown(KC_SYSRQ) && timeUntilNextToggle_ <= 0)
    349348  {
    350349    std::ostringstream ss;
    351     ss << "screenshot_" << ++mNumScreenShots << ".png";
    352     mWindow->writeContentsToFile(ss.str());
    353     mTimeUntilNextToggle = 0.5;
     350    ss << "screenshot_" << ++screenShotCounter_ << ".png";
     351    window_->writeContentsToFile(ss.str());
     352    timeUntilNextToggle_ = 0.5;
    354353    mDebugText = "Saved: " + ss.str();
    355354  }
    356355
    357   if(mKeyboard->isKeyDown(KC_R) && mTimeUntilNextToggle <=0)
    358   {
    359     mSceneDetailIndex = (mSceneDetailIndex+1)%3 ;
    360     switch(mSceneDetailIndex) {
    361         case 0 : mCamera->setPolygonMode(PM_SOLID); break;
    362         case 1 : mCamera->setPolygonMode(PM_WIREFRAME); break;
    363         case 2 : mCamera->setPolygonMode(PM_POINTS); break;
     356  if(keyboard_->isKeyDown(KC_R) && timeUntilNextToggle_ <=0)
     357  {
     358    sceneDetailIndex_ = (sceneDetailIndex_+1)%3 ;
     359    switch(sceneDetailIndex_) {
     360        case 0 : camera_->setPolygonMode(PM_SOLID); break;
     361        case 1 : camera_->setPolygonMode(PM_WIREFRAME); break;
     362        case 2 : camera_->setPolygonMode(PM_POINTS); break;
    364363    }
    365     mTimeUntilNextToggle = 0.5;
     364    timeUntilNextToggle_ = 0.5;
    366365  }
    367366
    368367  static bool displayCameraDetails = false;
    369   if(mKeyboard->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0)
     368  if(keyboard_->isKeyDown(KC_P) && timeUntilNextToggle_ <= 0)
    370369  {
    371370    displayCameraDetails = !displayCameraDetails;
    372     mTimeUntilNextToggle = 0.5;
     371    timeUntilNextToggle_ = 0.5;
    373372    if (!displayCameraDetails)
    374373      mDebugText = "";
     
    377376  // Print camera details
    378377  if(displayCameraDetails)
    379     mDebugText = StringConverter::toString(mShip->getThrust())
    380     + " | Speed = " + StringConverter::toString(mShip->speed);
    381   // mDebugText = "P: " + StringConverter::toString(mCamera
     378    mDebugText = StringConverter::toString(playerShip_->getThrust())
     379    + " | Speed = " + StringConverter::toString(playerShip_->speed);
     380  // mDebugText = "P: " + StringConverter::toString(camera_
    382381  //      ->getDerivedPosition()) + " " + "O: "
    383   //      + StringConverter::toString(mCamera->getDerivedOrientation());
     382  //      + StringConverter::toString(camera_->getDerivedOrientation());
    384383
    385384  // Return true to continue rendering
     
    399398  using namespace OIS;
    400399
    401   const MouseState &ms = mMouse->getMouseState();
     400  const MouseState &ms = mouse_->getMouseState();
    402401
    403402  // This is a 'hack' to show some flying barrels..
    404403  // Usually, the Bullet created by the ship should be managed
    405404  // by the physics engine..
    406   if (ms.buttonDown(MB_Left) && !leftButtonDown)
     405  if (ms.buttonDown(MB_Left) && !leftButtonDown_)
    407406  {
    408407    // Prevent continuous fire for the moment.
    409     leftButtonDown = true;
     408    leftButtonDown_ = true;
    410409   
    411410    // let ship fire one shot with its only weapon (Barrels..)
    412     Bullet *mTempBullet = mShip->fire();
     411    Bullet *tempBullet = playerShip_->fire();
    413412
    414413    // resize array if neccessary (double the size then)
    415     if (mBulletsPosition >= mBulletsSize)
     414    if (bulletsIndex_ >= bulletsSize_)
    416415    {
    417416      // redimension the array
    418       Bullet **mTempArray = new Bullet*[2*mBulletsSize];
    419       for (int i = 0; i < mBulletsSize; i++)
    420         mTempArray[i] = mBullets[i];
    421       mBulletsSize *= 2;
    422       delete mBullets;
    423       mBullets = mTempArray;
     417      Bullet **tempArray = new Bullet*[2*bulletsSize_];
     418      for (int i = 0; i < bulletsSize_; i++)
     419        tempArray[i] = bullets_[i];
     420      bulletsSize_ *= 2;
     421      delete bullets_;
     422      bullets_ = tempArray;
    424423    }
    425424
    426425    // add the bullet to the list
    427     mBullets[mBulletsPosition++] = mTempBullet;
     426    bullets_[bulletsIndex_++] = tempBullet;
    428427
    429428  }
    430429  else if (!ms.buttons)
    431     leftButtonDown = false;
     430    leftButtonDown_ = false;
    432431
    433432  // space ship steering. This should definitely be done in the steering object
    434433  // Simply give it the mouse movements.
    435   mShip->mRootNode->pitch(Degree(-ms.Y.rel * 0.13), Ogre::Node::TransformSpace::TS_LOCAL);
    436   mShip->mRootNode->yaw(Degree(-ms.X.rel * 0.13), Ogre::Node::TransformSpace::TS_PARENT);
     434  playerShip_->turnUpAndDown(Radian(ms.Y.rel * mouseSensitivity_));
     435  playerShip_->turnLeftAndRight(Radian(ms.X.rel * mousSensitivity_));
     436  //playerShip_->mRootNode->pitch(Degree(-ms.Y.rel * 0.13), Ogre::Node::TransformSpace::TS_LOCAL);
     437  //playerShip_->mRootNode->yaw(Degree(-ms.X.rel * 0.13), Ogre::Node::TransformSpace::TS_PARENT);
    437438
    438439  // keep rendering
     
    446447void RunManager::showDebugOverlay(bool show)
    447448{
    448   if (mDebugOverlay)
     449  if (debugOverlay_)
    449450  {
    450451    if (show)
    451       mDebugOverlay->show();
     452      debugOverlay_->show();
    452453    else
    453       mDebugOverlay->hide();
     454      debugOverlay_->hide();
    454455  }
    455456}
     
    480481      .getOverlayElement("Core/WorstFps");
    481482
    482     const RenderTarget::FrameStats& stats = mWindow->getStatistics();
     483    const RenderTarget::FrameStats& stats = window_->getStatistics();
    483484    guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
    484485    guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
     
    508509/**
    509510* Simple camera creator.
    510 * mShipNode->attachObject(mCamera) should no be here! This is what the camera
     511* playerShip_Node->attachObject(camera_) should no be here! This is what the camera
    511512* manager is for. Right now, this method should do just fine, setting the
    512513* cam behind the ship.
     
    514515void RunManager::createCamera(void)
    515516{
    516   mCamera = mSceneMgr->createCamera("PlayerCam");
    517   mShipNode->attachObject(mCamera);
    518   mCamera->setNearClipDistance(5);
    519   mCamera->setPosition(Vector3(0,10,500));
    520   mCamera->lookAt(Vector3(0,0,0));
     517  camera_ = sceneMgr_->createCamera("PlayerCam");
     518  playerShip_Node->attachObject(camera_);
     519  camera_->setNearClipDistance(5);
     520  camera_->setPosition(Vector3(0,10,500));
     521  camera_->lookAtVector3(0,0,0));
    521522}
    522523
     
    531532{
    532533  // Create one viewport, entire window
    533   Viewport* vp = mWindow->addViewport(mCamera);
     534  Viewport* vp = window_->addViewport(camera_);
    534535  vp->setBackgroundColour(ColourValue(0,0,0));
    535536
    536537  // Alter the camera aspect ratio to match the viewport
    537   mCamera->setAspectRatio(
     538  camera_->setAspectRatio(
    538539    Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
    539540}
Note: See TracChangeset for help on using the changeset viewer.