gltf_skeleton.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifndef GLTF_SKELETON_H
  31. #define GLTF_SKELETON_H
  32. #include "../gltf_defines.h"
  33. #include "core/io/resource.h"
  34. #include "scene/3d/bone_attachment_3d.h"
  35. #include "scene/3d/skeleton_3d.h"
  36. class GLTFSkeleton : public Resource {
  37. GDCLASS(GLTFSkeleton, Resource);
  38. friend class GLTFDocument;
  39. friend class SkinTool;
  40. friend class FBXDocument;
  41. private:
  42. // The *synthesized* skeletons joints
  43. Vector<GLTFNodeIndex> joints;
  44. // The roots of the skeleton. If there are multiple, each root must have the
  45. // same parent (ie roots are siblings)
  46. Vector<GLTFNodeIndex> roots;
  47. // The created Skeleton3D for the scene
  48. Skeleton3D *godot_skeleton = nullptr;
  49. // Set of unique bone names for the skeleton
  50. HashSet<String> unique_names;
  51. HashMap<int32_t, GLTFNodeIndex> godot_bone_node;
  52. Vector<BoneAttachment3D *> bone_attachments;
  53. protected:
  54. static void _bind_methods();
  55. public:
  56. Vector<GLTFNodeIndex> get_joints();
  57. void set_joints(Vector<GLTFNodeIndex> p_joints);
  58. Vector<GLTFNodeIndex> get_roots();
  59. void set_roots(Vector<GLTFNodeIndex> p_roots);
  60. Skeleton3D *get_godot_skeleton();
  61. // Skeleton *get_godot_skeleton() {
  62. // return godot_skeleton;
  63. // }
  64. // void set_godot_skeleton(Skeleton p_*godot_skeleton) {
  65. // godot_skeleton = p_godot_skeleton;
  66. // }
  67. TypedArray<String> get_unique_names();
  68. void set_unique_names(TypedArray<String> p_unique_names);
  69. //RBMap<int32_t, GLTFNodeIndex> get_godot_bone_node() {
  70. // return godot_bone_node;
  71. //}
  72. //void set_godot_bone_node(const RBMap<int32_t, GLTFNodeIndex> &p_godot_bone_node) {
  73. // godot_bone_node = p_godot_bone_node;
  74. //}
  75. Dictionary get_godot_bone_node();
  76. void set_godot_bone_node(Dictionary p_indict);
  77. //Dictionary get_godot_bone_node() {
  78. // return VariantConversion::to_dict(godot_bone_node);
  79. //}
  80. //void set_godot_bone_node(Dictionary p_indict) {
  81. // VariantConversion::set_from_dict(godot_bone_node, p_indict);
  82. //}
  83. BoneAttachment3D *get_bone_attachment(int idx);
  84. int32_t get_bone_attachment_count();
  85. };
  86. #endif // GLTF_SKELETON_H