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