Pixelpart 1.8.2
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/ParticleRuntimeId.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 {
24class PixelpartEffect : public VisualInstance3D {
25 GDCLASS(PixelpartEffect, VisualInstance3D)
26
27public:
28 PixelpartEffect();
29 virtual ~PixelpartEffect();
30
31#ifdef DOXYGEN
36
40 bool playing;
41
45 bool loop;
46
52 float loop_time;
53
60
64 float speed;
65
70
76 Dictionary inputs;
77
84#endif
85
86 virtual void _enter_tree() override;
87 virtual void _exit_tree() override;
88
89 virtual void _process(double dt) override;
90
91 void draw();
92
98 void set_effect(Ref<PixelpartEffectResource> resource);
99
105 Ref<PixelpartEffectResource> get_effect() const;
106
114 void play(bool state);
115
121 void pause();
122
127 void restart();
128
133 void reset();
134
140 bool is_playing() const;
141
147 float get_time() const;
148
154 void set_loop(bool mode);
155
161 bool get_loop() const;
162
170 void set_loop_time(float time);
171
177 float get_loop_time() const;
178
186 void set_warmup_time(float time);
187
193 float get_warmup_time() const;
194
200 void set_speed(float sp);
201
207 float get_speed() const;
208
214 void set_frame_rate(float rate);
215
221 float get_frame_rate() const;
222
230 void set_effect_scale(float scale);
231
237 float get_effect_scale() const;
238
246 void set_inputs(Dictionary inputs);
247
255 Dictionary get_inputs() const;
256
263 void set_input_bool(String name, bool value);
264
271 void set_input_int(String name, int value);
272
279 void set_input_float(String name, float value);
280
287 void set_input_float2(String name, Vector2 value);
288
295 void set_input_float3(String name, Vector3 value);
296
303 void set_input_float4(String name, Vector4 value);
304
311 bool get_input_bool(String name) const;
312
319 int get_input_int(String name) const;
320
327 float get_input_float(String name) const;
328
335 Vector2 get_input_float2(String name) const;
336
343 Vector3 get_input_float3(String name) const;
344
351 Vector4 get_input_float4(String name) const;
352
359 int get_input_type(String name) const;
360
366 TypedArray<String> get_input_names() const;
367
373 void activate_trigger(String name);
374
381 bool is_trigger_activated(String name) const;
382
390 void spawn_particles(String particleEmitterName, String particleTypeName, int count);
391
398 Ref<PixelpartNode> find_node(String name) const;
399
406 Ref<PixelpartNode> get_node(int id) const;
407
414 Ref<PixelpartNode> get_node_at_index(int index) const;
415
422 Ref<PixelpartParticleType> find_particle_type(String name) const;
423
430 Ref<PixelpartParticleType> get_particle_type(int id) const;
431
438 Ref<PixelpartParticleType> get_particle_type_at_index(int index) const;
439
448 Ref<PixelpartParticleEmitter> find_particle_emitter(String name) const;
449
458 Ref<PixelpartForceField> find_force_field(String name) const;
459
468 Ref<PixelpartCollider> find_collider(String name) const;
469
478 Ref<PixelpartParticleEmitter> get_particle_emitter(int id) const;
479
488 Ref<PixelpartForceField> get_force_field(int id) const;
489
498 Ref<PixelpartCollider> get_collider(int id) const;
499
508 Ref<PixelpartParticleEmitter> get_particle_emitter_at_index(int index) const;
509
518 Ref<PixelpartForceField> get_force_field_at_index(int index) const;
519
528 Ref<PixelpartCollider> get_collider_at_index(int index) const;
529
530protected:
531 static void _bind_methods();
532
533private:
534 void update_transform();
535
536 Ref<PixelpartEffectResource> effectResource;
537 PixelpartEffectRuntime effectRuntime;
538
539 float effectScale = 1.0f;
540
541 PixelpartGraphicsResourceProvider graphicsResourceProvider;
542 std::unordered_map<pixelpart::ParticleRuntimeId, std::unique_ptr<PixelpartParticleRenderer3D>> particleRenderers;
543};
544}
545
546#endif
float get_frame_rate() const
Return at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.cpp:175
void spawn_particles(String particleEmitterName, String particleTypeName, int count)
Generate count particles of the given type from the given emitter.
Definition PixelpartEffect.cpp:243
int get_input_int(String name) const
Return value of an effect input. The effect input must be of type int.
Definition PixelpartEffect.cpp:214
PixelpartEffectResource effect
Effect resource that is shown.
Definition PixelpartEffect.h:35
bool is_playing() const
Return whether the effect is currently playing or is paused.
Definition PixelpartEffect.cpp:137
void set_loop_time(float time)
Set time in seconds after which the effect loops.
Definition PixelpartEffect.cpp:151
void set_input_float3(String name, Vector3 value)
Definition PixelpartEffect.cpp:205
void set_inputs(Dictionary inputs)
Set dictionary of effect input values.
Definition PixelpartEffect.cpp:186
Ref< PixelpartForceField > get_force_field_at_index(int index) const
Return the force field at the given index.
Definition PixelpartEffect.cpp:288
void restart()
Restart the effect and remove all existing particles.
Definition PixelpartEffect.cpp:131
Ref< PixelpartCollider > get_collider(int id) const
Return the collider with the given ID.
Definition PixelpartEffect.cpp:282
void set_effect_scale(float scale)
Set multiplier for the size of the effect.
Definition PixelpartEffect.cpp:179
Ref< PixelpartParticleType > get_particle_type(int id) const
Return the particle type with the given ID.
Definition PixelpartEffect.cpp:260
Ref< PixelpartParticleType > get_particle_type_at_index(int index) const
Return the particle type at the given index.
Definition PixelpartEffect.cpp:263
Dictionary get_inputs() const
Return dictionary of effect input values.
Definition PixelpartEffect.cpp:189
float warmup_time
Time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.h:59
float get_time() const
Return the time in seconds since the effect has started playing.
Definition PixelpartEffect.cpp:140
bool get_input_bool(String name) const
Return value of an effect input. The effect input must be of type bool.
Definition PixelpartEffect.cpp:211
float effect_scale
Multiplier for the size of the effect.
Definition PixelpartEffect.h:83
void set_speed(float sp)
Set how fast the effect is being played.
Definition PixelpartEffect.cpp:165
bool playing
Whether the effect is currently playing or not.
Definition PixelpartEffect.h:40
float frame_rate
At which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.h:69
Ref< PixelpartForceField > find_force_field(String name) const
Return the force field with the given name.
Definition PixelpartEffect.cpp:270
void set_input_float(String name, float value)
Definition PixelpartEffect.cpp:199
float get_loop_time() const
Return time in seconds after which the effect loops.
Definition PixelpartEffect.cpp:154
Ref< PixelpartForceField > get_force_field(int id) const
Return the force field with the given ID.
Definition PixelpartEffect.cpp:279
Ref< PixelpartCollider > find_collider(String name) const
Return the collider with the given name.
Definition PixelpartEffect.cpp:273
void reset()
Restart the effect, but do not remove existing particles.
Definition PixelpartEffect.cpp:134
float get_input_float(String name) const
Return value of an effect input. The effect input must be of type float.
Definition PixelpartEffect.cpp:217
bool is_trigger_activated(String name) const
Return whether trigger name was activated.
Definition PixelpartEffect.cpp:239
Ref< PixelpartNode > get_node_at_index(int index) const
Return the node at the given index.
Definition PixelpartEffect.cpp:253
void activate_trigger(String name)
Activate trigger name.
Definition PixelpartEffect.cpp:236
void set_input_float2(String name, Vector2 value)
Definition PixelpartEffect.cpp:202
bool get_loop() const
Return whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.cpp:147
void set_effect(Ref< PixelpartEffectResource > resource)
Change the effect resource that is shown.
Definition PixelpartEffect.cpp:86
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:229
void play(bool state)
Start playing or pause simulation of the effect.
Definition PixelpartEffect.cpp:125
Ref< PixelpartNode > get_node(int id) const
Return the node with the given ID.
Definition PixelpartEffect.cpp:250
Ref< PixelpartEffectResource > get_effect() const
Return the effect resource that is being shown.
Definition PixelpartEffect.cpp:121
Ref< PixelpartNode > find_node(String name) const
Return the node with the given name.
Definition PixelpartEffect.cpp:247
void set_input_bool(String name, bool value)
Definition PixelpartEffect.cpp:193
float get_effect_scale() const
Return multiplier for the size of the effect.
Definition PixelpartEffect.cpp:182
void set_frame_rate(float rate)
Set at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect.cpp:172
void set_input_int(String name, int value)
Definition PixelpartEffect.cpp:196
Vector3 get_input_float3(String name) const
Return value of an effect input. The effect input must be of type Vector3.
Definition PixelpartEffect.cpp:223
float get_speed() const
Return how fast the effect is being played.
Definition PixelpartEffect.cpp:168
Vector2 get_input_float2(String name) const
Return value of an effect input. The effect input must be of type Vector2.
Definition PixelpartEffect.cpp:220
float speed
How fast the effect is being played.
Definition PixelpartEffect.h:64
Ref< PixelpartParticleType > find_particle_type(String name) const
Return the particle type with the given name.
Definition PixelpartEffect.cpp:257
void set_loop(bool mode)
Set whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.cpp:144
Ref< PixelpartCollider > get_collider_at_index(int index) const
Return the collider at the given index.
Definition PixelpartEffect.cpp:291
float loop_time
Time in seconds after which the effect loops.
Definition PixelpartEffect.h:52
Ref< PixelpartParticleEmitter > get_particle_emitter(int id) const
Return the particle emitter with the given ID.
Definition PixelpartEffect.cpp:276
float get_warmup_time() const
Return time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.cpp:161
Dictionary inputs
Dictionary of effect input values.
Definition PixelpartEffect.h:76
bool loop
Whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect.h:45
Vector4 get_input_float4(String name) const
Return value of an effect input. The effect input must be of type Vector4.
Definition PixelpartEffect.cpp:226
TypedArray< String > get_input_names() const
Return names of available effect inputs.
Definition PixelpartEffect.cpp:232
void pause()
Pause simulation of the effect.
Definition PixelpartEffect.cpp:128
void set_warmup_time(float time)
Set time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect.cpp:158
void set_input_float4(String name, Vector4 value)
Definition PixelpartEffect.cpp:208
Ref< PixelpartParticleEmitter > find_particle_emitter(String name) const
Return the particle emitter with the given name.
Definition PixelpartEffect.cpp:267
Ref< PixelpartParticleEmitter > get_particle_emitter_at_index(int index) const
Return the particle emitter at the given index.
Definition PixelpartEffect.cpp:285
Resource for a Pixelpart effect that is contained in a ppfx file.
Definition PixelpartEffectResource.h:15