[Orxonox-commit 61] r2765 - in branches/tutorial/src/orxonox/objects: controllers worldentities
scheusso at orxonox.net
scheusso at orxonox.net
Mon Mar 9 00:07:32 CET 2009
Author: scheusso
Date: 2009-03-09 00:07:31 +0100 (Mon, 09 Mar 2009)
New Revision: 2765
Modified:
branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
branches/tutorial/src/orxonox/objects/worldentities/Drone.h
Log:
the whole thing works kind of now
Modified: branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
===================================================================
--- branches/tutorial/src/orxonox/objects/controllers/DroneController.cc 2009-03-08 21:44:48 UTC (rev 2764)
+++ branches/tutorial/src/orxonox/objects/controllers/DroneController.cc 2009-03-08 23:07:31 UTC (rev 2765)
@@ -29,6 +29,7 @@
#include "OrxonoxStableHeaders.h"
#include "DroneController.h"
#include "objects/worldentities/Drone.h"
+#include "util/Math.h"
namespace orxonox
@@ -57,7 +58,10 @@
static float totaltime = 0;
totaltime += dt;
Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
- myDrone->rotateRoll(1000);
- myDrone->moveFrontBack( 1000 );
+ if(totaltime<1)
+ {
+ myDrone->moveFrontBack( -sqrt(dt) );
+ myDrone->rotatePitch(-dt);
+ }
}
}
Modified: branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/Drone.cc 2009-03-08 21:44:48 UTC (rev 2764)
+++ branches/tutorial/src/orxonox/objects/worldentities/Drone.cc 2009-03-08 23:07:31 UTC (rev 2765)
@@ -43,22 +43,25 @@
//put your code in here:
// - register the drone class to the core
// - create a new controller and pass our this pointer to it as creator
- this->myController = 0;
+ this->myController_ = 0;
RegisterObject(Drone);
this->localLinearAcceleration_.setValue(0, 0, 0);
- this->localAngularAcceleration_.setValue(0, 0, 0);this->rotationThrust_ = 0;
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->primaryThrust_ = 100;
+ this->auxilaryThrust_ = 100;
+ this->rotationThrust_ = 10;
this->steering_ = Vector3::ZERO;
this->setCollisionType(WorldEntity::Dynamic);
- myController = new DroneController(static_cast<BaseObject*>(this));
+ myController_ = new DroneController(static_cast<BaseObject*>(this));
}
Drone::~Drone()
{
- if( this->myController )
- delete this->myController;
+ if( this->myController_ )
+ delete this->myController_;
}
void Drone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -66,6 +69,8 @@
// this calls the XMLPort function of the parent class
SUPER(Drone, XMLPort, xmlelement, mode);
+ XMLPortParamVariable(Drone, "primaryThrust", primaryThrust_, xmlelement, mode);
+ XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode);
}
@@ -75,6 +80,15 @@
//if (this->hasLocalController())
//{
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
+ else
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
+ this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+
this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
this->localAngularAcceleration_.setValue(0, 0, 0);
Modified: branches/tutorial/src/orxonox/objects/worldentities/Drone.h
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/Drone.h 2009-03-08 21:44:48 UTC (rev 2764)
+++ branches/tutorial/src/orxonox/objects/worldentities/Drone.h 2009-03-08 23:07:31 UTC (rev 2765)
@@ -69,11 +69,13 @@
{ this->rotateRoll(Vector2(value, 0)); }
private:
- DroneController *myController;
+ DroneController *myController_;
Vector3 steering_;
btVector3 localLinearAcceleration_;
btVector3 localAngularAcceleration_;
+ float primaryThrust_;
+ float auxilaryThrust_;
float rotationThrust_;
};
More information about the Orxonox-commit
mailing list