Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 10, 2008, 1:37:36 AM (16 years ago)
Author:
rgrieder
Message:

merged gui back to trunk.
update the media repository!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1751 r1755  
    4949#include "CameraHandler.h"
    5050#include "ParticleSpawner.h"
     51#include "Settings.h"
    5152#include "RotatingProjectile.h"
    5253#include "ParticleProjectile.h"
     
    7980      }
    8081      assert(0);
     82      return 0;
    8183    }
    8284
     
    194196    void SpaceShip::init()
    195197    {
    196         // START CREATING THRUSTERS
    197         this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
    198         this->tt1_->createNewEmitter();
    199         this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
    200         this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1));
    201         this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1));
    202         this->tt1_->setSpeedFactor(3.0);
    203 
    204         Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a");
    205         node2a->setInheritScale(false);
    206         node2a->setScale(1, 1, 1);
    207         tt1_->addToSceneNode(node2a);
    208 
    209         this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
    210         this->tt2_->createNewEmitter();
    211         this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
    212         this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2));
    213         this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2));
    214 
    215         Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b");
    216         node2b->setInheritScale(false);
    217         node2b->setScale(0.5, 0.5, 0.5);
    218         tt2_->addToSceneNode(node2b);
    219 
    220         this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5));
    221         this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5));
    222 
    223         Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c");
    224         node2c->setInheritScale(false);
    225         node2c->setScale(2, 2, 2);
    226         node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
    227         node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
    228         // END CREATING THRUSTERS
    229 
    230         // START CREATING BLINKING LIGHTS
    231         this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
    232         this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
    233 
    234         this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
    235         this->redNode_->setInheritScale(false);
    236         this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
    237         this->greenNode_->setInheritScale(false);
    238 
    239         this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
    240         this->redNode_->setScale(0.3, 0.3, 0.3);
    241 
    242         this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
    243         this->greenNode_->setScale(0.3, 0.3, 0.3);
    244         // END CREATING BLINKING LIGHTS
    245 
    246         // START CREATING ADDITIONAL EFFECTS
    247         /*if(!network::Host::running() || network::Host::isServer()){
    248           this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
    249           this->attachObject(this->backlight_);
    250           this->backlight_->setPosition(-2.35, 0, 0.2);
    251           this->backlight_->setColour(this->getProjectileColour());
    252    
    253           this->smoke_ = new ParticleSpawner();
    254           this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
    255           this->attachObject(this->smoke_);
    256    
    257           this->fire_ = new ParticleSpawner();
    258           this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
    259           this->attachObject(this->fire_);
    260         }*/
    261         // END CREATING ADDITIONAL EFFECTS
    262 
    263         if (this->isExactlyA(Class(SpaceShip)))
    264         {
    265             // START of testing crosshair
    266             this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    267             this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    268 
    269             this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
    270             this->chNearNode_->setInheritScale(false);
    271             this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
    272             this->chFarNode_->setInheritScale(false);
    273 
    274             this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
    275             this->chNearNode_->setScale(0.2, 0.2, 0.2);
    276 
    277             this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    278             this->chFarNode_->setScale(0.4, 0.4, 0.4);
    279             // END of testing crosshair
     198        if (Settings::showsGraphics())
     199        {
     200            // START CREATING THRUSTERS
     201            this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
     202            this->tt1_->createNewEmitter();
     203            this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
     204            this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1));
     205            this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1));
     206            this->tt1_->setSpeedFactor(3.0);
     207
     208            Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a");
     209            node2a->setInheritScale(false);
     210            node2a->setScale(1, 1, 1);
     211            tt1_->addToSceneNode(node2a);
     212
     213            this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
     214            this->tt2_->createNewEmitter();
     215            this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
     216            this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2));
     217            this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2));
     218
     219            Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b");
     220            node2b->setInheritScale(false);
     221            node2b->setScale(0.5, 0.5, 0.5);
     222            tt2_->addToSceneNode(node2b);
     223
     224            this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5));
     225            this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5));
     226
     227            Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c");
     228            node2c->setInheritScale(false);
     229            node2c->setScale(2, 2, 2);
     230            node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
     231            node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
     232            // END CREATING THRUSTERS
     233
     234            // START CREATING BLINKING LIGHTS
     235            this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
     236            this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
     237
     238            this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
     239            this->redNode_->setInheritScale(false);
     240            this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
     241            this->greenNode_->setInheritScale(false);
     242
     243            this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
     244            this->redNode_->setScale(0.3, 0.3, 0.3);
     245
     246            this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
     247            this->greenNode_->setScale(0.3, 0.3, 0.3);
     248            // END CREATING BLINKING LIGHTS
     249
     250            // START CREATING ADDITIONAL EFFECTS
     251            /*this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
     252            this->attachObject(this->backlight_);
     253            this->backlight_->setPosition(-2.35, 0, 0.2);
     254            this->backlight_->setColour(this->getProjectileColour());
     255
     256            this->smoke_ = new ParticleSpawner();
     257            this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
     258            this->attachObject(this->smoke_);
     259
     260            this->fire_ = new ParticleSpawner();
     261            this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
     262            this->attachObject(this->fire_);
     263            */
     264            // END CREATING ADDITIONAL EFFECTS
     265
     266            if (this->isExactlyA(Class(SpaceShip)))
     267            {
     268                // START of testing crosshair
     269                this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     270                this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     271
     272                this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
     273                this->chNearNode_->setInheritScale(false);
     274                this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
     275                this->chFarNode_->setInheritScale(false);
     276
     277                this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
     278                this->chNearNode_->setScale(0.2, 0.2, 0.2);
     279
     280                this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
     281                this->chFarNode_->setScale(0.4, 0.4, 0.4);
     282                // END of testing crosshair
     283            }
    280284        }
    281285        // END of testing crosshair
     
    429433            this->cam_->tick(dt);
    430434
    431         if (this->smoke_)
    432             this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
    433         if (this->fire_)
    434             this->fire_->setVisible(this->isVisible() && this->health_ < 20);
    435 
    436         if (this->backlight_)
    437         {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
    438             if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
    439                 this->backlight_->setActive(false);
    440             else
    441                 this->backlight_->setActive(true);
    442         }
    443 
    444         if (this->redNode_ && this->greenNode_)
    445         {
    446             this->blinkTime_ += dt;
    447             float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
    448             float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
    449             this->redNode_->setScale(redScale, redScale, redScale);
    450             this->greenNode_->setScale(greenScale, greenScale, greenScale);
     435        if (Settings::showsGraphics())
     436        {
     437            if (this->smoke_)
     438                this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
     439            if (this->fire_)
     440                this->fire_->setVisible(this->isVisible() && this->health_ < 20);
     441
     442            if (this->backlight_)
     443            {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
     444                if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
     445                    this->backlight_->setActive(false);
     446                else
     447                    this->backlight_->setActive(true);
     448            }
     449
     450            if (this->redNode_ && this->greenNode_)
     451            {
     452                this->blinkTime_ += dt;
     453                float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
     454                float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
     455                this->redNode_->setScale(redScale, redScale, redScale);
     456                this->greenNode_->setScale(greenScale, greenScale, greenScale);
     457            }
    451458        }
    452459
Note: See TracChangeset for help on using the changeset viewer.