Leviathan  0.8.0.0
Leviathan game engine
Components.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2019 Henri Hyyryläinen
3 #pragma once
4 
6 #include "Define.h"
7 // ------------------------------------ //
8 #include "Common/Quaternion.h"
9 #include "Common/SFMLPackets.h"
10 #include "Common/Types.h"
11 #include "Physics/PhysicsBody.h"
12 #include "Physics/PhysicsShape.h"
14 #include "Rendering/Renderable.h"
15 #include "Rendering/Scene.h"
16 
17 #include "Component.h"
18 #include "ComponentState.h"
19 
20 #include <functional>
21 
22 namespace Leviathan {
23 
24 class PhysicalWorld;
25 
26 namespace Test {
27 class TestComponentCreation;
28 }
29 
30 class PositionState;
31 
36 class Position : public ComponentWithStates<PositionState>, public PhysicsPositionProvider {
37 public:
38  struct Data {
39 
40  Data(const Float3& position, const Quaternion& orientation) :
41  _Position(position), _Orientation(orientation)
42  {}
43 
46  };
47 
48 public:
50  inline Position(const Data& data) : ComponentWithStates(TYPE), Members(data) {}
51 
53  const Float3*& position, const Quaternion*& orientation) const override
54  {
55  position = &Members._Position;
56  orientation = &Members._Orientation;
57  }
58 
60  const Float3& position, const Quaternion& orientation) override
61  {
62  Members._Position = position;
63  Members._Orientation = orientation;
64  Marked = true;
65  }
66 
69  DLLEXPORT void ApplyState(const PositionState& state);
70 
72 
74 
75  static constexpr auto TYPE = COMPONENT_TYPE::Position;
76  using StateT = PositionState;
77 };
78 
82 class RenderNode : public Component {
83 public:
84  DLLEXPORT RenderNode(const Scene::pointer& scene);
85 
87  DLLEXPORT RenderNode(const Test::TestComponentCreation& test);
88 
90  DLLEXPORT void Release(const Scene::pointer& worldsscene);
91 
93 
94  SceneNode::pointer Node;
95 
97  bool Hidden = false;
98 
100  Float3 Scale = Float3(1, 1, 1);
101 
102  // TODO: implement
104  // ObjectID ParentEntity = NULL_OBJECT;
105 
106  static constexpr auto TYPE = COMPONENT_TYPE::RenderNode;
107 };
108 
115 class Sendable : public Component {
116 public:
122  public:
123  inline ActiveConnection(const std::shared_ptr<Connection>& connection) :
124  CorrespondingConnection(connection)
125  {}
126 
130 
132  inline void AddSentPacket(int tick, const std::shared_ptr<EntityState>& state,
133  std::shared_ptr<SentNetworkThing> packet)
134  {
135  SentPackets.emplace_back(tick, state, packet);
136  }
137 
138  std::shared_ptr<Connection> CorrespondingConnection;
139 
143  std::shared_ptr<EntityState> LastConfirmedData;
144 
147  // LastConfirmedData will be replaced.
149 
151  std::vector<
152  std::tuple<int, std::shared_ptr<EntityState>, std::shared_ptr<SentNetworkThing>>>
154  };
155 
156 public:
157  inline Sendable() : Component(TYPE) {}
158 
160 
162  std::vector<ActiveConnection> UpdateReceivers;
163 
164  static constexpr auto TYPE = COMPONENT_TYPE::Sendable;
165 };
166 
170 class Received : public Component {
171 public:
172  // //! \brief Storage class for ObjectDeltaStateData
173  // //! \todo Possibly add move constructors
174  // class StoredState {
175  // public:
176  // inline StoredState(std::shared_ptr<ComponentState> safedata, int tick, void* data) :
177  // DeltaData(safedata), Tick(tick), DirectData(data)
178  // {}
179 
180  // std::shared_ptr<ComponentState> DeltaData;
181 
182  // //! Tick number, should be retrieved from DeltaData
183  // int Tick;
184 
185  // //! This avoids using dynamic_cast
186  // void* DirectData;
187  // };
188 
189 public:
190  inline Received() :
191  Component(TYPE) //, ClientStateBuffer(BASESENDABLE_STORED_RECEIVED_STATES)
192  {}
193 
194  // DLLEXPORT void GetServerSentStates(StoredState const** first, StoredState const**
195  // second,
196  // int tick, float& progress) const;
197 
199 
200  // //! Client side buffer of past states
201  // boost::circular_buffer<StoredState> ClientStateBuffer;
202 
204  bool LocallyControlled = false;
205 
206  static constexpr auto TYPE = COMPONENT_TYPE::Received;
207 };
208 
209 
212 class BoxGeometry : public Component {
213 public:
214  inline BoxGeometry(const Float3& size, const std::string& material) :
215  Component(TYPE), Sizes(size), BoxMaterial(material)
216  {}
217 
219 
222 
224  std::string BoxMaterial;
225 
226  // //! Entity created from a box mesh
227  // Ogre::Item* GraphicalObject = nullptr;
228 
229  static constexpr auto TYPE = COMPONENT_TYPE::BoxGeometry;
230 };
231 
233 class Model : public Component {
234 public:
235  DLLEXPORT Model(const Scene::pointer& scene, RenderNode& parent,
236  const std::string& meshname, const Material::pointer& material);
237 
238  DLLEXPORT void Release();
239 
240  DLLEXPORT void ApplyMeshName();
241 
243 
245  Renderable::pointer GraphicalObject;
246 
248  std::string MeshName;
249 
251  Material::pointer ObjectMaterial;
252 
253  static constexpr auto TYPE = COMPONENT_TYPE::Model;
254 };
255 
258  friend class AnimationSystem;
259 
260 public:
261  DLLEXPORT inline SimpleAnimation(const std::string& name) : Name(name) {}
262 
264  Name(std::move(other.Name)), Loop(other.Loop), SpeedFactor(other.SpeedFactor),
265  Paused(other.Paused), _LoadedAnimation(std::move(other._LoadedAnimation))
266  {
267  Loop = other.Loop;
268  SpeedFactor = other.SpeedFactor;
269  Paused = other.Paused;
270  }
271 
273  Name(other.Name), Loop(other.Loop), SpeedFactor(other.SpeedFactor),
275  {}
276 
278  std::string Name;
279  bool NameMarked = true;
280 
282  bool Loop = false;
283 
285  float SpeedFactor = 1;
286 
288  bool Paused = false;
289 
290 protected:
292  AnimationTrack::pointer _LoadedAnimation;
293 };
294 
296 class Animated : public Component {
297 public:
299 
300  DLLEXPORT void Release();
301 
303 
305  ObjectAnimationHandler::pointer Animation;
306 
310  std::vector<SimpleAnimation> Animations;
311 
312  static constexpr auto TYPE = COMPONENT_TYPE::Animated;
313 };
314 
315 // //! \brief Plane component
316 // //!
317 // //! Creates a static mesh for this
318 // class Plane : public Component {
319 // public:
320 // DLLEXPORT Plane(bs::Scene* scene, Ogre::SceneNode* parent,
321 // const std::string& material, const Ogre::Plane& plane, const Float2& size,
322 // const Ogre::Vector3& uvupvector = Ogre::Vector3::UNIT_Y);
323 
324 // //! \brief Destroys GraphicalObject
325 // DLLEXPORT void Release(bs::Scene* scene);
326 
327 // REFERENCE_HANDLE_UNCOUNTED_TYPE(Plane);
328 
329 // //! The plane that this component creates
330 // Ogre::Item* GraphicalObject = nullptr;
331 
332 // const std::string GeneratedMeshName;
333 
334 // // Changing any of these does nothing
335 // std::string Material;
336 // Ogre::Plane PlaneDefinition;
337 // Float2 Size;
338 // Float3 UpVector;
339 
340 // static constexpr auto TYPE = COMPONENT_TYPE::Plane;
341 // };
342 
343 
347 class Physics : public Component {
348 public:
351  public:
354  ApplyForceInfo(bool addmass,
355  std::function<Float3(ApplyForceInfo* instance, Physics& object)> getforce,
356  std::unique_ptr<std::string> name = nullptr) :
357  OptionalName(move(name)),
358  MultiplyByMass(addmass), Callback(getforce)
359  {}
360 
363  {
364  if(other.OptionalName)
365  OptionalName = std::make_unique<std::string>(*other.OptionalName);
366  }
367 
369  OptionalName(move(other.OptionalName)),
370  MultiplyByMass(std::move(other.MultiplyByMass)), Callback(move(other.Callback))
371  {}
372 
374  {
375 
376  if(other.OptionalName)
377  OptionalName = std::make_unique<std::string>(*other.OptionalName);
378 
380  Callback = other.Callback;
381 
382  return *this;
383  }
384 
386  std::unique_ptr<std::string> OptionalName;
387 
391 
394  std::function<Float3(ApplyForceInfo* instance, Physics& object)> Callback;
395  };
396 
398 
401  };
402 
403  struct Data {
404 
410  };
411 
412 public:
413  inline Physics(const Data& args) :
414  Component(TYPE), ThisEntity(args.id), _Position(args.updatepos)
415  {}
416 
418 
420  DLLEXPORT void Release(PhysicalWorld* world);
421 
429  DLLEXPORT PhysicsBody::pointer CreatePhysicsBody(PhysicalWorld* world,
430  const PhysicsShape::pointer& shape, float mass, int physicsmaterialid = -1);
431 
434  DLLEXPORT bool ChangeShape(PhysicalWorld* world, const PhysicsShape::pointer& shape);
435 
440  DLLEXPORT void JumpTo(Position& target);
441 
443  DLLEXPORT void ApplyPhysicalState(const BasePhysicsData& data);
444 
446  Float3 _GatherApplyForces(const float& mass);
447 
448  DLLEXPORT float GetMass() const;
449 
450  inline PhysicsBody* GetBody() const
451  {
452  return Body.get();
453  }
454 
455  //
456  // Script wrappers
457  //
458 
459  inline PhysicsBody* GetBodyWrapper() const
460  {
461  if(Body)
462  Body->AddRef();
463  return Body.get();
464  }
465 
466  inline bool ChangeShapeWrapper(PhysicalWorld* world, PhysicsShape* shape)
467  {
468  return ChangeShape(world, ReferenceCounted::WrapPtr(shape));
469  }
470 
472  PhysicalWorld* world, PhysicsShape* shape, float mass, int physicsmaterialid)
473  {
474  auto body = CreatePhysicsBody(
475  world, ReferenceCounted::WrapPtr(shape), mass, physicsmaterialid);
476 
477  if(body)
478  body->AddRef();
479  return body.get();
480  }
481 
483 
484 private:
485  PhysicsBody::pointer Body;
486 
487 public:
490 
491  // //! Used to access gravity data
492  // GameWorld* World = nullptr;
493 
496 
497  static constexpr auto TYPE = COMPONENT_TYPE::Physics;
498 };
499 
500 // class ManualObject : public Component {
501 // public:
502 // DLLEXPORT ManualObject(bs::Scene* scene);
503 
504 // DLLEXPORT void Release(bs::Scene* scene);
505 
506 // REFERENCE_HANDLE_UNCOUNTED_TYPE(ManualObject);
507 
508 // Ogre::ManualObject* Object = nullptr;
509 
510 // //! When not empty the ManualObject has been created into an actual mesh
511 // //! that needs to be destroyed on release
512 // //! \note The Object can be directly added to a scene so this may be empty even
513 // //! if the Object is created
514 // std::string CreatedMesh;
515 
516 // static constexpr auto TYPE = COMPONENT_TYPE::ManualObject;
517 // };
518 
519 
520 // class Parent : public Component{
521 // public:
522 
523 // struct Data{
524 
525 // std::vector<ObjectID> EntityIDs;
526 // };
527 
528 // public:
529 // DLLEXPORT Parent();
530 
531 // DLLEXPORT Parent(const Data &data, GameWorld* world, Lock &worldlock);
532 
533 // //! \brief Removes child object without notifying it
534 // DLLEXPORT void RemoveChildNoNotify(Parentable* which);
535 
536 // //! \brief Removes all children notifying them
537 // DLLEXPORT void RemoveChildren();
538 
539 // DLLEXPORT void AddDataToPacket(sf::Packet &packet) const;
540 
541 // //! \note The packet needs to be checked that it is still valid after this call
542 // DLLEXPORT static Data LoadDataFromPacket(sf::Packet &packet);
543 
544 // //! \brief Does everything necessary to attach a child
545 // DLLEXPORT void AddChild(ObjectID childid, Parentable &child);
546 
547 // //! Attached children which can be moved at certain times
548 // //! \todo Make improvements to component lookup performance through this
549 // std::vector<std::tuple<ObjectID, Parentable*>> Children;
550 // };
551 
552 
553 
554 // class Constraintable : public Component{
555 // public:
556 // //! \param world Used to allow created constraints to access world data (including
557 // physics) DLLEXPORT Constraintable(ObjectID id, GameWorld* world);
558 
559 // //! \brief Destroys all constraints attached to this
560 // DLLEXPORT ~Constraintable();
561 
562 // //! Creates a constraint between this and another object
563 // //! \warning DO NOT store the returned value (since that reference isn't counted)
564 // //! \note Before the constraint is actually finished, you need to
565 // //! call ->SetParameters() on the returned ptr
566 // //! and then ->Init() and then let go of the ptr
567 // //! \note If you do not want to allow constraints where child is NULL you have to
568 // //! check if child is NULL before calling this function
569 // template<class ConstraintClass, typename... Args>
570 // std::shared_ptr<ConstraintClass> CreateConstraintWith(Constraintable &other,
571 // Args&&... args)
572 // {
573 // auto tmpconstraint = std::make_shared<ConstraintClass>(World, *this, other,
574 // args...);
575 
576 // if(tmpconstraint)
577 // _NotifyCreate(tmpconstraint, other);
578 
579 // return tmpconstraint;
580 // }
581 
582 // DLLEXPORT void RemoveConstraint(BaseConstraint* removed);
583 
584 // DLLEXPORT void AddConstraint(std::shared_ptr<BaseConstraint> added);
585 
586 // protected:
587 
588 // //! \brief Notifies the other object and the GameWorld of the new constraint
589 // DLLEXPORT void _NotifyCreate(std::shared_ptr<BaseConstraint> newconstraint,
590 // Constraintable &other);
591 
592 // public:
593 
594 
595 // std::vector<std::shared_ptr<BaseConstraint>> PartInConstraints;
596 
597 // GameWorld* World;
598 
599 // //! ID for other component lookup
600 // ObjectID PartOfEntity;
601 // };
602 
603 // class Trail : public Component{
604 // public:
605 
606 // struct ElementProperties{
607 // ElementProperties(const Float4 &initialcolour,
608 // const Float4 &colourchange, const float &initialsize, const float &sizechange) :
609 // InitialColour(initialcolour), ColourChange(colourchange),
610 // InitialSize(initialsize), SizeChange(sizechange)
611 // {
612 
613 // }
614 
615 // ElementProperties(const Float4 &initialcolour,
616 // const float &initialsize) :
617 // InitialColour(initialcolour), ColourChange(0), InitialSize(initialsize),
618 // SizeChange(0)
619 // {
620 
621 // }
622 
623 // ElementProperties() :
624 // InitialColour(1), ColourChange(0), InitialSize(1), SizeChange(0)
625 // {
626 
627 // }
628 
629 // Float4 InitialColour;
630 // Float4 ColourChange;
631 // float InitialSize;
632 // float SizeChange;
633 // };
634 
635 // struct Properties{
636 // public:
637 // Properties(size_t maxelements, float lenght, float maxdistance,
638 // bool castshadows = false) :
639 // TrailLenght(lenght), MaxDistance(maxdistance),
640 // MaxChainElements(maxelements), CastShadows(castshadows), Elements(1)
641 // {
642 // }
643 
644 // float TrailLenght;
645 // float MaxDistance;
646 // size_t MaxChainElements;
647 // bool CastShadows;
648 
649 // std::vector<ElementProperties> Elements;
650 // };
651 
652 
653 // public:
654 
655 // DLLEXPORT Trail(RenderNode* node, const std::string &materialname,
656 // const Properties &variables);
657 
658 // //! \brief Sets properties on the trail object
659 // //! \pre Ogre objects have been created
660 // //! \param force If set to true all settings will be applied
661 // DLLEXPORT bool SetTrailProperties(const Properties &variables, bool force = false);
662 
663 // //! \brief Destroys the TrailEntity
664 // DLLEXPORT void Release(bs::Scene* scene);
665 
666 // //! The trail entity which is attached at the root scene node and follows our RenderNode
667 // //! component around
668 // Ogre::RibbonTrail* TrailEntity = nullptr;
669 
670 // //! For ease of use direct access to ogre node is required
671 // //! Not valid in non-gui mode
672 // RenderNode* _RenderNode = nullptr;
673 
674 // //! The used trail material
675 // std::string Material;
676 
677 // //! Current settings, when updating settings only changed ones are applied
678 // Properties CurrentSettings;
679 // };
680 
681 // //! \todo Add the Markers to the actual world for sending over the network individually
682 // class PositionMarkerOwner : public Component{
683 // public:
684 
685 // struct Data{
686 
687 // std::vector<std::tuple<ObjectID, Float3, Float4>> EntityPositions;
688 // };
689 
690 // public:
691 // DLLEXPORT PositionMarkerOwner();
692 
693 // //! \brief Create with automatically created positions
694 // DLLEXPORT PositionMarkerOwner(const Data &positions, GameWorld* world,
695 // Lock &worldlock);
696 
697 // //! \brief Queues destruction and clears the list of Markers
698 // DLLEXPORT void Release(GameWorld* world, Lock &worldlock);
699 
700 // //! Adds a node
701 // //! \todo Allow not deleting entities on release
702 // DLLEXPORT void Add(ObjectID entity, Position& pos);
703 
704 // DLLEXPORT void AddDataToPacket(sf::Packet &packet) const;
705 
706 // //! \note The packet needs to be checked that it is valid after this call
707 // DLLEXPORT static Data LoadDataFromPacket(sf::Packet &packet);
708 
709 // std::vector<std::tuple<ObjectID, Position*>> Markers;
710 // };
711 
712 
714 class Camera : public Component {
715 public:
718  inline Camera(uint8_t fov = 90, bool soundperceiver = true) :
719  Component(TYPE), FOV(fov), SoundPerceiver(soundperceiver)
720  {}
721 
723 
726 
728  // TODO: orthographic
729  // bool Orthographic;
730 
731  static constexpr auto TYPE = COMPONENT_TYPE::Camera;
732 };
733 
734 } // namespace Leviathan
735 
736 #ifdef LEAK_INTO_GLOBAL
737 using ApplyForceInfo = Leviathan::Physics::ApplyForceInfo;
738 #endif
std::vector< ActiveConnection > UpdateReceivers
Clients we have already sent a state to.
Definition: Components.h:162
PhysicsBody * GetBody() const
Definition: Components.h:450
DLLEXPORT void CheckReceivedPackets()
Checks has any packet been successfully received and updates last confirmed.
Definition: Components.cpp:244
REFERENCE_HANDLE_UNCOUNTED_TYPE(Physics)
ObjectID ThisEntity
For passing to PhysicsBody::SetOwningEntity.
Definition: Components.h:489
Entity is received from a server.
Definition: Components.h:170
PositionState StateT
Definition: Components.h:76
void SetPositionDataFromPhysics(const Float3 &position, const Quaternion &orientation) override
Definition: Components.h:59
int32_t ObjectID
Definition: EntityCommon.h:11
Camera(uint8_t fov=90, bool soundperceiver=true)
Creates at specific position.
Definition: Components.h:718
ObjectAnimationHandler::pointer Animation
Created animation component for this entity.
Definition: Components.h:305
Float3 Scale
Sets the scale of the node.
Definition: Components.h:100
static constexpr auto TYPE
Definition: Components.h:229
std::function< Float3(ApplyForceInfo *instance, Physics &object)> Callback
Definition: Components.h:394
This acts as a bridge between Leviathan positions and physics engine positions.
Definition: PhysicsBody.h:27
std::shared_ptr< Connection > CorrespondingConnection
Definition: Components.h:138
DLLEXPORT void Release(const Scene::pointer &worldsscene)
Gracefully releases while world is still valid.
Definition: Components.cpp:39
Material::pointer ObjectMaterial
Material set on the object.
Definition: Components.h:251
REFERENCE_HANDLE_UNCOUNTED_TYPE(Model)
DLLEXPORT SimpleAnimation(SimpleAnimation &&other)
Definition: Components.h:263
REFERENCE_HANDLE_UNCOUNTED_TYPE(RenderNode)
A physical shape that can be used to create PhysicsBody objects.
Definition: PhysicsShape.h:18
REFERENCE_HANDLE_UNCOUNTED_TYPE(Position)
ApplyForceInfo & operator=(const ApplyForceInfo &other)
Definition: Components.h:373
std::string MeshName
Changing this loads a different mesh.
Definition: Components.h:248
REFERENCE_HANDLE_UNCOUNTED_TYPE(Received)
AnimationTrack::pointer _LoadedAnimation
Loaded animation.
Definition: Components.h:292
REFERENCE_HANDLE_UNCOUNTED_TYPE(BoxGeometry)
ActiveConnection(const std::shared_ptr< Connection > &connection)
Definition: Components.h:123
DLLEXPORT void ApplyState(const PositionState &state)
Applies the state and marks this as changed. Doesn't check if the state is actually different.
Definition: Components.cpp:20
Alternative base class for Component that creates distinct state objects.
Position(const Data &data)
Creates at specific position.
Definition: Components.h:50
ApplyForceInfo(ApplyForceInfo &&other)
Definition: Components.h:368
Contains an animation for Animated component.
Definition: Components.h:257
std::vector< std::tuple< int, std::shared_ptr< EntityState >, std::shared_ptr< SentNetworkThing > > > SentPackets
Holds packets sent to this connection that haven't failed or been received yet.
Definition: Components.h:153
bool Loop
If true the animation will automatically loop.
Definition: Components.h:282
void AddSentPacket(int tick, const std::shared_ptr< EntityState > &state, std::shared_ptr< SentNetworkThing > packet)
Adds a package to be checked for finalization in CheckReceivedPackages.
Definition: Components.h:132
static constexpr auto TYPE
Definition: Components.h:75
static constexpr auto TYPE
Definition: Components.h:497
bool LocallyControlled
If true this uses local control and will send updates to the server.
Definition: Components.h:204
DLLEXPORT bool ChangeShape(PhysicalWorld *world, const PhysicsShape::pointer &shape)
Updates the shape. This can be the same pointer as before. BUT if the shape is modified this MUST be ...
Definition: Components.cpp:136
bool Paused
If true then the animation will be paused.
Definition: Components.h:288
This is an instance of a collision body.
Definition: PhysicsBody.h:77
unsigned char uint8_t
Definition: core.h:38
bool Hidden
Sets objects attached to the node to be hidden or visible.
Definition: Components.h:97
Data(const Float3 &position, const Quaternion &orientation)
Definition: Components.h:40
Holder for information regarding a single force.
Definition: Components.h:350
DLLEXPORT SimpleAnimation(const std::string &name)
Definition: Components.h:261
Float3 Sizes
Size along the axises.
Definition: Components.h:221
std::shared_ptr< EntityState > LastConfirmedData
Definition: Components.h:143
ApplyForceInfo(const ApplyForceInfo &other)
Definition: Components.h:361
DLLEXPORT Model(const Scene::pointer &scene, RenderNode &parent, const std::string &meshname, const Material::pointer &material)
Definition: Components.cpp:287
Entity has a box for geometry/model, possibly also physics.
Definition: Components.h:212
bool ChangeShapeWrapper(PhysicalWorld *world, PhysicsShape *shape)
Definition: Components.h:466
PhysicsBody * CreatePhysicsBodyWrapper(PhysicalWorld *world, PhysicsShape *shape, float mass, int physicsmaterialid)
Definition: Components.h:471
Entity has position and direction it is looking at.
Definition: Components.h:36
Entity has a scene node.
Definition: Components.h:82
DLLEXPORT void Release()
Definition: Components.cpp:305
void GetPositionDataForPhysics(const Float3 *&position, const Quaternion *&orientation) const override
Definition: Components.h:52
DLLEXPORT ~Physics()
Definition: Components.cpp:93
DLLEXPORT SimpleAnimation(const SimpleAnimation &other)
Definition: Components.h:272
static constexpr auto TYPE
Definition: Components.h:312
Renderable::pointer GraphicalObject
The rendebale that has this model's mesh loaded.
Definition: Components.h:245
Float3 _GatherApplyForces(const float &mass)
Adds all applied forces together.
ApplyForceInfo(bool addmass, std::function< Float3(ApplyForceInfo *instance, Physics &object)> getforce, std::unique_ptr< std::string > name=nullptr)
Definition: Components.h:354
BoxGeometry(const Float3 &size, const std::string &material)
Definition: Components.h:214
unsigned short uint16_t
Definition: core.h:39
SceneNode::pointer Node
Definition: Components.h:94
static constexpr auto TYPE
Definition: Components.h:164
Physics(const Data &args)
Definition: Components.h:413
DLLEXPORT void Release()
Definition: Components.cpp:349
DLLEXPORT PhysicsBody::pointer CreatePhysicsBody(PhysicalWorld *world, const PhysicsShape::pointer &shape, float mass, int physicsmaterialid=-1)
Use this to create a body for this component once Collision is set.
Definition: Components.cpp:116
Entity has a physical component.
Definition: Components.h:347
Handles updating time of Ogre animations.
Definition: Systems.h:126
DLLEXPORT void Release(PhysicalWorld *world)
Destroys the physical body.
Definition: Components.cpp:100
Entity has a model.
Definition: Components.h:233
static constexpr auto TYPE
Attaches this node to this parent (if null entity then attached to the scene root)
Definition: Components.h:106
std::unique_ptr< std::string > OptionalName
Set a name when you don't want other non-named forces to override this.
Definition: Components.h:386
static constexpr auto TYPE
Definition: Components.h:731
REFERENCE_HANDLE_UNCOUNTED_TYPE(Sendable)
DLLEXPORT void JumpTo(Position &target)
Syncs this physics body to a changed position.
Definition: Components.cpp:110
DLLEXPORT RenderNode(const Scene::pointer &scene)
Definition: Components.cpp:28
DLLEXPORT Animated(RenderNode &node)
Definition: Components.cpp:344
Properties that a camera entity has (will also need a Position component)
Definition: Components.h:714
A Quaternion type to make quaternion specific operations easier to access.
Definition: Quaternion.h:14
uint16_t FOV
Horizontal (ie. "normal") field of view.
Definition: Components.h:725
static constexpr auto TYPE
Definition: Components.h:253
REFERENCE_HANDLE_UNCOUNTED_TYPE(Camera)
#define DLLEXPORT
Definition: Include.h:84
static constexpr auto TYPE
Definition: Components.h:206
Entity plays animations on an Ogre::Item.
Definition: Components.h:296
Base class for all components.
Definition: Component.h:52
Position & _Position
Physics object requires a position.
Definition: Components.h:495
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
Entity is sendable to clients.
Definition: Components.h:115
DLLEXPORT float GetMass() const
DLLEXPORT void ApplyPhysicalState(const BasePhysicsData &data)
Applies physical state from holder object.
float SpeedFactor
Controls how fast the animation plays.
Definition: Components.h:285
std::string BoxMaterial
Rendering surface material name.
Definition: Components.h:224
static boost::intrusive_ptr< ActualType > WrapPtr(ActualType *ptr)
Creates an intrusive_ptr from raw pointer.
REFERENCE_HANDLE_UNCOUNTED_TYPE(Animated)
DLLEXPORT void ApplyMeshName()
Definition: Components.cpp:311
Represents a world that contains entities.
Definition: GameWorld.h:57
std::vector< SimpleAnimation > Animations
Definition: Components.h:310
PhysicsBody * GetBodyWrapper() const
Definition: Components.h:459