2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2020-03-27 08:44:44 +01:00
|
|
|
/* gpu_particles_2d.h */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2020-01-01 11:16:22 +01:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 02:10:30 +01: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. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
#ifndef PARTICLES_2D_H
|
|
|
|
#define PARTICLES_2D_H
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-09-11 18:13:45 +02:00
|
|
|
#include "core/rid.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/2d/node_2d.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/resources/texture.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-03-27 08:44:44 +01:00
|
|
|
class GPUParticles2D : public Node2D {
|
2017-06-21 21:25:45 +02:00
|
|
|
private:
|
2020-03-27 08:44:44 +01:00
|
|
|
GDCLASS(GPUParticles2D, Node2D);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2017-06-21 21:25:45 +02:00
|
|
|
enum DrawOrder {
|
|
|
|
DRAW_ORDER_INDEX,
|
|
|
|
DRAW_ORDER_LIFETIME,
|
2017-02-27 10:47:28 +01:00
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
private:
|
2017-06-21 21:25:45 +02:00
|
|
|
RID particles;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-25 13:01:15 +02:00
|
|
|
bool one_shot;
|
2017-06-21 21:25:45 +02:00
|
|
|
int amount;
|
|
|
|
float lifetime;
|
|
|
|
float pre_process_time;
|
|
|
|
float explosiveness_ratio;
|
|
|
|
float randomness_ratio;
|
|
|
|
float speed_scale;
|
|
|
|
Rect2 visibility_rect;
|
|
|
|
bool local_coords;
|
|
|
|
int fixed_fps;
|
|
|
|
bool fractional_delta;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
Ref<Material> process_material;
|
2017-02-27 10:47:28 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
DrawOrder draw_order;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> texture;
|
|
|
|
Ref<Texture2D> normal_map;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
void _update_particle_emission_transform();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual void _validate_property(PropertyInfo &property) const override;
|
2017-06-21 21:25:45 +02:00
|
|
|
void _notification(int p_what);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
void set_emitting(bool p_emitting);
|
|
|
|
void set_amount(int p_amount);
|
|
|
|
void set_lifetime(float p_lifetime);
|
2017-08-11 21:10:05 +02:00
|
|
|
void set_one_shot(bool p_enable);
|
2017-06-21 21:25:45 +02:00
|
|
|
void set_pre_process_time(float p_time);
|
|
|
|
void set_explosiveness_ratio(float p_ratio);
|
|
|
|
void set_randomness_ratio(float p_ratio);
|
2018-08-17 11:47:29 +02:00
|
|
|
void set_visibility_rect(const Rect2 &p_visibility_rect);
|
2017-06-21 21:25:45 +02:00
|
|
|
void set_use_local_coordinates(bool p_enable);
|
|
|
|
void set_process_material(const Ref<Material> &p_material);
|
|
|
|
void set_speed_scale(float p_scale);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
bool is_emitting() const;
|
|
|
|
int get_amount() const;
|
|
|
|
float get_lifetime() const;
|
2017-06-25 13:01:15 +02:00
|
|
|
bool get_one_shot() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
float get_pre_process_time() const;
|
2017-06-21 21:25:45 +02:00
|
|
|
float get_explosiveness_ratio() const;
|
|
|
|
float get_randomness_ratio() const;
|
|
|
|
Rect2 get_visibility_rect() const;
|
|
|
|
bool get_use_local_coordinates() const;
|
|
|
|
Ref<Material> get_process_material() const;
|
|
|
|
float get_speed_scale() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
void set_fixed_fps(int p_count);
|
|
|
|
int get_fixed_fps() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
void set_fractional_delta(bool p_enable);
|
|
|
|
bool get_fractional_delta() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-21 21:25:45 +02:00
|
|
|
void set_draw_order(DrawOrder p_order);
|
|
|
|
DrawOrder get_draw_order() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
void set_texture(const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_texture() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
void set_normal_map(const Ref<Texture2D> &p_normal_map);
|
|
|
|
Ref<Texture2D> get_normal_map() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual String get_configuration_warning() const override;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-25 13:01:15 +02:00
|
|
|
void restart();
|
2017-06-21 21:25:45 +02:00
|
|
|
Rect2 capture_rect() const;
|
2020-03-27 08:44:44 +01:00
|
|
|
GPUParticles2D();
|
|
|
|
~GPUParticles2D();
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2020-03-27 08:44:44 +01:00
|
|
|
VARIANT_ENUM_CAST(GPUParticles2D::DrawOrder)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-09-04 11:30:04 +02:00
|
|
|
#endif // PARTICLES_2D_H
|