1 /**
2 A twist joint between two 3D bodies.
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.conetwistjoint;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.joint;
24 import godot.spatial;
25 import godot.node;
26 /**
27 A twist joint between two 3D bodies.
28 
29 The joint can rotate the bodies across an axis defined by the local x-axes of the $(D Joint).
30 The twist axis is initiated as the x-axis of the $(D Joint).
31 Once the Bodies swing, the twist axis is calculated as the middle of the x-axes of the Joint in the local space of the two Bodies.
32 */
33 @GodotBaseClass struct ConeTwistJoint
34 {
35 	enum string _GODOT_internal_name = "ConeTwistJoint";
36 public:
37 @nogc nothrow:
38 	union { godot_object _godot_object; Joint _GODOT_base; }
39 	alias _GODOT_base this;
40 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
41 	package(godot) __gshared bool _classBindingInitialized = false;
42 	package(godot) static struct _classBinding
43 	{
44 		__gshared:
45 		@GodotName("set_param") GodotMethod!(void, long, double) setParam;
46 		@GodotName("get_param") GodotMethod!(double, long) getParam;
47 		@GodotName("_set_swing_span") GodotMethod!(void, double) _setSwingSpan;
48 		@GodotName("_get_swing_span") GodotMethod!(double) _getSwingSpan;
49 		@GodotName("_set_twist_span") GodotMethod!(void, double) _setTwistSpan;
50 		@GodotName("_get_twist_span") GodotMethod!(double) _getTwistSpan;
51 	}
52 	bool opEquals(in ConeTwistJoint other) const { return _godot_object.ptr is other._godot_object.ptr; }
53 	ConeTwistJoint opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
54 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
55 	mixin baseCasts;
56 	static ConeTwistJoint _new()
57 	{
58 		static godot_class_constructor constructor;
59 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ConeTwistJoint");
60 		if(constructor is null) return typeof(this).init;
61 		return cast(ConeTwistJoint)(constructor());
62 	}
63 	@disable new(size_t s);
64 	/// 
65 	enum Param : int
66 	{
67 		/**
68 		Swing is rotation from side to side, around the axis perpendicular to the twist axis.
69 		The swing span defines, how much rotation will not get corrected allong the swing axis.
70 		Could be defined as looseness in the `ConeTwistJoint`.
71 		If below 0.05, this behaviour is locked. Default value: `PI/4`.
72 		*/
73 		paramSwingSpan = 0,
74 		/**
75 		Twist is the rotation around the twist axis, this value defined how far the joint can twist.
76 		Twist is locked if below 0.05.
77 		*/
78 		paramTwistSpan = 1,
79 		/**
80 		The speed with which the swing or twist will take place.
81 		The higher, the faster.
82 		*/
83 		paramBias = 2,
84 		/**
85 		The ease with which the joint starts to twist. If it's too low, it takes more force to start twisting the joint.
86 		*/
87 		paramSoftness = 3,
88 		/**
89 		Defines, how fast the swing- and twist-speed-difference on both sides gets synced.
90 		*/
91 		paramRelaxation = 4,
92 		/**
93 		End flag of PARAM_* constants, used internally.
94 		*/
95 		paramMax = 5,
96 	}
97 	/// 
98 	enum Constants : int
99 	{
100 		paramSwingSpan = 0,
101 		paramTwistSpan = 1,
102 		paramBias = 2,
103 		paramSoftness = 3,
104 		paramRelaxation = 4,
105 		paramMax = 5,
106 	}
107 	/**
108 	
109 	*/
110 	void setParam(in long param, in double value)
111 	{
112 		checkClassBinding!(typeof(this))();
113 		ptrcall!(void)(_classBinding.setParam, _godot_object, param, value);
114 	}
115 	/**
116 	
117 	*/
118 	double getParam(in long param) const
119 	{
120 		checkClassBinding!(typeof(this))();
121 		return ptrcall!(double)(_classBinding.getParam, _godot_object, param);
122 	}
123 	/**
124 	
125 	*/
126 	void _setSwingSpan(in double swing_span)
127 	{
128 		Array _GODOT_args = Array.empty_array;
129 		_GODOT_args.append(swing_span);
130 		String _GODOT_method_name = String("_set_swing_span");
131 		this.callv(_GODOT_method_name, _GODOT_args);
132 	}
133 	/**
134 	
135 	*/
136 	double _getSwingSpan() const
137 	{
138 		Array _GODOT_args = Array.empty_array;
139 		String _GODOT_method_name = String("_get_swing_span");
140 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double);
141 	}
142 	/**
143 	
144 	*/
145 	void _setTwistSpan(in double twist_span)
146 	{
147 		Array _GODOT_args = Array.empty_array;
148 		_GODOT_args.append(twist_span);
149 		String _GODOT_method_name = String("_set_twist_span");
150 		this.callv(_GODOT_method_name, _GODOT_args);
151 	}
152 	/**
153 	
154 	*/
155 	double _getTwistSpan() const
156 	{
157 		Array _GODOT_args = Array.empty_array;
158 		String _GODOT_method_name = String("_get_twist_span");
159 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double);
160 	}
161 	/**
162 	Swing is rotation from side to side, around the axis perpendicular to the twist axis.
163 	The swing span defines, how much rotation will not get corrected allong the swing axis.
164 	Could be defined as looseness in the `ConeTwistJoint`.
165 	If below 0.05, this behaviour is locked. Default value: `PI/4`.
166 	*/
167 	@property double swingSpan()
168 	{
169 		return _getSwingSpan();
170 	}
171 	/// ditto
172 	@property void swingSpan(double v)
173 	{
174 		_setSwingSpan(v);
175 	}
176 	/**
177 	Twist is the rotation around the twist axis, this value defined how far the joint can twist.
178 	Twist is locked if below 0.05.
179 	*/
180 	@property double twistSpan()
181 	{
182 		return _getTwistSpan();
183 	}
184 	/// ditto
185 	@property void twistSpan(double v)
186 	{
187 		_setTwistSpan(v);
188 	}
189 	/**
190 	The speed with which the swing or twist will take place.
191 	The higher, the faster.
192 	*/
193 	@property double bias()
194 	{
195 		return getParam(2);
196 	}
197 	/// ditto
198 	@property void bias(double v)
199 	{
200 		setParam(2, v);
201 	}
202 	/**
203 	The ease with which the joint starts to twist. If it's too low, it takes more force to start twisting the joint.
204 	*/
205 	@property double softness()
206 	{
207 		return getParam(3);
208 	}
209 	/// ditto
210 	@property void softness(double v)
211 	{
212 		setParam(3, v);
213 	}
214 	/**
215 	Defines, how fast the swing- and twist-speed-difference on both sides gets synced.
216 	*/
217 	@property double relaxation()
218 	{
219 		return getParam(4);
220 	}
221 	/// ditto
222 	@property void relaxation(double v)
223 	{
224 		setParam(4, v);
225 	}
226 }