Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2300 was 2300, checked in by rgrieder, 15 years ago

Still getting physics and its implications straight:

  • Removed PositionableEntity —> StaticEntity is now the way to go. They cannot be translated in any way during physics simulation. The trick will be to remove them and add them again to Bullet. This however is not yet implemented.
  • Forgot a few consts in WorldEntity
  • Fixed a bug with infinite masses
  • WE throws exception if you try to apply physics when the SceneNode is not in the root space of the Scene.
  • Moved velocity_ to MovableEntity
  • Outside world reference of WE/ME are now always the non-physical values. getPosition() will always return node_→getPosition() and when setting it, both RigidBody and SceneNode are translated. This accounts for velocity, orientation and position.
  • Property svn:eol-style set to native
File size: 3.5 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 setAcceleration(const Vector3& acceleration)
51                { this->acceleration_ = acceleration; }
52            inline void setAcceleration(float x, float y, float z)
53                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
54            inline const Vector3& getAcceleration() const
55                { return this->acceleration_; }
56
57            inline void setRotationAxis(const Vector3& axis)
58                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
59            inline void setRotationAxis(float x, float y, float z)
60                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
61            inline const Vector3& getRotationAxis() const
62                { return this->rotationAxis_; }
63
64            inline void setRotationRate(const Degree& angle)
65                { this->rotationRate_ = angle; }
66            inline void setRotationRate(const Radian& angle)
67                { this->rotationRate_ = angle; }
68            inline const Degree& getRotationRate() const
69                { return this->rotationRate_; }
70
71            inline void setMomentum(const Degree& angle)
72                { this->momentum_ = angle; }
73            inline void setMomentum(const Radian& angle)
74                { this->momentum_ = angle; }
75            inline const Degree& getMomentum() const
76                { return this->momentum_; }
77
78        private:
79            void clientConnected(unsigned int clientID);
80            void clientDisconnected(unsigned int clientID);
81            void resynchronize();
82
83            void overwritePosition();
84            void overwriteOrientation();
85
86            void positionChanged();
87            void orientationChanged();
88
89            Vector3 acceleration_;
90            Vector3 rotationAxis_;
91            Degree rotationRate_;
92            Degree momentum_;
93
94            Vector3 overwrite_position_;
95            Quaternion overwrite_orientation_;
96    };
97}
98
99#endif /* _LinearEntity_H__ */
Note: See TracBrowser for help on using the repository browser.