Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 12, 2009, 11:12:01 AM (16 years ago)
Author:
landauf
Message:

small adjustments

Location:
code/branches/tutorial/src/orxonox/objects/worldentities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutorial/src/orxonox/objects/worldentities/Drone.cc

    r2766 r2775  
    3737    // PLACE YOUR CODE HERE
    3838    // create the factory for the drone
    39     CreateFactory(Drone);
    4039
    4140    Drone::Drone(BaseObject* creator) : ControllableEntity(creator)
     
    4544        // - register the drone class to the core
    4645        // - create a new controller and pass our this pointer to it as creator
    47        
     46
    4847        this->localLinearAcceleration_.setValue(0, 0, 0);
    4948        this->localAngularAcceleration_.setValue(0, 0, 0);
     
    5251        this->rotationThrust_ = 10;
    5352        this->steering_ = Vector3::ZERO;
    54        
     53
    5554        this->setCollisionType(WorldEntity::Dynamic);
    56        
    57         myController_ = new DroneController(static_cast<BaseObject*>(this));
     55
     56        this->myController_ = new DroneController(this);
    5857    }
    5958
    6059    Drone::~Drone()
    6160    {
    62         if( this->myController_ )
     61        if (this->isInitialized() && this->myController_)
    6362            delete this->myController_;
    6463    }
     
    7978        // PLACE YOUR CODE HERE
    8079        // make sure the tick function of the base class gets called here
    81        
     80
    8281        this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
    8382        this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
    8483        if (this->localLinearAcceleration_.z() > 0)
    85           this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
     84            this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
    8685        else
    87           this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
     86            this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    8887        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    8988        this->localLinearAcceleration_.setValue(0, 0, 0);
    90    
     89
    9190        this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
    9291        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
    9392        this->localAngularAcceleration_.setValue(0, 0, 0);
    9493    }
    95    
    96    
     94
     95
    9796    void Drone::moveFrontBack(const Vector2& value)
    9897    {
     
    127126        this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
    128127    }
    129    
    130128}
  • code/branches/tutorial/src/orxonox/objects/worldentities/Drone.h

    r2766 r2775  
    4545            virtual void tick(float dt);
    4646
    47            
     47
    4848            virtual void moveFrontBack(const Vector2& value);
    4949            virtual void moveRightLeft(const Vector2& value);
     
    5353            virtual void rotatePitch(const Vector2& value);
    5454            virtual void rotateRoll(const Vector2& value);
    55            
    56            
     55
     56
    5757            inline void moveFrontBack(float value)
    5858            { this->moveFrontBack(Vector2(value, 0)); }
     
    6161            inline void moveUpDown(float value)
    6262            { this->moveUpDown(Vector2(value, 0)); }
    63            
     63
    6464            inline void rotateYaw(float value)
    6565            { this->rotateYaw(Vector2(value, 0)); }
     
    6868            inline void rotateRoll(float value)
    6969            { this->rotateRoll(Vector2(value, 0)); }
    70            
     70
    7171        private:
    72             DroneController *myController_;
    73            
     72            DroneController* myController_;
     73
    7474            Vector3 steering_;
    7575            btVector3 localLinearAcceleration_;
Note: See TracChangeset for help on using the changeset viewer.