Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2009, 12:07:31 AM (16 years ago)
Author:
scheusso
Message:

the whole thing works kind of now

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

Legend:

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

    r2764 r2765  
    4444        // - register the drone class to the core
    4545        // - create a new controller and pass our this pointer to it as creator
    46         this->myController = 0;
     46        this->myController_ = 0;
    4747        RegisterObject(Drone);
    4848       
    4949        this->localLinearAcceleration_.setValue(0, 0, 0);
    50         this->localAngularAcceleration_.setValue(0, 0, 0);this->rotationThrust_ = 0;
     50        this->localAngularAcceleration_.setValue(0, 0, 0);
     51        this->primaryThrust_  = 100;
     52        this->auxilaryThrust_ = 100;
     53        this->rotationThrust_ = 10;
    5154        this->steering_ = Vector3::ZERO;
    5255       
    5356        this->setCollisionType(WorldEntity::Dynamic);
    5457       
    55         myController = new DroneController(static_cast<BaseObject*>(this));
     58        myController_ = new DroneController(static_cast<BaseObject*>(this));
    5659    }
    5760
    5861    Drone::~Drone()
    5962    {
    60         if( this->myController )
    61             delete this->myController;
     63        if( this->myController_ )
     64            delete this->myController_;
    6265    }
    6366
     
    6770        SUPER(Drone, XMLPort, xmlelement, mode);
    6871
     72        XMLPortParamVariable(Drone, "primaryThrust",  primaryThrust_,  xmlelement, mode);
     73        XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
    6974        XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode);
    7075    }
     
    7681        //if (this->hasLocalController())
    7782        //{
     83            this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
     84            this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
     85            if (this->localLinearAcceleration_.z() > 0)
     86              this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
     87            else
     88              this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
     89            this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
     90            this->localLinearAcceleration_.setValue(0, 0, 0);
     91       
    7892            this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
    7993            this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
  • code/branches/tutorial/src/orxonox/objects/worldentities/Drone.h

    r2763 r2765  
    7070           
    7171        private:
    72             DroneController *myController;
     72            DroneController *myController_;
    7373           
    7474            Vector3 steering_;
    7575            btVector3 localLinearAcceleration_;
    7676            btVector3 localAngularAcceleration_;
     77            float primaryThrust_;
     78            float auxilaryThrust_;
    7779            float rotationThrust_;
    7880    };
Note: See TracChangeset for help on using the changeset viewer.