Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 17, 2008, 3:33:03 PM (16 years ago)
Author:
landauf
Message:
  • added a backlight to all SpaceShips, leaving a trail behind (configurable)
  • changed some lines in SpaceShipAI, AI seems to be more fair now…
  • fixed a bug in Math.cc algorithms to calculate radar positions and AI movement (division by zero and acos of 1.000001)
  • added destroy() and destroydelay to ParticleSpawner, so the smoketrail of a destroyed enemy stays visible for some seconds
  • added 2 lines to Orxonox.cc to make the length of the backlight-trail independend of the gamespeed

########################
# !!! MEDIA UPDATE !!! #
########################

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1602 r1608  
    3535#include <OgreSceneNode.h>
    3636
    37 #include "CameraHandler.h"
    3837#include "util/Convert.h"
    3938#include "util/Math.h"
     39
    4040#include "core/CoreIncludes.h"
    4141#include "core/ConfigValueIncludes.h"
    4242#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
    4352#include "GraphicsEngine.h"
    44 #include "core/input/InputManager.h"
    45 #include "tools/ParticleInterface.h"
    4653#include "RotatingProjectile.h"
    4754#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"
    5258
    5359namespace orxonox
     
    101107        this->tt1_ = 0;
    102108        this->tt2_ = 0;
     109        this->smoke_ = 0;
     110        this->fire_ = 0;
     111
     112        this->backlight_ = 0;
    103113
    104114        this->redNode_ = 0;
     
    143153                delete this->tt2_;
    144154
    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_)
    146164                InputManager::removeMouseHandler("SpaceShip");
    147165
     
    184202    void SpaceShip::init()
    185203    {
    186         // START CREATING THRUSTER
     204        // START CREATING THRUSTERS
    187205        this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
    188206        this->tt1_->createNewEmitter();
     
    216234        node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
    217235        node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
    218         // END CREATING THRUSTER
     236        // END CREATING THRUSTERS
    219237
    220238        // START CREATING BLINKING LIGHTS
     
    234252        // END CREATING BLINKING LIGHTS
    235253
    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);
    238262        this->attachObject(this->smoke_);
     263
     264        this->fire_ = new ParticleSpawner();
     265        this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
    239266        this->attachObject(this->fire_);
     267        // END CREATING ADDITIONAL EFFECTS
    240268
    241269        if (this->isExactlyA(Class(SpaceShip)))
     
    255283            this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    256284            this->chFarNode_->setScale(0.4, 0.4, 0.4);
     285            // END of testing crosshair
    257286        }
    258287
    259288        createCamera();
    260         // END of testing crosshair
    261289    }
    262290
     
    280308        this->rightThrusterFlare_.setVisible(this->isVisible());
    281309        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());
    284313    }
    285314
     
    336365        CameraHandler::getInstance()->requestFocus(cam_);
    337366      }
    338 
    339367    }
    340368
     
    378406    }
    379407
    380     int sgn(float x)
    381     {
    382         if (x >= 0)
    383             return 1;
    384         else
    385             return -1;
    386     }
    387 
    388408    std::string SpaceShip::whereAmI() {
    389         return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
    390         + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y)
    391         + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z);
     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);
    392412    }
    393413
     
    403423            this->cam_->tick(dt);
    404424
    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        }
    407437
    408438        if (this->redNode_ && this->greenNode_)
     
    521551        }
    522552
    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;
    535560    }
    536561
Note: See TracChangeset for help on using the changeset viewer.