1 /**
2 A hinge between two 3D PhysicsBodies.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.hingejoint;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.joint;
25 /**
26 A hinge between two 3D PhysicsBodies.
27 
28 A HingeJoint normally uses the Z axis of body A as the hinge axis, another axis can be specified when adding it manually though. See also $(D Generic6DOFJoint).
29 */
30 @GodotBaseClass struct HingeJoint
31 {
32 	package(godot) enum string _GODOT_internal_name = "HingeJoint";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ Joint _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("_get_lower_limit") GodotMethod!(double) _getLowerLimit;
43 		@GodotName("_get_upper_limit") GodotMethod!(double) _getUpperLimit;
44 		@GodotName("_set_lower_limit") GodotMethod!(void, double) _setLowerLimit;
45 		@GodotName("_set_upper_limit") GodotMethod!(void, double) _setUpperLimit;
46 		@GodotName("get_flag") GodotMethod!(bool, long) getFlag;
47 		@GodotName("get_param") GodotMethod!(double, long) getParam;
48 		@GodotName("set_flag") GodotMethod!(void, long, bool) setFlag;
49 		@GodotName("set_param") GodotMethod!(void, long, double) setParam;
50 	}
51 	/// 
52 	pragma(inline, true) bool opEquals(in HingeJoint other) const
53 	{ return _godot_object.ptr is other._godot_object.ptr; }
54 	/// 
55 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
56 	{ _godot_object.ptr = n; return null; }
57 	/// 
58 	pragma(inline, true) bool opEquals(typeof(null) n) const
59 	{ return _godot_object.ptr is n; }
60 	/// 
61 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
62 	mixin baseCasts;
63 	/// Construct a new instance of HingeJoint.
64 	/// Note: use `memnew!HingeJoint` instead.
65 	static HingeJoint _new()
66 	{
67 		static godot_class_constructor constructor;
68 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("HingeJoint");
69 		if(constructor is null) return typeof(this).init;
70 		return cast(HingeJoint)(constructor());
71 	}
72 	@disable new(size_t s);
73 	/// 
74 	enum Param : int
75 	{
76 		/**
77 		The speed with which the two bodies get pulled together when they move in different directions.
78 		*/
79 		paramBias = 0,
80 		/**
81 		The maximum rotation. Only active if $(D angularLimit/enable) is `true`.
82 		*/
83 		paramLimitUpper = 1,
84 		/**
85 		The minimum rotation. Only active if $(D angularLimit/enable) is `true`.
86 		*/
87 		paramLimitLower = 2,
88 		/**
89 		The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
90 		*/
91 		paramLimitBias = 3,
92 		/**
93 		
94 		*/
95 		paramLimitSoftness = 4,
96 		/**
97 		The lower this value, the more the rotation gets slowed down.
98 		*/
99 		paramLimitRelaxation = 5,
100 		/**
101 		Target speed for the motor.
102 		*/
103 		paramMotorTargetVelocity = 6,
104 		/**
105 		Maximum acceleration for the motor.
106 		*/
107 		paramMotorMaxImpulse = 7,
108 		/**
109 		Represents the size of the $(D param) enum.
110 		*/
111 		paramMax = 8,
112 	}
113 	/// 
114 	enum Flag : int
115 	{
116 		/**
117 		If `true`, the hinges maximum and minimum rotation, defined by $(D angularLimit/lower) and $(D angularLimit/upper) has effects.
118 		*/
119 		flagUseLimit = 0,
120 		/**
121 		When activated, a motor turns the hinge.
122 		*/
123 		flagEnableMotor = 1,
124 		/**
125 		Represents the size of the $(D flag) enum.
126 		*/
127 		flagMax = 2,
128 	}
129 	/// 
130 	enum Constants : int
131 	{
132 		paramBias = 0,
133 		flagUseLimit = 0,
134 		flagEnableMotor = 1,
135 		paramLimitUpper = 1,
136 		flagMax = 2,
137 		paramLimitLower = 2,
138 		paramLimitBias = 3,
139 		paramLimitSoftness = 4,
140 		paramLimitRelaxation = 5,
141 		paramMotorTargetVelocity = 6,
142 		paramMotorMaxImpulse = 7,
143 		paramMax = 8,
144 	}
145 	/**
146 	
147 	*/
148 	double _getLowerLimit() const
149 	{
150 		Array _GODOT_args = Array.make();
151 		String _GODOT_method_name = String("_get_lower_limit");
152 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double);
153 	}
154 	/**
155 	
156 	*/
157 	double _getUpperLimit() const
158 	{
159 		Array _GODOT_args = Array.make();
160 		String _GODOT_method_name = String("_get_upper_limit");
161 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double);
162 	}
163 	/**
164 	
165 	*/
166 	void _setLowerLimit(in double lower_limit)
167 	{
168 		Array _GODOT_args = Array.make();
169 		_GODOT_args.append(lower_limit);
170 		String _GODOT_method_name = String("_set_lower_limit");
171 		this.callv(_GODOT_method_name, _GODOT_args);
172 	}
173 	/**
174 	
175 	*/
176 	void _setUpperLimit(in double upper_limit)
177 	{
178 		Array _GODOT_args = Array.make();
179 		_GODOT_args.append(upper_limit);
180 		String _GODOT_method_name = String("_set_upper_limit");
181 		this.callv(_GODOT_method_name, _GODOT_args);
182 	}
183 	/**
184 	Returns the value of the specified flag.
185 	*/
186 	bool getFlag(in long flag) const
187 	{
188 		checkClassBinding!(typeof(this))();
189 		return ptrcall!(bool)(GDNativeClassBinding.getFlag, _godot_object, flag);
190 	}
191 	/**
192 	Returns the value of the specified parameter.
193 	*/
194 	double getParam(in long param) const
195 	{
196 		checkClassBinding!(typeof(this))();
197 		return ptrcall!(double)(GDNativeClassBinding.getParam, _godot_object, param);
198 	}
199 	/**
200 	If `true`, enables the specified flag.
201 	*/
202 	void setFlag(in long flag, in bool enabled)
203 	{
204 		checkClassBinding!(typeof(this))();
205 		ptrcall!(void)(GDNativeClassBinding.setFlag, _godot_object, flag, enabled);
206 	}
207 	/**
208 	Sets the value of the specified parameter.
209 	*/
210 	void setParam(in long param, in double value)
211 	{
212 		checkClassBinding!(typeof(this))();
213 		ptrcall!(void)(GDNativeClassBinding.setParam, _godot_object, param, value);
214 	}
215 	/**
216 	The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
217 	*/
218 	@property double angularLimitBias()
219 	{
220 		return getParam(3);
221 	}
222 	/// ditto
223 	@property void angularLimitBias(double v)
224 	{
225 		setParam(3, v);
226 	}
227 	/**
228 	If `true`, the hinges maximum and minimum rotation, defined by $(D angularLimit/lower) and $(D angularLimit/upper) has effects.
229 	*/
230 	@property bool angularLimitEnable()
231 	{
232 		return getFlag(0);
233 	}
234 	/// ditto
235 	@property void angularLimitEnable(bool v)
236 	{
237 		setFlag(0, v);
238 	}
239 	/**
240 	The minimum rotation. Only active if $(D angularLimit/enable) is `true`.
241 	*/
242 	@property double angularLimitLower()
243 	{
244 		return _getLowerLimit();
245 	}
246 	/// ditto
247 	@property void angularLimitLower(double v)
248 	{
249 		_setLowerLimit(v);
250 	}
251 	/**
252 	The lower this value, the more the rotation gets slowed down.
253 	*/
254 	@property double angularLimitRelaxation()
255 	{
256 		return getParam(5);
257 	}
258 	/// ditto
259 	@property void angularLimitRelaxation(double v)
260 	{
261 		setParam(5, v);
262 	}
263 	/**
264 	
265 	*/
266 	@property double angularLimitSoftness()
267 	{
268 		return getParam(4);
269 	}
270 	/// ditto
271 	@property void angularLimitSoftness(double v)
272 	{
273 		setParam(4, v);
274 	}
275 	/**
276 	The maximum rotation. Only active if $(D angularLimit/enable) is `true`.
277 	*/
278 	@property double angularLimitUpper()
279 	{
280 		return _getUpperLimit();
281 	}
282 	/// ditto
283 	@property void angularLimitUpper(double v)
284 	{
285 		_setUpperLimit(v);
286 	}
287 	/**
288 	When activated, a motor turns the hinge.
289 	*/
290 	@property bool motorEnable()
291 	{
292 		return getFlag(1);
293 	}
294 	/// ditto
295 	@property void motorEnable(bool v)
296 	{
297 		setFlag(1, v);
298 	}
299 	/**
300 	Maximum acceleration for the motor.
301 	*/
302 	@property double motorMaxImpulse()
303 	{
304 		return getParam(7);
305 	}
306 	/// ditto
307 	@property void motorMaxImpulse(double v)
308 	{
309 		setParam(7, v);
310 	}
311 	/**
312 	Target speed for the motor.
313 	*/
314 	@property double motorTargetVelocity()
315 	{
316 		return getParam(6);
317 	}
318 	/// ditto
319 	@property void motorTargetVelocity(double v)
320 	{
321 		setParam(6, v);
322 	}
323 	/**
324 	The speed with which the two bodies get pulled together when they move in different directions.
325 	*/
326 	@property double paramsBias()
327 	{
328 		return getParam(0);
329 	}
330 	/// ditto
331 	@property void paramsBias(double v)
332 	{
333 		setParam(0, v);
334 	}
335 }