1 /**
2 Skeleton for characters and animated objects.
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.skeleton;
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.spatial;
25 import godot.node;
26 import godot.skinreference;
27 import godot.skin;
28 /**
29 Skeleton for characters and animated objects.
30 
31 Skeleton provides a hierarchical interface for managing bones, including pose, rest and animation (see $(D Animation)). It can also use ragdoll physics.
32 The overall transform of a bone with respect to the skeleton is determined by the following hierarchical order: rest pose, custom pose and pose.
33 Note that "global pose" below refers to the overall transform of the bone with respect to skeleton, so it not the actual global/world transform of the bone.
34 */
35 @GodotBaseClass struct Skeleton
36 {
37 	package(godot) enum string _GODOT_internal_name = "Skeleton";
38 public:
39 @nogc nothrow:
40 	union { /** */ godot_object _godot_object; /** */ Spatial _GODOT_base; }
41 	alias _GODOT_base this;
42 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
43 	package(godot) __gshared bool _classBindingInitialized = false;
44 	package(godot) static struct GDNativeClassBinding
45 	{
46 		__gshared:
47 		@GodotName("add_bone") GodotMethod!(void, String) addBone;
48 		@GodotName("bind_child_node_to_bone") GodotMethod!(void, long, Node) bindChildNodeToBone;
49 		@GodotName("clear_bones") GodotMethod!(void) clearBones;
50 		@GodotName("clear_bones_global_pose_override") GodotMethod!(void) clearBonesGlobalPoseOverride;
51 		@GodotName("find_bone") GodotMethod!(long, String) findBone;
52 		@GodotName("get_bone_count") GodotMethod!(long) getBoneCount;
53 		@GodotName("get_bone_custom_pose") GodotMethod!(Transform, long) getBoneCustomPose;
54 		@GodotName("get_bone_global_pose") GodotMethod!(Transform, long) getBoneGlobalPose;
55 		@GodotName("get_bone_global_pose_no_override") GodotMethod!(Transform, long) getBoneGlobalPoseNoOverride;
56 		@GodotName("get_bone_name") GodotMethod!(String, long) getBoneName;
57 		@GodotName("get_bone_parent") GodotMethod!(long, long) getBoneParent;
58 		@GodotName("get_bone_pose") GodotMethod!(Transform, long) getBonePose;
59 		@GodotName("get_bone_rest") GodotMethod!(Transform, long) getBoneRest;
60 		@GodotName("get_bound_child_nodes_to_bone") GodotMethod!(Array, long) getBoundChildNodesToBone;
61 		@GodotName("is_bone_rest_disabled") GodotMethod!(bool, long) isBoneRestDisabled;
62 		@GodotName("localize_rests") GodotMethod!(void) localizeRests;
63 		@GodotName("physical_bones_add_collision_exception") GodotMethod!(void, RID) physicalBonesAddCollisionException;
64 		@GodotName("physical_bones_remove_collision_exception") GodotMethod!(void, RID) physicalBonesRemoveCollisionException;
65 		@GodotName("physical_bones_start_simulation") GodotMethod!(void, Array) physicalBonesStartSimulation;
66 		@GodotName("physical_bones_stop_simulation") GodotMethod!(void) physicalBonesStopSimulation;
67 		@GodotName("register_skin") GodotMethod!(SkinReference, Skin) registerSkin;
68 		@GodotName("set_bone_custom_pose") GodotMethod!(void, long, Transform) setBoneCustomPose;
69 		@GodotName("set_bone_disable_rest") GodotMethod!(void, long, bool) setBoneDisableRest;
70 		@GodotName("set_bone_global_pose_override") GodotMethod!(void, long, Transform, double, bool) setBoneGlobalPoseOverride;
71 		@GodotName("set_bone_parent") GodotMethod!(void, long, long) setBoneParent;
72 		@GodotName("set_bone_pose") GodotMethod!(void, long, Transform) setBonePose;
73 		@GodotName("set_bone_rest") GodotMethod!(void, long, Transform) setBoneRest;
74 		@GodotName("unbind_child_node_from_bone") GodotMethod!(void, long, Node) unbindChildNodeFromBone;
75 		@GodotName("unparent_bone_and_rest") GodotMethod!(void, long) unparentBoneAndRest;
76 	}
77 	/// 
78 	pragma(inline, true) bool opEquals(in Skeleton other) const
79 	{ return _godot_object.ptr is other._godot_object.ptr; }
80 	/// 
81 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
82 	{ _godot_object.ptr = n; return null; }
83 	/// 
84 	pragma(inline, true) bool opEquals(typeof(null) n) const
85 	{ return _godot_object.ptr is n; }
86 	/// 
87 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
88 	mixin baseCasts;
89 	/// Construct a new instance of Skeleton.
90 	/// Note: use `memnew!Skeleton` instead.
91 	static Skeleton _new()
92 	{
93 		static godot_class_constructor constructor;
94 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Skeleton");
95 		if(constructor is null) return typeof(this).init;
96 		return cast(Skeleton)(constructor());
97 	}
98 	@disable new(size_t s);
99 	/// 
100 	enum Constants : int
101 	{
102 		/**
103 		
104 		*/
105 		notificationUpdateSkeleton = 50,
106 	}
107 	/**
108 	Adds a bone, with name `name`. $(D getBoneCount) will become the bone index.
109 	*/
110 	void addBone(in String name)
111 	{
112 		checkClassBinding!(typeof(this))();
113 		ptrcall!(void)(GDNativeClassBinding.addBone, _godot_object, name);
114 	}
115 	/**
116 	$(I Deprecated soon.)
117 	*/
118 	void bindChildNodeToBone(in long bone_idx, Node node)
119 	{
120 		checkClassBinding!(typeof(this))();
121 		ptrcall!(void)(GDNativeClassBinding.bindChildNodeToBone, _godot_object, bone_idx, node);
122 	}
123 	/**
124 	Clear all the bones in this skeleton.
125 	*/
126 	void clearBones()
127 	{
128 		checkClassBinding!(typeof(this))();
129 		ptrcall!(void)(GDNativeClassBinding.clearBones, _godot_object);
130 	}
131 	/**
132 	
133 	*/
134 	void clearBonesGlobalPoseOverride()
135 	{
136 		checkClassBinding!(typeof(this))();
137 		ptrcall!(void)(GDNativeClassBinding.clearBonesGlobalPoseOverride, _godot_object);
138 	}
139 	/**
140 	Returns the bone index that matches `name` as its name.
141 	*/
142 	long findBone(in String name) const
143 	{
144 		checkClassBinding!(typeof(this))();
145 		return ptrcall!(long)(GDNativeClassBinding.findBone, _godot_object, name);
146 	}
147 	/**
148 	Returns the amount of bones in the skeleton.
149 	*/
150 	long getBoneCount() const
151 	{
152 		checkClassBinding!(typeof(this))();
153 		return ptrcall!(long)(GDNativeClassBinding.getBoneCount, _godot_object);
154 	}
155 	/**
156 	Returns the custom pose of the specified bone. Custom pose is applied on top of the rest pose.
157 	*/
158 	Transform getBoneCustomPose(in long bone_idx) const
159 	{
160 		checkClassBinding!(typeof(this))();
161 		return ptrcall!(Transform)(GDNativeClassBinding.getBoneCustomPose, _godot_object, bone_idx);
162 	}
163 	/**
164 	Returns the overall transform of the specified bone, with respect to the skeleton. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
165 	*/
166 	Transform getBoneGlobalPose(in long bone_idx) const
167 	{
168 		checkClassBinding!(typeof(this))();
169 		return ptrcall!(Transform)(GDNativeClassBinding.getBoneGlobalPose, _godot_object, bone_idx);
170 	}
171 	/**
172 	Returns the overall transform of the specified bone, with respect to the skeleton, but without any global pose overrides. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
173 	*/
174 	Transform getBoneGlobalPoseNoOverride(in long bone_idx) const
175 	{
176 		checkClassBinding!(typeof(this))();
177 		return ptrcall!(Transform)(GDNativeClassBinding.getBoneGlobalPoseNoOverride, _godot_object, bone_idx);
178 	}
179 	/**
180 	Returns the name of the bone at index `index`.
181 	*/
182 	String getBoneName(in long bone_idx) const
183 	{
184 		checkClassBinding!(typeof(this))();
185 		return ptrcall!(String)(GDNativeClassBinding.getBoneName, _godot_object, bone_idx);
186 	}
187 	/**
188 	Returns the bone index which is the parent of the bone at `bone_idx`. If -1, then bone has no parent.
189 	$(B Note:) The parent bone returned will always be less than `bone_idx`.
190 	*/
191 	long getBoneParent(in long bone_idx) const
192 	{
193 		checkClassBinding!(typeof(this))();
194 		return ptrcall!(long)(GDNativeClassBinding.getBoneParent, _godot_object, bone_idx);
195 	}
196 	/**
197 	Returns the pose transform of the specified bone. Pose is applied on top of the custom pose, which is applied on top the rest pose.
198 	*/
199 	Transform getBonePose(in long bone_idx) const
200 	{
201 		checkClassBinding!(typeof(this))();
202 		return ptrcall!(Transform)(GDNativeClassBinding.getBonePose, _godot_object, bone_idx);
203 	}
204 	/**
205 	Returns the rest transform for a bone `bone_idx`.
206 	*/
207 	Transform getBoneRest(in long bone_idx) const
208 	{
209 		checkClassBinding!(typeof(this))();
210 		return ptrcall!(Transform)(GDNativeClassBinding.getBoneRest, _godot_object, bone_idx);
211 	}
212 	/**
213 	$(I Deprecated soon.)
214 	*/
215 	Array getBoundChildNodesToBone(in long bone_idx) const
216 	{
217 		checkClassBinding!(typeof(this))();
218 		return ptrcall!(Array)(GDNativeClassBinding.getBoundChildNodesToBone, _godot_object, bone_idx);
219 	}
220 	/**
221 	
222 	*/
223 	bool isBoneRestDisabled(in long bone_idx) const
224 	{
225 		checkClassBinding!(typeof(this))();
226 		return ptrcall!(bool)(GDNativeClassBinding.isBoneRestDisabled, _godot_object, bone_idx);
227 	}
228 	/**
229 	
230 	*/
231 	void localizeRests()
232 	{
233 		checkClassBinding!(typeof(this))();
234 		ptrcall!(void)(GDNativeClassBinding.localizeRests, _godot_object);
235 	}
236 	/**
237 	
238 	*/
239 	void physicalBonesAddCollisionException(in RID exception)
240 	{
241 		checkClassBinding!(typeof(this))();
242 		ptrcall!(void)(GDNativeClassBinding.physicalBonesAddCollisionException, _godot_object, exception);
243 	}
244 	/**
245 	
246 	*/
247 	void physicalBonesRemoveCollisionException(in RID exception)
248 	{
249 		checkClassBinding!(typeof(this))();
250 		ptrcall!(void)(GDNativeClassBinding.physicalBonesRemoveCollisionException, _godot_object, exception);
251 	}
252 	/**
253 	
254 	*/
255 	void physicalBonesStartSimulation(in Array bones = Array.make())
256 	{
257 		checkClassBinding!(typeof(this))();
258 		ptrcall!(void)(GDNativeClassBinding.physicalBonesStartSimulation, _godot_object, bones);
259 	}
260 	/**
261 	
262 	*/
263 	void physicalBonesStopSimulation()
264 	{
265 		checkClassBinding!(typeof(this))();
266 		ptrcall!(void)(GDNativeClassBinding.physicalBonesStopSimulation, _godot_object);
267 	}
268 	/**
269 	
270 	*/
271 	Ref!SkinReference registerSkin(Skin skin)
272 	{
273 		checkClassBinding!(typeof(this))();
274 		return ptrcall!(SkinReference)(GDNativeClassBinding.registerSkin, _godot_object, skin);
275 	}
276 	/**
277 	
278 	*/
279 	void setBoneCustomPose(in long bone_idx, in Transform custom_pose)
280 	{
281 		checkClassBinding!(typeof(this))();
282 		ptrcall!(void)(GDNativeClassBinding.setBoneCustomPose, _godot_object, bone_idx, custom_pose);
283 	}
284 	/**
285 	
286 	*/
287 	void setBoneDisableRest(in long bone_idx, in bool disable)
288 	{
289 		checkClassBinding!(typeof(this))();
290 		ptrcall!(void)(GDNativeClassBinding.setBoneDisableRest, _godot_object, bone_idx, disable);
291 	}
292 	/**
293 	
294 	*/
295 	void setBoneGlobalPoseOverride(in long bone_idx, in Transform pose, in double amount, in bool persistent = false)
296 	{
297 		checkClassBinding!(typeof(this))();
298 		ptrcall!(void)(GDNativeClassBinding.setBoneGlobalPoseOverride, _godot_object, bone_idx, pose, amount, persistent);
299 	}
300 	/**
301 	Sets the bone index `parent_idx` as the parent of the bone at `bone_idx`. If -1, then bone has no parent.
302 	$(B Note:) `parent_idx` must be less than `bone_idx`.
303 	*/
304 	void setBoneParent(in long bone_idx, in long parent_idx)
305 	{
306 		checkClassBinding!(typeof(this))();
307 		ptrcall!(void)(GDNativeClassBinding.setBoneParent, _godot_object, bone_idx, parent_idx);
308 	}
309 	/**
310 	Sets the pose transform for bone `bone_idx`.
311 	*/
312 	void setBonePose(in long bone_idx, in Transform pose)
313 	{
314 		checkClassBinding!(typeof(this))();
315 		ptrcall!(void)(GDNativeClassBinding.setBonePose, _godot_object, bone_idx, pose);
316 	}
317 	/**
318 	Sets the rest transform for bone `bone_idx`.
319 	*/
320 	void setBoneRest(in long bone_idx, in Transform rest)
321 	{
322 		checkClassBinding!(typeof(this))();
323 		ptrcall!(void)(GDNativeClassBinding.setBoneRest, _godot_object, bone_idx, rest);
324 	}
325 	/**
326 	$(I Deprecated soon.)
327 	*/
328 	void unbindChildNodeFromBone(in long bone_idx, Node node)
329 	{
330 		checkClassBinding!(typeof(this))();
331 		ptrcall!(void)(GDNativeClassBinding.unbindChildNodeFromBone, _godot_object, bone_idx, node);
332 	}
333 	/**
334 	
335 	*/
336 	void unparentBoneAndRest(in long bone_idx)
337 	{
338 		checkClassBinding!(typeof(this))();
339 		ptrcall!(void)(GDNativeClassBinding.unparentBoneAndRest, _godot_object, bone_idx);
340 	}
341 }