2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* light_2d.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2016-06-18 12:46:12 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2015-02-16 17:45:11 +00:00
|
|
|
#ifndef LIGHT_2D_H
|
|
|
|
#define LIGHT_2D_H
|
|
|
|
|
|
|
|
#include "scene/2d/node_2d.h"
|
|
|
|
|
|
|
|
class Light2D : public Node2D {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
OBJ_TYPE(Light2D, Node2D);
|
|
|
|
|
2015-04-03 04:43:37 +00:00
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
MODE_ADD,
|
|
|
|
MODE_SUB,
|
|
|
|
MODE_MIX,
|
2015-12-08 23:25:08 +00:00
|
|
|
MODE_MASK,
|
2015-04-03 04:43:37 +00:00
|
|
|
};
|
|
|
|
|
2015-02-16 17:45:11 +00:00
|
|
|
private:
|
|
|
|
RID canvas_light;
|
|
|
|
bool enabled;
|
2016-10-04 14:44:59 +00:00
|
|
|
bool editor_only;
|
2015-02-16 17:45:11 +00:00
|
|
|
bool shadow;
|
|
|
|
Color color;
|
2015-06-24 21:15:43 +00:00
|
|
|
Color shadow_color;
|
2015-02-16 17:45:11 +00:00
|
|
|
float height;
|
2015-03-22 13:33:58 +00:00
|
|
|
float _scale;
|
2015-04-03 04:43:37 +00:00
|
|
|
float energy;
|
2015-02-16 17:45:11 +00:00
|
|
|
int z_min;
|
|
|
|
int z_max;
|
2015-02-18 22:39:44 +00:00
|
|
|
int layer_min;
|
|
|
|
int layer_max;
|
2015-02-16 17:45:11 +00:00
|
|
|
int item_mask;
|
2015-03-09 05:34:56 +00:00
|
|
|
int item_shadow_mask;
|
2015-03-02 03:54:10 +00:00
|
|
|
int shadow_buffer_size;
|
|
|
|
float shadow_esm_multiplier;
|
2015-04-03 04:43:37 +00:00
|
|
|
Mode mode;
|
2015-02-16 17:45:11 +00:00
|
|
|
Ref<Texture> texture;
|
|
|
|
Vector2 texture_offset;
|
|
|
|
|
2016-01-01 13:45:24 +00:00
|
|
|
void _update_light_visibility();
|
2015-02-16 17:45:11 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
protected:
|
2015-02-18 22:39:44 +00:00
|
|
|
void _notification(int p_what);
|
2015-02-16 17:45:11 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
public:
|
|
|
|
virtual void edit_set_pivot(const Point2 &p_pivot);
|
2015-02-18 22:39:44 +00:00
|
|
|
virtual Point2 edit_get_pivot() const;
|
|
|
|
virtual bool edit_has_pivot() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_enabled(bool p_enabled);
|
2015-02-16 17:45:11 +00:00
|
|
|
bool is_enabled() const;
|
|
|
|
|
2016-10-04 14:44:59 +00:00
|
|
|
void set_editor_only(bool p_editor_only);
|
|
|
|
bool is_editor_only() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_texture(const Ref<Texture> &p_texture);
|
2015-02-16 17:45:11 +00:00
|
|
|
Ref<Texture> get_texture() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_texture_offset(const Vector2 &p_offset);
|
2015-02-16 17:45:11 +00:00
|
|
|
Vector2 get_texture_offset() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_color(const Color &p_color);
|
2015-02-16 17:45:11 +00:00
|
|
|
Color get_color() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_height(float p_height);
|
2015-02-16 17:45:11 +00:00
|
|
|
float get_height() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_energy(float p_energy);
|
2015-04-03 04:43:37 +00:00
|
|
|
float get_energy() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_texture_scale(float p_scale);
|
2015-03-22 13:39:32 +00:00
|
|
|
float get_texture_scale() const;
|
2015-03-11 00:05:49 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_z_range_min(int p_min_z);
|
2015-02-16 17:45:11 +00:00
|
|
|
int get_z_range_min() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_z_range_max(int p_max_z);
|
2015-02-16 17:45:11 +00:00
|
|
|
int get_z_range_max() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_layer_range_min(int p_min_layer);
|
2015-02-18 22:39:44 +00:00
|
|
|
int get_layer_range_min() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_layer_range_max(int p_max_layer);
|
2015-02-18 22:39:44 +00:00
|
|
|
int get_layer_range_max() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_item_mask(int p_mask);
|
2015-02-16 17:45:11 +00:00
|
|
|
int get_item_mask() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_item_shadow_mask(int p_mask);
|
2015-03-09 05:34:56 +00:00
|
|
|
int get_item_shadow_mask() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_mode(Mode p_mode);
|
2015-04-03 04:43:37 +00:00
|
|
|
Mode get_mode() const;
|
2015-02-16 17:45:11 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_shadow_enabled(bool p_enabled);
|
2015-02-16 17:45:11 +00:00
|
|
|
bool is_shadow_enabled() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_shadow_buffer_size(int p_size);
|
2015-03-02 03:54:10 +00:00
|
|
|
int get_shadow_buffer_size() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_shadow_esm_multiplier(float p_multiplier);
|
2015-03-02 03:54:10 +00:00
|
|
|
float get_shadow_esm_multiplier() const;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void set_shadow_color(const Color &p_shadow_color);
|
2015-06-24 21:15:43 +00:00
|
|
|
Color get_shadow_color() const;
|
|
|
|
|
2015-02-18 22:39:44 +00:00
|
|
|
virtual Rect2 get_item_rect() const;
|
2015-02-16 17:45:11 +00:00
|
|
|
|
2016-05-17 21:27:15 +00:00
|
|
|
String get_configuration_warning() const;
|
|
|
|
|
2015-02-16 17:45:11 +00:00
|
|
|
Light2D();
|
|
|
|
~Light2D();
|
|
|
|
};
|
|
|
|
|
2015-04-03 04:43:37 +00:00
|
|
|
VARIANT_ENUM_CAST(Light2D::Mode);
|
2015-02-16 17:45:11 +00:00
|
|
|
|
|
|
|
#endif // LIGHT_2D_H
|