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