ik.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*************************************************************************/
  2. /* ik.h */
  3. /* Copyright (c) 2016 Sergey Lapin <slapinid@gmail.com> */
  4. /*************************************************************************/
  5. /* This file is part of: */
  6. /* GODOT ENGINE */
  7. /* https://godotengine.org */
  8. /*************************************************************************/
  9. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  10. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  11. /* */
  12. /* Permission is hereby granted, free of charge, to any person obtaining */
  13. /* a copy of this software and associated documentation files (the */
  14. /* "Software"), to deal in the Software without restriction, including */
  15. /* without limitation the rights to use, copy, modify, merge, publish, */
  16. /* distribute, sublicense, and/or sell copies of the Software, and to */
  17. /* permit persons to whom the Software is furnished to do so, subject to */
  18. /* the following conditions: */
  19. /* */
  20. /* The above copyright notice and this permission notice shall be */
  21. /* included in all copies or substantial portions of the Software. */
  22. /* */
  23. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  24. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  25. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  26. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  27. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  28. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  29. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  30. /*************************************************************************/
  31. #ifndef IK_H
  32. #define IK_H
  33. #include "scene/3d/skeleton.h"
  34. class InverseKinematics : public Spatial {
  35. OBJ_TYPE(InverseKinematics, Spatial);
  36. bool bound;
  37. String ik_bone;
  38. int ik_bone_no;
  39. int tail_bone;
  40. int chain_size;
  41. Skeleton *skel;
  42. List<int> chain;
  43. void _check_bind();
  44. void _check_unbind();
  45. int iterations;
  46. float precision;
  47. float speed;
  48. bool changed;
  49. protected:
  50. bool _set(const StringName &p_name, const Variant &p_value);
  51. bool _get(const StringName &p_name, Variant &r_ret) const;
  52. void _get_property_list(List<PropertyInfo> *p_list) const;
  53. void _notification(int p_what);
  54. static void _bind_methods();
  55. void update_parameters();
  56. public:
  57. Skeleton *get_skeleton();
  58. void set_bone_name(const String &p_name);
  59. String get_bone_name() const;
  60. void set_iterations(int itn);
  61. int get_iterations() const;
  62. void set_chain_size(int cs);
  63. int get_chain_size() const;
  64. void set_precision(float p);
  65. float get_precision() const;
  66. void set_speed(float p);
  67. float get_speed() const;
  68. InverseKinematics();
  69. };
  70. #endif