Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
CollisionComponent3D.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Development Kit"
3 // For conditions of distribution and use, see copyright notice in Prerequesites.hpp
4 
5 #pragma once
6 
7 #ifndef NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
8 #define NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
9 
10 #include <Nazara/Physics3D/Collider3D.hpp>
11 #include <Nazara/Physics3D/RigidBody3D.hpp>
12 #include <NDK/Component.hpp>
13 #include <memory>
14 
15 namespace Ndk
16 {
17  class NDK_API CollisionComponent3D : public Component<CollisionComponent3D>
18  {
19  friend class PhysicsSystem3D;
20 
21  public:
24  ~CollisionComponent3D() = default;
25 
26  const Nz::Collider3DRef& GetGeom() const;
27 
28  void SetGeom(Nz::Collider3DRef geom);
29 
30  CollisionComponent3D& operator=(Nz::Collider3DRef geom);
31  CollisionComponent3D& operator=(CollisionComponent3D&& collision) = default;
32 
33  static ComponentIndex componentIndex;
34 
35  private:
36  void InitializeStaticBody();
37  Nz::RigidBody3D* GetStaticBody();
38 
39  void OnAttached() override;
40  void OnComponentAttached(BaseComponent& component) override;
41  void OnComponentDetached(BaseComponent& component) override;
42  void OnDetached() override;
43 
44  std::unique_ptr<Nz::RigidBody3D> m_staticBody;
45  Nz::Collider3DRef m_geom;
46  bool m_bodyUpdated;
47  };
48 }
49 
50 #include <NDK/Components/CollisionComponent3D.inl>
51 
52 #endif // NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
TODO: For now is unable to display different color in the history, it needs a RichTextDrawer to do so...
Definition: Algorithm.hpp:12
NDK class that represents the component for collision (meant for static objects)
Definition: CollisionComponent3D.hpp:17
NDK class that represents the common base of all components.
Definition: BaseComponent.hpp:17