Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 19, 2018, 10:32:12 PM (7 years ago)
Author:
landauf
Message:

[Waypoints_HS17] removed lots of copy-paste- and otherwise unnecessary code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/orxonox/worldentities/Arrow.cc

    r11774 r11777  
    2121 *
    2222 *   Author:
    23  *      Oli Scheuss
     23 *      jostoffe
    2424 *   Co-authors:
    25  *      Damian 'Mozork' Frick
     25 *      ...
    2626 *
    2727 */
     
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "BulletDynamics/Dynamics/btRigidBody.h"
    3332
    3433namespace orxonox
     
    3635
    3736    RegisterClass(Arrow);
    38     /**
    39     @brief
    40         Constructor. Registers the object and initializes some default values.
    41     @param creator
    42         The creator of this object.
    43     */
     37
    4438    Arrow::Arrow(Context* context) : ControllableEntity(context)
    4539    {
    4640        RegisterObject(Arrow);
    47 
    48         this->localLinearAcceleration_.setValue(0, 0, 0);
    49         this->localAngularAcceleration_.setValue(0, 0, 0);
    50         this->primaryThrust_  = 100;
    51         this->auxiliaryThrust_ = 100;
    52         this->rotationThrust_ = 10;
    53 
    54         this->setCollisionType(CollisionType::Dynamic);
    55 
    56        
    5741    }
    58 
    59     /**
    60     @brief
    61         Destructor. Destroys controller, if present.
    62     */
    63     Arrow::~Arrow()
    64     {
    65 
    66     }
    67 
    68     /**
    69     @brief
    70         Method for creating a Arrow through XML.
    71     */
    72     void Arrow::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    73     {
    74         // This calls the XMLPort function of the parent class
    75         SUPER(Arrow, XMLPort, xmlelement, mode);
    76 
    77         XMLPortParam(Arrow, "primaryThrust", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
    78         XMLPortParam(Arrow, "auxiliaryThrust", setAuxiliaryThrust, getAuxiliaryThrust, xmlelement, mode);
    79         XMLPortParam(Arrow, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode);
    80      
    81     }
    82 
    83     /**
    84     @brief
    85         Defines which actions the Arrow has to take in each tick.
    86     @param dt
    87         The length of the tick.
    88     */
    89     void Arrow::tick(float dt)
    90     {
    91         SUPER(Arrow, tick, dt);
    92 
    93         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxiliaryThrust_);
    94         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxiliaryThrust_);
    95         if (this->localLinearAcceleration_.z() > 0)
    96             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxiliaryThrust_);
    97         else
    98             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    99         this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    100         this->localLinearAcceleration_.setValue(0, 0, 0);
    101 
    102         this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
    103         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
    104         this->localAngularAcceleration_.setValue(0, 0, 0);
    105     }
    106 
    107     /**
    108     @brief
    109         Moves the Arrow in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
    110     @param value
    111         The vector determining the amount of the movement.
    112     */
    113     void Arrow::moveFrontBack(const Vector2& value)
    114     {
    115         this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
    116     }
    117 
    118     /**
    119     @brief
    120         Moves the Arrow in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
    121     @param value
    122         The vector determining the amount of the movement.
    123     */
    124     void Arrow::moveRightLeft(const Vector2& value)
    125     {
    126         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
    127     }
    128 
    129     /**
    130     @brief
    131         Moves the Arrow in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
    132     @param value
    133         The vector determining the amount of the movement.
    134     */
    135     void Arrow::moveUpDown(const Vector2& value)
    136     {
    137         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
    138     }
    139 
    140     /**
    141     @brief
    142         Rotates the Arrow around the y-axis by the amount specified by the first component of the input 2-dim vector.
    143     @param value
    144         The vector determining the amount of the angular movement.
    145     */
    146     void Arrow::rotateYaw(const Vector2& value)
    147     {
    148         this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
    149     }
    150 
    151     /**
    152     @brief
    153         Rotates the Arrow around the x-axis by the amount specified by the first component of the input 2-dim vector.
    154     @param value
    155         The vector determining the amount of the angular movement.
    156     */
    157     void Arrow::rotatePitch(const Vector2& value)
    158     {
    159         this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
    160     }
    161 
    162     /**
    163     @brief
    164         Rotates the Arrow around the z-axis by the amount specified by the first component of the input 2-dim vector.
    165     @param value
    166         The vector determining the amount of the angular movement.
    167     */
    168     void Arrow::rotateRoll(const Vector2& value)
    169     {
    170         this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
    171     }
    172 
    173 
    17442}
Note: See TracChangeset for help on using the changeset viewer.