Pixelpart 1.10.0
Godot Plugin
Loading...
Searching...
No Matches
PixelpartEffect.h
1#ifndef PIXELPART_EFFECT_H
2#define PIXELPART_EFFECT_H
3
4#include "PixelpartEffectResource.h"
5#include "PixelpartEffectRuntime.h"
6#include "rendering/PixelpartGraphicsResourceProvider.h"
7#include "rendering/PixelpartParticleInstance3D.h"
8#include "particletype/PixelpartParticleType.h"
9#include "node/PixelpartParticleEmitter.h"
10#include "node/PixelpartForceField.h"
11#include "node/PixelpartCollider.h"
12#include <pixelpart-runtime/effect/ParticleEmissionPair.h>
13#include <godot_cpp/core/binder_common.hpp>
14#include <godot_cpp/classes/visual_instance3d.hpp>
15#include <cstdint>
16#include <memory>
17#include <unordered_map>
18
19namespace godot {
30class PixelpartEffect : public VisualInstance3D {
31 GDCLASS(PixelpartEffect, VisualInstance3D)
32
33public:
34 PixelpartEffect();
35 virtual ~PixelpartEffect();
36
37#ifdef DOXYGEN
42
46 bool playing;
47
51 bool loop;
52
58 float loop_time;
59
66
70 float speed;
71
76
82 int seed;
83
88
94 Dictionary inputs;
95
102#endif
103
104 virtual void _enter_tree() override;
105 virtual void _exit_tree() override;
106
107 virtual void _process(double dt) override;
108
109 void _notification(int p_what);
110
111 void draw();
112
118 void set_effect(Ref<PixelpartEffectResource> resource);
119
125 Ref<PixelpartEffectResource> get_effect() const;
126
134 void play(bool state = true);
135
141 void pause();
142
148 void restart(bool clear = true);
149
155 void reset();
156
162 bool is_playing() const;
163
169 float get_time() const;
170
176 void set_loop(bool mode);
177
183 bool get_loop() const;
184
192 void set_loop_time(float time);
193
199 float get_loop_time() const;
200
208 void set_warmup_time(float time);
209
215 float get_warmup_time() const;
216
222 void set_speed(float sp);
223
229 float get_speed() const;
230
236 void set_frame_rate(float rate);
237
243 float get_frame_rate() const;
244
252 void set_seed(int sd);
253
259 int get_seed() const;
260
266 void enable_random_seed(bool mode);
267
273 bool is_random_seed_enabled() const;
274
282 void set_effect_scale(float scale);
283
289 float get_effect_scale() const;
290
298 void set_inputs(Dictionary inputs);
299
307 Dictionary get_inputs() const;
308
315 void set_input_bool(String name, bool value);
316
323 void set_input_int(String name, int value);
324
331 void set_input_float(String name, float value);
332
339 void set_input_float2(String name, Vector2 value);
340
347 void set_input_float3(String name, Vector3 value);
348
355 void set_input_float4(String name, Vector4 value);
356
363 bool get_input_bool(String name) const;
364
371 int get_input_int(String name) const;
372
379 float get_input_float(String name) const;
380
387 Vector2 get_input_float2(String name) const;
388
395 Vector3 get_input_float3(String name) const;
396
403 Vector4 get_input_float4(String name) const;
404
411 int get_input_type(String name) const;
412
418 TypedArray<String> get_input_names() const;
419
425 void activate_trigger(String name);
426
433 bool is_trigger_activated(String name) const;
434
442 void spawn_particles(String particleEmitterName, String particleTypeName, int count);
443
450 Ref<PixelpartNode> find_effect_node(String name) const;
451
458 Ref<PixelpartNode> get_effect_node(int id) const;
459
466 Ref<PixelpartNode> get_effect_node_at_index(int index) const;
467
474 Ref<PixelpartParticleType> find_particle_type(String name) const;
475
482 Ref<PixelpartParticleType> get_particle_type(int id) const;
483
490 Ref<PixelpartParticleType> get_particle_type_at_index(int index) const;
491
492#ifdef DOXYGEN
501 Ref<PixelpartNode> find_node(String name) const;
502
511 Ref<PixelpartNode> get_node_at_index(int index) const;
512#endif
513
514protected:
515 static void _bind_methods();
516
517private:
518 void apply_transform();
519 void apply_lod();
520
521 Ref<PixelpartEffectResource> effectResource;
522 PixelpartEffectRuntime effectRuntime;
523 bool editorPreviewEnabled = true;
524
525 float effectScale = 1.0f;
526
527 bool finishedSignalEmitted = false;
528
529 PixelpartGraphicsResourceProvider graphicsResourceProvider;
530 std::unordered_map<pixelpart::ParticleEmissionPair, std::unique_ptr<PixelpartParticleInstance3D>> particleInstances;
531};
532}
533
534#endif
void play(bool state=true)
Start playing or pause simulation of the effect.
Definition PixelpartEffect.cpp:158
float get_frame_rate() const
Return at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.cpp:208
void spawn_particles(String particleEmitterName, String particleTypeName, int count)
Generate count particles of the given type from the given emitter.
Definition PixelpartEffect.cpp:291
int get_seed() const
Return the seed used to initialize the effect simulation.
Definition PixelpartEffect.cpp:215
int get_input_int(String name) const
Return value of an effect input. The effect input must be of type int.
Definition PixelpartEffect.cpp:262
PixelpartEffectResource effect
Effect resource that is shown.
Definition PixelpartEffect.h:41
bool is_playing() const
Return whether the effect is currently playing or is paused.
Definition PixelpartEffect.cpp:170
void set_loop_time(float time)
Set time in seconds after which the effect loops.
Definition PixelpartEffect.cpp:184
void set_input_float3(String name, Vector3 value)
Definition PixelpartEffect.cpp:253
void set_inputs(Dictionary inputs)
Set dictionary of effect input values.
Definition PixelpartEffect.cpp:234
void restart(bool clear=true)
Restart the effect.
Definition PixelpartEffect.cpp:164
bool is_random_seed_enabled() const
Return whether a random seed is used to initialize the effect simulation.
Definition PixelpartEffect.cpp:222
void set_effect_scale(float scale)
Set multiplier for the size of the effect.
Definition PixelpartEffect.cpp:226
Ref< PixelpartParticleType > get_particle_type(int id) const
Return the particle type with the given ID.
Definition PixelpartEffect.cpp:308
Ref< PixelpartParticleType > get_particle_type_at_index(int index) const
Return the particle type at the given index.
Definition PixelpartEffect.cpp:311
Dictionary get_inputs() const
Return dictionary of effect input values.
Definition PixelpartEffect.cpp:237
float warmup_time
Time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.h:65
float get_time() const
Return the time in seconds since the effect has started playing.
Definition PixelpartEffect.cpp:173
bool get_input_bool(String name) const
Return value of an effect input. The effect input must be of type bool.
Definition PixelpartEffect.cpp:259
float effect_scale
Multiplier for the size of the effect.
Definition PixelpartEffect.h:101
void set_speed(float sp)
Set how fast the effect is being played.
Definition PixelpartEffect.cpp:198
bool playing
Whether the effect is currently playing or not.
Definition PixelpartEffect.h:46
float frame_rate
At which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.h:75
void set_input_float(String name, float value)
Definition PixelpartEffect.cpp:247
float get_loop_time() const
Return time in seconds after which the effect loops.
Definition PixelpartEffect.cpp:187
void reset()
Restart the effect, but do not remove existing particles.
Definition PixelpartEffect.cpp:167
void set_seed(int sd)
Set the seed used to initialize the effect simulation.
Definition PixelpartEffect.cpp:212
float get_input_float(String name) const
Return value of an effect input. The effect input must be of type float.
Definition PixelpartEffect.cpp:265
bool is_trigger_activated(String name) const
Return whether trigger name was activated.
Definition PixelpartEffect.cpp:287
Ref< PixelpartNode > get_node_at_index(int index) const
Return the effect node at the given index.
void activate_trigger(String name)
Activate trigger name.
Definition PixelpartEffect.cpp:284
void set_input_float2(String name, Vector2 value)
Definition PixelpartEffect.cpp:250
bool get_loop() const
Return whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.cpp:180
void set_effect(Ref< PixelpartEffectResource > resource)
Change the effect resource that is shown.
Definition PixelpartEffect.cpp:109
int get_input_type(String name) const
Return the type of an effect input or -1 if the effect input does not exist.
Definition PixelpartEffect.cpp:277
Ref< PixelpartEffectResource > get_effect() const
Return the effect resource that is being shown.
Definition PixelpartEffect.cpp:154
Ref< PixelpartNode > find_node(String name) const
Return the effect node with the given name.
void enable_random_seed(bool mode)
Use a random seed to initialize the effect simulation.
Definition PixelpartEffect.cpp:219
void set_input_bool(String name, bool value)
Definition PixelpartEffect.cpp:241
float get_effect_scale() const
Return multiplier for the size of the effect.
Definition PixelpartEffect.cpp:230
void set_frame_rate(float rate)
Set at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.cpp:205
void set_input_int(String name, int value)
Definition PixelpartEffect.cpp:244
Vector3 get_input_float3(String name) const
Return value of an effect input. The effect input must be of type Vector3.
Definition PixelpartEffect.cpp:271
float get_speed() const
Return how fast the effect is being played.
Definition PixelpartEffect.cpp:201
Vector2 get_input_float2(String name) const
Return value of an effect input. The effect input must be of type Vector2.
Definition PixelpartEffect.cpp:268
float speed
How fast the effect is being played.
Definition PixelpartEffect.h:70
Ref< PixelpartParticleType > find_particle_type(String name) const
Return the particle type with the given name.
Definition PixelpartEffect.cpp:305
bool random_seed
Whether to use a random seed to initialize the effect simulation.
Definition PixelpartEffect.h:87
void set_loop(bool mode)
Set whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.cpp:177
float loop_time
Time in seconds after which the effect loops.
Definition PixelpartEffect.h:58
float get_warmup_time() const
Return time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.cpp:194
Dictionary inputs
Dictionary of effect input values.
Definition PixelpartEffect.h:94
bool loop
Whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.h:51
Vector4 get_input_float4(String name) const
Return value of an effect input. The effect input must be of type Vector4.
Definition PixelpartEffect.cpp:274
Ref< PixelpartNode > find_effect_node(String name) const
Return the effect node with the given name.
Definition PixelpartEffect.cpp:295
TypedArray< String > get_input_names() const
Return names of available effect inputs.
Definition PixelpartEffect.cpp:280
Ref< PixelpartNode > get_effect_node_at_index(int index) const
Return the effect node at the given index.
Definition PixelpartEffect.cpp:301
void pause()
Pause simulation of the effect.
Definition PixelpartEffect.cpp:161
void set_warmup_time(float time)
Set time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.cpp:191
int seed
Seed used to initialize the effect simulation.
Definition PixelpartEffect.h:82
void set_input_float4(String name, Vector4 value)
Definition PixelpartEffect.cpp:256
Ref< PixelpartNode > get_effect_node(int id) const
Return the effect node with the given ID.
Definition PixelpartEffect.cpp:298
Resource for a Pixelpart effect that is contained in a ppfx file.
Definition PixelpartEffectResource.h:15