| 1 | /* |
|---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
|---|
| 3 | * |
|---|
| 4 | * |
|---|
| 5 | * License notice: |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or |
|---|
| 8 | * modify it under the terms of the GNU General Public License |
|---|
| 9 | * as published by the Free Software Foundation; either version 2 |
|---|
| 10 | * of the License, or (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|---|
| 20 | * |
|---|
| 21 | * Author: |
|---|
| 22 | * ... |
|---|
| 23 | * Co-authors: |
|---|
| 24 | * ... |
|---|
| 25 | * |
|---|
| 26 | */ |
|---|
| 27 | |
|---|
| 28 | #include <string> |
|---|
| 29 | #include <sstream> |
|---|
| 30 | |
|---|
| 31 | #include "WorldEntity.h" |
|---|
| 32 | #include "../core/CoreIncludes.h" |
|---|
| 33 | #include "../orxonox.h" |
|---|
| 34 | |
|---|
| 35 | namespace orxonox |
|---|
| 36 | { |
|---|
| 37 | CreateFactory(WorldEntity); |
|---|
| 38 | |
|---|
| 39 | unsigned int WorldEntity::worldEntityCounter_s = 0; |
|---|
| 40 | |
|---|
| 41 | WorldEntity::WorldEntity() |
|---|
| 42 | { |
|---|
| 43 | RegisterObject(WorldEntity); |
|---|
| 44 | |
|---|
| 45 | std::cout << "10_1\n"; |
|---|
| 46 | if (Orxonox::getSingleton()->getSceneManager()) |
|---|
| 47 | { |
|---|
| 48 | std::cout << "10_2\n"; |
|---|
| 49 | std::ostringstream name; |
|---|
| 50 | name << (WorldEntity::worldEntityCounter_s++); |
|---|
| 51 | this->setName("WorldEntity" + name.str()); |
|---|
| 52 | node_ = Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName()); |
|---|
| 53 | std::cout << "blubbbi: " << this->getName() << " .. " << this->node_ << std::endl; |
|---|
| 54 | } |
|---|
| 55 | std::cout << "10_3\n"; |
|---|
| 56 | |
|---|
| 57 | this->bStatic_ = true; |
|---|
| 58 | this->velocity_ = Vector3(0, 0, 0); |
|---|
| 59 | this->acceleration_ = Vector3(0, 0, 0); |
|---|
| 60 | this->rotationAxis_ = Vector3(0, 1, 0); |
|---|
| 61 | this->rotationRate_ = 0; |
|---|
| 62 | this->momentum_ = 0; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | WorldEntity::~WorldEntity() |
|---|
| 66 | { |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | void WorldEntity::tick(float dt) |
|---|
| 70 | { |
|---|
| 71 | if (!this->bStatic_) |
|---|
| 72 | { |
|---|
| 73 | this->velocity_ += (dt * this->acceleration_); |
|---|
| 74 | this->translate(dt * this->velocity_); |
|---|
| 75 | |
|---|
| 76 | this->rotationRate_ += (dt * this->momentum_); |
|---|
| 77 | this->rotate(this->rotationAxis_, dt * this->rotationRate_); |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | void WorldEntity::registerAllVariables(){ |
|---|
| 82 | // to be implemented ! |
|---|
| 83 | |
|---|
| 84 | } |
|---|
| 85 | } |
|---|