- Timestamp:
- Mar 12, 2009, 11:12:01 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
r2766 r2775 37 37 // PLACE YOUR CODE HERE 38 38 // create the factory for the drone 39 CreateFactory(Drone);40 39 41 40 Drone::Drone(BaseObject* creator) : ControllableEntity(creator) … … 45 44 // - register the drone class to the core 46 45 // - create a new controller and pass our this pointer to it as creator 47 46 48 47 this->localLinearAcceleration_.setValue(0, 0, 0); 49 48 this->localAngularAcceleration_.setValue(0, 0, 0); … … 52 51 this->rotationThrust_ = 10; 53 52 this->steering_ = Vector3::ZERO; 54 53 55 54 this->setCollisionType(WorldEntity::Dynamic); 56 57 myController_ = new DroneController(static_cast<BaseObject*>(this));55 56 this->myController_ = new DroneController(this); 58 57 } 59 58 60 59 Drone::~Drone() 61 60 { 62 if ( this->myController_)61 if (this->isInitialized() && this->myController_) 63 62 delete this->myController_; 64 63 } … … 79 78 // PLACE YOUR CODE HERE 80 79 // make sure the tick function of the base class gets called here 81 80 82 81 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 83 82 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 84 83 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_); 86 85 else 87 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);86 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 88 87 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 89 88 this->localLinearAcceleration_.setValue(0, 0, 0); 90 89 91 90 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 92 91 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 93 92 this->localAngularAcceleration_.setValue(0, 0, 0); 94 93 } 95 96 94 95 97 96 void Drone::moveFrontBack(const Vector2& value) 98 97 { … … 127 126 this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x); 128 127 } 129 130 128 }
Note: See TracChangeset
for help on using the changeset viewer.