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