[460] | 1 | #include <string> |
---|
| 2 | #include <sstream> |
---|
| 3 | |
---|
| 4 | #include "WorldEntity.h" |
---|
| 5 | #include "../core/CoreIncludes.h" |
---|
| 6 | |
---|
| 7 | namespace orxonox |
---|
| 8 | { |
---|
| 9 | CreateFactory(WorldEntity); |
---|
| 10 | |
---|
| 11 | Ogre::SceneManager* WorldEntity::sceneManager_s = 0; |
---|
| 12 | unsigned int WorldEntity::worldEntityCounter_s = 0; |
---|
| 13 | int WorldEntity::num_s = 0; |
---|
| 14 | |
---|
| 15 | WorldEntity::WorldEntity() |
---|
| 16 | { |
---|
| 17 | RegisterObject(WorldEntity); |
---|
| 18 | |
---|
| 19 | if (WorldEntity::sceneManager_s) |
---|
| 20 | WorldEntity::sceneManager_s->setAmbientLight( ColourValue( 1, 1, 1 ) ); // remove this |
---|
| 21 | |
---|
| 22 | if (WorldEntity::sceneManager_s) |
---|
| 23 | { |
---|
| 24 | std::ostringstream name; |
---|
| 25 | name << (WorldEntity::worldEntityCounter_s++); |
---|
| 26 | this->setName("WorldEntity" + name.str()); |
---|
| 27 | node_ = WorldEntity::sceneManager_s->getRootSceneNode()->createChildSceneNode(this->getName()); |
---|
| 28 | } |
---|
| 29 | |
---|
[472] | 30 | this->bStatic_ = true; |
---|
[460] | 31 | this->velocity_ = Vector3(0, 0, 0); |
---|
[472] | 32 | this->acceleration_ = Vector3(0, 0, 0); |
---|
| 33 | this->rotationAxis_ = Vector3(0, 1, 0); |
---|
| 34 | this->rotationRate_ = 0; |
---|
| 35 | this->momentum_ = 0; |
---|
[460] | 36 | } |
---|
| 37 | |
---|
| 38 | WorldEntity::~WorldEntity() |
---|
| 39 | { |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | void WorldEntity::tick(float dt) |
---|
| 43 | { |
---|
| 44 | if (!this->bStatic_) |
---|
| 45 | { |
---|
[472] | 46 | this->velocity_ += (dt * this->acceleration_); |
---|
[461] | 47 | this->translate(dt * this->velocity_); |
---|
[472] | 48 | |
---|
| 49 | this->rotationRate_ += (dt * this->momentum_); |
---|
| 50 | this->rotate(this->rotationAxis_, dt * this->rotationRate_); |
---|
[460] | 51 | } |
---|
| 52 | } |
---|
| 53 | } |
---|