Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 7, 2007, 10:03:26 PM (17 years ago)
Author:
rgrieder
Message:

added files from rev 189

Location:
code/branches/main_reto/src
Files:
13 added
9 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto/src/CMakeLists.txt

    r180 r190  
    3333TARGET_LINK_LIBRARIES(../bin/main ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${CEGUI_LIBRARIES} ${CEGUI_OGRE_LIBRARIES})
    3434
     35#add main source dir
     36ADD_SUBDIRECTORY(weapon)
  • code/branches/main_reto/src/main.cc

    r171 r190  
    4444  {
    4545    try {
    46       // create an orxonox aplication and run it
     46      // create an orxonox application and run it
    4747      orxonox::Orxonox myApp;
    4848
  • code/branches/main_reto/src/orxonox_prerequisites.h

    r182 r190  
    3232namespace orxonox {
    3333
    34   class AmmunitionDump;
    35   class Bullet;
    3634  class CameraManager;
     35  class InertialNode;
    3736  class OgreControl;
    3837  class Orxonox;
     
    4039  class OrxonoxScene;
    4140  class RunManager;
    42   class Weapon;
    43   class WeaponManager;
     41
     42
     43  namespace weapon {
     44
     45    class AmmunitionDump;
     46    class Bullet;
     47    class BulletManager;
     48    class Weapon;
     49    class WeaponManager;
     50
     51  }
    4452
    4553}
  • code/branches/main_reto/src/orxonox_ship.cc

    r171 r190  
    3333
    3434#include "bullet.h"
     35#include "bullet_manager.h"
     36#include "inertial_node.h"
     37#include "weapon_manager.h"
    3538
    3639#include "orxonox_ship.h"
    37 #include "weapon_manager.h"
    3840
    3941
    4042namespace orxonox {
    4143  using namespace Ogre;
     44  using namespace weapon;
    4245
    4346  /**
     
    6265  * @param mNode The scene node which the ship will be attached to later.
    6366  */
    64   OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node)
    65               : sceneMgr_(sceneMgr), rootNode_(node), currentSpeed_(Vector3(0, 0, 0)),
     67  OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node,
     68        BulletManager *bulletManager)
     69              : sceneMgr_(sceneMgr), //currentSpeed_(Vector3(0, 0, 0)),
    6670        baseThrust_(1000), currentThrust_(Vector3::ZERO),
    67         objectCounter_(0), bulletSpeed_(400)
    68   {
     71        objectCounter_(0), bulletManager_(bulletManager)//, bulletSpeed_(400)
     72  {
     73    rootNode_ = new InertialNode(node, Vector3::ZERO);
    6974  }
    7075
     
    7681  OrxonoxShip::~OrxonoxShip()
    7782  {
     83    if (mainWeapon_)
     84      delete mainWeapon_;
     85    if (rootNode_)
     86      delete rootNode_;
    7887  }
    7988
     
    95104          // TODO: names must be unique! use static variables..
    96105          shipEntity_ = sceneMgr_->createEntity("Ship", "fish.mesh");
    97           SceneNode *fishNode = rootNode_->createChildSceneNode("fishNode");
    98           fishNode->yaw(Degree(-90));
    99           fishNode->attachObject(shipEntity_);
    100           fishNode->setScale(Vector3(10, 10, 10));
     106          InertialNode *fishNode = rootNode_->createChildNode();
     107    fishNode->getSceneNode()->yaw(Degree(-90));
     108          fishNode->getSceneNode()->attachObject(shipEntity_);
     109          fishNode->getSceneNode()->setScale(Vector3(10, 10, 10));
    101110
    102111    // initialise weapon(s)
    103     SceneNode *mainWeaponNode = rootNode_->createChildSceneNode("mainWeaponNode");
    104     mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode, 1);
     112    InertialNode *mainWeaponNode = rootNode_->createChildNode();
     113    mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode,
     114          bulletManager_, 1);
     115    mainWeapon_->addWeapon("Barrel Gun");
    105116
    106117          return true;
     
    110121  /**
    111122  * Gets the ship to accelerate in the current direction.
    112   * The value should be between 0 and 1, with one beeing full thrust and 0 none.
     123  * The value should be between 0 and 1, with one beeing full thrust and 0 none
    113124  * @param value Acceleration between 0 and 1
    114125  */
    115126  void OrxonoxShip::setMainThrust(const Real value)
    116127  {
    117           //currentThrust_ = value * baseThrust_;
    118128    currentThrust_.z = value * baseThrust_;
    119129  }
     
    122132  /**
    123133  * Gets the ship to accelerate sideways regarding the current direction.
    124   * The value should be between 0 and 1, with one beeing full thrust and 0 none.
     134  * The value should be between 0 and 1, with one beeing full thrust and 0 none
    125135  * @param value Acceleration between 0 and 1
    126136  */
    127137  void OrxonoxShip::setSideThrust(const Real value)
    128138  {
    129           //currentSideThrust_ = value * baseThrust_;
    130139    currentThrust_.x = value * baseThrust_;
    131140  }
     
    134143  /**
    135144  * Gets the ship to accelerate up and down.
    136   * The value should be between 0 and 1, with one beeing full thrust and 0 none.
     145  * The value should be between 0 and 1, with one beeing full thrust and 0 none
    137146  * @param value Acceleration between 0 and 1
    138147  */
    139148  void OrxonoxShip::setYThrust(const Real value)
    140149  {
    141     //currentYThrust_ = value * baseThrust_;
    142150    currentThrust_.y = value * baseThrust_;
    143151  }
     
    150158  void OrxonoxShip::turnUpAndDown(const Radian &angle)
    151159  {
    152     rootNode_->pitch(-angle, Node::TS_LOCAL);
     160    rootNode_->getSceneNode()->pitch(-angle, Node::TS_LOCAL);
    153161  }
    154162
     
    160168  void OrxonoxShip::turnLeftAndRight(const Radian &angle)
    161169  {
    162     rootNode_->yaw(-angle, Node::TS_PARENT);
     170    rootNode_->getSceneNode()->yaw(-angle, Node::TS_PARENT);
    163171  }
    164172
     
    170178  Vector3 OrxonoxShip::getSpeed()
    171179  {
    172     return currentSpeed_;
     180    return rootNode_->getSpeed();
    173181  }
    174182
     
    177185  * @return The Root Node.
    178186  */
    179   SceneNode* OrxonoxShip::getRootNode()
     187  InertialNode* OrxonoxShip::getRootNode()
    180188  {
    181189    return rootNode_;
     
    189197  * @return Bullet containing speed and entity.
    190198  */
    191   Bullet* OrxonoxShip::fire()
    192   {
    193           // TODO: Names must be unique!
    194           SceneNode *temp = rootNode_->getParentSceneNode()->createChildSceneNode(
    195           "BulletNode" + StringConverter::toString(objectCounter_));
    196           temp->setOrientation(rootNode_->getOrientation());
    197           temp->setPosition(rootNode_->getPosition());
    198           temp->setScale(Vector3(1, 1, 1) * 10);
    199           temp->yaw(Degree(-90));
    200           return new Bullet(temp, sceneMgr_->createEntity("bullet"
    201           + StringConverter::toString(objectCounter_++), "Barrel.mesh"), currentSpeed_
    202           + (rootNode_->getOrientation() * Vector3(0, 0, -1)).normalisedCopy()
    203           * bulletSpeed_);
     199  void OrxonoxShip::fire()
     200  {
     201    mainWeapon_->primaryFireRequest();
    204202  }
    205203
     
    214212  bool OrxonoxShip::tick(unsigned long time, Real deltaTime)
    215213  {
    216     Quaternion quad = rootNode_->getOrientation();
     214    mainWeapon_->tick(time, deltaTime);
     215
     216    Quaternion quad = rootNode_->getSceneNode()->getOrientation();
    217217    quad.normalise();
    218     currentSpeed_ += quad * (Vector3(-1, -1, -1) * currentThrust_) * deltaTime;
    219     //currentSpeed_ += quad * Vector3(0, 0, -1) * currentThrust_ * deltaTime;
    220           //currentSpeed_ += quad * Vector3(-1, 0,  0) * currentSideThrust_ * deltaTime;
    221 
    222           rootNode_->translate(currentSpeed_ * deltaTime);
     218    rootNode_->addSpeed(quad * (Vector3(-1, -1, -1) * currentThrust_) * deltaTime);
     219
     220    rootNode_->getSceneNode()->translate(rootNode_->getSpeed() * deltaTime);
    223221
    224222          return true;
  • code/branches/main_reto/src/orxonox_ship.h

    r182 r190  
    4040  {
    4141  public:
    42           OrxonoxShip(Ogre::SceneManager*, Ogre::SceneNode*);
     42    OrxonoxShip(Ogre::SceneManager*, Ogre::SceneNode*, weapon::BulletManager*);
    4343          virtual ~OrxonoxShip();
    4444
     
    5151          void turnLeftAndRight(const Ogre::Radian&);
    5252
    53     Ogre::SceneNode* getRootNode();
     53    InertialNode* getRootNode();
    5454    Ogre::Vector3 getSpeed();
    5555
    56           Bullet* fire();
     56          void fire();
    5757
    5858          bool tick(unsigned long, Ogre::Real);
     
    6262  protected:
    6363          Ogre::SceneManager *sceneMgr_;
    64           Ogre::SceneNode *rootNode_;
     64          //Ogre::SceneNode *rootNode_;
     65    InertialNode *rootNode_;
    6566          Ogre::Entity *shipEntity_;
    6667
    67           Ogre::Vector3 currentSpeed_;  // relative to space
     68          //Ogre::Vector3 currentSpeed_;  // relative to space
    6869          Ogre::Vector3 currentThrust_; // relative to the ship
    6970    Ogre::Real baseThrust_;
    7071          int objectCounter_;
    71           Ogre::Vector3 bulletSpeed_;
    7272
    73     WeaponManager *mainWeapon_;
     73    weapon::BulletManager *bulletManager_;
     74          //Ogre::Vector3 bulletSpeed_;
     75
     76    weapon::WeaponManager *mainWeapon_;
    7477  };
    7578
  • code/branches/main_reto/src/run_manager.cc

    r171 r190  
    5252#include "orxonox_ship.h"
    5353#include "bullet.h"
     54#include "bullet_manager.h"
    5455#include "camera_manager.h"
     56#include "weapon_manager.h"
     57#include "inertial_node.h"
    5558
    5659#include "run_manager.h"
     
    5861namespace orxonox {
    5962  using namespace Ogre;
     63  using namespace weapon;
    6064
    6165  /**
     
    97101    // background scene (world objects, skybox, lights, etc.)
    98102    backgroundScene_ = new OrxonoxScene(sceneMgr_);
     103
     104
     105    // BULLET LIST FOR THE TEST APPLICATION
     106
     107    // create a bullet manager
     108    bulletManager_ = new BulletManager(sceneMgr_);
     109    WeaponManager::loadWeapons();
     110
     111    // TODO: Use STL to make life easier. But it works this way too..
     112    /*bullets_ = new Bullet*[10];
     113    bulletsIndex_ = 0;
     114    bulletsSize_ = 10;*/
     115
    99116
    100117    // PLAYER SPACESHIP
     
    114131    // Construct a new spaceship and give it the node
    115132    playerShip_ = new OrxonoxShip(sceneMgr_, sceneMgr_->getRootSceneNode()
    116       ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)));
     133      ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)), bulletManager_);
    117134
    118135
     
    140157
    141158   
    142     // BULLET LIST FOR THE TEST APPLICATION
    143 
    144     // TODO: Use STL to make life easier. But it works this way too..
    145     bullets_ = new Bullet*[10];
    146     bulletsIndex_ = 0;
    147     bulletsSize_ = 10;
    148 
    149159
    150160    // HUMAN INTERFACE
     
    205215    if (playerShip_)
    206216      delete playerShip_;
     217    if (bulletManager_)
     218      delete bulletManager_;
     219
     220    WeaponManager::destroyWeapons();
    207221
    208222    // clean up the bullet list
    209     for (int i = 0; i < bulletsIndex_; i++)
     223    /*for (int i = 0; i < bulletsIndex_; i++)
    210224      delete bullets_[i];
    211     delete bullets_;
     225    delete bullets_;*/
    212226  }
    213227
     
    239253
    240254    // update the bullet positions
    241     for (int i = 0; i < bulletsIndex_; i++)
     255    bulletManager_->tick(time, deltaTime);
     256
     257    /*for (int i = 0; i < bulletsIndex_; i++)
    242258    {
    243259      bullets_[i]->node_->translate(bullets_[i]->speed_*deltaTime);
    244260      bullets_[i]->node_->yaw(Degree(deltaTime*100));
    245261      bullets_[i]->node_->roll(Degree(deltaTime*300));
    246     }
     262    }*/
    247263
    248264    // HUMAN INTERFACE
     
    447463      // Prevent continuous fire for the moment.
    448464      leftButtonDown_ = true;
     465
     466      playerShip_->fire();
    449467     
    450468      // let ship fire one shot with its only weapon (Barrels..)
    451       Bullet *tempBullet = playerShip_->fire();
     469      /*Bullet *tempBullet = playerShip_->fire();
    452470
    453471      // resize array if neccessary (double the size then)
     
    464482
    465483      // add the bullet to the list
    466       bullets_[bulletsIndex_++] = tempBullet;
     484      bullets_[bulletsIndex_++] = tempBullet;*/
    467485
    468486    }
     
    556574  {
    557575    camera_ = sceneMgr_->createCamera("PlayerCam");
    558     playerShip_->getRootNode()->attachObject(camera_);
     576    playerShip_->getRootNode()->getSceneNode()->attachObject(camera_);
    559577    camera_->setNearClipDistance(5);
    560578    camera_->setPosition(Vector3(0,10,500));
  • code/branches/main_reto/src/run_manager.h

    r182 r190  
    109109
    110110    // Bullet array
    111           Bullet **bullets_;
     111          /*Bullet **bullets_;
    112112          int bulletsSize_;
    113           int bulletsIndex_;
     113          int bulletsIndex_;*/
     114    weapon::BulletManager *bulletManager_;
    114115
    115116          // previously elapsed render time
Note: See TracChangeset for help on using the changeset viewer.