Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core/src/orxonox/objects/WorldEntity.h @ 856

Last change on this file since 856 was 856, checked in by landauf, 16 years ago

loader seems to work now
added function/macro XMLPortObject to load objects as subobjects into another object (like attaching a weapon to a player) + nice debug output with indentation

File size: 7.9 KB
Line 
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
17namespace 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 Element& 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 setPosition(Real x, Real y, Real z)
42//                { this->node_->setPosition(x, y, z); }
43            inline const Vector3& getPosition() const
44                { return this->node_->getPosition(); }
45
46            inline void translate(const Vector3 &d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
47                { this->node_->translate(d, relativeTo); }
48            inline void translate(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
49                { this->node_->translate(x, y, z, relativeTo); }
50            inline void translate(const Matrix3 &axes, const Vector3 &move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
51                { this->node_->translate(axes, move, relativeTo); }
52            inline void translate(const Matrix3 &axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
53                { this->node_->translate(axes, x, y, z, relativeTo); }
54
55            inline void yaw(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
56                { this->node_->yaw(angle, relativeTo); }
57            inline void pitch(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
58                { this->node_->pitch(angle, relativeTo); }
59            inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
60                { this->node_->roll(angle, relativeTo); }
61
62            inline void setYaw(const Degree &angle)
63                { this->node_->yaw(angle, Ogre::Node::TS_LOCAL); }
64            inline void setPitch(const Degree &angle)
65                { this->node_->pitch(angle, Ogre::Node::TS_LOCAL); }
66            inline void setRoll(const Degree &angle)
67                { this->node_->roll(angle, Ogre::Node::TS_LOCAL); }
68
69            inline const Ogre::Quaternion& getOrientation()
70              { return this->node_->getOrientation(); }
71            inline void setOrientation(const Ogre::Quaternion& quat)
72              { this->node_->setOrientation(quat); }
73            inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
74              { this->node_->rotate(axis, angle, relativeTo); }
75            inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
76              { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); }
77            inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
78              { this->node_->setDirection(vec, relativeTo, localDirectionVector); }
79            inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
80              { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); }
81
82            inline void setScale(const Vector3 &scale)
83              { this->node_->setScale(scale); }
84            inline void setScale(Real x, Real y, Real z)
85              { this->node_->setScale(x, y, z); }
86            inline void setScale(Real scale)
87              { this->node_->setScale(scale, scale, scale); }
88            inline void setTotalScale(Real scale)
89              { this->node_->setScale(scale, scale, scale); }
90            inline const Vector3& getScale(void) const
91              { return this->node_->getScale(); }
92            inline void scale(const Vector3 &scale)
93              { this->node_->scale(scale); }
94            inline void scale(Real x, Real y, Real z)
95              { this->node_->scale(x, y, z); }
96            inline void scale(Real scale)
97              { this->node_->scale(scale, scale, scale); }
98
99            inline void attachObject(Ogre::MovableObject *obj)
100              { this->node_->attachObject(obj); }
101            inline void attachObject(Mesh &mesh)
102              { this->node_->attachObject(mesh.getEntity()); }
103            inline void detachObject(Ogre::MovableObject *obj)
104              { this->node_->detachObject(obj); }
105            inline void detachAllObjects()
106              { this->node_->detachAllObjects(); }
107
108            inline void setVelocity(const Vector3& velocity)
109                { this->velocity_ = velocity; }
110            inline void setVelocity(Real x, Real y, Real z)
111                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
112            inline const Vector3& getVelocity() const
113                { return this->velocity_; }
114
115            inline void setAcceleration(const Vector3& acceleration)
116                { this->acceleration_ = acceleration; }
117            inline void setAcceleration(Real x, Real y, Real z)
118                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
119            inline const Vector3& getAcceleration() const
120                { return this->acceleration_; }
121
122            inline void setRotationAxis(const Vector3& axis)
123                { this->rotationAxis_ = axis; }
124//            inline void setRotationAxis(Real x, Real y, Real z)
125//                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; }
126            inline const Vector3& getRotationAxis() const
127                { return this->rotationAxis_; }
128
129//            inline void setRotationRate(const Radian& angle)
130//                { this->rotationRate_ = angle; }
131            inline void setRotationRate(const Degree& angle)
132                { this->rotationRate_ = angle; }
133            inline const Radian& getRotationRate() const
134                { return this->rotationRate_; }
135
136            inline void setMomentum(const Radian& angle)
137                { this->momentum_ = angle; }
138            inline void setMomentum(const Degree& angle)
139                { this->momentum_ = angle; }
140            inline const Radian& getMomentum() const
141                { return this->momentum_; }
142
143            inline void setStatic(bool bStatic)
144                { this->bStatic_ = bStatic; }
145            inline bool isStatic()
146                { return this->bStatic_; }
147
148        protected:
149            void registerAllVariables();
150
151            Vector3 velocity_;
152            Vector3 acceleration_;
153            Vector3 rotationAxis_;
154            Radian rotationRate_;
155            Radian momentum_;
156
157        private:
158            static unsigned int worldEntityCounter_s;
159            Ogre::SceneNode* node_;
160            bool bStatic_;
161            std::vector<WorldEntity*> attachedWorldEntities_;
162    };
163}
164
165#endif /* _WorldEntity_H__ */
Note: See TracBrowser for help on using the repository browser.