Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10021


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

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

Location:
code/branches/turretFS14
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt

    r10018 r10021  
    11<Template name=spaceshipturrettest>
    2   <SpaceShip
    3    hudtemplate            = spaceshiphud
    4    camerapositiontemplate = spaceshipturretcameras
    5    spawnparticlesource    = "Orxonox/fairytwirl"
    6    spawnparticleduration  = 3
    7    explosionchunks        = 6
    8 
    9    health            = 100
    10    maxhealth         = 200
    11    initialhealth     = 100
    12 
    13    shieldhealth        = 30
    14    initialshieldhealth = 30
    15    maxshieldhealth     = 50
    16    shieldabsorption    = 0.8
    17    reloadrate          = 1
    18    reloadwaittime      = 1
    19 
    20    primaryThrust     = 100
    21    auxilaryThrust    = 30
    22    rotationThrust    = 50
    23 
    24    lift = 1;
    25    stallSpeed = 220;
    26 
    27    boostPower            = 15
    28    boostPowerRate        = 1
    29    boostRate             = 5
    30    boostCooldownDuration = 10
    31 
    32    shakeFrequency = 15
    33    shakeAmplitude = 9
    34 
    35    collisionType     = "dynamic"
    36    mass              = 100
    37    linearDamping     = 0.7
    38    angularDamping    = 0.9999999
    39   >
     2  <Turret position="0,0,0" collisionType="dynamic" angularDamping=0.999999 mass=100>
    403    <attached>
    414        <Model position="0,0,0" pitch="90" roll="0" mesh="turretHead.mesh" scale3D="10,10,10"/>
     
    447        <SphereCollisionShape radius="10"   position = "0,0,0"/>
    458    </collisionShapes>
     9  </Turret>
    4610<?lua
    4711  include("../includes/weaponSettingsTurretTest.oxi")
    4812?>
    49   </SpaceShip>
    5013</Template>
    5114
  • 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.