Pixelpart 1.8.4
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/PixelpartParticleRenderer3D.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 <memory>
16#include <unordered_map>
17
18namespace godot {
28class PixelpartEffect : public VisualInstance3D {
29 GDCLASS(PixelpartEffect, VisualInstance3D)
30
31public:
32 PixelpartEffect();
33 virtual ~PixelpartEffect();
34
35#ifdef DOXYGEN
40
44 bool playing;
45
49 bool loop;
50
56 float loop_time;
57
64
68 float speed;
69
74
80 int seed;
81
86
92 Dictionary inputs;
93
100#endif
101
102 virtual void _enter_tree() override;
103 virtual void _exit_tree() override;
104
105 virtual void _process(double dt) override;
106
107 void draw();
108
114 void set_effect(Ref<PixelpartEffectResource> resource);
115
121 Ref<PixelpartEffectResource> get_effect() const;
122
130 void play(bool state);
131
137 void pause();
138
143 void restart();
144
149 void reset();
150
156 bool is_playing() const;
157
163 float get_time() const;
164
170 void set_loop(bool mode);
171
177 bool get_loop() const;
178
186 void set_loop_time(float time);
187
193 float get_loop_time() const;
194
202 void set_warmup_time(float time);
203
209 float get_warmup_time() const;
210
216 void set_speed(float sp);
217
223 float get_speed() const;
224
230 void set_frame_rate(float rate);
231
237 float get_frame_rate() const;
238
246 void set_seed(int sd);
247
253 int get_seed() const;
254
260 void enable_random_seed(bool mode);
261
267 bool is_random_seed_enabled() const;
268
276 void set_effect_scale(float scale);
277
283 float get_effect_scale() const;
284
292 void set_inputs(Dictionary inputs);
293
301 Dictionary get_inputs() const;
302
309 void set_input_bool(String name, bool value);
310
317 void set_input_int(String name, int value);
318
325 void set_input_float(String name, float value);
326
333 void set_input_float2(String name, Vector2 value);
334
341 void set_input_float3(String name, Vector3 value);
342
349 void set_input_float4(String name, Vector4 value);
350
357 bool get_input_bool(String name) const;
358
365 int get_input_int(String name) const;
366
373 float get_input_float(String name) const;
374
381 Vector2 get_input_float2(String name) const;
382
389 Vector3 get_input_float3(String name) const;
390
397 Vector4 get_input_float4(String name) const;
398
405 int get_input_type(String name) const;
406
412 TypedArray<String> get_input_names() const;
413
419 void activate_trigger(String name);
420
427 bool is_trigger_activated(String name) const;
428
436 void spawn_particles(String particleEmitterName, String particleTypeName, int count);
437
444 Ref<PixelpartNode> find_node(String name) const;
445
452 Ref<PixelpartNode> get_node(int id) const;
453
460 Ref<PixelpartNode> get_node_at_index(int index) const;
461
468 Ref<PixelpartParticleType> find_particle_type(String name) const;
469
476 Ref<PixelpartParticleType> get_particle_type(int id) const;
477
484 Ref<PixelpartParticleType> get_particle_type_at_index(int index) const;
485
494 Ref<PixelpartParticleEmitter> find_particle_emitter(String name) const;
495
504 Ref<PixelpartForceField> find_force_field(String name) const;
505
514 Ref<PixelpartCollider> find_collider(String name) const;
515
524 Ref<PixelpartParticleEmitter> get_particle_emitter(int id) const;
525
534 Ref<PixelpartForceField> get_force_field(int id) const;
535
544 Ref<PixelpartCollider> get_collider(int id) const;
545
554 Ref<PixelpartParticleEmitter> get_particle_emitter_at_index(int index) const;
555
564 Ref<PixelpartForceField> get_force_field_at_index(int index) const;
565
574 Ref<PixelpartCollider> get_collider_at_index(int index) const;
575
576protected:
577 static void _bind_methods();
578
579private:
580 void update_transform();
581
582 Ref<PixelpartEffectResource> effectResource;
583 PixelpartEffectRuntime effectRuntime;
584
585 float effectScale = 1.0f;
586
587 bool finishedSignalEmitted = false;
588
589 PixelpartGraphicsResourceProvider graphicsResourceProvider;
590 std::unordered_map<pixelpart::ParticleEmissionPair, std::unique_ptr<PixelpartParticleRenderer3D>> particleRenderers;
591};
592}
593
594#endif
float get_frame_rate() const
Return at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.cpp:193
void spawn_particles(String particleEmitterName, String particleTypeName, int count)
Generate count particles of the given type from the given emitter.
Definition PixelpartEffect.cpp:275
int get_seed() const
Return the seed used to initialize the effect simulation.
Definition PixelpartEffect.cpp:200
int get_input_int(String name) const
Return value of an effect input. The effect input must be of type int.
Definition PixelpartEffect.cpp:246
PixelpartEffectResource effect
Effect resource that is shown.
Definition PixelpartEffect.h:39
bool is_playing() const
Return whether the effect is currently playing or is paused.
Definition PixelpartEffect.cpp:155
void set_loop_time(float time)
Set time in seconds after which the effect loops.
Definition PixelpartEffect.cpp:169
void set_input_float3(String name, Vector3 value)
Definition PixelpartEffect.cpp:237
void set_inputs(Dictionary inputs)
Set dictionary of effect input values.
Definition PixelpartEffect.cpp:218
Ref< PixelpartForceField > get_force_field_at_index(int index) const
Return the force field at the given index.
Definition PixelpartEffect.cpp:320
void restart()
Restart the effect and remove all existing particles.
Definition PixelpartEffect.cpp:149
Ref< PixelpartCollider > get_collider(int id) const
Return the collider with the given ID.
Definition PixelpartEffect.cpp:314
bool is_random_seed_enabled() const
Return whether a random seed is used to initialize the effect simulation.
Definition PixelpartEffect.cpp:207
void set_effect_scale(float scale)
Set multiplier for the size of the effect.
Definition PixelpartEffect.cpp:211
Ref< PixelpartParticleType > get_particle_type(int id) const
Return the particle type with the given ID.
Definition PixelpartEffect.cpp:292
Ref< PixelpartParticleType > get_particle_type_at_index(int index) const
Return the particle type at the given index.
Definition PixelpartEffect.cpp:295
Dictionary get_inputs() const
Return dictionary of effect input values.
Definition PixelpartEffect.cpp:221
float warmup_time
Time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.h:63
float get_time() const
Return the time in seconds since the effect has started playing.
Definition PixelpartEffect.cpp:158
bool get_input_bool(String name) const
Return value of an effect input. The effect input must be of type bool.
Definition PixelpartEffect.cpp:243
float effect_scale
Multiplier for the size of the effect.
Definition PixelpartEffect.h:99
void set_speed(float sp)
Set how fast the effect is being played.
Definition PixelpartEffect.cpp:183
bool playing
Whether the effect is currently playing or not.
Definition PixelpartEffect.h:44
float frame_rate
At which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.h:73
Ref< PixelpartForceField > find_force_field(String name) const
Return the force field with the given name.
Definition PixelpartEffect.cpp:302
void set_input_float(String name, float value)
Definition PixelpartEffect.cpp:231
float get_loop_time() const
Return time in seconds after which the effect loops.
Definition PixelpartEffect.cpp:172
Ref< PixelpartForceField > get_force_field(int id) const
Return the force field with the given ID.
Definition PixelpartEffect.cpp:311
Ref< PixelpartCollider > find_collider(String name) const
Return the collider with the given name.
Definition PixelpartEffect.cpp:305
void reset()
Restart the effect, but do not remove existing particles.
Definition PixelpartEffect.cpp:152
void set_seed(int sd)
Set the seed used to initialize the effect simulation.
Definition PixelpartEffect.cpp:197
float get_input_float(String name) const
Return value of an effect input. The effect input must be of type float.
Definition PixelpartEffect.cpp:249
bool is_trigger_activated(String name) const
Return whether trigger name was activated.
Definition PixelpartEffect.cpp:271
Ref< PixelpartNode > get_node_at_index(int index) const
Return the node at the given index.
Definition PixelpartEffect.cpp:285
void activate_trigger(String name)
Activate trigger name.
Definition PixelpartEffect.cpp:268
void set_input_float2(String name, Vector2 value)
Definition PixelpartEffect.cpp:234
bool get_loop() const
Return whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.cpp:165
void set_effect(Ref< PixelpartEffectResource > resource)
Change the effect resource that is shown.
Definition PixelpartEffect.cpp:103
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:261
void play(bool state)
Start playing or pause simulation of the effect.
Definition PixelpartEffect.cpp:143
Ref< PixelpartNode > get_node(int id) const
Return the node with the given ID.
Definition PixelpartEffect.cpp:282
Ref< PixelpartEffectResource > get_effect() const
Return the effect resource that is being shown.
Definition PixelpartEffect.cpp:139
Ref< PixelpartNode > find_node(String name) const
Return the node with the given name.
Definition PixelpartEffect.cpp:279
void enable_random_seed(bool mode)
Use a random seed to initialize the effect simulation.
Definition PixelpartEffect.cpp:204
void set_input_bool(String name, bool value)
Definition PixelpartEffect.cpp:225
float get_effect_scale() const
Return multiplier for the size of the effect.
Definition PixelpartEffect.cpp:214
void set_frame_rate(float rate)
Set at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.cpp:190
void set_input_int(String name, int value)
Definition PixelpartEffect.cpp:228
Vector3 get_input_float3(String name) const
Return value of an effect input. The effect input must be of type Vector3.
Definition PixelpartEffect.cpp:255
float get_speed() const
Return how fast the effect is being played.
Definition PixelpartEffect.cpp:186
Vector2 get_input_float2(String name) const
Return value of an effect input. The effect input must be of type Vector2.
Definition PixelpartEffect.cpp:252
float speed
How fast the effect is being played.
Definition PixelpartEffect.h:68
Ref< PixelpartParticleType > find_particle_type(String name) const
Return the particle type with the given name.
Definition PixelpartEffect.cpp:289
bool random_seed
Whether to use a random seed to initialize the effect simulation.
Definition PixelpartEffect.h:85
void set_loop(bool mode)
Set whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.cpp:162
Ref< PixelpartCollider > get_collider_at_index(int index) const
Return the collider at the given index.
Definition PixelpartEffect.cpp:323
float loop_time
Time in seconds after which the effect loops.
Definition PixelpartEffect.h:56
Ref< PixelpartParticleEmitter > get_particle_emitter(int id) const
Return the particle emitter with the given ID.
Definition PixelpartEffect.cpp:308
float get_warmup_time() const
Return time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.cpp:179
Dictionary inputs
Dictionary of effect input values.
Definition PixelpartEffect.h:92
bool loop
Whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.h:49
Vector4 get_input_float4(String name) const
Return value of an effect input. The effect input must be of type Vector4.
Definition PixelpartEffect.cpp:258
TypedArray< String > get_input_names() const
Return names of available effect inputs.
Definition PixelpartEffect.cpp:264
void pause()
Pause simulation of the effect.
Definition PixelpartEffect.cpp:146
void set_warmup_time(float time)
Set time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.cpp:176
int seed
Seed used to initialize the effect simulation.
Definition PixelpartEffect.h:80
void set_input_float4(String name, Vector4 value)
Definition PixelpartEffect.cpp:240
Ref< PixelpartParticleEmitter > find_particle_emitter(String name) const
Return the particle emitter with the given name.
Definition PixelpartEffect.cpp:299
Ref< PixelpartParticleEmitter > get_particle_emitter_at_index(int index) const
Return the particle emitter at the given index.
Definition PixelpartEffect.cpp:317
Resource for a Pixelpart effect that is contained in a ppfx file.
Definition PixelpartEffectResource.h:15