[497] | 1 | #ifndef _WorldEntity_H__ |
---|
| 2 | #define _WorldEntity_H__ |
---|
| 3 | |
---|
| 4 | #include "BaseObject.h" |
---|
| 5 | #include "Tickable.h" |
---|
| 6 | #include "../core/CoreIncludes.h" |
---|
| 7 | #include "OgreSceneManager.h" |
---|
| 8 | #include "OgreSceneNode.h" |
---|
[576] | 9 | #include "Mesh.h" |
---|
[565] | 10 | #include "network/Synchronisable.h" |
---|
[583] | 11 | #include "tinyxml/tinyxml.h" |
---|
[497] | 12 | |
---|
| 13 | namespace orxonox |
---|
| 14 | { |
---|
[565] | 15 | class WorldEntity : public BaseObject, public Tickable, public network::Synchronisable |
---|
| 16 | { |
---|
| 17 | public: |
---|
| 18 | WorldEntity(); |
---|
| 19 | ~WorldEntity(); |
---|
[497] | 20 | |
---|
[583] | 21 | virtual void tick(float dt); |
---|
| 22 | virtual void loadParams(TiXmlElement* xmlElem); |
---|
[630] | 23 | bool create(); |
---|
| 24 | |
---|
[565] | 25 | inline Ogre::SceneNode* getNode() |
---|
| 26 | { return this->node_; } |
---|
[497] | 27 | |
---|
[580] | 28 | inline void setNode(Ogre::SceneNode* node) |
---|
| 29 | { this->node_ = node; } |
---|
| 30 | |
---|
[565] | 31 | inline void setPosition(const Vector3& pos) |
---|
| 32 | { this->node_->setPosition(pos); } |
---|
| 33 | inline void setPosition(Real x, Real y, Real z) |
---|
| 34 | { this->node_->setPosition(x, y, z); } |
---|
| 35 | inline const Vector3& getPosition() const |
---|
| 36 | { return this->node_->getPosition(); } |
---|
[497] | 37 | |
---|
[565] | 38 | inline void translate(const Vector3 &d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) |
---|
| 39 | { this->node_->translate(d, relativeTo); } |
---|
| 40 | inline void translate(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) |
---|
| 41 | { this->node_->translate(x, y, z, relativeTo); } |
---|
| 42 | inline void translate(const Matrix3 &axes, const Vector3 &move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) |
---|
| 43 | { this->node_->translate(axes, move, relativeTo); } |
---|
| 44 | inline void translate(const Matrix3 &axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) |
---|
| 45 | { this->node_->translate(axes, x, y, z, relativeTo); } |
---|
[497] | 46 | |
---|
[565] | 47 | inline void yaw(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) |
---|
| 48 | { this->node_->yaw(angle, relativeTo); } |
---|
| 49 | inline void pitch(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) |
---|
| 50 | { this->node_->pitch(angle, relativeTo); } |
---|
| 51 | inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) |
---|
| 52 | { this->node_->roll(angle, relativeTo); } |
---|
[497] | 53 | |
---|
[565] | 54 | inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) |
---|
[576] | 55 | { this->node_->rotate(axis, angle, relativeTo); } |
---|
[565] | 56 | inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
[576] | 57 | { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); } |
---|
[565] | 58 | inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
[576] | 59 | { this->node_->setDirection(vec, relativeTo, localDirectionVector); } |
---|
[565] | 60 | inline void setOrientation(const Ogre::Quaternion quat) |
---|
[576] | 61 | { this->node_->setOrientation(quat); } |
---|
[565] | 62 | inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
[576] | 63 | { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); } |
---|
[497] | 64 | |
---|
[576] | 65 | inline void setScale(const Vector3 &scale) |
---|
| 66 | { this->node_->setScale(scale); } |
---|
| 67 | inline void setScale(Real x, Real y, Real z) |
---|
| 68 | { this->node_->setScale(x, y, z); } |
---|
| 69 | inline void setScale(Real scale) |
---|
| 70 | { this->node_->setScale(scale, scale, scale); } |
---|
| 71 | inline const Vector3& getScale(void) const |
---|
| 72 | { return this->node_->getScale(); } |
---|
| 73 | inline void scale(const Vector3 &scale) |
---|
| 74 | { this->node_->scale(scale); } |
---|
| 75 | inline void scale(Real x, Real y, Real z) |
---|
| 76 | { this->node_->scale(x, y, z); } |
---|
| 77 | inline void scale(Real scale) |
---|
| 78 | { this->node_->scale(scale, scale, scale); } |
---|
| 79 | |
---|
[565] | 80 | inline void attachObject(Ogre::MovableObject *obj) |
---|
[589] | 81 | { this->node_->attachObject(obj); } |
---|
[576] | 82 | inline void attachObject(Mesh &mesh) |
---|
[589] | 83 | { this->node_->attachObject(mesh.getEntity()); } |
---|
[565] | 84 | inline void detachObject(Ogre::MovableObject *obj) |
---|
[576] | 85 | { this->node_->detachObject(obj); } |
---|
[565] | 86 | inline void detachAllObjects() |
---|
[576] | 87 | { this->node_->detachAllObjects(); } |
---|
[497] | 88 | |
---|
[565] | 89 | inline void setVelocity(const Vector3& velocity) |
---|
| 90 | { this->velocity_ = velocity; } |
---|
| 91 | inline void setVelocity(Real x, Real y, Real z) |
---|
| 92 | { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; } |
---|
| 93 | inline const Vector3& getVelocity() const |
---|
| 94 | { return this->velocity_; } |
---|
[497] | 95 | |
---|
[565] | 96 | inline void setAcceleration(const Vector3& acceleration) |
---|
| 97 | { this->acceleration_ = acceleration; } |
---|
| 98 | inline void setAcceleration(Real x, Real y, Real z) |
---|
| 99 | { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; } |
---|
| 100 | inline const Vector3& getAcceleration() const |
---|
| 101 | { return this->acceleration_; } |
---|
[497] | 102 | |
---|
[565] | 103 | inline void setRotationAxis(const Vector3& axis) |
---|
| 104 | { this->rotationAxis_ = axis; } |
---|
| 105 | inline void setRotationAxis(Real x, Real y, Real z) |
---|
| 106 | { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; } |
---|
| 107 | inline const Vector3& getRotationAxis() const |
---|
| 108 | { return this->rotationAxis_; } |
---|
[497] | 109 | |
---|
[565] | 110 | inline void setRotationRate(const Radian& angle) |
---|
| 111 | { this->rotationRate_ = angle; } |
---|
| 112 | inline void setRotationRate(const Degree& angle) |
---|
| 113 | { this->rotationRate_ = angle; } |
---|
| 114 | inline const Radian& getRotationRate() const |
---|
| 115 | { return this->rotationRate_; } |
---|
[497] | 116 | |
---|
[565] | 117 | inline void setMomentum(const Radian& angle) |
---|
| 118 | { this->momentum_ = angle; } |
---|
| 119 | inline void setMomentum(const Degree& angle) |
---|
| 120 | { this->momentum_ = angle; } |
---|
| 121 | inline const Radian& getMomentum() const |
---|
| 122 | { return this->momentum_; } |
---|
| 123 | inline const Ogre::Quaternion& getOrientation() |
---|
| 124 | { return this->node_->getOrientation(); } |
---|
[576] | 125 | |
---|
[622] | 126 | inline void setStatic(bool bStatic) |
---|
| 127 | { this->bStatic_ = bStatic; } |
---|
| 128 | inline bool isStatic() |
---|
| 129 | { return this->bStatic_; } |
---|
| 130 | |
---|
[567] | 131 | protected: |
---|
| 132 | void registerAllVariables(); |
---|
[576] | 133 | |
---|
[565] | 134 | private: |
---|
| 135 | Ogre::SceneNode* node_; |
---|
| 136 | static unsigned int worldEntityCounter_s; |
---|
[497] | 137 | |
---|
[565] | 138 | bool bStatic_; |
---|
| 139 | Vector3 velocity_; |
---|
| 140 | Vector3 acceleration_; |
---|
| 141 | Vector3 rotationAxis_; |
---|
| 142 | Radian rotationRate_; |
---|
| 143 | Radian momentum_; |
---|
| 144 | }; |
---|
[497] | 145 | } |
---|
| 146 | |
---|
| 147 | #endif |
---|