skeleton_modifier_3d.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**************************************************************************/
  2. /* skeleton_modifier_3d.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 SKELETON_MODIFIER_3D_H
  31. #define SKELETON_MODIFIER_3D_H
  32. #include "scene/3d/node_3d.h"
  33. #include "scene/3d/skeleton_3d.h"
  34. class SkeletonModifier3D : public Node3D {
  35. GDCLASS(SkeletonModifier3D, Node3D);
  36. void rebind();
  37. public:
  38. enum BoneAxis {
  39. BONE_AXIS_PLUS_X,
  40. BONE_AXIS_MINUS_X,
  41. BONE_AXIS_PLUS_Y,
  42. BONE_AXIS_MINUS_Y,
  43. BONE_AXIS_PLUS_Z,
  44. BONE_AXIS_MINUS_Z,
  45. };
  46. protected:
  47. bool active = true;
  48. real_t influence = 1.0;
  49. // Cache them for the performance reason since finding node with NodePath is slow.
  50. ObjectID skeleton_id;
  51. void _update_skeleton();
  52. void _update_skeleton_path();
  53. void _force_update_skeleton_skin();
  54. virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new);
  55. void _validate_property(PropertyInfo &p_property) const;
  56. void _notification(int p_what);
  57. static void _bind_methods();
  58. virtual void _set_active(bool p_active);
  59. virtual void _process_modification();
  60. GDVIRTUAL0(_process_modification);
  61. public:
  62. virtual PackedStringArray get_configuration_warnings() const override;
  63. virtual bool has_process() const { return false; } // Return true if modifier needs to modify bone pose without external animation such as physics, jiggle and etc.
  64. void set_active(bool p_active);
  65. bool is_active() const;
  66. void set_influence(real_t p_influence);
  67. real_t get_influence() const;
  68. Skeleton3D *get_skeleton() const;
  69. void process_modification();
  70. // Utility APIs.
  71. static Vector3 get_vector_from_bone_axis(BoneAxis p_axis);
  72. static Vector3 get_vector_from_axis(Vector3::Axis p_axis);
  73. static Vector3::Axis get_axis_from_bone_axis(BoneAxis p_axis);
  74. #ifdef TOOLS_ENABLED
  75. virtual bool is_processed_on_saving() const { return false; }
  76. #endif
  77. SkeletonModifier3D();
  78. };
  79. VARIANT_ENUM_CAST(SkeletonModifier3D::BoneAxis);
  80. #endif // SKELETON_MODIFIER_3D_H