Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (17 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2475 r2485  
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     38#include "core/Template.h"
    3839#include "core/XMLPort.h"
     40#include "objects/items/Engine.h"
    3941
    4042namespace orxonox
     
    5355        this->localLinearAcceleration_.setValue(0, 0, 0);
    5456        this->localAngularAcceleration_.setValue(0, 0, 0);
     57        this->bBoost_ = false;
     58        this->steering_ = Vector3::ZERO;
     59        this->engine_ = 0;
     60
    5561
    5662        this->bInvertYAxis_ = false;
     
    7076    SpaceShip::~SpaceShip()
    7177    {
     78        if (this->isInitialized() && this->engine_)
     79            delete this->engine_;
    7280    }
    7381
     
    7684        SUPER(SpaceShip, XMLPort, xmlelement, mode);
    7785
     86        XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
    7887        XMLPortParamVariable(SpaceShip, "primaryThrust",  primaryThrust_,  xmlelement, mode);
    7988        XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
     
    109118        SUPER(SpaceShip, tick, dt);
    110119
    111         if (this->isLocallyControlled())
     120        if (this->hasLocalController())
    112121        {
    113             this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
    114             this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
    115             if (this->localLinearAcceleration_.z() > 0)
    116                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
    117             else
    118                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    119             this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    120             this->localLinearAcceleration_.setValue(0, 0, 0);
     122            if (!this->isInMouseLook())
     123            {
     124                this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
     125                this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
     126                if (this->localLinearAcceleration_.z() > 0)
     127                    this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
     128                else
     129                    this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
     130                this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
     131                this->localLinearAcceleration_.setValue(0, 0, 0);
     132            }
    121133
    122134            this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
     
    129141    {
    130142        this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
     143        this->steering_.z = -value.x;
    131144    }
    132145
     
    134147    {
    135148        this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
     149        this->steering_.x = value.x;
    136150    }
    137151
     
    139153    {
    140154        this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
     155        this->steering_.y = value.x;
    141156    }
    142157
     
    144159    {
    145160        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
     161
     162        Pawn::rotateYaw(value);
    146163    }
    147164
     
    149166    {
    150167        this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
     168
     169        Pawn::rotatePitch(value);
    151170    }
    152171
     
    154173    {
    155174        this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
     175
     176        Pawn::rotateRoll(value);
    156177    }
    157178
     
    159180    {
    160181    }
     182
     183    void SpaceShip::boost()
     184    {
     185        this->bBoost_ = true;
     186    }
     187
     188    void SpaceShip::loadEngineTemplate()
     189    {
     190        if (this->enginetemplate_ != "")
     191        {
     192            Template* temp = Template::getTemplate(this->enginetemplate_);
     193
     194            if (temp)
     195            {
     196                Identifier* identifier = temp->getBaseclassIdentifier();
     197
     198                if (identifier)
     199                {
     200                    BaseObject* object = identifier->fabricate(this);
     201                    this->engine_ = dynamic_cast<Engine*>(object);
     202
     203                    if (this->engine_)
     204                    {
     205                        this->engine_->addTemplate(temp);
     206                        this->engine_->addToSpaceShip(this);
     207                    }
     208                    else
     209                    {
     210                        delete object;
     211                    }
     212                }
     213            }
     214        }
     215    }
     216
     217    void SpaceShip::setEngine(Engine* engine)
     218    {
     219        this->engine_ = engine;
     220        if (engine && engine->getShip() != this)
     221            engine->addToSpaceShip(this);
     222    }
    161223}
Note: See TracChangeset for help on using the changeset viewer.