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 | ~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 void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) |
---|
56 | { this->node_->rotate(axis, angle, relativeTo); } |
---|
57 | inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
58 | { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); } |
---|
59 | inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
60 | { this->node_->setDirection(vec, relativeTo, localDirectionVector); } |
---|
61 | inline void setOrientation(const Ogre::Quaternion quat) |
---|
62 | { this->node_->setOrientation(quat); } |
---|
63 | inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) |
---|
64 | { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); } |
---|
65 | |
---|
66 | inline void setScale(const Vector3 &scale) |
---|
67 | { this->node_->setScale(scale); } |
---|
68 | inline void setScale(Real x, Real y, Real z) |
---|
69 | { this->node_->setScale(x, y, z); } |
---|
70 | inline void setScale(Real scale) |
---|
71 | { this->node_->setScale(scale, scale, scale); } |
---|
72 | inline const Vector3& getScale(void) const |
---|
73 | { return this->node_->getScale(); } |
---|
74 | inline void scale(const Vector3 &scale) |
---|
75 | { this->node_->scale(scale); } |
---|
76 | inline void scale(Real x, Real y, Real z) |
---|
77 | { this->node_->scale(x, y, z); } |
---|
78 | inline void scale(Real scale) |
---|
79 | { this->node_->scale(scale, scale, scale); } |
---|
80 | |
---|
81 | inline void attachObject(Ogre::MovableObject *obj) |
---|
82 | { this->node_->attachObject(obj); } |
---|
83 | inline void attachObject(Mesh &mesh) |
---|
84 | { this->node_->attachObject(mesh.getEntity()); } |
---|
85 | inline void detachObject(Ogre::MovableObject *obj) |
---|
86 | { this->node_->detachObject(obj); } |
---|
87 | inline void detachAllObjects() |
---|
88 | { this->node_->detachAllObjects(); } |
---|
89 | |
---|
90 | inline void setVelocity(const Vector3& velocity) |
---|
91 | { this->velocity_ = velocity; } |
---|
92 | inline void setVelocity(Real x, Real y, Real z) |
---|
93 | { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; } |
---|
94 | inline const Vector3& getVelocity() const |
---|
95 | { return this->velocity_; } |
---|
96 | |
---|
97 | inline void setAcceleration(const Vector3& acceleration) |
---|
98 | { this->acceleration_ = acceleration; } |
---|
99 | inline void setAcceleration(Real x, Real y, Real z) |
---|
100 | { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; } |
---|
101 | inline const Vector3& getAcceleration() const |
---|
102 | { return this->acceleration_; } |
---|
103 | |
---|
104 | inline void setRotationAxis(const Vector3& axis) |
---|
105 | { this->rotationAxis_ = axis; } |
---|
106 | inline void setRotationAxis(Real x, Real y, Real z) |
---|
107 | { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; } |
---|
108 | inline const Vector3& getRotationAxis() const |
---|
109 | { return this->rotationAxis_; } |
---|
110 | |
---|
111 | inline void setRotationRate(const Radian& angle) |
---|
112 | { this->rotationRate_ = angle; } |
---|
113 | inline void setRotationRate(const Degree& angle) |
---|
114 | { this->rotationRate_ = angle; } |
---|
115 | inline const Radian& getRotationRate() const |
---|
116 | { return this->rotationRate_; } |
---|
117 | |
---|
118 | inline void setMomentum(const Radian& angle) |
---|
119 | { this->momentum_ = angle; } |
---|
120 | inline void setMomentum(const Degree& angle) |
---|
121 | { this->momentum_ = angle; } |
---|
122 | inline const Radian& getMomentum() const |
---|
123 | { return this->momentum_; } |
---|
124 | inline const Ogre::Quaternion& getOrientation() |
---|
125 | { return this->node_->getOrientation(); } |
---|
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 | private: |
---|
136 | Ogre::SceneNode* node_; |
---|
137 | static unsigned int worldEntityCounter_s; |
---|
138 | |
---|
139 | bool bStatic_; |
---|
140 | Vector3 velocity_; |
---|
141 | Vector3 acceleration_; |
---|
142 | Vector3 rotationAxis_; |
---|
143 | Radian rotationRate_; |
---|
144 | Radian momentum_; |
---|
145 | }; |
---|
146 | } |
---|
147 | |
---|
148 | #endif |
---|