| 1 | /**************************************************************************/ | 
|---|
| 2 | /*  gltf_skeleton.h                                                       */ | 
|---|
| 3 | /**************************************************************************/ | 
|---|
| 4 | /*                         This file is part of:                          */ | 
|---|
| 5 | /*                             GODOT ENGINE                               */ | 
|---|
| 6 | /*                        https://godotengine.org                         */ | 
|---|
| 7 | /**************************************************************************/ | 
|---|
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
|---|
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
|---|
| 10 | /*                                                                        */ | 
|---|
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
|---|
| 12 | /* a copy of this software and associated documentation files (the        */ | 
|---|
| 13 | /* "Software"), to deal in the Software without restriction, including    */ | 
|---|
| 14 | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
|---|
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
|---|
| 16 | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
|---|
| 17 | /* the following conditions:                                              */ | 
|---|
| 18 | /*                                                                        */ | 
|---|
| 19 | /* The above copyright notice and this permission notice shall be         */ | 
|---|
| 20 | /* included in all copies or substantial portions of the Software.        */ | 
|---|
| 21 | /*                                                                        */ | 
|---|
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
|---|
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
|---|
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
|---|
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
|---|
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
|---|
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
|---|
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
|---|
| 29 | /**************************************************************************/ | 
|---|
| 30 |  | 
|---|
| 31 | #ifndef GLTF_SKELETON_H | 
|---|
| 32 | #define GLTF_SKELETON_H | 
|---|
| 33 |  | 
|---|
| 34 | #include "../gltf_defines.h" | 
|---|
| 35 |  | 
|---|
| 36 | #include "core/io/resource.h" | 
|---|
| 37 |  | 
|---|
| 38 | class GLTFSkeleton : public Resource { | 
|---|
| 39 | GDCLASS(GLTFSkeleton, Resource); | 
|---|
| 40 | friend class GLTFDocument; | 
|---|
| 41 |  | 
|---|
| 42 | private: | 
|---|
| 43 | // The *synthesized* skeletons joints | 
|---|
| 44 | Vector<GLTFNodeIndex> joints; | 
|---|
| 45 |  | 
|---|
| 46 | // The roots of the skeleton. If there are multiple, each root must have the | 
|---|
| 47 | // same parent (ie roots are siblings) | 
|---|
| 48 | Vector<GLTFNodeIndex> roots; | 
|---|
| 49 |  | 
|---|
| 50 | // The created Skeleton3D for the scene | 
|---|
| 51 | Skeleton3D *godot_skeleton = nullptr; | 
|---|
| 52 |  | 
|---|
| 53 | // Set of unique bone names for the skeleton | 
|---|
| 54 | HashSet<String> unique_names; | 
|---|
| 55 |  | 
|---|
| 56 | HashMap<int32_t, GLTFNodeIndex> godot_bone_node; | 
|---|
| 57 |  | 
|---|
| 58 | Vector<BoneAttachment3D *> bone_attachments; | 
|---|
| 59 |  | 
|---|
| 60 | protected: | 
|---|
| 61 | static void _bind_methods(); | 
|---|
| 62 |  | 
|---|
| 63 | public: | 
|---|
| 64 | Vector<GLTFNodeIndex> get_joints(); | 
|---|
| 65 | void set_joints(Vector<GLTFNodeIndex> p_joints); | 
|---|
| 66 |  | 
|---|
| 67 | Vector<GLTFNodeIndex> get_roots(); | 
|---|
| 68 | void set_roots(Vector<GLTFNodeIndex> p_roots); | 
|---|
| 69 |  | 
|---|
| 70 | Skeleton3D *get_godot_skeleton(); | 
|---|
| 71 |  | 
|---|
| 72 | // Skeleton *get_godot_skeleton() { | 
|---|
| 73 | // 	return this->godot_skeleton; | 
|---|
| 74 | // } | 
|---|
| 75 | // void set_godot_skeleton(Skeleton p_*godot_skeleton) { | 
|---|
| 76 | // 	this->godot_skeleton = p_godot_skeleton; | 
|---|
| 77 | // } | 
|---|
| 78 |  | 
|---|
| 79 | TypedArray<String> get_unique_names(); | 
|---|
| 80 | void set_unique_names(TypedArray<String> p_unique_names); | 
|---|
| 81 |  | 
|---|
| 82 | //RBMap<int32_t, GLTFNodeIndex> get_godot_bone_node() { | 
|---|
| 83 | //	return this->godot_bone_node; | 
|---|
| 84 | //} | 
|---|
| 85 | //void set_godot_bone_node(RBMap<int32_t, GLTFNodeIndex> p_godot_bone_node) { | 
|---|
| 86 | //	this->godot_bone_node = p_godot_bone_node; | 
|---|
| 87 | //} | 
|---|
| 88 | Dictionary get_godot_bone_node(); | 
|---|
| 89 | void set_godot_bone_node(Dictionary p_indict); | 
|---|
| 90 |  | 
|---|
| 91 | //Dictionary get_godot_bone_node() { | 
|---|
| 92 | //	return VariantConversion::to_dict(this->godot_bone_node); | 
|---|
| 93 | //} | 
|---|
| 94 | //void set_godot_bone_node(Dictionary p_indict) { | 
|---|
| 95 | //	VariantConversion::set_from_dict(this->godot_bone_node, p_indict); | 
|---|
| 96 | //} | 
|---|
| 97 |  | 
|---|
| 98 | BoneAttachment3D *get_bone_attachment(int idx); | 
|---|
| 99 |  | 
|---|
| 100 | int32_t get_bone_attachment_count(); | 
|---|
| 101 | }; | 
|---|
| 102 |  | 
|---|
| 103 | #endif // GLTF_SKELETON_H | 
|---|
| 104 |  | 
|---|