animation_blend_space_1d.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*************************************************************************/
  2. /* animation_blend_space_1d.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 ANIMATION_BLEND_SPACE_1D_H
  31. #define ANIMATION_BLEND_SPACE_1D_H
  32. #include "scene/animation/animation_tree.h"
  33. class AnimationNodeBlendSpace1D : public AnimationRootNode {
  34. GDCLASS(AnimationNodeBlendSpace1D, AnimationRootNode)
  35. enum {
  36. MAX_BLEND_POINTS = 64
  37. };
  38. struct BlendPoint {
  39. StringName name;
  40. Ref<AnimationRootNode> node;
  41. float position;
  42. };
  43. BlendPoint blend_points[MAX_BLEND_POINTS];
  44. int blend_points_used;
  45. float max_space;
  46. float min_space;
  47. float snap;
  48. String value_label;
  49. void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node);
  50. void _tree_changed();
  51. StringName blend_position;
  52. protected:
  53. virtual void _validate_property(PropertyInfo &property) const;
  54. static void _bind_methods();
  55. public:
  56. virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
  57. virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
  58. virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
  59. void add_blend_point(const Ref<AnimationRootNode> &p_node, float p_position, int p_at_index = -1);
  60. void set_blend_point_position(int p_point, float p_position);
  61. void set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node);
  62. float get_blend_point_position(int p_point) const;
  63. Ref<AnimationRootNode> get_blend_point_node(int p_point) const;
  64. void remove_blend_point(int p_point);
  65. int get_blend_point_count() const;
  66. void set_min_space(float p_min);
  67. float get_min_space() const;
  68. void set_max_space(float p_max);
  69. float get_max_space() const;
  70. void set_snap(float p_snap);
  71. float get_snap() const;
  72. void set_value_label(const String &p_label);
  73. String get_value_label() const;
  74. float process(float p_time, bool p_seek);
  75. String get_caption() const;
  76. Ref<AnimationNode> get_child_by_name(const StringName &p_name);
  77. AnimationNodeBlendSpace1D();
  78. ~AnimationNodeBlendSpace1D();
  79. };
  80. #endif // ANIMATION_BLEND_SPACE_1D_H