1 /** 2 3D particle emitter. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.particles; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.geometryinstance; 24 import godot.material; 25 import godot.mesh; 26 import godot.visualinstance; 27 import godot.spatial; 28 import godot.node; 29 /** 30 3D particle emitter. 31 32 3D particle node used to create a variety of particle systems and effects. `Particles` features an emitter that generates some number of particles at a given rate. 33 Use the `process_material` property to add a $(D ParticlesMaterial) to configure particle appearance and behavior. Alternatively, you can add a $(D ShaderMaterial) which will be applied to all particles. 34 */ 35 @GodotBaseClass struct Particles 36 { 37 enum string _GODOT_internal_name = "Particles"; 38 public: 39 @nogc nothrow: 40 union { godot_object _godot_object; GeometryInstance _GODOT_base; } 41 alias _GODOT_base this; 42 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 43 package(godot) __gshared bool _classBindingInitialized = false; 44 package(godot) static struct _classBinding 45 { 46 __gshared: 47 @GodotName("set_emitting") GodotMethod!(void, bool) setEmitting; 48 @GodotName("set_amount") GodotMethod!(void, long) setAmount; 49 @GodotName("set_lifetime") GodotMethod!(void, double) setLifetime; 50 @GodotName("set_one_shot") GodotMethod!(void, bool) setOneShot; 51 @GodotName("set_pre_process_time") GodotMethod!(void, double) setPreProcessTime; 52 @GodotName("set_explosiveness_ratio") GodotMethod!(void, double) setExplosivenessRatio; 53 @GodotName("set_randomness_ratio") GodotMethod!(void, double) setRandomnessRatio; 54 @GodotName("set_visibility_aabb") GodotMethod!(void, AABB) setVisibilityAabb; 55 @GodotName("set_use_local_coordinates") GodotMethod!(void, bool) setUseLocalCoordinates; 56 @GodotName("set_fixed_fps") GodotMethod!(void, long) setFixedFps; 57 @GodotName("set_fractional_delta") GodotMethod!(void, bool) setFractionalDelta; 58 @GodotName("set_process_material") GodotMethod!(void, Material) setProcessMaterial; 59 @GodotName("set_speed_scale") GodotMethod!(void, double) setSpeedScale; 60 @GodotName("is_emitting") GodotMethod!(bool) isEmitting; 61 @GodotName("get_amount") GodotMethod!(long) getAmount; 62 @GodotName("get_lifetime") GodotMethod!(double) getLifetime; 63 @GodotName("get_one_shot") GodotMethod!(bool) getOneShot; 64 @GodotName("get_pre_process_time") GodotMethod!(double) getPreProcessTime; 65 @GodotName("get_explosiveness_ratio") GodotMethod!(double) getExplosivenessRatio; 66 @GodotName("get_randomness_ratio") GodotMethod!(double) getRandomnessRatio; 67 @GodotName("get_visibility_aabb") GodotMethod!(AABB) getVisibilityAabb; 68 @GodotName("get_use_local_coordinates") GodotMethod!(bool) getUseLocalCoordinates; 69 @GodotName("get_fixed_fps") GodotMethod!(long) getFixedFps; 70 @GodotName("get_fractional_delta") GodotMethod!(bool) getFractionalDelta; 71 @GodotName("get_process_material") GodotMethod!(Material) getProcessMaterial; 72 @GodotName("get_speed_scale") GodotMethod!(double) getSpeedScale; 73 @GodotName("set_draw_order") GodotMethod!(void, long) setDrawOrder; 74 @GodotName("get_draw_order") GodotMethod!(Particles.DrawOrder) getDrawOrder; 75 @GodotName("set_draw_passes") GodotMethod!(void, long) setDrawPasses; 76 @GodotName("set_draw_pass_mesh") GodotMethod!(void, long, Mesh) setDrawPassMesh; 77 @GodotName("get_draw_passes") GodotMethod!(long) getDrawPasses; 78 @GodotName("get_draw_pass_mesh") GodotMethod!(Mesh, long) getDrawPassMesh; 79 @GodotName("restart") GodotMethod!(void) restart; 80 @GodotName("capture_aabb") GodotMethod!(AABB) captureAabb; 81 } 82 bool opEquals(in Particles other) const { return _godot_object.ptr is other._godot_object.ptr; } 83 Particles opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 84 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 85 mixin baseCasts; 86 static Particles _new() 87 { 88 static godot_class_constructor constructor; 89 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Particles"); 90 if(constructor is null) return typeof(this).init; 91 return cast(Particles)(constructor()); 92 } 93 @disable new(size_t s); 94 /// 95 enum DrawOrder : int 96 { 97 /** 98 Particles are drawn in the order emitted. 99 */ 100 drawOrderIndex = 0, 101 /** 102 Particles are drawn in order of remaining lifetime. 103 */ 104 drawOrderLifetime = 1, 105 /** 106 Particles are drawn in order of depth. 107 */ 108 drawOrderViewDepth = 2, 109 } 110 /// 111 enum Constants : int 112 { 113 drawOrderIndex = 0, 114 drawOrderLifetime = 1, 115 drawOrderViewDepth = 2, 116 /** 117 Maximum number of draw passes supported. 118 */ 119 maxDrawPasses = 4, 120 } 121 /** 122 123 */ 124 void setEmitting(in bool emitting) 125 { 126 checkClassBinding!(typeof(this))(); 127 ptrcall!(void)(_classBinding.setEmitting, _godot_object, emitting); 128 } 129 /** 130 131 */ 132 void setAmount(in long amount) 133 { 134 checkClassBinding!(typeof(this))(); 135 ptrcall!(void)(_classBinding.setAmount, _godot_object, amount); 136 } 137 /** 138 139 */ 140 void setLifetime(in double secs) 141 { 142 checkClassBinding!(typeof(this))(); 143 ptrcall!(void)(_classBinding.setLifetime, _godot_object, secs); 144 } 145 /** 146 147 */ 148 void setOneShot(in bool enable) 149 { 150 checkClassBinding!(typeof(this))(); 151 ptrcall!(void)(_classBinding.setOneShot, _godot_object, enable); 152 } 153 /** 154 155 */ 156 void setPreProcessTime(in double secs) 157 { 158 checkClassBinding!(typeof(this))(); 159 ptrcall!(void)(_classBinding.setPreProcessTime, _godot_object, secs); 160 } 161 /** 162 163 */ 164 void setExplosivenessRatio(in double ratio) 165 { 166 checkClassBinding!(typeof(this))(); 167 ptrcall!(void)(_classBinding.setExplosivenessRatio, _godot_object, ratio); 168 } 169 /** 170 171 */ 172 void setRandomnessRatio(in double ratio) 173 { 174 checkClassBinding!(typeof(this))(); 175 ptrcall!(void)(_classBinding.setRandomnessRatio, _godot_object, ratio); 176 } 177 /** 178 179 */ 180 void setVisibilityAabb(in AABB aabb) 181 { 182 checkClassBinding!(typeof(this))(); 183 ptrcall!(void)(_classBinding.setVisibilityAabb, _godot_object, aabb); 184 } 185 /** 186 187 */ 188 void setUseLocalCoordinates(in bool enable) 189 { 190 checkClassBinding!(typeof(this))(); 191 ptrcall!(void)(_classBinding.setUseLocalCoordinates, _godot_object, enable); 192 } 193 /** 194 195 */ 196 void setFixedFps(in long fps) 197 { 198 checkClassBinding!(typeof(this))(); 199 ptrcall!(void)(_classBinding.setFixedFps, _godot_object, fps); 200 } 201 /** 202 203 */ 204 void setFractionalDelta(in bool enable) 205 { 206 checkClassBinding!(typeof(this))(); 207 ptrcall!(void)(_classBinding.setFractionalDelta, _godot_object, enable); 208 } 209 /** 210 211 */ 212 void setProcessMaterial(Material material) 213 { 214 checkClassBinding!(typeof(this))(); 215 ptrcall!(void)(_classBinding.setProcessMaterial, _godot_object, material); 216 } 217 /** 218 219 */ 220 void setSpeedScale(in double scale) 221 { 222 checkClassBinding!(typeof(this))(); 223 ptrcall!(void)(_classBinding.setSpeedScale, _godot_object, scale); 224 } 225 /** 226 227 */ 228 bool isEmitting() const 229 { 230 checkClassBinding!(typeof(this))(); 231 return ptrcall!(bool)(_classBinding.isEmitting, _godot_object); 232 } 233 /** 234 235 */ 236 long getAmount() const 237 { 238 checkClassBinding!(typeof(this))(); 239 return ptrcall!(long)(_classBinding.getAmount, _godot_object); 240 } 241 /** 242 243 */ 244 double getLifetime() const 245 { 246 checkClassBinding!(typeof(this))(); 247 return ptrcall!(double)(_classBinding.getLifetime, _godot_object); 248 } 249 /** 250 251 */ 252 bool getOneShot() const 253 { 254 checkClassBinding!(typeof(this))(); 255 return ptrcall!(bool)(_classBinding.getOneShot, _godot_object); 256 } 257 /** 258 259 */ 260 double getPreProcessTime() const 261 { 262 checkClassBinding!(typeof(this))(); 263 return ptrcall!(double)(_classBinding.getPreProcessTime, _godot_object); 264 } 265 /** 266 267 */ 268 double getExplosivenessRatio() const 269 { 270 checkClassBinding!(typeof(this))(); 271 return ptrcall!(double)(_classBinding.getExplosivenessRatio, _godot_object); 272 } 273 /** 274 275 */ 276 double getRandomnessRatio() const 277 { 278 checkClassBinding!(typeof(this))(); 279 return ptrcall!(double)(_classBinding.getRandomnessRatio, _godot_object); 280 } 281 /** 282 283 */ 284 AABB getVisibilityAabb() const 285 { 286 checkClassBinding!(typeof(this))(); 287 return ptrcall!(AABB)(_classBinding.getVisibilityAabb, _godot_object); 288 } 289 /** 290 291 */ 292 bool getUseLocalCoordinates() const 293 { 294 checkClassBinding!(typeof(this))(); 295 return ptrcall!(bool)(_classBinding.getUseLocalCoordinates, _godot_object); 296 } 297 /** 298 299 */ 300 long getFixedFps() const 301 { 302 checkClassBinding!(typeof(this))(); 303 return ptrcall!(long)(_classBinding.getFixedFps, _godot_object); 304 } 305 /** 306 307 */ 308 bool getFractionalDelta() const 309 { 310 checkClassBinding!(typeof(this))(); 311 return ptrcall!(bool)(_classBinding.getFractionalDelta, _godot_object); 312 } 313 /** 314 315 */ 316 Ref!Material getProcessMaterial() const 317 { 318 checkClassBinding!(typeof(this))(); 319 return ptrcall!(Material)(_classBinding.getProcessMaterial, _godot_object); 320 } 321 /** 322 323 */ 324 double getSpeedScale() const 325 { 326 checkClassBinding!(typeof(this))(); 327 return ptrcall!(double)(_classBinding.getSpeedScale, _godot_object); 328 } 329 /** 330 331 */ 332 void setDrawOrder(in long order) 333 { 334 checkClassBinding!(typeof(this))(); 335 ptrcall!(void)(_classBinding.setDrawOrder, _godot_object, order); 336 } 337 /** 338 339 */ 340 Particles.DrawOrder getDrawOrder() const 341 { 342 checkClassBinding!(typeof(this))(); 343 return ptrcall!(Particles.DrawOrder)(_classBinding.getDrawOrder, _godot_object); 344 } 345 /** 346 347 */ 348 void setDrawPasses(in long passes) 349 { 350 checkClassBinding!(typeof(this))(); 351 ptrcall!(void)(_classBinding.setDrawPasses, _godot_object, passes); 352 } 353 /** 354 355 */ 356 void setDrawPassMesh(in long pass, Mesh mesh) 357 { 358 checkClassBinding!(typeof(this))(); 359 ptrcall!(void)(_classBinding.setDrawPassMesh, _godot_object, pass, mesh); 360 } 361 /** 362 363 */ 364 long getDrawPasses() const 365 { 366 checkClassBinding!(typeof(this))(); 367 return ptrcall!(long)(_classBinding.getDrawPasses, _godot_object); 368 } 369 /** 370 371 */ 372 Ref!Mesh getDrawPassMesh(in long pass) const 373 { 374 checkClassBinding!(typeof(this))(); 375 return ptrcall!(Mesh)(_classBinding.getDrawPassMesh, _godot_object, pass); 376 } 377 /** 378 Restarts the particle emmission, clearing existing particles. 379 */ 380 void restart() 381 { 382 checkClassBinding!(typeof(this))(); 383 ptrcall!(void)(_classBinding.restart, _godot_object); 384 } 385 /** 386 387 */ 388 AABB captureAabb() const 389 { 390 checkClassBinding!(typeof(this))(); 391 return ptrcall!(AABB)(_classBinding.captureAabb, _godot_object); 392 } 393 /** 394 If `true` particles are being emitted. Default value: `true`. 395 */ 396 @property bool emitting() 397 { 398 return isEmitting(); 399 } 400 /// ditto 401 @property void emitting(bool v) 402 { 403 setEmitting(v); 404 } 405 /** 406 Number of particles to emit. 407 */ 408 @property long amount() 409 { 410 return getAmount(); 411 } 412 /// ditto 413 @property void amount(long v) 414 { 415 setAmount(v); 416 } 417 /** 418 Amount of time each particle will exist. Default value: `1`. 419 */ 420 @property double lifetime() 421 { 422 return getLifetime(); 423 } 424 /// ditto 425 @property void lifetime(double v) 426 { 427 setLifetime(v); 428 } 429 /** 430 If `true` only `amount` particles will be emitted. Default value: `false`. 431 */ 432 @property bool oneShot() 433 { 434 return getOneShot(); 435 } 436 /// ditto 437 @property void oneShot(bool v) 438 { 439 setOneShot(v); 440 } 441 /** 442 Amount of time to preprocess the particles before animation starts. Lets you start the animation some time after particles have started emitting. 443 */ 444 @property double preprocess() 445 { 446 return getPreProcessTime(); 447 } 448 /// ditto 449 @property void preprocess(double v) 450 { 451 setPreProcessTime(v); 452 } 453 /** 454 Speed scaling ratio. Default value: `1`. A value of `0` can be used to pause the particles. 455 */ 456 @property double speedScale() 457 { 458 return getSpeedScale(); 459 } 460 /// ditto 461 @property void speedScale(double v) 462 { 463 setSpeedScale(v); 464 } 465 /** 466 Time ratio between each emission. If `0` particles are emitted continuously. If `1` all particles are emitted simultaneously. Default value: `0`. 467 */ 468 @property double explosiveness() 469 { 470 return getExplosivenessRatio(); 471 } 472 /// ditto 473 @property void explosiveness(double v) 474 { 475 setExplosivenessRatio(v); 476 } 477 /** 478 Emission randomness ratio. Default value: `0`. 479 */ 480 @property double randomness() 481 { 482 return getRandomnessRatio(); 483 } 484 /// ditto 485 @property void randomness(double v) 486 { 487 setRandomnessRatio(v); 488 } 489 /** 490 491 */ 492 @property long fixedFps() 493 { 494 return getFixedFps(); 495 } 496 /// ditto 497 @property void fixedFps(long v) 498 { 499 setFixedFps(v); 500 } 501 /** 502 503 */ 504 @property bool fractDelta() 505 { 506 return getFractionalDelta(); 507 } 508 /// ditto 509 @property void fractDelta(bool v) 510 { 511 setFractionalDelta(v); 512 } 513 /** 514 The $(D AABB) that determines the area of the world part of which needs to be visible on screen for the particle system to be active. 515 */ 516 @property AABB visibilityAabb() 517 { 518 return getVisibilityAabb(); 519 } 520 /// ditto 521 @property void visibilityAabb(AABB v) 522 { 523 setVisibilityAabb(v); 524 } 525 /** 526 If `true` particles use the parent node's coordinate space. If `false` they use global coordinates. Default value: `true`. 527 */ 528 @property bool localCoords() 529 { 530 return getUseLocalCoordinates(); 531 } 532 /// ditto 533 @property void localCoords(bool v) 534 { 535 setUseLocalCoordinates(v); 536 } 537 /** 538 Particle draw order. Uses `DRAW_ORDER_*` values. Default value: `DRAW_ORDER_INDEX`. 539 */ 540 @property Particles.DrawOrder drawOrder() 541 { 542 return getDrawOrder(); 543 } 544 /// ditto 545 @property void drawOrder(long v) 546 { 547 setDrawOrder(v); 548 } 549 /** 550 The number of draw passes when rendering particles. 551 */ 552 @property long drawPasses() 553 { 554 return getDrawPasses(); 555 } 556 /// ditto 557 @property void drawPasses(long v) 558 { 559 setDrawPasses(v); 560 } 561 /** 562 $(D Mesh) that is drawn for the first draw pass. 563 */ 564 @property Mesh drawPass1() 565 { 566 return getDrawPassMesh(0); 567 } 568 /// ditto 569 @property void drawPass1(Mesh v) 570 { 571 setDrawPassMesh(0, v); 572 } 573 /** 574 $(D Mesh) that is drawn for the second draw pass. 575 */ 576 @property Mesh drawPass2() 577 { 578 return getDrawPassMesh(1); 579 } 580 /// ditto 581 @property void drawPass2(Mesh v) 582 { 583 setDrawPassMesh(1, v); 584 } 585 /** 586 $(D Mesh) that is drawn for the third draw pass. 587 */ 588 @property Mesh drawPass3() 589 { 590 return getDrawPassMesh(2); 591 } 592 /// ditto 593 @property void drawPass3(Mesh v) 594 { 595 setDrawPassMesh(2, v); 596 } 597 /** 598 $(D Mesh) that is drawn for the fourth draw pass. 599 */ 600 @property Mesh drawPass4() 601 { 602 return getDrawPassMesh(3); 603 } 604 /// ditto 605 @property void drawPass4(Mesh v) 606 { 607 setDrawPassMesh(3, v); 608 } 609 }