fbx_bone.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**************************************************************************/
  2. /* fbx_bone.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 FBX_BONE_H
  31. #define FBX_BONE_H
  32. #include "fbx_node.h"
  33. #include "import_state.h"
  34. #include "fbx_parser/FBXDocument.h"
  35. struct PivotTransform;
  36. struct FBXBone : public Reference {
  37. uint64_t parent_bone_id = 0;
  38. uint64_t bone_id = 0;
  39. bool valid_parent = false; // if the parent bone id is set up.
  40. String bone_name = String(); // bone name
  41. bool is_root_bone() const {
  42. return !valid_parent;
  43. }
  44. // Godot specific data
  45. int godot_bone_id = -2; // godot internal bone id assigned after import
  46. // if a bone / armature is the root then FBX skeleton will contain the bone not any other skeleton.
  47. // this is to support joints by themselves in scenes
  48. bool valid_armature_id = false;
  49. uint64_t armature_id = 0;
  50. /* link node is the parent bone */
  51. mutable const FBXDocParser::Geometry *geometry = nullptr;
  52. mutable const FBXDocParser::ModelLimbNode *limb_node = nullptr;
  53. void set_node(Ref<FBXNode> p_node) {
  54. node = p_node;
  55. }
  56. // Stores the pivot xform for this bone
  57. Ref<FBXNode> node = nullptr;
  58. Ref<FBXBone> parent_bone = nullptr;
  59. Ref<FBXSkeleton> fbx_skeleton = nullptr;
  60. };
  61. struct FBXSkinDeformer {
  62. FBXSkinDeformer(Ref<FBXBone> p_bone, const FBXDocParser::Cluster *p_cluster) :
  63. cluster(p_cluster), bone(p_bone) {}
  64. ~FBXSkinDeformer() {}
  65. const FBXDocParser::Cluster *cluster;
  66. Ref<FBXBone> bone;
  67. /* get associate model - the model can be invalid sometimes */
  68. Ref<FBXBone> get_associate_model() const {
  69. return bone->parent_bone;
  70. }
  71. Ref<FBXNode> get_link(const ImportState &state) const;
  72. };
  73. #endif // FBX_BONE_H