1 | #ifndef _WorldEntity_H__ |
---|
2 | #define _WorldEntity_H__ |
---|
3 | |
---|
4 | #include <OgreSceneManager.h> |
---|
5 | #include <OgreSceneNode.h> |
---|
6 | |
---|
7 | #include "network/Synchronisable.h" |
---|
8 | #include "tinyxml/tinyxml.h" |
---|
9 | #include "../core/CoreIncludes.h" |
---|
10 | #include "BaseObject.h" |
---|
11 | #include "Tickable.h" |
---|
12 | #include "Mesh.h" |
---|
13 | |
---|
14 | namespace orxonox |
---|
15 | { |
---|
16 | class WorldEntity : public BaseObject, public Tickable, public network::Synchronisable |
---|
17 | { |
---|
18 | public: |
---|
19 | WorldEntity(); |
---|
20 | virtual ~WorldEntity(); |
---|
21 | |
---|
22 | virtual void tick(float dt); |
---|
23 | virtual void loadParams(TiXmlElement* xmlElem); |
---|
24 | bool create(); |
---|
25 | |
---|
26 | inline Ogre::SceneNode* getNode() |
---|
27 | { return this->node_; } |
---|
28 | |
---|
29 | inline void setNode(Ogre::SceneNode* node) |
---|
30 | { this->node_ = node; } |
---|
31 | |
---|
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(); } |
---|
38 | |
---|
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); } |
---|
47 | |
---|
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); } |
---|
54 | |
---|
55 | inline const Ogre::Quaternion& getOrientation() |
---|
56 | { return this->node_->getOrientation(); } |
---|
57 | inline void setOrientation(const Ogre::Quaternion& quat) |
---|
58 | { this->node_->setOrientation(quat); } |
---|
59 | inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) |
---|
60 | { this->node_->rotate(axis, angle, relativeTo); } |
---|
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) |
---|
62 | { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); } |
---|
63 | inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
64 | { this->node_->setDirection(vec, relativeTo, localDirectionVector); } |
---|
65 | inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
66 | { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); } |
---|
67 | |
---|
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 | |
---|
83 | inline void attachObject(Ogre::MovableObject *obj) |
---|
84 | { this->node_->attachObject(obj); } |
---|
85 | inline void attachObject(Mesh &mesh) |
---|
86 | { this->node_->attachObject(mesh.getEntity()); } |
---|
87 | inline void detachObject(Ogre::MovableObject *obj) |
---|
88 | { this->node_->detachObject(obj); } |
---|
89 | inline void detachAllObjects() |
---|
90 | { this->node_->detachAllObjects(); } |
---|
91 | |
---|
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_; } |
---|
98 | |
---|
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_; } |
---|
105 | |
---|
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_; } |
---|
112 | |
---|
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_; } |
---|
119 | |
---|
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_; } |
---|
126 | |
---|
127 | inline void setStatic(bool bStatic) |
---|
128 | { this->bStatic_ = bStatic; } |
---|
129 | inline bool isStatic() |
---|
130 | { return this->bStatic_; } |
---|
131 | |
---|
132 | protected: |
---|
133 | void registerAllVariables(); |
---|
134 | |
---|
135 | Vector3 velocity_; |
---|
136 | Vector3 acceleration_; |
---|
137 | Vector3 rotationAxis_; |
---|
138 | Radian rotationRate_; |
---|
139 | Radian momentum_; |
---|
140 | |
---|
141 | private: |
---|
142 | static unsigned int worldEntityCounter_s; |
---|
143 | Ogre::SceneNode* node_; |
---|
144 | bool bStatic_; |
---|
145 | }; |
---|
146 | } |
---|
147 | |
---|
148 | #endif |
---|