Changeset 1608
- Timestamp:
- Jun 17, 2008, 3:33:03 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/bin/levels/sample.oxw
r1602 r1608 9 9 </audio--> 10 10 11 <Ambient colourvalue="0. 1, 0.1, 0.1" />11 <Ambient colourvalue="0.5, 0.5, 0.5" /> 12 12 <Skybox src="Orxonox/Starbox" /> 13 13 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" /> -
code/trunk/src/core/BaseObject.h
r1558 r1608 66 66 67 67 /** @brief Sets the state of the objects activity. @param bActive True = active */ 68 inline void setActiv ity(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }68 inline void setActive(bool bActive) { this->bActive_ = bActive; this->changedActivity(); } 69 69 /** @brief Returns the state of the objects activity. @return The state of the activity */ 70 70 inline bool isActive() const { return this->bActive_; } … … 73 73 74 74 /** @brief Sets the state of the objects visibility. @param bVisible True = visible */ 75 inline void setVisib ility(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }75 inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); } 76 76 /** @brief Returns the state of the objects visibility. @return The state of the visibility */ 77 77 inline bool isVisible() const { return this->bVisible_; } -
code/trunk/src/orxonox/CMakeLists.txt
r1555 r1608 20 20 21 21 objects/Ambient.cc 22 objects/Backlight.cc 22 23 objects/Camera.cc 23 24 objects/CameraHandler.cc -
code/trunk/src/orxonox/Orxonox.cc
r1577 r1608 72 72 #include "console/InGameConsole.h" 73 73 #include "objects/Tickable.h" 74 #include "objects/Backlight.h" 74 75 #include "tools/ParticleInterface.h" 75 76 … … 169 170 float change = factor / Orxonox::getSingleton()->getTimeFactor(); 170 171 Orxonox::getSingleton()->timefactor_ = factor; 171 172 172 for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it) 173 173 it->setSpeedFactor(it->getSpeedFactor() * change); 174 175 for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it) 176 it->setTimeFactor(Orxonox::getSingleton()->getTimeFactor()); 174 177 } 175 178 -
code/trunk/src/orxonox/objects/ParticleSpawner.cc
r1602 r1608 33 33 #include "core/Executor.h" 34 34 #include "tools/ParticleInterface.h" 35 #include "GraphicsEngine.h" 35 36 36 37 namespace orxonox … … 44 45 } 45 46 46 ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float delay, const Vector3& direction)47 ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction) 47 48 { 48 49 RegisterObject(ParticleSpawner); 49 this->setParticle(templateName, detaillevel, lifetime, delay, direction);50 this->setParticle(templateName, detaillevel, lifetime, startdelay, destroydelay, direction); 50 51 } 51 52 52 void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float delay, const Vector3& direction)53 void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction) 53 54 { 54 55 ExecutorMember<ParticleSpawner>* executor = createExecutor(createFunctor(&ParticleSpawner::createParticleSpawner)); 56 this->destroydelay_ = destroydelay; 55 57 executor->setDefaultValues(lifetime); 56 this->timer_.setTimer( delay, false, this, executor);58 this->timer_.setTimer(startdelay, false, this, executor); 57 59 this->particle_ = new ParticleInterface(templateName, detaillevel); 58 60 this->particle_->addToSceneNode(this->getNode()); … … 72 74 } 73 75 }; 76 77 void ParticleSpawner::destroy() 78 { 79 this->setPosition(this->getNode()->getParent()->getPosition()); 80 this->getNode()->getParent()->removeChild(this->getNode()); 81 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->addChild(this->getNode()); 82 if (this->particle_) 83 this->particle_->setEnabled(false); 84 if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_) 85 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner))); 86 } 74 87 75 88 void ParticleSpawner::createParticleSpawner(float lifetime) -
code/trunk/src/orxonox/objects/ParticleSpawner.h
r1602 r1608 41 41 public: 42 42 ParticleSpawner(); 43 ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float delay = 0, const Vector3& direction = Vector3::ZERO);43 ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO); 44 44 virtual ~ParticleSpawner(); 45 void destroy(); 45 46 46 void setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float delay = 0, const Vector3& direction = Vector3::ZERO);47 void setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO); 47 48 inline ParticleInterface* getParticleInterface() const 48 49 { return this->particle_; } … … 56 57 Timer<ParticleSpawner> timer_; 57 58 ParticleInterface* particle_; 59 float destroydelay_; 58 60 }; 59 61 } -
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 -
code/trunk/src/orxonox/objects/SpaceShip.h
r1602 r1608 37 37 #include "Model.h" 38 38 #include "tools/BillboardSet.h" 39 #include "ParticleSpawner.h"40 39 41 40 namespace orxonox … … 145 144 BillboardSet rightThrusterFlare_; 146 145 146 Backlight* backlight_; 147 147 148 BillboardSet redBillboard_; 148 149 BillboardSet greenBillboard_; … … 151 152 float blinkTime_; 152 153 153 ParticleSpawner smoke_;154 ParticleSpawner fire_;154 ParticleSpawner* smoke_; 155 ParticleSpawner* fire_; 155 156 156 157 BillboardSet crosshairNear_; -
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1566 r1608 102 102 newenemy->XMLPort(xmlelement, XMLPort::LoadObject); 103 103 104 ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0 .0, newenemy->getOrth());104 ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0, 0, newenemy->getOrth()); 105 105 spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50); 106 106 spawneffect->create(); … … 131 131 // search enemy 132 132 random = rnd(maxrand); 133 if (random < 20&& (!this->target_))133 if (random < 15 && (!this->target_)) 134 134 this->searchNewTarget(); 135 135 … … 146 146 // fly somewhere 147 147 random = rnd(maxrand); 148 if (random < 40 && (!this->bHasTargetPosition_ && !this->target_))148 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 149 149 this->searchNewTargetPosition(); 150 150 … … 201 201 Vector3 ringdirection = Vector3(rnd(), rnd(), rnd()); 202 202 ringdirection.normalise(); 203 explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, ringdirection);204 explosion->setPosition(this->getPosition()); 205 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 206 explosion->setScale(4); 207 explosion->create(); 208 explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, ringdirection);203 explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, 0, ringdirection); 204 explosion->setPosition(this->getPosition()); 205 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 206 explosion->setScale(4); 207 explosion->create(); 208 explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, 0, ringdirection); 209 209 explosion->setPosition(this->getPosition()); 210 210 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); … … 235 235 { 236 236 Vector2 coord = get2DViewdirection(this->getPosition(), this->getDir(), this->getOrth(), this->targetPosition_); 237 this->setMoveYaw(0.8 * sgn(coord.x)); 238 this->setMovePitch(0.8 * sgn(coord.y)); 239 240 if ((this->targetPosition_ - this->getPosition()).length() > 500) 237 238 float distance = (this->targetPosition_ - this->getPosition()).length(); 239 if (this->target_ || distance > 50) 240 { 241 // Multiply with 0.8 to make them a bit slower 242 this->setMoveYaw(0.8 * sgn(coord.x) * coord.x*coord.x); 243 this->setMovePitch(0.8 * sgn(coord.y) * coord.y*coord.y); 244 } 245 246 if (this->target_ && distance < 1000 && this->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 247 this->setMoveLongitudinal(-0.5); // They don't brake with full power to give the player a chance 248 else if (!this->target_ && distance <= this->getVelocity().length() / (2 * this->getTransAcc())) 249 this->setMoveLongitudinal(-1.0); 250 else 241 251 this->setMoveLongitudinal(0.8); 242 243 if (this->isCloseAtTarget(300) && this->target_)244 {245 if (this->getVelocity().length() > this->target_->getVelocity().length())246 this->setMoveLongitudinal(-0.5);247 }248 252 } 249 253 … … 306 310 void SpaceShipAI::shipDied(SpaceShipAI* ship) 307 311 { 308 this->forgetTarget(); 309 this->searchNewTargetPosition(); 312 if (ship == this->target_) 313 { 314 this->forgetTarget(); 315 this->searchNewTargetPosition(); 316 } 310 317 } 311 318 } -
code/trunk/src/orxonox/tools/Timer.h
r1552 r1608 95 95 inline bool isActive() const 96 96 { return this->bActive_; } 97 /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */ 98 inline float getRemainingTime() const 99 { return this->time_; } 97 100 /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */ 98 101 inline void addTime(float time) -
code/trunk/src/util/Math.cc
r1566 r1608 75 75 { 76 76 orxonox::Vector3 distance = otherposition - myposition; 77 return acos(mydirection.dotProduct(distance) / distance.length()); 77 float distancelength = distance.length(); 78 if (distancelength == 0) 79 return 0; 80 else 81 return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)); 78 82 } 79 83 … … 84 88 // project difference vector on our plane 85 89 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 86 float angle = acos(myorthonormal.dotProduct(projection) / projection.length()); 90 91 float projectionlength = projection.length(); 92 if (projectionlength == 0) return orxonox::Vector2(0, 0); 93 float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1)); 87 94 88 95 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0) … … 98 105 // project difference vector on our plane 99 106 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 100 float angle = acos(myorthonormal.dotProduct(projection) / projection.length()); 101 float radius = acos(mydirection.dotProduct(distance) / distance.length()) / Ogre::Math::PI; 107 108 float projectionlength = projection.length(); 109 if (projectionlength == 0) return orxonox::Vector2(0, 0); 110 float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1)); 111 112 float distancelength = distance.length(); 113 if (distancelength == 0) return orxonox::Vector2(0, 0); 114 float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI; 102 115 103 116 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
Note: See TracChangeset
for help on using the changeset viewer.