Changeset 177 for code/branches/main_reto_vs05/src/orxonox_ship.cc
- Timestamp:
- Nov 7, 2007, 12:39:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto_vs05/src/orxonox_ship.cc
r169 r177 33 33 34 34 #include "bullet.h" 35 #include "bullet_manager.h" 35 36 36 37 #include "orxonox_ship.h" … … 62 63 * @param mNode The scene node which the ship will be attached to later. 63 64 */ 64 OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node) 65 OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node, 66 BulletManager *bulletManager) 65 67 : sceneMgr_(sceneMgr), rootNode_(node), currentSpeed_(Vector3(0, 0, 0)), 66 68 baseThrust_(1000), currentThrust_(Vector3::ZERO), 67 objectCounter_(0), bullet Speed_(400)69 objectCounter_(0), bulletManager_(bulletManager)//, bulletSpeed_(400) 68 70 { 69 71 } … … 76 78 OrxonoxShip::~OrxonoxShip() 77 79 { 80 if (mainWeapon_) 81 delete mainWeapon_; 78 82 } 79 83 … … 101 105 102 106 // initialise weapon(s) 103 SceneNode *mainWeaponNode = rootNode_->createChildSceneNode("mainWeaponNode"); 104 mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode, 1); 107 SceneNode *mainWeaponNode = rootNode_ 108 ->createChildSceneNode("mainWeaponNode"); 109 mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode, 110 bulletManager_, 1); 111 mainWeapon_->addWeapon("Barrel Gun"); 105 112 106 113 return true; … … 110 117 /** 111 118 * 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 .119 * The value should be between 0 and 1, with one beeing full thrust and 0 none 113 120 * @param value Acceleration between 0 and 1 114 121 */ 115 122 void OrxonoxShip::setMainThrust(const Real value) 116 123 { 117 //currentThrust_ = value * baseThrust_;118 124 currentThrust_.z = value * baseThrust_; 119 125 } … … 122 128 /** 123 129 * 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 .130 * The value should be between 0 and 1, with one beeing full thrust and 0 none 125 131 * @param value Acceleration between 0 and 1 126 132 */ 127 133 void OrxonoxShip::setSideThrust(const Real value) 128 134 { 129 //currentSideThrust_ = value * baseThrust_;130 135 currentThrust_.x = value * baseThrust_; 131 136 } … … 134 139 /** 135 140 * 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 .141 * The value should be between 0 and 1, with one beeing full thrust and 0 none 137 142 * @param value Acceleration between 0 and 1 138 143 */ 139 144 void OrxonoxShip::setYThrust(const Real value) 140 145 { 141 //currentYThrust_ = value * baseThrust_;142 146 currentThrust_.y = value * baseThrust_; 143 147 } … … 189 193 * @return Bullet containing speed and entity. 190 194 */ 191 Bullet*OrxonoxShip::fire()195 void OrxonoxShip::fire() 192 196 { 193 197 // TODO: Names must be unique! 194 SceneNode *temp = rootNode_->getParentSceneNode()->createChildSceneNode(198 /*SceneNode *temp = rootNode_->getParentSceneNode()->createChildSceneNode( 195 199 "BulletNode" + StringConverter::toString(objectCounter_)); 196 200 temp->setOrientation(rootNode_->getOrientation()); … … 201 205 + StringConverter::toString(objectCounter_++), "Barrel.mesh"), currentSpeed_ 202 206 + (rootNode_->getOrientation() * Vector3(0, 0, -1)).normalisedCopy() 203 * bulletSpeed_); 207 * bulletSpeed_);*/ 208 209 mainWeapon_->primaryFireRequest(); 204 210 } 205 211 … … 214 220 bool OrxonoxShip::tick(unsigned long time, Real deltaTime) 215 221 { 222 mainWeapon_->tick(time, deltaTime); 223 216 224 Quaternion quad = rootNode_->getOrientation(); 217 225 quad.normalise(); 218 226 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 227 222 228 rootNode_->translate(currentSpeed_ * deltaTime);
Note: See TracChangeset
for help on using the changeset viewer.