path_2d.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*************************************************************************/
  2. /* path_2d.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 PATH_2D_H
  31. #define PATH_2D_H
  32. #include "scene/2d/node_2d.h"
  33. #include "scene/resources/curve.h"
  34. class Path2D : public Node2D {
  35. GDCLASS(Path2D, Node2D);
  36. Ref<Curve2D> curve;
  37. void _curve_changed();
  38. protected:
  39. void _notification(int p_what);
  40. static void _bind_methods();
  41. public:
  42. virtual Rect2 _edit_get_rect() const;
  43. virtual bool _edit_use_rect() const;
  44. virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
  45. void set_curve(const Ref<Curve2D> &p_curve);
  46. Ref<Curve2D> get_curve() const;
  47. Path2D();
  48. };
  49. class PathFollow2D : public Node2D {
  50. GDCLASS(PathFollow2D, Node2D);
  51. public:
  52. private:
  53. Path2D *path;
  54. real_t offset;
  55. real_t h_offset;
  56. real_t v_offset;
  57. real_t lookahead;
  58. bool cubic;
  59. bool loop;
  60. bool rotate;
  61. void _update_transform();
  62. protected:
  63. virtual void _validate_property(PropertyInfo &property) const;
  64. void _notification(int p_what);
  65. static void _bind_methods();
  66. public:
  67. void set_offset(float p_offset);
  68. float get_offset() const;
  69. void set_h_offset(float p_h_offset);
  70. float get_h_offset() const;
  71. void set_v_offset(float p_v_offset);
  72. float get_v_offset() const;
  73. void set_unit_offset(float p_unit_offset);
  74. float get_unit_offset() const;
  75. void set_lookahead(float p_lookahead);
  76. float get_lookahead() const;
  77. void set_loop(bool p_loop);
  78. bool has_loop() const;
  79. void set_rotate(bool p_rotate);
  80. bool is_rotating() const;
  81. void set_cubic_interpolation(bool p_enable);
  82. bool get_cubic_interpolation() const;
  83. String get_configuration_warning() const;
  84. PathFollow2D();
  85. };
  86. #endif // PATH_2D_H