gltf_skin.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* gltf_skin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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_SKIN_H
  31. #define GLTF_SKIN_H
  32. #include "core/resource.h"
  33. #include "gltf_document.h"
  34. class GLTFSkin : public Resource {
  35. GDCLASS(GLTFSkin, Resource);
  36. friend class GLTFDocument;
  37. private:
  38. // The "skeleton" property defined in the gltf spec. -1 = Scene Root
  39. GLTFNodeIndex skin_root = -1;
  40. Vector<GLTFNodeIndex> joints_original;
  41. Vector<Transform> inverse_binds;
  42. // Note: joints + non_joints should form a complete subtree, or subtrees
  43. // with a common parent
  44. // All nodes that are skins that are caught in-between the original joints
  45. // (inclusive of joints_original)
  46. Vector<GLTFNodeIndex> joints;
  47. // All Nodes that are caught in-between skin joint nodes, and are not
  48. // defined as joints by any skin
  49. Vector<GLTFNodeIndex> non_joints;
  50. // The roots of the skin. In the case of multiple roots, their parent *must*
  51. // be the same (the roots must be siblings)
  52. Vector<GLTFNodeIndex> roots;
  53. // The GLTF Skeleton this Skin points to (after we determine skeletons)
  54. GLTFSkeletonIndex skeleton = -1;
  55. // A mapping from the joint indices (in the order of joints_original) to the
  56. // Godot Skeleton's bone_indices
  57. Map<int, int> joint_i_to_bone_i;
  58. Map<int, StringName> joint_i_to_name;
  59. // The Actual Skin that will be created as a mapping between the IBM's of
  60. // this skin to the generated skeleton for the mesh instances.
  61. Ref<Skin> godot_skin;
  62. protected:
  63. static void _bind_methods();
  64. public:
  65. GLTFNodeIndex get_skin_root();
  66. void set_skin_root(GLTFNodeIndex p_skin_root);
  67. Vector<GLTFNodeIndex> get_joints_original();
  68. void set_joints_original(Vector<GLTFNodeIndex> p_joints_original);
  69. Array get_inverse_binds();
  70. void set_inverse_binds(Array p_inverse_binds);
  71. Vector<GLTFNodeIndex> get_joints();
  72. void set_joints(Vector<GLTFNodeIndex> p_joints);
  73. Vector<GLTFNodeIndex> get_non_joints();
  74. void set_non_joints(Vector<GLTFNodeIndex> p_non_joints);
  75. Vector<GLTFNodeIndex> get_roots();
  76. void set_roots(Vector<GLTFNodeIndex> p_roots);
  77. int get_skeleton();
  78. void set_skeleton(int p_skeleton);
  79. Dictionary get_joint_i_to_bone_i();
  80. void set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i);
  81. Dictionary get_joint_i_to_name();
  82. void set_joint_i_to_name(Dictionary p_joint_i_to_name);
  83. Ref<Skin> get_godot_skin();
  84. void set_godot_skin(Ref<Skin> p_godot_skin);
  85. };
  86. #endif // GLTF_SKIN_H