Leviathan  0.8.0.0
Leviathan game engine
Constraints.h
Go to the documentation of this file.
1 #pragma once
2 // ------------------------------------ //
3 #include "Define.h"
4 // ------------------------------------ //
5 #include "Common/ThreadSafe.h"
6 #include "../../Common/Types.h"
7 #include "../Components.h"
8 
9 namespace Leviathan{
10 
13  {
15  Slider = 1,
16 
17 
21 
22 
23 
26  Destructed,
27 
28  Custom = 1000
29  };
30 
34  public:
35 
36 
37  };
38 
39 
42  class BaseConstraint : public ThreadSafe{
43  public:
45  Constraintable &first, Constraintable &second);
46 
50  DLLEXPORT BaseConstraint(ENTITY_CONSTRAINT_TYPE type, GameWorld* world,
51  Constraintable &first, Constraintable &second, int id);
52 
53 
54  DLLEXPORT virtual ~BaseConstraint();
55 
61  DLLEXPORT virtual bool Init();
62 
64  DLLEXPORT void Release();
65 
70  DLLEXPORT void Destroy(Constraintable* skipthis = nullptr);
71 
73  return Type;
74  }
75 
77  DLLEXPORT Constraintable& GetFirstEntity() const;
78 
80  DLLEXPORT Constraintable& GetSecondEntity() const;
81 
83  DLLEXPORT int GetID() const;
84 
85  protected:
86  // called to verify params before init proceeds //
87  DLLEXPORT virtual bool _CheckParameters();
88  DLLEXPORT virtual bool _CreateActualJoint();
89 
90  // ------------------------------------ //
91  Constraintable& FirstObject;
92  Constraintable& SecondObject;
93 
95  int ID;
96 
100  NewtonJoint* Joint;
101 
104  };
105 
106  // Different types of constraints //
107 
111  public:
112  DLLEXPORT SliderConstraint(GameWorld* world, Constraintable &first,
113  Constraintable &second);
114 
118  DLLEXPORT SliderConstraint(GameWorld* world, Constraintable &first,
119  Constraintable &second, int id);
120 
121  DLLEXPORT virtual ~SliderConstraint();
122 
123 
128  DLLEXPORT SliderConstraint* SetParameters(const Float3 &slidingaxis);
129 
130 
132  DLLEXPORT Float3 GetAxis() const;
133 
134  protected:
135  virtual bool _CheckParameters() override;
136  virtual bool _CreateActualJoint() override;
137  // ------------------------------------ //
138 
139  // Stored parameters //
141 
142  };
143 
144 }
145 
Constraintable & FirstObject
Definition: Constraints.h:91
All values above this are application specific types.
Allows the inherited object to be locked.
Definition: ThreadSafe.h:107
Base class for constraint data types, used to serialize constraint states to state objects...
Definition: Constraints.h:33
DLLEXPORT ENTITY_CONSTRAINT_TYPE GetType() const
Definition: Constraints.h:72
ENTITY_CONSTRAINT_TYPE Type
Constraint type used by serializers to identify the type.
Definition: Constraints.h:103
unsigned short uint16_t
Definition: core.h:39
ENTITY_CONSTRAINT_TYPE
Holds built-in types of constraints, used to identify types over the network.
Definition: Constraints.h:12
#define DLLEXPORT
Definition: Include.h:118
Constraintable & SecondObject
Definition: Constraints.h:92
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
int ID
Server and client matching identifier for deleting constraints.
Definition: Constraints.h:95
Represents a world that contains entities.
Definition: GameWorld.h:96