Changeset 190 for code/branches/main_reto/src
- Timestamp:
- Nov 7, 2007, 10:03:26 PM (17 years ago)
- 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 33 33 TARGET_LINK_LIBRARIES(../bin/main ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${CEGUI_LIBRARIES} ${CEGUI_OGRE_LIBRARIES}) 34 34 35 #add main source dir 36 ADD_SUBDIRECTORY(weapon) -
code/branches/main_reto/src/main.cc
r171 r190 44 44 { 45 45 try { 46 // create an orxonox ap lication and run it46 // create an orxonox application and run it 47 47 orxonox::Orxonox myApp; 48 48 -
code/branches/main_reto/src/orxonox_prerequisites.h
r182 r190 32 32 namespace orxonox { 33 33 34 class AmmunitionDump;35 class Bullet;36 34 class CameraManager; 35 class InertialNode; 37 36 class OgreControl; 38 37 class Orxonox; … … 40 39 class OrxonoxScene; 41 40 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 } 44 52 45 53 } -
code/branches/main_reto/src/orxonox_ship.cc
r171 r190 33 33 34 34 #include "bullet.h" 35 #include "bullet_manager.h" 36 #include "inertial_node.h" 37 #include "weapon_manager.h" 35 38 36 39 #include "orxonox_ship.h" 37 #include "weapon_manager.h"38 40 39 41 40 42 namespace orxonox { 41 43 using namespace Ogre; 44 using namespace weapon; 42 45 43 46 /** … … 62 65 * @param mNode The scene node which the ship will be attached to later. 63 66 */ 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)), 66 70 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); 69 74 } 70 75 … … 76 81 OrxonoxShip::~OrxonoxShip() 77 82 { 83 if (mainWeapon_) 84 delete mainWeapon_; 85 if (rootNode_) 86 delete rootNode_; 78 87 } 79 88 … … 95 104 // TODO: names must be unique! use static variables.. 96 105 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)); 101 110 102 111 // 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"); 105 116 106 117 return true; … … 110 121 /** 111 122 * 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 113 124 * @param value Acceleration between 0 and 1 114 125 */ 115 126 void OrxonoxShip::setMainThrust(const Real value) 116 127 { 117 //currentThrust_ = value * baseThrust_;118 128 currentThrust_.z = value * baseThrust_; 119 129 } … … 122 132 /** 123 133 * 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 125 135 * @param value Acceleration between 0 and 1 126 136 */ 127 137 void OrxonoxShip::setSideThrust(const Real value) 128 138 { 129 //currentSideThrust_ = value * baseThrust_;130 139 currentThrust_.x = value * baseThrust_; 131 140 } … … 134 143 /** 135 144 * 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 137 146 * @param value Acceleration between 0 and 1 138 147 */ 139 148 void OrxonoxShip::setYThrust(const Real value) 140 149 { 141 //currentYThrust_ = value * baseThrust_;142 150 currentThrust_.y = value * baseThrust_; 143 151 } … … 150 158 void OrxonoxShip::turnUpAndDown(const Radian &angle) 151 159 { 152 rootNode_-> pitch(-angle, Node::TS_LOCAL);160 rootNode_->getSceneNode()->pitch(-angle, Node::TS_LOCAL); 153 161 } 154 162 … … 160 168 void OrxonoxShip::turnLeftAndRight(const Radian &angle) 161 169 { 162 rootNode_-> yaw(-angle, Node::TS_PARENT);170 rootNode_->getSceneNode()->yaw(-angle, Node::TS_PARENT); 163 171 } 164 172 … … 170 178 Vector3 OrxonoxShip::getSpeed() 171 179 { 172 return currentSpeed_;180 return rootNode_->getSpeed(); 173 181 } 174 182 … … 177 185 * @return The Root Node. 178 186 */ 179 SceneNode* OrxonoxShip::getRootNode()187 InertialNode* OrxonoxShip::getRootNode() 180 188 { 181 189 return rootNode_; … … 189 197 * @return Bullet containing speed and entity. 190 198 */ 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(); 204 202 } 205 203 … … 214 212 bool OrxonoxShip::tick(unsigned long time, Real deltaTime) 215 213 { 216 Quaternion quad = rootNode_->getOrientation(); 214 mainWeapon_->tick(time, deltaTime); 215 216 Quaternion quad = rootNode_->getSceneNode()->getOrientation(); 217 217 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); 223 221 224 222 return true; -
code/branches/main_reto/src/orxonox_ship.h
r182 r190 40 40 { 41 41 public: 42 OrxonoxShip(Ogre::SceneManager*, Ogre::SceneNode*);42 OrxonoxShip(Ogre::SceneManager*, Ogre::SceneNode*, weapon::BulletManager*); 43 43 virtual ~OrxonoxShip(); 44 44 … … 51 51 void turnLeftAndRight(const Ogre::Radian&); 52 52 53 Ogre::SceneNode* getRootNode();53 InertialNode* getRootNode(); 54 54 Ogre::Vector3 getSpeed(); 55 55 56 Bullet*fire();56 void fire(); 57 57 58 58 bool tick(unsigned long, Ogre::Real); … … 62 62 protected: 63 63 Ogre::SceneManager *sceneMgr_; 64 Ogre::SceneNode *rootNode_; 64 //Ogre::SceneNode *rootNode_; 65 InertialNode *rootNode_; 65 66 Ogre::Entity *shipEntity_; 66 67 67 Ogre::Vector3 currentSpeed_; // relative to space68 //Ogre::Vector3 currentSpeed_; // relative to space 68 69 Ogre::Vector3 currentThrust_; // relative to the ship 69 70 Ogre::Real baseThrust_; 70 71 int objectCounter_; 71 Ogre::Vector3 bulletSpeed_;72 72 73 WeaponManager *mainWeapon_; 73 weapon::BulletManager *bulletManager_; 74 //Ogre::Vector3 bulletSpeed_; 75 76 weapon::WeaponManager *mainWeapon_; 74 77 }; 75 78 -
code/branches/main_reto/src/run_manager.cc
r171 r190 52 52 #include "orxonox_ship.h" 53 53 #include "bullet.h" 54 #include "bullet_manager.h" 54 55 #include "camera_manager.h" 56 #include "weapon_manager.h" 57 #include "inertial_node.h" 55 58 56 59 #include "run_manager.h" … … 58 61 namespace orxonox { 59 62 using namespace Ogre; 63 using namespace weapon; 60 64 61 65 /** … … 97 101 // background scene (world objects, skybox, lights, etc.) 98 102 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 99 116 100 117 // PLAYER SPACESHIP … … 114 131 // Construct a new spaceship and give it the node 115 132 playerShip_ = new OrxonoxShip(sceneMgr_, sceneMgr_->getRootSceneNode() 116 ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)) );133 ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)), bulletManager_); 117 134 118 135 … … 140 157 141 158 142 // BULLET LIST FOR THE TEST APPLICATION143 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 149 159 150 160 // HUMAN INTERFACE … … 205 215 if (playerShip_) 206 216 delete playerShip_; 217 if (bulletManager_) 218 delete bulletManager_; 219 220 WeaponManager::destroyWeapons(); 207 221 208 222 // clean up the bullet list 209 for (int i = 0; i < bulletsIndex_; i++)223 /*for (int i = 0; i < bulletsIndex_; i++) 210 224 delete bullets_[i]; 211 delete bullets_; 225 delete bullets_;*/ 212 226 } 213 227 … … 239 253 240 254 // 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++) 242 258 { 243 259 bullets_[i]->node_->translate(bullets_[i]->speed_*deltaTime); 244 260 bullets_[i]->node_->yaw(Degree(deltaTime*100)); 245 261 bullets_[i]->node_->roll(Degree(deltaTime*300)); 246 } 262 }*/ 247 263 248 264 // HUMAN INTERFACE … … 447 463 // Prevent continuous fire for the moment. 448 464 leftButtonDown_ = true; 465 466 playerShip_->fire(); 449 467 450 468 // let ship fire one shot with its only weapon (Barrels..) 451 Bullet *tempBullet = playerShip_->fire();469 /*Bullet *tempBullet = playerShip_->fire(); 452 470 453 471 // resize array if neccessary (double the size then) … … 464 482 465 483 // add the bullet to the list 466 bullets_[bulletsIndex_++] = tempBullet; 484 bullets_[bulletsIndex_++] = tempBullet;*/ 467 485 468 486 } … … 556 574 { 557 575 camera_ = sceneMgr_->createCamera("PlayerCam"); 558 playerShip_->getRootNode()-> attachObject(camera_);576 playerShip_->getRootNode()->getSceneNode()->attachObject(camera_); 559 577 camera_->setNearClipDistance(5); 560 578 camera_->setPosition(Vector3(0,10,500)); -
code/branches/main_reto/src/run_manager.h
r182 r190 109 109 110 110 // Bullet array 111 Bullet **bullets_;111 /*Bullet **bullets_; 112 112 int bulletsSize_; 113 int bulletsIndex_; 113 int bulletsIndex_;*/ 114 weapon::BulletManager *bulletManager_; 114 115 115 116 // previously elapsed render time
Note: See TracChangeset
for help on using the changeset viewer.