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