Changeset 1608 for code/trunk/src/orxonox/objects/SpaceShip.cc
- Timestamp:
- Jun 17, 2008, 3:33:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/SpaceShip.cc
r1602 r1608 35 35 #include <OgreSceneNode.h> 36 36 37 #include "CameraHandler.h"38 37 #include "util/Convert.h" 39 38 #include "util/Math.h" 39 40 40 #include "core/CoreIncludes.h" 41 41 #include "core/ConfigValueIncludes.h" 42 42 #include "core/Debug.h" 43 #include "core/XMLPort.h" 44 #include "core/ConsoleCommand.h" 45 #include "core/input/InputManager.h" 46 47 #include "network/Client.h" 48 49 #include "hud/HUD.h" 50 #include "tools/ParticleInterface.h" 51 43 52 #include "GraphicsEngine.h" 44 #include "core/input/InputManager.h"45 #include "tools/ParticleInterface.h"46 53 #include "RotatingProjectile.h" 47 54 #include "ParticleProjectile.h" 48 #include "core/XMLPort.h" 49 #include "core/ConsoleCommand.h" 50 #include "network/Client.h" 51 #include "hud/HUD.h" 55 #include "ParticleSpawner.h" 56 #include "Backlight.h" 57 #include "CameraHandler.h" 52 58 53 59 namespace orxonox … … 101 107 this->tt1_ = 0; 102 108 this->tt2_ = 0; 109 this->smoke_ = 0; 110 this->fire_ = 0; 111 112 this->backlight_ = 0; 103 113 104 114 this->redNode_ = 0; … … 143 153 delete this->tt2_; 144 154 145 if (setMouseEventCallback_) 155 if (this->smoke_) 156 this->smoke_->destroy(); 157 if (this->fire_) 158 this->fire_->destroy(); 159 160 if (this->backlight_) 161 delete this->backlight_; 162 163 if (this->setMouseEventCallback_) 146 164 InputManager::removeMouseHandler("SpaceShip"); 147 165 … … 184 202 void SpaceShip::init() 185 203 { 186 // START CREATING THRUSTER 204 // START CREATING THRUSTERS 187 205 this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low); 188 206 this->tt1_->createNewEmitter(); … … 216 234 node2c->attachObject(this->leftThrusterFlare_.getBillboardSet()); 217 235 node2c->attachObject(this->rightThrusterFlare_.getBillboardSet()); 218 // END CREATING THRUSTER 236 // END CREATING THRUSTERS 219 237 220 238 // START CREATING BLINKING LIGHTS … … 234 252 // END CREATING BLINKING LIGHTS 235 253 236 this->smoke_.setParticle("Orxonox/smoke5", LODParticle::normal); 237 this->fire_.setParticle("Orxonox/fire3", LODParticle::normal); 254 // START CREATING ADDITIONAL EFFECTS 255 this->backlight_ = new Backlight(this->maxSpeed_, 0.8); 256 this->attachObject(this->backlight_); 257 this->backlight_->setPosition(-2.35, 0, 0.2); 258 this->backlight_->setColour(this->getProjectileColour()); 259 260 this->smoke_ = new ParticleSpawner(); 261 this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3); 238 262 this->attachObject(this->smoke_); 263 264 this->fire_ = new ParticleSpawner(); 265 this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1); 239 266 this->attachObject(this->fire_); 267 // END CREATING ADDITIONAL EFFECTS 240 268 241 269 if (this->isExactlyA(Class(SpaceShip))) … … 255 283 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 256 284 this->chFarNode_->setScale(0.4, 0.4, 0.4); 285 // END of testing crosshair 257 286 } 258 287 259 288 createCamera(); 260 // END of testing crosshair261 289 } 262 290 … … 280 308 this->rightThrusterFlare_.setVisible(this->isVisible()); 281 309 this->leftThrusterFlare_.setVisible(this->isVisible()); 282 this->smoke_.setVisible(this->isVisible()); 283 this->fire_.setVisible(this->isVisible()); 310 this->smoke_->setVisible(this->isVisible()); 311 this->fire_->setVisible(this->isVisible()); 312 this->backlight_->setVisible(this->isVisible()); 284 313 } 285 314 … … 336 365 CameraHandler::getInstance()->requestFocus(cam_); 337 366 } 338 339 367 } 340 368 … … 378 406 } 379 407 380 int sgn(float x)381 {382 if (x >= 0)383 return 1;384 else385 return -1;386 }387 388 408 std::string SpaceShip::whereAmI() { 389 390 391 409 return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x) 410 + " " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y) 411 + " " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z); 392 412 } 393 413 … … 403 423 this->cam_->tick(dt); 404 424 405 this->smoke_.setVisible(this->isVisible() && this->health_ < 40); 406 this->fire_.setVisible(this->isVisible() && this->health_ < 20); 425 if (this->smoke_) 426 this->smoke_->setVisible(this->isVisible() && this->health_ < 40); 427 if (this->fire_) 428 this->fire_->setVisible(this->isVisible() && this->health_ < 20); 429 430 if (this->backlight_) 431 { // (there's already fire || we're to slow || we're moving backwards ) 432 if (this->health_ < 20 || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0) 433 this->backlight_->setActive(false); 434 else 435 this->backlight_->setActive(true); 436 } 407 437 408 438 if (this->redNode_ && this->greenNode_) … … 521 551 } 522 552 523 if( myShip_ ) 524 { 525 COUT(5) << "steering our ship: " << objectID << std::endl; 526 this->acceleration_.x = 0; 527 this->acceleration_.y = 0; 528 this->momentum_ = 0; 529 this->mouseXRotation_ = Radian(0); 530 this->mouseYRotation_ = Radian(0); 531 }/*else 532 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/ 533 534 this->bLMousePressed_ = false; 553 COUT(5) << "steering our ship: " << objectID << std::endl; 554 this->acceleration_.x = 0; 555 this->acceleration_.y = 0; 556 this->momentum_ = 0; 557 this->mouseXRotation_ = Radian(0); 558 this->mouseYRotation_ = Radian(0); 559 this->bLMousePressed_ = false; 535 560 } 536 561
Note: See TracChangeset
for help on using the changeset viewer.