Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

small adjustments

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.