Changeset 2765
- Timestamp:
- Mar 9, 2009, 12:07:31 AM (16 years ago)
- Location:
- code/branches/tutorial/src/orxonox/objects
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
r2763 r2765 30 30 #include "DroneController.h" 31 31 #include "objects/worldentities/Drone.h" 32 #include "util/Math.h" 32 33 33 34 … … 58 59 totaltime += dt; 59 60 Drone *myDrone = static_cast<Drone*>(this->getControllableEntity()); 60 myDrone->rotateRoll(1000); 61 myDrone->moveFrontBack( 1000 ); 61 if(totaltime<1) 62 { 63 myDrone->moveFrontBack( -sqrt(dt) ); 64 myDrone->rotatePitch(-dt); 65 } 62 66 } 63 67 } -
code/branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
r2764 r2765 44 44 // - register the drone class to the core 45 45 // - create a new controller and pass our this pointer to it as creator 46 this->myController = 0;46 this->myController_ = 0; 47 47 RegisterObject(Drone); 48 48 49 49 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; 51 54 this->steering_ = Vector3::ZERO; 52 55 53 56 this->setCollisionType(WorldEntity::Dynamic); 54 57 55 myController = new DroneController(static_cast<BaseObject*>(this));58 myController_ = new DroneController(static_cast<BaseObject*>(this)); 56 59 } 57 60 58 61 Drone::~Drone() 59 62 { 60 if( this->myController )61 delete this->myController ;63 if( this->myController_ ) 64 delete this->myController_; 62 65 } 63 66 … … 67 70 SUPER(Drone, XMLPort, xmlelement, mode); 68 71 72 XMLPortParamVariable(Drone, "primaryThrust", primaryThrust_, xmlelement, mode); 73 XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); 69 74 XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode); 70 75 } … … 76 81 //if (this->hasLocalController()) 77 82 //{ 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 78 92 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 79 93 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); -
code/branches/tutorial/src/orxonox/objects/worldentities/Drone.h
r2763 r2765 70 70 71 71 private: 72 DroneController *myController ;72 DroneController *myController_; 73 73 74 74 Vector3 steering_; 75 75 btVector3 localLinearAcceleration_; 76 76 btVector3 localAngularAcceleration_; 77 float primaryThrust_; 78 float auxilaryThrust_; 77 79 float rotationThrust_; 78 80 };
Note: See TracChangeset
for help on using the changeset viewer.