ParticleArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "ArmA 2" to "Arma 2")
m (Text replacement - "[[Image:" to "[[File:")
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{TOC|side}}
{{TOC|side}}
{{Wikipedia|Particle_system|Particle}} is a lightweight for performance effect system that is to be used for emulate dusts, fires, explosions, and/or anything. Every explosions, dusts, fires and most of in-game 3D effects are made in this system. <br>
{{Link|https://en.wikipedia.org/wiki/Particle_system|Particle}} is a lightweight for performance effect system that is to be used for emulate dusts, fires, explosions, and/or anything. Every explosions, dusts, fires and most of in-game 3D effects are made in this system.<br>
Particles can be generated by script commands like [[drop]], so you can also do emulate them easily.
Particles can be generated by script commands like [[drop]], so you can also do emulate them easily.


Line 6: Line 6:
== Format ==
== Format ==


<code>[
{| class="wikitable sortable align-center-col-5"
shapeName,
! Index !! parameter name !! Type !! Description !! Since
animationName,
type,
timerPeriod,
lifeTime,
position,
moveVelocity,
rotationVelocity,
weight,
volume,
rubbing,
size,
color,
animationPhase,
randomDirectionPeriod,
randomDirectionIntensity,
onTimer,
beforeDestroy,
object,
angle, {{cc|{{since||}}}}
onSurface, {{cc|{{since|arma3|0.74}}}}
bounceOnSurface, {{cc|{{since|arma3|0.74}}}}
emissiveColor, {{cc|{{since|arma3|1.08}}}}
vectorDir {{cc|{{since|arma3|1.92}}}}
]</code>
{| class="wikitable sortable"
! # !! parameter name !! Type !! Description
|-
|-
| 1 || shapeName || Render || [[String]] or [[Array]] format [p3dPath, n<sup>th</sup>, index, count, loop]:
| 0 || shapeName || Render || [[String]] or [[Array]] format [p3dPath, n<sup>th</sup>, index, count, loop]:
* p3dPath: [[String]]
* p3dPath: [[String]]
* n<sup>th</sup>: [[Number]]
* n<sup>th</sup>: [[Number]]
Line 41: Line 15:
* count: [[Number]]
* count: [[Number]]
* loop: [[Number]]
* loop: [[Number]]
|
|-
|-
| 2 || animationName || {{n/a}} || [[String]] - obsolete parameter that was meant to play .rtm anims, will throw "Skeletal animation not supported for particles" rpt error if not empty
| 1 || animationName || {{n/a}} || [[String]] - obsolete parameter that was meant to play {{hl|.rtm}} anims, will throw "Skeletal animation not supported for particles" rpt error if not empty ||
|-
|-
| 3 || type || Render || [[String]] - "Billboard" or "SpaceObject"
| 2 || type || Render || [[String]] - "Billboard" or "SpaceObject" ||
|-
|-
| 4 || timerPeriod || Script || [[Number]] - In seconds.
| 3 || timerPeriod || Script || [[Number]] - In seconds. ||
|-
|-
| 5 || lifetime || Physical || [[Number]] - In seconds.
| 4 || lifetime || Physical || [[Number]] - In seconds. ||
|-
|-
| 6 || position || Physical || [[Array]] format [[Position]]
| 5 || position || Physical || [[Array]] format [[Position]] or [[String]] ''object''<nowiki/>'s selection ||
|-
|-
| 7 || moveVelocity || Physical || [[Array]] format [[velocity]]
| 6 || moveVelocity || Physical || [[Array]] format [[velocity]] ||
|-
|-
| 8 || rotationVelocity || Physical || [[Number]] - rotations per second
| 7 || rotationVelocity || Physical || [[Number]] - rotations per second ||
|-
|-
| 9 || weight || Physical || [[Number]] - weight of the particle (kg)
| 8 || weight || Physical || [[Number]] - weight of the particle (kg) ||
|-
|-
| 10 || volume || Physical || [[Number]] - volume of the particle in m<sup>3</sup>
| 9 || volume || Physical || [[Number]] - volume of the particle in m<sup>3</sup> ||
|-
|-
| 11 || rubbing || Physical || [[Number]] - Determines how particles blown by winds (include downwash by helicopters).
| 10 || rubbing || Physical || [[Number]] - Determines how particles are affected by wind (include downwash by helicopters). ||
|-
|-
| 12 || size || Render || [[Array]] of [[Number]]s - particle size along its ''lifetime'', in meter
| 11 || size || Render || [[Array]] of [[Number]]s - particle size along its ''lifetime'', in meter ||
|-
|-
| 13 || color || Render || [[Array]] of [[Array]]s format [[Color|Color (RGBA)]]
| 12 || color || Render || [[Array]] of [[Array]]s format [[Color|Color (RGBA)]] ||
|-
|-
| 14 || animationPhase || Render || [[Array]] of [[Number]]s - phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect.
| 13 || animationPhase || Render || [[Array]] of [[Number]]s - phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect. ||
|-
|-
| 15 || randomDirectionPeriod || Random || [[Number]] - In seconds.
| 14 || randomDirectionPeriod || Random || [[Number]] - In seconds. ||
|-
|-
| 16 || randomDirectionIntensity || Random || [[Number]] - How particles change its velocity every once in ''randomDirectionPeriod'' seconds, in meters'''?'''
| 15 || randomDirectionIntensity || Random || [[Number]] - How particles change its velocity every once in ''randomDirectionPeriod'' seconds, in meters'''?''' ||
|-
|-
| 17 || onTimer || Script || [[String]] - path to the script to be executed on timer. Variable [[_this]] contains particle position. <code>[[private]] _particlePosition = [[_this]];</code>
| 16 || onTimer || Script || [[String]] - '''path''' to the script to be executed on timer. Variable <sqf inline>_this</sqf> contains particle position in format [[Position#PositionAGL|PositionAGL]]. <sqf>private _particlePosition = _this;</sqf> ||
|-
|-
| 18 || beforeDestroy || Script || [[String]] - code executed right before particle's destruction. <code>[[private]] _particlePosition = [[this]];</code>
| 17 || beforeDestroy || Script || [[String]] - '''path''' to the script to be executed right before particle's destruction. Variable [[Magic Variables#this|_this]] contains particle position in format [[Position#PositionAGL|PositionAGL]]. <sqf>private _particlePosition = _this;</sqf> ||
|-
|-
| 19 || object || Physical || [[Object]] - If this parameter isn't [[objNull]], the particle source will be attached to the object. The source will stop to generate its particles when the distahce between the object and the source is further than [[getObjectViewDistance|Object View Distance]].
| 18 || object || Physical || [[Object]] - If this parameter isn't [[objNull]], the particle source will be attached to the object. The source will stop to generate its particles when the distahce between the object and the source is further than [[getObjectViewDistance|Object View Distance]]. ||
|-
|-
| 20 || angle || Physical || [[Number]] - ('''Optional''', default 0) determines the particle's starting angle '''in radian'''. [[pi]] = 180°. {{since|||y}}
| 19 || angle || Physical || [[Number]] - ('''Optional''', default 0) determines the particle's starting angle '''in radian'''. [[pi]] = 180°. || {{Icon|Unknown}}
|-
|-
| 21 || onSurface || Physical || [[Boolean]] - ('''Optional''', default [[false]]) Bounce the particles when hit the surface if [[true]]. If ''circleRadius'' > 0, placing of particle on (water) surface on start of its existence. Circle radius is defined by command [[setParticleCircle]]. {{since|arma3|0.74|y}}
| 20 || onSurface || Physical || [[Boolean]] - ('''Optional''', default [[false]]) Bounce the particles when hit the surface if [[true]]. If ''circleRadius'' > 0, placing of particle on (water) surface on start of its existence. Circle radius is defined by command [[setParticleCircle]]. || {{GVI|arma3|0.74}}
|-
|-
| 22 || bounceOnSurface || Physical || [[Number]] - ('''Optional''', default -1) coef of bounce in collision with ground, 0..1 for collisions, -1 to disable collision. Should be used soberly as it has a significant impact on performance. {{since|arma3|0.74|y}}
| 21 || bounceOnSurface || Physical || [[Number]] - ('''Optional''', default -1) coef of bounce in collision with ground, 0..1 for collisions, -1 to disable collision. Should be used soberly as it has a significant impact on performance. || {{GVI|arma3|0.74}}
|-
|-
| 23 || emissiveColor || Render || [[Array]] of [[Array]]s format [[Color|Color (RGBA)]] - ('''Optional''', default {{Inline code|[&nbsp;]}}'''?''') Sets emissivity of the particle ('''RGB0'''). Works as lighting of particles, so must be combined with correctly set particle color. Values need to be higher than just 0-1 to have a real effect (f.e. 100 times the RGB color values). Last parameter has no meaning for now. {{since|arma3|1.08|y}}
| 22 || emissiveColor || Render || [[Array]] of [[Array]]s format [[Color|Color (RGBA)]] - ('''Optional''', default {{hl|[&nbsp;]}}'''?''') Sets emissivity of the particle ('''RGB0'''). Works as lighting of particles, so must be combined with correctly set particle color. Values need to be higher than just 0-1 to have a real effect (f.e. 100 times the RGB color values). Last parameter has no meaning for now. || {{GVI|arma3|1.08}}
|-
|-
| 24 || vectorDir || Physical || [[Array]] format [[vectorDir]]'''?''' - ('''Optional''') Sets the default direction for '''SpaceObject''' particles. {{since|arma3|1.92|y}}
| 23 || vectorDir || Physical || [[Array]] format [[vectorDir]] - ('''Optional''') Sets the default direction for '''SpaceObject''' particles.<br>[[Array]] format [<nowiki/>[[vectorDir]], [[vectorUp]]] - ('''Optional''') Sets the default [[vectorDir]]/[[vectorUp]] for '''SpaceObject''' particles. || {{GVI|arma3|1.92}}<br>{{GVI|arma3|2.12}}
|}
|}


== Parameters ==
== Parameters ==


=== Global parameters ===
=== Global Parameters ===


[[Image:Particles.jpg|thumb|ArmA particle texture]]
[[File:Particles.jpg|thumb|{{Name|arma1|short}} particle texture]]
'''ShapeName -''' Name of the shape associated with the particle.
'''ShapeName''' - Name of the shape associated with the particle.
: In ArmA, the ShapeName is defined as an array. This should be the particle shape name, followed by three integers.
: In {{Name|arma1|short}}, the ShapeName is defined as an array. This should be the particle shape name, followed by three integers.
: Example: ["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 0]
: Example: ["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 0]
: 1. Anim Divisor (1 for a 1x1, 8 for a 8x8, etc)
:# Anim Divisor (1 for a 1x1, 8 for a 8x8, etc)
: 2. Anim Starting Row
:# Anim Starting Row
: 3. Number of Frames to Play (speed controlled by animation phase below)
:# Number of Frames to Play (speed controlled by animation phase below)


: In this shot of [[:Image:Particles.jpg|"\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d"]], note the following:
: In this shot of [[:Image:Particles.jpg|"\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d"]], note the following:


:: The image used for this particle effect is 8X8 effect frames. This means you need to use 8 as your Anim Divisor. Overwise, the game will either draw too much of the image used, or too little. This is highly visible in most situations.
:: The image used for this particle effect is 8X8 effect frames. This means you need to use 8 as your Anim Divisor. Overwise, the game will either draw too much of the image used, or too little. This is highly visible in most situations.


:: The Anim Starting Row picks the coresponding superimposed number in the image above. 0 picks the first smoke effect, 1 picks the second smoke effect, 2 picks the first fire effect, etc.
:: The Anim Starting Row picks the coresponding superimposed number in the image above. 0 picks the first smoke effect, 1 picks the second smoke effect, 2 picks the first fire effect, etc.


:: The setting for the Number of Number of Frames to Play should, in most cases, be the number of effects available to the animation. If you go over this (for example, selecting 9 in this 8X8 tile), it will start playing the animation frames of the next effect down. If there is nothing below to grab, it will draw a blank for that frame. If 1 is used, it will only play the first frame of the selected row.
:: The setting for the Number of Number of Frames to Play should, in most cases, be the number of effects available to the animation. If you go over this (for example, selecting 9 in this 8X8 tile), it will start playing the animation frames of the next effect down. If there is nothing below to grab, it will draw a blank for that frame. If 1 is used, it will only play the first frame of the selected row.
:: If you want to find out of how many rows a datasource consists use ["...", 1, 0, 1] to see the full picture as a particle.
:: If you want to find out of how many rows a datasource consists use ["...", 1, 0, 1] to see the full picture as a particle.


[[Image:Arma2_universal_particle_texture.jpg|thumb|Arma2 particle texture]]
[[File:Arma2_universal_particle_texture.jpg|thumb|Arma2 particle texture]]
In '''Arma 2 (and OA)''', the method for determining how many frames to play has changed.
In '''{{arma2}} (and {{Name|arma2oa|short}})''', the method for determining how many frames to play has changed.


''Example 1:''
''Example 1:''
:["\Ca\Data\ParticleEffects\Universal\Universal", 16, 10, 32, 1]  
: ["\Ca\Data\ParticleEffects\Universal\Universal", 16, 10, 32, 1]  
:1. Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)  
:# Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)  
:2. Anim Starting Row (starting a 0)
:# Anim Starting Row (starting a 0)
:3. Number of Frames to play (Starting with 1 and not 0)
:# Number of Frames to play (Starting with 1 and not 0)
:4. Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
:# Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))


:Example 1 above (a fire burning) will start the animation in row 10, will play from frames 1 to 32, and will loop.
:Example 1 above (a fire burning) will start the animation in row 10, will play from frames 1 to 32, and will loop.




Also in '''Arma 2 and OA''', To achieve a single frame of animation that is not the first column of a row, use the third numerical value as a column selection instead of indicating how many frames to play.
Also in '''{{arma2}} and {{Name|arma2|short}}''', to achieve a single frame of animation that is not the first column of a row, use the third numerical value as a column selection instead of indicating how many frames to play.


''Example 2:''
''Example 2:''
:["\Ca\Data\ParticleEffects\Universal\Universal", 16, 12, 9, 0]  
: ["\Ca\Data\ParticleEffects\Universal\Universal", 16, 12, 9, 0]  
:1. Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)  
:# Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)  
:2. Anim Starting Row (starting at 0)
:# Anim Starting Row (starting at 0)
:3. Column Selection (Starting with 1 and not 0)
:# Column Selection (Starting with 1 and not 0)
:4. Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
:# Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
:Additional Step: You must also set the AnimationPhase value (described in render parameters) to a large number (such as 1000) if you only want to play a single frame. The reason for this is that the game engine does not only play a single frame, it actually begins at the first frame in the row and cycles to the desired frame. If a small AnimationPhase number is used then you can actualy see the animation cycle through the all the frames (1-9). A large number makes this imperceptible and only the desired frame appears to be displayed.
: Additional Step: You must also set the AnimationPhase value (described in render parameters) to a large number (such as 1000) if you only want to play a single frame. The reason for this is that the game engine does not only play a single frame, it actually begins at the first frame in the row and cycles to the desired frame. If a small AnimationPhase number is used then you can actualy see the animation cycle through the all the frames (1-9). A large number makes this imperceptible and only the desired frame appears to be displayed.


[[Image:a3_universal_ca.jpg|thumb|Arma3 particle texture (Universal)]]
[[File:a3_universal_ca.jpg|thumb|{{arma3}} particle texture (Universal)]]
:Example 2 above (exploding rock dust) will start the animation in row 12, will only play frame 9, and will not loop.
:Example 2 above (exploding rock dust) will start the animation in row 12, will only play frame 9, and will not loop.




'''AnimationName -''' Has to be a [[String]], but it is obsolete. Used to play .rtm anims, if not empty, it will throw "Skeletal animation not supported for particles" rpt error
'''AnimationName''' - Has to be a [[String]], but it is obsolete. Used to play .rtm anims, if not empty, it will throw "Skeletal animation not supported for particles" rpt error


'''Type -''' Type of particle (either "Billboard" or "SpaceObject").
'''Type''' - Type of particle (either "Billboard" or "SpaceObject").


'''TimerPeriod -''' The period of calling the "OnTimer" event (in sec).
'''TimerPeriod''' - The period of calling the "OnTimer" event (in sec).


'''LifeTime -''' Life time of the particle (in sec).
'''LifeTime''' - Life time of the particle (in sec).


=== Physical parameters ===
=== Physical Parameters ===


''Position -''' Either 3D coordinate (x, y, z) or name of the selection - in this case the Object property must be set.
''Position''' - Either 3D coordinate (x, y, z) or name of the selection - in this case the Object property must be set.


'''MoveVelocity -''' 3D vector (x, y, z) which describes the velocity vector of the particle direction and speed in m/s.
'''MoveVelocity''' - 3D vector (x, y, z) which describes the velocity vector of the particle direction and speed in m/s.


'''RotationVelocity -''' Float number which determines number of rotations in one second.
'''RotationVelocity''' - Float number which determines number of rotations in one second.


'''Weight -''' Weight of the particle (kg).
'''Weight''' - Weight of the particle (kg).


'''Volume -''' Volume of the particle (m^3).
'''Volume''' - Volume of the particle (m<sup>3</sup>).


'''Rubbing -''' Float number without dimension which determines the impact of the density of the environment on this particle. '''0''' - no impact (vacuum).
'''Rubbing''' - Float number without dimension which determines the impact of the density of the environment on this particle. '''0''' - no impact (vacuum).


'''Angle -''' Float number which determines starting angle of the particle.  
'''Angle''' - Float number which determines starting angle of the particle.  


'''OnSurface -''' Boolean. Placing of particle on (water) surface on start of it is existence, default value is true, works only if circleRadius > 0. Circle radius is defined by command [[setParticleCircle]]. Works since Arma 3 v. 0.74.
'''OnSurface''' - Boolean. Placing of particle on (water) surface on start of it is existence, default value is true, works only if circleRadius > 0. Circle radius is defined by command [[setParticleCircle]]. Works since {{GVI|arma3|0.74|size= 0.75}}.


'''BounceOnSurface -''' Coef of speed's loosing in collision with ground, 0-1 for collisions, -1 disable collision. Default value -1. Should be used soberly, it has significant impact on performance. Works since Arma 3 v. 0.74.
'''BounceOnSurface''' - Coef of speed's loosing in collision with ground, 0-1 for collisions, -1 disable collision. Default value -1. Should be used soberly, it has significant impact on performance. Works since {{GVI|arma3|0.74|size= 0.75}}.


[[Image:a3_universal_02_ca.jpg|thumb|Arma3 particle texture (Universal_02)]]
[[File:a3_universal_02_ca.jpg|thumb|{{arma3}} particle texture (Universal_02)]]
=== Render parameters ===
=== Render Parameters ===


 
{{Feature|informative|All these values are set as arrays to show their development in time.}}
'''Note:''' All these values are set as arrays to show their development in time.


If you set the array [1, 2] as a size, then at the beginning the size of the particle will be 1 and at the end of the life time of the particle its size will be 2.
If you set the array [1, 2] as a size, then at the beginning the size of the particle will be 1 and at the end of the life time of the particle its size will be 2.
Line 176: Line 151:




'''Size -''' Size of the particle in time to render ('''m''').
'''Size''' - Size of the particle in time to render ('''m''').


'''Color -''' Colour of the particle in time to render ('''RGBA''').
'''Color''' - Colour of the particle in time to render ('''RGBA''').


'''EmissiveColor -''' Sets emissivity of the particle ('''RGB0'''). Works as lighting of particles, so must be combined with correctly set particle color. Last parameter has no meaning for now.
'''EmissiveColor''' - Sets emissivity of the particle ('''RGB0'''). Works as lighting of particles, so must be combined with correctly set particle color. Last parameter has no meaning for now.


'''AnimationPhase -''' Phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect.
'''AnimationPhase''' - Phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect.


=== Random parameters ===
=== Randomness Parameters ===


'''RandomDirectionPeriod -''' Period of change of the velocity vector (s).
'''RandomDirectionPeriod''' - Period of change of the velocity vector (s).


'''RandomDirectionIntensity -''' Each MoveVelocity component will be changed with random value from interval <0, RandomDirectionIntensity>.
'''RandomDirectionIntensity''' - Each MoveVelocity component will be changed with random value from interval <0, RandomDirectionIntensity>.


'''OnTimer -''' Name of the script to run every period determined by TimerPeriod property.
'''OnTimer''' - Name of the script to run every period determined by TimerPeriod property.


Position of the particle is stored in "this" variable.
Position of the particle is stored in "this" variable.


'''BeforeDestroy -''' Name of the script to run right before destroying the particle.
'''BeforeDestroy''' - Name of the script to run right before destroying the particle.


Position of the particle is stored in "this" variable.
Position of the particle is stored in "this" variable.


'''Object -''' Object to bind this particle to.
'''Object''' - Object to bind this particle to.




Line 207: Line 182:
=== Thunderbolt ===
=== Thunderbolt ===


Create thunderbolt on logic named ''logic1'':
Create a thunderbolt on logic named ''logic1'':
[[private]] _pos = [<nowiki/>[[position]] logic1 [[select]] 0,[[position]] logic1 [[select]] 1, 10];
<sqf>
[[drop]] ["blesk1", "", "Billboard", 0.01, 0.2, _pos, [0,0,0], 0, 1, 1, 0, [20 + [[random]] 20], [<nowiki/>[1,1,1,1], [1,1,1,0.7]], [1,0], 0, 0, "", "", ""];
private _pos = [position logic1 select 0, position logic1 select 1, 10];
drop ["blesk1", "", "Billboard", 0.01, 0.2, _pos, [0,0,0], 0, 1, 1, 0, [20 + random 20], [[1,1,1,1], [1,1,1,0.7]], [1, 0], 0, 0, "", "", ""];
</sqf>
 
=== Mass Grave Flies ===
 
<sqf>
// SCRIPT FOR GENERATING FLIES AROUND MASS GRAVE
 
// FIXED PARAMS
private _source = "#particlesource" createVehicleLocal getPos (_this select 0);
_source setParticleParams [
/* Sprite */ ["\ca\characters2\OTHER\FLY.p3d", 1, 0, 1, 0], // File,Ntieth,Index,Count,Loop
/* Animation */ "",
/* Type */ "spaceObject",
/* TimerPer */ 1,
/* Lifetime */ 4,
/* Position */ [0,0,0],
/* MoveVelocity */ [0,0,0.5],
/* Simulation */ 1, 1.30, 1, 0, // rotationVel, weight, volume, rubbing
/* Scale */ [0.03, 0.03, 0.03, 0],
/* Color */ [[1,1,1,1], [1,1,1,1]],
/* AnimSpeed */ [1.5, 0.5],
/* randDirPeriod */ 0.01,
/* randDirIntensity */ 0.08,
/* onTimerScript */ "",
/* DestroyScript */ "",
/* object */ _this,
/* Angle */ 0,
/* onSurface */ true,
/* bounceOnSurface */ 0.5,
/* emissiveColor */ [[0,0,0,0]]
];


=== Mass grave Flies ===
// RANDOM / TOLERANCE PARAMS
_source setParticleRandom [
/* LifeTime */ 2,
/* Position */ [2,2,0.25],
/* MoveVelocity */ [0,0,0],
/* rotationVel */ 1,
/* Scale */ 0.02,
/* Color */ [0,0,0,0.1],
/* randDirPeriod */ 0.01,
/* randDirIntensity */ 0.03,
/* Angle */ 10
];


{{cc|SCRIPT FOR GENERATING FLIES AROUND MASS GRAVE}}
_source setDropInterval 0.003;
private _soundSource = createSoundSource ["Sound_Flies", getPos (_this select 0), [], 0];
{{cc|FIXED PARAMS}}
</sqf>
[[private]] _source = "#particlesource" [[createVehicleLocal]] [[getPos]] (_this [[select]] 0);
_source [[setParticleParams]] [
{{codecomment|/* Sprite */}} ["\ca\characters2\OTHER\FLY.p3d",1,0,1,0], {{cc|File,Ntieth,Index,Count,Loop}}
{{codecomment|/* Animation */}} "",
{{codecomment|/* Type */}} "spaceObject",
{{codecomment|/* TimerPer */}} 1,
{{codecomment|/* Lifetime */}} 4,
{{codecomment|/* Position */}} [0,0,0],
{{codecomment|/* MoveVelocity */}} [0,0,0.5],
{{codecomment|/* Simulation */}} 1,1.30,1,0, {{cc|rotationVel, weight, volume, rubbing}}
{{codecomment|/* Scale */}} [0.03,0.03,0.03,0],
{{codecomment|/* Color */}} [[1,1,1,1],[1,1,1,1]],
{{codecomment|/* AnimSpeed */}} [1.5,0.5],
{{codecomment|/* randDirPeriod */}} 0.01,
{{codecomment|/* randDirIntensity */}} 0.08,
{{codecomment|/* onTimerScript */}} "",
{{codecomment|/* DestroyScript */}} "",
{{codecomment|/* object */}} _this,
{{codecomment|/* Angle */}}            0,
{{codecomment|/* onSurface */}}        true,
{{codecomment|/* bounceOnSurface */}}  0.5,
{{codecomment|/* emissiveColor */}}    [<nowiki/>[0,0,0,0]]];
{{cc|RANDOM / TOLERANCE PARAMS}}
_source [[setParticleRandom]] [
{{codecomment|/* LifeTime */}} 2,
{{codecomment|/* Position */}} [2,2,0.25],
{{codecomment|/* MoveVelocity */}} [0,0,0],
{{codecomment|/* rotationVel */}} 1,
{{codecomment|/* Scale */}} 0.02,
{{codecomment|/* Color */}} [0,0,0,0.1],
{{codecomment|/* randDirPeriod */}} 0.01,
{{codecomment|/* randDirIntensity */}} 0.03,
{{codecomment|/* Angle */}} 10];
_source [[setDropInterval]] 0.003;
[[private]] _soundSource = [[createSoundSource]] ["Sound_Flies", [[getPos]] ([[_this]] [[select]] 0), [], 0];




Line 259: Line 240:
* [[Particles Tutorial]] ({{arma2}} &amp; {{arma3}})
* [[Particles Tutorial]] ({{arma2}} &amp; {{arma3}})
* [[ParticleTemplates]] ({{arma1}})
* [[ParticleTemplates]] ({{arma1}})
* [http://www.ofpec.com/ed_depot/index.php?action=details&id=38&page=0&cat=xyz Vektorboson's Drop Tutorial]
* {{Link|https://www.ofpec.com/editors-depot/index.php?action{{=}}details&id{{=}}38&game{{=}}ArmA|Vektorboson's Drop Tutorial}}




[[Category: Arrays]]
[[Category: Arrays]]
[[Category: Particle System]]
[[Category: Particle System]]

Latest revision as of 23:11, 20 November 2023

Particle is a lightweight for performance effect system that is to be used for emulate dusts, fires, explosions, and/or anything. Every explosions, dusts, fires and most of in-game 3D effects are made in this system.
Particles can be generated by script commands like drop, so you can also do emulate them easily.


Format

Index parameter name Type Description Since
0 shapeName Render String or Array format [p3dPath, nth, index, count, loop]:
1 animationName N/A String - obsolete parameter that was meant to play .rtm anims, will throw "Skeletal animation not supported for particles" rpt error if not empty
2 type Render String - "Billboard" or "SpaceObject"
3 timerPeriod Script Number - In seconds.
4 lifetime Physical Number - In seconds.
5 position Physical Array format Position or String object's selection
6 moveVelocity Physical Array format velocity
7 rotationVelocity Physical Number - rotations per second
8 weight Physical Number - weight of the particle (kg)
9 volume Physical Number - volume of the particle in m3
10 rubbing Physical Number - Determines how particles are affected by wind (include downwash by helicopters).
11 size Render Array of Numbers - particle size along its lifetime, in meter
12 color Render Array of Arrays format Color (RGBA)
13 animationPhase Render Array of Numbers - phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect.
14 randomDirectionPeriod Random Number - In seconds.
15 randomDirectionIntensity Random Number - How particles change its velocity every once in randomDirectionPeriod seconds, in meters?
16 onTimer Script String - path to the script to be executed on timer. Variable _this contains particle position in format PositionAGL.
private _particlePosition = _this;
17 beforeDestroy Script String - path to the script to be executed right before particle's destruction. Variable _this contains particle position in format PositionAGL.
private _particlePosition = _this;
18 object Physical Object - If this parameter isn't objNull, the particle source will be attached to the object. The source will stop to generate its particles when the distahce between the object and the source is further than Object View Distance.
19 angle Physical Number - (Optional, default 0) determines the particle's starting angle in radian. pi = 180°. Unknown
20 onSurface Physical Boolean - (Optional, default false) Bounce the particles when hit the surface if true. If circleRadius > 0, placing of particle on (water) surface on start of its existence. Circle radius is defined by command setParticleCircle. Arma 3 logo black.png0.74
21 bounceOnSurface Physical Number - (Optional, default -1) coef of bounce in collision with ground, 0..1 for collisions, -1 to disable collision. Should be used soberly as it has a significant impact on performance. Arma 3 logo black.png0.74
22 emissiveColor Render Array of Arrays format Color (RGBA) - (Optional, default [ ]?) Sets emissivity of the particle (RGB0). Works as lighting of particles, so must be combined with correctly set particle color. Values need to be higher than just 0-1 to have a real effect (f.e. 100 times the RGB color values). Last parameter has no meaning for now. Arma 3 logo black.png1.08
23 vectorDir Physical Array format vectorDir - (Optional) Sets the default direction for SpaceObject particles.
Array format [vectorDir, vectorUp] - (Optional) Sets the default vectorDir/vectorUp for SpaceObject particles.
Arma 3 logo black.png1.92
Arma 3 logo black.png2.12


Parameters

Global Parameters

ArmA particle texture

ShapeName - Name of the shape associated with the particle.

In ArmA, the ShapeName is defined as an array. This should be the particle shape name, followed by three integers.
Example: ["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 0]
  1. Anim Divisor (1 for a 1x1, 8 for a 8x8, etc)
  2. Anim Starting Row
  3. Number of Frames to Play (speed controlled by animation phase below)
In this shot of "\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", note the following:
The image used for this particle effect is 8X8 effect frames. This means you need to use 8 as your Anim Divisor. Overwise, the game will either draw too much of the image used, or too little. This is highly visible in most situations.
The Anim Starting Row picks the coresponding superimposed number in the image above. 0 picks the first smoke effect, 1 picks the second smoke effect, 2 picks the first fire effect, etc.
The setting for the Number of Number of Frames to Play should, in most cases, be the number of effects available to the animation. If you go over this (for example, selecting 9 in this 8X8 tile), it will start playing the animation frames of the next effect down. If there is nothing below to grab, it will draw a blank for that frame. If 1 is used, it will only play the first frame of the selected row.
If you want to find out of how many rows a datasource consists use ["...", 1, 0, 1] to see the full picture as a particle.
Arma2 particle texture

In Arma 2 (and Arma 2:OA), the method for determining how many frames to play has changed.

Example 1:

["\Ca\Data\ParticleEffects\Universal\Universal", 16, 10, 32, 1]
  1. Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)
  2. Anim Starting Row (starting a 0)
  3. Number of Frames to play (Starting with 1 and not 0)
  4. Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
Example 1 above (a fire burning) will start the animation in row 10, will play from frames 1 to 32, and will loop.


Also in Arma 2 and Arma 2, to achieve a single frame of animation that is not the first column of a row, use the third numerical value as a column selection instead of indicating how many frames to play.

Example 2:

["\Ca\Data\ParticleEffects\Universal\Universal", 16, 12, 9, 0]
  1. Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)
  2. Anim Starting Row (starting at 0)
  3. Column Selection (Starting with 1 and not 0)
  4. Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
Additional Step: You must also set the AnimationPhase value (described in render parameters) to a large number (such as 1000) if you only want to play a single frame. The reason for this is that the game engine does not only play a single frame, it actually begins at the first frame in the row and cycles to the desired frame. If a small AnimationPhase number is used then you can actualy see the animation cycle through the all the frames (1-9). A large number makes this imperceptible and only the desired frame appears to be displayed.
Arma 3 particle texture (Universal)
Example 2 above (exploding rock dust) will start the animation in row 12, will only play frame 9, and will not loop.


AnimationName - Has to be a String, but it is obsolete. Used to play .rtm anims, if not empty, it will throw "Skeletal animation not supported for particles" rpt error

Type - Type of particle (either "Billboard" or "SpaceObject").

TimerPeriod - The period of calling the "OnTimer" event (in sec).

LifeTime - Life time of the particle (in sec).

Physical Parameters

Position' - Either 3D coordinate (x, y, z) or name of the selection - in this case the Object property must be set.

MoveVelocity - 3D vector (x, y, z) which describes the velocity vector of the particle direction and speed in m/s.

RotationVelocity - Float number which determines number of rotations in one second.

Weight - Weight of the particle (kg).

Volume - Volume of the particle (m3).

Rubbing - Float number without dimension which determines the impact of the density of the environment on this particle. 0 - no impact (vacuum).

Angle - Float number which determines starting angle of the particle.

OnSurface - Boolean. Placing of particle on (water) surface on start of it is existence, default value is true, works only if circleRadius > 0. Circle radius is defined by command setParticleCircle. Works since Arma 3 logo black.png0.74.

BounceOnSurface - Coef of speed's loosing in collision with ground, 0-1 for collisions, -1 disable collision. Default value -1. Should be used soberly, it has significant impact on performance. Works since Arma 3 logo black.png0.74.

Arma 3 particle texture (Universal_02)

Render Parameters

All these values are set as arrays to show their development in time.

If you set the array [1, 2] as a size, then at the beginning the size of the particle will be 1 and at the end of the life time of the particle its size will be 2.

The rest of the values during the life time will be linearly interpolated.


Size - Size of the particle in time to render (m).

Color - Colour of the particle in time to render (RGBA).

EmissiveColor - Sets emissivity of the particle (RGB0). Works as lighting of particles, so must be combined with correctly set particle color. Last parameter has no meaning for now.

AnimationPhase - Phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect.

Randomness Parameters

RandomDirectionPeriod - Period of change of the velocity vector (s).

RandomDirectionIntensity - Each MoveVelocity component will be changed with random value from interval <0, RandomDirectionIntensity>.

OnTimer - Name of the script to run every period determined by TimerPeriod property.

Position of the particle is stored in "this" variable.

BeforeDestroy - Name of the script to run right before destroying the particle.

Position of the particle is stored in "this" variable.

Object - Object to bind this particle to.


Example

For several examples of the kind of effects that can be accomplished via particles, see ParticleTemplates.

Thunderbolt

Create a thunderbolt on logic named logic1:

private _pos = [position logic1 select 0, position logic1 select 1, 10]; drop ["blesk1", "", "Billboard", 0.01, 0.2, _pos, [0,0,0], 0, 1, 1, 0, [20 + random 20], [[1,1,1,1], [1,1,1,0.7]], [1, 0], 0, 0, "", "", ""];

Mass Grave Flies

// SCRIPT FOR GENERATING FLIES AROUND MASS GRAVE // FIXED PARAMS private _source = "#particlesource" createVehicleLocal getPos (_this select 0); _source setParticleParams [ /* Sprite */ ["\ca\characters2\OTHER\FLY.p3d", 1, 0, 1, 0], // File,Ntieth,Index,Count,Loop /* Animation */ "", /* Type */ "spaceObject", /* TimerPer */ 1, /* Lifetime */ 4, /* Position */ [0,0,0], /* MoveVelocity */ [0,0,0.5], /* Simulation */ 1, 1.30, 1, 0, // rotationVel, weight, volume, rubbing /* Scale */ [0.03, 0.03, 0.03, 0], /* Color */ [[1,1,1,1], [1,1,1,1]], /* AnimSpeed */ [1.5, 0.5], /* randDirPeriod */ 0.01, /* randDirIntensity */ 0.08, /* onTimerScript */ "", /* DestroyScript */ "", /* object */ _this, /* Angle */ 0, /* onSurface */ true, /* bounceOnSurface */ 0.5, /* emissiveColor */ [[0,0,0,0]] ]; // RANDOM / TOLERANCE PARAMS _source setParticleRandom [ /* LifeTime */ 2, /* Position */ [2,2,0.25], /* MoveVelocity */ [0,0,0], /* rotationVel */ 1, /* Scale */ 0.02, /* Color */ [0,0,0,0.1], /* randDirPeriod */ 0.01, /* randDirIntensity */ 0.03, /* Angle */ 10 ]; _source setDropInterval 0.003; private _soundSource = createSoundSource ["Sound_Flies", getPos (_this select 0), [], 0];


Tutorials