[6524] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
[6970] | 12 | main-programmer: Benjamin Grauer |
---|
[6524] | 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 17 | |
---|
[6970] | 18 | #include "model_entity.h" |
---|
[6524] | 19 | |
---|
| 20 | #include "load_param.h" |
---|
| 21 | #include "factory.h" |
---|
| 22 | |
---|
| 23 | using namespace std; |
---|
| 24 | |
---|
| 25 | |
---|
[6968] | 26 | CREATE_FACTORY(ModelEntity, CL_MODEL_ENTITY); |
---|
[6524] | 27 | |
---|
| 28 | /** |
---|
| 29 | * initializes a skybox from a XmlElement |
---|
| 30 | */ |
---|
[6968] | 31 | ModelEntity::ModelEntity(const TiXmlElement* root) |
---|
[6524] | 32 | { |
---|
[6968] | 33 | this->setClassID(CL_MODEL_ENTITY, "ModelEntity"); |
---|
| 34 | this->toList(OM_ENVIRON_NOTICK); |
---|
[6524] | 35 | |
---|
[7048] | 36 | this->speed = NULL; |
---|
| 37 | this->momentum = NULL; |
---|
| 38 | |
---|
[6968] | 39 | if (root != NULL) |
---|
| 40 | this->loadParams(root); |
---|
[6524] | 41 | } |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * default destructor |
---|
| 46 | */ |
---|
[6968] | 47 | ModelEntity::~ModelEntity() |
---|
[6524] | 48 | { |
---|
[7048] | 49 | if (this->speed != NULL) |
---|
| 50 | delete this->speed; |
---|
| 51 | if (this->momentum) |
---|
| 52 | delete this->momentum; |
---|
[6524] | 53 | } |
---|
| 54 | |
---|
[7048] | 55 | void ModelEntity::loadParams(const TiXmlElement* root) |
---|
| 56 | { |
---|
| 57 | WorldEntity::loadParams(root); |
---|
[6524] | 58 | |
---|
[7048] | 59 | LoadParam(root, "speed", this, ModelEntity, setSpeed); |
---|
| 60 | LoadParam(root, "momentum", this, ModelEntity, setMomentum); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | void ModelEntity::setSpeed(float x, float y, float z) |
---|
| 65 | { |
---|
| 66 | if (this->speed == NULL) |
---|
| 67 | this->speed = new Vector; |
---|
| 68 | *this->speed = Vector(x,y,z); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | void ModelEntity::setMomentum (float angle, float x, float y, float z) |
---|
| 72 | { |
---|
| 73 | if (this->momentum == NULL) |
---|
| 74 | this->momentum = new Quaternion; |
---|
| 75 | *this->momentum = Quaternion(angle, Vector(x, y, z)); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | void ModelEntity::tick(float dt) |
---|
| 79 | { |
---|
| 80 | if (this->speed != NULL) |
---|
| 81 | this->shiftCoor(*this->speed * dt); |
---|
| 82 | |
---|
| 83 | if (this->momentum != NULL) |
---|
| 84 | this->shiftDir(*this->momentum * dt); |
---|
| 85 | } |
---|