Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/items/Engine.cc

    r8079 r8706  
    3535#include "Scene.h"
    3636#include "worldentities/pawns/SpaceShip.h"
    37 #include "tools/Shader.h"
     37#include "core/Template.h"
    3838
    3939namespace orxonox
     
    4747        this->ship_ = 0;
    4848        this->shipID_ = OBJECTID_UNKNOWN;
     49        this->relativePosition_ = Vector3(0,0,0);
    4950
    5051        this->boostFactor_ = 1.5;
     
    6263        this->accelerationUpDown_ = 0.0;
    6364
    64         this->boostBlur_ = 0;
    65 
    6665        this->speedAdd_ = 0.0;
    6766        this->speedMultiply_ = 1.0;
     
    7372    Engine::~Engine()
    7473    {
    75         if (this->isInitialized() && this->ship_)
    76         {
    77             this->ship_->setEngine(0);
    78 
    79             if (this->boostBlur_)
    80                 this->boostBlur_->destroy();
     74        if (this->isInitialized())
     75        {
     76            if (this->ship_ && this->ship_->hasEngine(this))
     77                this->ship_->removeEngine(this);
    8178        }
    8279    }
     
    9895        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    9996        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
     97
     98        XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode);
     99        XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode);
    100100    }
    101101
    102102    void Engine::setConfigValues()
    103103    {
    104         SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
    105             .description("Enable or disable the motion blur effect when moving very fast")
    106             .callback(this, &Engine::changedEnableMotionBlur);
    107         SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
    108             .description("Defines the strength of the motion blur effect");
    109104    }
    110105
     
    163158        SUPER(Engine, tick, dt);
    164159
    165         const Vector3& direction = this->getDirection();
     160        Vector3 direction = this->getDirection();
     161        float directionLength = direction.length();
     162        if (directionLength > 1.0f)
     163            direction /= directionLength; // normalize
     164       
    166165        Vector3 velocity = this->ship_->getLocalVelocity();
    167166        Vector3 acceleration = Vector3::ZERO;
     
    202201        }
    203202
    204         this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
    205 
    206         if (!this->ship_->getPermanentBoost())
    207             this->ship_->setBoost(false);
    208         this->ship_->setSteeringDirection(Vector3::ZERO);
    209 
    210         if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
    211         {
    212             this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
    213             this->boostBlur_->setCompositorName("Radial Blur");
    214         }
    215 
    216         if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    217         {
    218             float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f);
    219 
    220             this->boostBlur_->setVisible(blur > 0);
    221             this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     203        // NOTE: Bullet always uses global coordinates.
     204        this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_);
     205
     206        // Hack to reset a temporary variable "direction"
     207        this->ship_->oneEngineTickDone();
     208        if(!this->ship_->hasEngineTicksRemaining())
     209        {
     210            this->ship_->setSteeringDirection(Vector3::ZERO);
     211            this->ship_->resetEngineTicks();
    222212        }
    223213    }
     
    226216    {
    227217        SUPER(Engine, changedActivity);
    228 
    229         if (this->boostBlur_)
    230             this->boostBlur_->setVisible(this->isVisible());
    231218    }
    232219
     
    238225        {
    239226            this->shipID_ = ship->getObjectID();
    240             if (ship->getEngine() != this)
    241                 ship->setEngine(this);
    242 
    243             if (this->boostBlur_)
    244             {
    245                 this->boostBlur_->destroy();
    246                 this->boostBlur_ = 0;
    247             }
     227            if (!ship->hasEngine(this))
     228                ship->addEngine(this);
    248229        }
    249230    }
     
    267248    }
    268249
    269     void Engine::changedEnableMotionBlur()
    270     {
    271         if (!this->bEnableMotionBlur_)
    272         {
    273             this->boostBlur_->destroy();
    274             this->boostBlur_ = 0;
     250    void Engine::loadEngineTemplate()
     251    {
     252        if(!this->engineTemplate_.empty())
     253        {
     254            COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n";
     255            Template *temp = Template::getTemplate(this->engineTemplate_);
     256            if(temp)
     257            {
     258                this->addTemplate(temp);
     259            }
    275260        }
    276261    }
  • code/trunk/src/orxonox/items/Engine.h

    r8079 r8706  
    5454            inline SpaceShip* getShip() const
    5555                { return this->ship_; }
     56
     57            inline void setRelativePosition(const Vector3 &position)
     58                { this->relativePosition_ = position; }
     59            inline Vector3& getRelativePosition()
     60                { return this->relativePosition_; }
    5661
    5762            inline void setBoostFactor(float factor)
     
    119124                { this->speedMultiply_=speedMultiply; }
    120125
     126           
     127            inline void setEngineTemplate(const std::string& temp)
     128                { this->engineTemplate_ = temp; this->loadEngineTemplate(); }
     129            inline const std::string& getEngineTemplate() const
     130                { return this->engineTemplate_; }
     131
    121132        protected:
    122133            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
    123134                { return new std::vector<PickupCarrier*>(); }
    124135            virtual PickupCarrier* getCarrierParent(void) const;
     136           
     137            void loadEngineTemplate();
    125138
    126139        private:
    127140            void registerVariables();
    128141            void networkcallback_shipID();
    129             void changedEnableMotionBlur();
     142
     143            std::string engineTemplate_;
    130144
    131145            SpaceShip* ship_;
    132146            unsigned int shipID_;
     147            Vector3 relativePosition_;
    133148
    134149            float boostFactor_;
     
    148163            float accelerationLeftRight_;
    149164            float accelerationUpDown_;
    150 
    151             Shader* boostBlur_;
    152             float blurStrength_;
    153             bool bEnableMotionBlur_;
    154165    };
    155166}
Note: See TracChangeset for help on using the changeset viewer.