Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/orxonox/objects/worldentities/LinearEntity.h @ 2296

Last change on this file since 2296 was 2292, checked in by rgrieder, 16 years ago

Finally managed to work out some physics. According to my tests, collisions with simple spheres should work with dynamic/kinematic/static objects. There are currently only a limited number of XML parameters, but we're surely going to extend that. Furthermore there is some more thinking to be done concerning changes of btRigidBody properties when it's already added to the world.

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _LinearEntity_H__
30#define _LinearEntity_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "MovableEntity.h"
35#include "objects/Tickable.h"
36#include "network/ClientConnectionListener.h"
37
38namespace orxonox
39{
40    class _OrxonoxExport LinearEntity : public MovableEntity, public network::ClientConnectionListener, public Tickable
41    {
42        public:
43            LinearEntity(BaseObject* creator);
44            virtual ~LinearEntity();
45
46            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
47            virtual void tick(float dt);
48            void registerVariables();
49
50            inline void setVelocity(const Vector3& velocity);
51            inline void setVelocity(float x, float y, float z)
52                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
53            inline const Vector3& getVelocity() const
54                { return this->velocity_; }
55
56            inline void setAcceleration(const Vector3& acceleration)
57                { this->acceleration_ = acceleration; }
58            inline void setAcceleration(float x, float y, float z)
59                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
60            inline const Vector3& getAcceleration() const
61                { return this->acceleration_; }
62
63            inline void setRotationAxis(const Vector3& axis)
64                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
65            inline void setRotationAxis(float x, float y, float z)
66                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
67            inline const Vector3& getRotationAxis() const
68                { return this->rotationAxis_; }
69
70            inline void setRotationRate(const Degree& angle)
71                { this->rotationRate_ = angle; }
72            inline void setRotationRate(const Radian& angle)
73                { this->rotationRate_ = angle; }
74            inline const Degree& getRotationRate() const
75                { return this->rotationRate_; }
76
77            inline void setMomentum(const Degree& angle)
78                { this->momentum_ = angle; }
79            inline void setMomentum(const Radian& angle)
80                { this->momentum_ = angle; }
81            inline const Degree& getMomentum() const
82                { return this->momentum_; }
83
84        private:
85            void clientConnected(unsigned int clientID);
86            void clientDisconnected(unsigned int clientID);
87            void resynchronize();
88
89            void overwritePosition();
90            void overwriteOrientation();
91
92            void positionChanged();
93            void orientationChanged();
94            inline void internalSetVelocity(const Vector3& velocity)
95                { this->velocity_ = velocity; }
96
97            Vector3 velocity_;
98            Vector3 acceleration_;
99            Vector3 rotationAxis_;
100            Degree rotationRate_;
101            Degree momentum_;
102
103            Vector3 overwrite_position_;
104            Quaternion overwrite_orientation_;
105    };
106}
107
108#endif /* _LinearEntity_H__ */
Note: See TracBrowser for help on using the repository browser.