i6engine  1.0
MoverComponent.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_API_MOVERCOMPONENT_H__
26 #define __I6ENGINE_API_MOVERCOMPONENT_H__
27 
30 
32 
33 #include "boost/thread/mutex.hpp"
34 
35 namespace i6e {
36 namespace api {
37 
38  class PhysicalStateComponent; // forward declaration
39 
40  typedef std::pair<Vec3, Quaternion> keyFrame;
41 
62  public:
63  enum class Positioning : uint16_t {
64  POSITIONING_ABSOLUTE, // ! the GameObject is moved to exactly this position (you won't be able to move it manually with a lasting effect)
65  POSITIONING_RELATIVE // ! the positions are calculated like with absolute, but the GameObject is just moved by the difference vector (lastPos - curPos)
66  };
67 
68  MoverComponent(const int64_t id, const attributeMap & params);
69  virtual ~MoverComponent();
70 
71  virtual void Tick() override;
72 
73  virtual void Init() override;
74 
75  virtual void Finalize() override;
76 
81  void setDuration(const uint64_t duration) {
82  _duration = duration;
83  }
84 
85  void setPositioning(const Positioning posing) { _positioning = posing; }
86 
92  virtual void start(Vec3 & startPos) = 0;
93 
97  void stop();
98 
102  virtual void reset() = 0;
103 
107  virtual attributeMap synchronize() const override;
108 
109  std::pair<AddStrategy, int64_t> howToAdd(const ComPtr & comp) const override;
110 
111  void shatter(const GOPtr & go) override;
112 
113  std::vector<componentOptions> getComponentOptions() override;
114 
115  protected:
119  uint64_t _duration;
120 
125 
130 
134  uint64_t _startTime;
135 
141 
147 
153 
157  bool _moving;
158 
162  bool _initial;
163 
167  bool _started;
168 
172  bool _linkable;
173 
177  std::vector<int64_t> _linked;
178 
184  virtual void News(const GameMessage::Ptr & msg) override = 0;
185 
189  virtual void loadParams(const attributeMap & params);
190 
197  virtual void getNewPosition(const uint64_t t, Vec3 & newPos, Quaternion & newRot) = 0;
198 
199  MoverComponent(const MoverComponent &) = delete;
200 
201  const MoverComponent & operator=(const MoverComponent &) = delete;
202  };
203 
204 } /* namespace api */
205 } /* namespace i6e */
206 
207 #endif /* __I6ENGINE_API_MOVERCOMPONENT_H__ */
208 
bool _moving
current status
uint64_t _startTime
time the moving started
bool _started
whether the Mover should be started on creation or not
Quaternion _lastRot
last rotation value calculated in imaginary path used for RELATIVE positioning
This component let's the Object move through the world automatically on fixed paths Use addKeyFrame()...
Class describing a 3d rotation.
Definition: i6eQuaternion.h:58
#define ISIXE_MODULES_API
bool _linkable
whether the object on the Mover should be linked and moved with the Mover
A weak pointer observing a sharedPtr.
Definition: sharedPtr.h:53
bool _initial
whether the call to start() will start or continue the movement
boost::shared_ptr< Message > Ptr
Definition: Message.h:66
std::map< std::string, std::string > attributeMap
Definition: attributeMap.h:42
Implements 3-dimensional vectors.
Definition: i6eVector.h:48
std::pair< Vec3, Quaternion > keyFrame
Vec3 _lastPos
last position value calculated in imaginary path used for RELATIVE positioning
std::vector< int64_t > _linked
vector of all linked GameObject IDs
void setPositioning(const Positioning posing)
A shared pointer counting references and adds objects being not referenced any more to an internal li...
Definition: sharedPtr.h:50
Positioning _positioning
type of positioning
Vec3 _realStartPos
real starting position needed for synchronizing
uint64_t _duration
duration for one path
This class is needed on every GameObject with: TRIGGER The shatter() method is called for detected co...
void setDuration(const uint64_t duration)
Represents an object's physical state and synchronizes with the Physics subsystem. For creating a PhysicalStateComponent, these keys are possible: Name Required Type Description Public syncPrio no int priority from which upwards updates should be sent through network yes gravity no Vec3 gravity for this object. Replaces default yes pos yes Vec3 position of the SceneNode yes rot yes Quaternion rotation of the SceneNode yes scale yes Vec3 scale of the SceneNode yes collisionGroup yes int int int ResponseType CrashType CrashMask yes shapeType yes int one of the shapeTypes from ShapeType enum yes shatterInterest yes int one of the shatterInterests from ShatterInterest enum yes compound yes bool should this PSC be used as a compound shape together with other ones of this GameObject yes
utils::weakPtr< PhysicalStateComponent, Component > _psc
PSC of the GameObject.