godot/scene/3d/gpu_particles_3d.h

186 lines
6.1 KiB
C++
Raw Normal View History

2014-02-10 01:10:30 +00:00
/*************************************************************************/
/* gpu_particles_3d.h */
2014-02-10 01:10:30 +00:00
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
2014-02-10 01:10:30 +00:00
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
2014-02-10 01:10:30 +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. */
/*************************************************************************/
#ifndef PARTICLES_H
#define PARTICLES_H
2014-02-10 01:10:30 +00:00
#include "core/templates/rid.h"
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/material.h"
#include "scene/resources/skin.h"
2014-02-10 01:10:30 +00:00
class GPUParticles3D : public GeometryInstance3D {
private:
GDCLASS(GPUParticles3D, GeometryInstance3D);
2014-02-10 01:10:30 +00:00
public:
enum DrawOrder {
DRAW_ORDER_INDEX,
DRAW_ORDER_LIFETIME,
DRAW_ORDER_REVERSE_LIFETIME,
DRAW_ORDER_VIEW_DEPTH,
};
2014-02-10 01:10:30 +00:00
enum TransformAlign {
TRANSFORM_ALIGN_DISABLED,
TRANSFORM_ALIGN_Z_BILLBOARD,
TRANSFORM_ALIGN_Y_TO_VELOCITY,
TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY
};
enum {
MAX_DRAW_PASSES = 4
2014-02-10 01:10:30 +00:00
};
private:
RID particles;
2016-03-08 23:00:52 +00:00
bool one_shot;
int amount;
float lifetime;
float pre_process_time;
float explosiveness_ratio;
float randomness_ratio;
2017-04-09 01:38:11 +00:00
float speed_scale;
2017-11-17 02:09:00 +00:00
AABB visibility_aabb;
bool local_coords;
int fixed_fps;
bool fractional_delta;
bool interpolate = true;
NodePath sub_emitter;
float collision_base_size = 0.01;
2016-03-08 23:00:52 +00:00
bool trail_enabled = false;
float trail_length = 0.3;
TransformAlign transform_align = TRANSFORM_ALIGN_DISABLED;
Ref<Material> process_material;
2016-03-08 23:00:52 +00:00
DrawOrder draw_order;
2014-02-10 01:10:30 +00:00
Vector<Ref<Mesh>> draw_passes;
Ref<Skin> skin;
2014-02-10 01:10:30 +00:00
void _attach_sub_emitter();
void _skinning_changed();
2016-03-08 23:00:52 +00:00
protected:
2014-02-10 01:10:30 +00:00
static void _bind_methods();
void _notification(int p_what);
2020-07-10 10:34:39 +00:00
virtual void _validate_property(PropertyInfo &property) const override;
2016-03-08 23:00:52 +00:00
2014-02-10 01:10:30 +00:00
public:
2020-07-10 10:34:39 +00:00
AABB get_aabb() const override;
Vector<Face3> get_faces(uint32_t p_usage_flags) const override;
2014-02-10 01:10:30 +00:00
void set_emitting(bool p_emitting);
2014-02-10 01:10:30 +00:00
void set_amount(int p_amount);
void set_lifetime(float p_lifetime);
void set_one_shot(bool p_one_shot);
void set_pre_process_time(float p_time);
void set_explosiveness_ratio(float p_ratio);
void set_randomness_ratio(float p_ratio);
2017-11-17 02:09:00 +00:00
void set_visibility_aabb(const AABB &p_aabb);
void set_use_local_coordinates(bool p_enable);
void set_process_material(const Ref<Material> &p_material);
2017-04-09 01:38:11 +00:00
void set_speed_scale(float p_scale);
void set_collision_base_size(float p_ratio);
void set_trail_enabled(bool p_enabled);
void set_trail_length(float p_seconds);
2016-03-08 23:00:52 +00:00
2014-02-10 01:10:30 +00:00
bool is_emitting() const;
int get_amount() const;
float get_lifetime() const;
bool get_one_shot() const;
float get_pre_process_time() const;
float get_explosiveness_ratio() const;
float get_randomness_ratio() const;
2017-11-17 02:09:00 +00:00
AABB get_visibility_aabb() const;
bool get_use_local_coordinates() const;
Ref<Material> get_process_material() const;
2017-04-09 01:38:11 +00:00
float get_speed_scale() const;
float get_collision_base_size() const;
bool is_trail_enabled() const;
float get_trail_length() const;
2016-03-08 23:00:52 +00:00
void set_fixed_fps(int p_count);
int get_fixed_fps() const;
2016-03-08 23:00:52 +00:00
void set_fractional_delta(bool p_enable);
bool get_fractional_delta() const;
2014-02-10 01:10:30 +00:00
void set_interpolate(bool p_enable);
bool get_interpolate() const;
void set_draw_order(DrawOrder p_order);
DrawOrder get_draw_order() const;
2014-02-10 01:10:30 +00:00
void set_draw_passes(int p_count);
int get_draw_passes() const;
2014-02-10 01:10:30 +00:00
void set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh);
Ref<Mesh> get_draw_pass_mesh(int p_pass) const;
2016-03-08 23:00:52 +00:00
TypedArray<String> get_configuration_warnings() const override;
2017-04-09 01:38:11 +00:00
void set_sub_emitter(const NodePath &p_path);
NodePath get_sub_emitter() const;
void set_skin(const Ref<Skin> &p_skin);
Ref<Skin> get_skin() const;
void set_transform_align(TransformAlign p_align);
TransformAlign get_transform_align() const;
void restart();
enum EmitFlags {
EMIT_FLAG_POSITION = RS::PARTICLES_EMIT_FLAG_POSITION,
EMIT_FLAG_ROTATION_SCALE = RS::PARTICLES_EMIT_FLAG_ROTATION_SCALE,
EMIT_FLAG_VELOCITY = RS::PARTICLES_EMIT_FLAG_VELOCITY,
EMIT_FLAG_COLOR = RS::PARTICLES_EMIT_FLAG_COLOR,
EMIT_FLAG_CUSTOM = RS::PARTICLES_EMIT_FLAG_CUSTOM
};
void emit_particle(const Transform &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags);
2017-11-17 02:09:00 +00:00
AABB capture_aabb() const;
GPUParticles3D();
~GPUParticles3D();
};
2016-03-08 23:00:52 +00:00
VARIANT_ENUM_CAST(GPUParticles3D::DrawOrder)
VARIANT_ENUM_CAST(GPUParticles3D::TransformAlign)
VARIANT_ENUM_CAST(GPUParticles3D::EmitFlags)
2014-02-10 01:10:30 +00:00
#endif // PARTICLES_H