light_occluder_2d.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*************************************************************************/
  2. /* light_occluder_2d.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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 LIGHTOCCLUDER2D_H
  31. #define LIGHTOCCLUDER2D_H
  32. #include "scene/2d/node_2d.h"
  33. class OccluderPolygon2D : public Resource {
  34. GDCLASS(OccluderPolygon2D, Resource);
  35. public:
  36. enum CullMode {
  37. CULL_DISABLED,
  38. CULL_CLOCKWISE,
  39. CULL_COUNTER_CLOCKWISE
  40. };
  41. private:
  42. RID occ_polygon;
  43. PoolVector<Vector2> polygon;
  44. bool closed;
  45. CullMode cull;
  46. protected:
  47. static void _bind_methods();
  48. public:
  49. void set_polygon(const PoolVector<Vector2> &p_polygon);
  50. PoolVector<Vector2> get_polygon() const;
  51. void set_closed(bool p_closed);
  52. bool is_closed() const;
  53. void set_cull_mode(CullMode p_mode);
  54. CullMode get_cull_mode() const;
  55. virtual RID get_rid() const;
  56. OccluderPolygon2D();
  57. ~OccluderPolygon2D();
  58. };
  59. VARIANT_ENUM_CAST(OccluderPolygon2D::CullMode);
  60. class LightOccluder2D : public Node2D {
  61. GDCLASS(LightOccluder2D, Node2D);
  62. RID occluder;
  63. bool enabled;
  64. int mask;
  65. Ref<OccluderPolygon2D> occluder_polygon;
  66. #ifdef DEBUG_ENABLED
  67. void _poly_changed();
  68. #endif
  69. protected:
  70. void _notification(int p_what);
  71. static void _bind_methods();
  72. public:
  73. void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);
  74. Ref<OccluderPolygon2D> get_occluder_polygon() const;
  75. void set_occluder_light_mask(int p_mask);
  76. int get_occluder_light_mask() const;
  77. String get_configuration_warning() const;
  78. LightOccluder2D();
  79. ~LightOccluder2D();
  80. };
  81. #endif // LIGHTOCCLUDER2D_H