Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 3, 2014, 4:04:32 PM (10 years ago)
Author:
muemart
Message:

Turret: Move the turret up in the hierarchy, edit the template accordingly

Location:
code/branches/turretFS14/src/modules/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/turretFS14/src/modules/objects/Turret.cc

    r10018 r10021  
    2929#include "Turret.h"
    3030#include "core/CoreIncludes.h"
    31 #include "OgreQuaternion.h"
    3231#include "core/XMLPort.h"
    33 #include "controllers/WaypointPatrolController.h"
     32#include "BulletDynamics/Dynamics/btRigidBody.h"
    3433
    3534namespace orxonox
     
    4241     * @brief Constructor
    4342     */
    44     Turret::Turret(Context* context) : SpaceShip(context)
     43    Turret::Turret(Context* context) : Pawn(context)
    4544    {
    4645        RegisterObject(Turret);
     
    4948        this->maxYaw_ = 0;
    5049        this->gotOrient_ = false;
     50        this->rotationThrust_ = 50;
     51
     52        this->localAngularAcceleration_.setValue(0, 0, 0);
    5153    }
    5254
     
    6870        if (this->maxPitch_ >= 180) //no need to check, if the limit too big
    6971        {
    70            SpaceShip::rotatePitch(value);
    71            return;
     72            this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
     73            return;
    7274        }
    7375
     
    9294        if ((val >= lowerBound || value.x > 0) && (val <= upperBound || value.x < 0))
    9395        {
    94             SpaceShip::rotatePitch(value);
     96            this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
    9597        }
    9698        return;
     
    105107        if (this->maxPitch_ >= 180) //no need to check, if the limit too big
    106108        {
    107            SpaceShip::rotateYaw(value);
    108            return;
     109            this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
     110            return;
    109111        }
    110112
     
    129131        if ((val >= lowerBound || value.x > 0) && (val <= upperBound || value.x < 0))
    130132        {
    131             SpaceShip::rotateYaw(value);
     133           this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
    132134        }
    133135        return;
     
    148150    void Turret::tick(float dt)
    149151    {
     152        SUPER(Turret, tick, dt);
     153
    150154        if(!gotOrient_)
    151155        {
     
    155159        Quaternion drot = startOrientInv_ * this->getOrientation();
    156160        orxout() << "Pitch: " << drot.getPitch(false).valueDegrees() << "\tYaw: " << drot.getYaw(false).valueDegrees() << "\tRoll: " << drot.getRoll(false).valueDegrees() << endl;
    157         SUPER(Turret, tick, dt);
     161       
     162        this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
     163        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
     164        this->localAngularAcceleration_.setValue(0, 0, 0);
    158165    }
    159166
  • code/branches/turretFS14/src/modules/objects/Turret.h

    r10018 r10021  
    4040
    4141#include "worldentities/pawns/SpaceShip.h"
    42 #include "controllers/TurretController.h"
    4342
    4443namespace orxonox
    4544{
    46     class _ObjectsExport Turret : public SpaceShip
     45    class _ObjectsExport Turret : public Pawn
    4746    {
    4847        public:
     
    7473            Ogre::Real maxYaw_;
    7574            Quaternion startOrientInv_;
     75            float rotationThrust_;
     76
     77            btVector3 localAngularAcceleration_;
    7678
    7779            Ogre::Real boundBetween(float val, float lowerBound, float upperBound);
Note: See TracChangeset for help on using the changeset viewer.