Difference between revisions of "Template:LSL Function/ParticleSystem/ru"
Line 78: | Line 78: | ||
{{#vardefine:caveats| | {{#vardefine:caveats| | ||
# При использовании системы частиц с ненулевым значением срока жизни эмиттера (PSYS_SRC_MAX_AGE) можно заметить, что система частиц иногда перезапускается самовольно, без вызова из скрипта. Это связано с глюком, который заставляет эмиттер "перезапускаться", когда какое-то свойство примитива обновляется или как-либо еще передаётся программе-просмотрщику (вьюверу). Для обхода этой ошибки вы можете воспользоваться [[timer|таймером]] или принудительным вызовом [[llSleep]], а потом, по прошествии нужного времени, отключить эмиттер. Пользователь Debbie Trilling опубликовал метод обхода здесь: http://forums-archive.secondlife.com/54/fa/260031/1.html#post1996465 | # При использовании системы частиц с ненулевым значением срока жизни эмиттера (PSYS_SRC_MAX_AGE) можно заметить, что система частиц иногда перезапускается самовольно, без вызова из скрипта. Это связано с глюком, который заставляет эмиттер "перезапускаться", когда какое-то свойство примитива обновляется или как-либо еще передаётся программе-просмотрщику (вьюверу). Для обхода этой ошибки вы можете воспользоваться [[timer|таймером]] или принудительным вызовом [[llSleep]], а потом, по прошествии нужного времени, отключить эмиттер. Пользователь Debbie Trilling опубликовал метод обхода здесь: http://forums-archive.secondlife.com/54/fa/260031/1.html#post1996465 | ||
# | # Вращение, запущенное посредством PSYS_SRC_OMEGA осуществляется относительно [[Viewer coordinate frames#Region|региональных]] координат, а не [[Viewer coordinate frames#Local|локальных]] координат примитива. | ||
# | # Когда эмиттер создан в примитиве, его угол поворота устанавливается на нулевое значение (ZERO_ROTATION). При использовании PSYS_SRC_OMEGA эмиттер поворачивается. Если вы измените значение вектора при PSYS_SRC_OMEGA, эмиттер не вернется к нулевому углу, а останется в том значении угла вращения, в котором он был при остановке/изменении. Это может привести к тому, что частицы в примитиве с повернутым эмиттером будут отображаться отлично от таковых в "свежем" примитиве со "свежим" эмиттером. | ||
# | # Частицы, движущиеся в сторону гуманоидного аватара, обозначенного при правиле PSYS_SRC_TARGET_KEY (при условии наличия флага PSYS_PART_TARGET_POS_MASK), будут попадать в центр его граничной рамки, который, к сожалению, находится в области паха. Если вы хотите, чтобы они попадали в другую часть тела аватара, вам придется расположить целевой примитив в требуемом месте назначения и использовать ключ этого примитива при правиле PSYS_SRC_TARGET_KEY. | ||
# | # Программа-просмотрщик (вьювер), для улучшения своей работы, выбрасывает маленькие объекты из поля зрения на некотором расстоянии. Если примитив с эмиттером достаточно мал, чтобы быть вырезанным из поля зрения таким образом, испускаемые им частицы также не будут отображаться. | ||
{{#var:caveats}}}} | {{#var:caveats}}}} | ||
}}<noinclude> | }}<noinclude> |
Revision as of 08:14, 27 July 2012
spec
Определяет систему испускания частиц, которая устанавливает состояние испускателя (эмиттера) внутри примитива, в котором содержится скрипт. Другие скрипты, находящиеся в данном примитиве и вызывающие эту функцию, будут изменять состояние этого эмиттера. По сути, система испускания частиц, определённая данной функцией, является свойством примитива, как, например, цвет, форма, размеры, и т.д. . В каждом примитиве может быть только один эмиттер, расположенный в геометрическом центре и выровненный вдоль локальной оси Z в положительном направлении.
Это одна из нескольких функций, которые изменяют состояние эмиттера в примитиве; так, если вы хотите изменить состояние эмиттера (поменять систему частиц или вовсе выключить эмиттер), достаточно вызвать эту функцию с параметрами новой системы. Задание пустого списка правил ( {{{1}}}
; ) выключит эмиттер.
По существу, частицы являются двумерными спрайтами, они всегда направлены в сторону камеры.
Значения правил и данных описаны ниже.
caveats
- При использовании системы частиц с ненулевым значением срока жизни эмиттера (PSYS_SRC_MAX_AGE) можно заметить, что система частиц иногда перезапускается самовольно, без вызова из скрипта. Это связано с глюком, который заставляет эмиттер "перезапускаться", когда какое-то свойство примитива обновляется или как-либо еще передаётся программе-просмотрщику (вьюверу). Для обхода этой ошибки вы можете воспользоваться таймером или принудительным вызовом llSleep, а потом, по прошествии нужного времени, отключить эмиттер. Пользователь Debbie Trilling опубликовал метод обхода здесь: http://forums-archive.secondlife.com/54/fa/260031/1.html#post1996465
- Вращение, запущенное посредством PSYS_SRC_OMEGA осуществляется относительно региональных координат, а не локальных координат примитива.
- Когда эмиттер создан в примитиве, его угол поворота устанавливается на нулевое значение (ZERO_ROTATION). При использовании PSYS_SRC_OMEGA эмиттер поворачивается. Если вы измените значение вектора при PSYS_SRC_OMEGA, эмиттер не вернется к нулевому углу, а останется в том значении угла вращения, в котором он был при остановке/изменении. Это может привести к тому, что частицы в примитиве с повернутым эмиттером будут отображаться отлично от таковых в "свежем" примитиве со "свежим" эмиттером.
- Частицы, движущиеся в сторону гуманоидного аватара, обозначенного при правиле PSYS_SRC_TARGET_KEY (при условии наличия флага PSYS_PART_TARGET_POS_MASK), будут попадать в центр его граничной рамки, который, к сожалению, находится в области паха. Если вы хотите, чтобы они попадали в другую часть тела аватара, вам придется расположить целевой примитив в требуемом месте назначения и использовать ключ этого примитива при правиле PSYS_SRC_TARGET_KEY.
- Программа-просмотрщик (вьювер), для улучшения своей работы, выбрасывает маленькие объекты из поля зрения на некотором расстоянии. Если примитив с эмиттером достаточно мал, чтобы быть вырезанным из поля зрения таким образом, испускаемые им частицы также не будут отображаться.
notes
- The default particle count for the client is normally set at 4096. That is the max particle count the client will render for ALL active particle systems within view range. Good particle system design is key to avoid "spamming" everyone with your particles, and starving out other people's particle systems. As such, if you are experiencing trouble getting your particle emitter to emit as many particles as you like, it may be the victim of particle starvation. Client/viewer lag (low frame rates) can also cause this issue, as particles are a rather low priority for rendering. The best solution for this is to move to a less laggy environment relatively free of other particle systems when designing and testing your own.
- Once particles are emitted, their direction of motion can only be affected by PSYS_SRC_ACCEL, the PSYS_PART_TARGET_POS_MASK flag, or the PSYS_PART_FOLLOW_SRC_MASK flag. As such, there is no good way to create the "swirling vortex" effect (like the one used in the viewer to indicate an object talking, begin derezzed, or when an avatar leaves the sim/grid). The effect can be created with a moving particle source (E.G. An orbiting script.)
helpers
Useful functions for storing/retrieving color and alpha values to/from integers:
<lsl>integer ColorAlphatoRGBA(vector color, float alpha) {
return (((integer)(alpha * 255.0) & 0xFF) << 24)
constants_nb
Rule / Value Constant | Rule Parameter | Description | Value | |
System Behavior | ||||
PSYS_PART_FLAGS | integer flags | Various flags controlling the behavior of the particle system. The value may be specified as an integer in decimal or hex format, or by ORing together (using the | operator) one or more of the following flag constants: | 0 | |
V a l u e s |
PSYS_PART_BOUNCE_MASK | When set, specifies particles will bounce off a plane at the region Z height of the emitter. On "bounce", each particle reverses velocity and angle. This only works for particles above the plane falling down on it. | 0x004 | |
PSYS_PART_EMISSIVE_MASK | When set, particles are full-bright and are unaffected by global lighting (sunlight). Otherwise, particles will be lit depending on the current global lighting conditions. Note that point lights do illuminate non-emissive particles. | 0x100 | ||
PSYS_PART_FOLLOW_SRC_MASK | When set, particles move relative to the position of the emitter. Otherwise, particle position and movement are unaffected by the position/movement of the emitter. This flag disables the PSYS_SRC_BURST_RADIUS rule. | 0x010 | ||
PSYS_PART_FOLLOW_VELOCITY_MASK | When set, particles rotate to orient their "top" towards the direction of movement or emission. Otherwise, particles are oriented vertically as their textures would appear (top of texture at top, left at left). | 0x020 | ||
PSYS_PART_INTERP_COLOR_MASK | When set, particle color and alpha transition from their START settings to their END settings during the particle's lifetime. The transition is a smooth interpolation. | 0x001 | ||
PSYS_PART_INTERP_SCALE_MASK | When set, particle size/scale transitions from its START setting to its END setting during the particle's lifetime. | 0x002 | ||
PSYS_PART_TARGET_LINEAR_MASK | When set, emitted particles move in a straight line towards the target specified by the PSYS_SRC_TARGET_KEY rule. In this mode, PSYS_SRC_ACCEL, PSYS_SRC_BURST_RADIUS, and possibly other rules are ignored. | 0x080 | ||
PSYS_PART_TARGET_POS_MASK | When set, emitted particles change course during their lifetime, attempting to move towards the target specified by the PSYS_SRC_TARGET_KEY rule by the time they expire. Note that if no target is specified, the target moves out of range, or an invalid target is specified, the particles target the prim itself. | 0x040 | ||
PSYS_PART_WIND_MASK | When set, particle movement is affected by the wind. It is applied as a secondary force on the particles. | 0x008 | ||
(unimplemented) mask but in the enum | 0x200 | |||
Used by the viewer to keep HUD and World particle sources separate. | 0x40000000 | |||
Removes particles, not compatible with any other PSYS_PART_*_MASK | 0x80000000 | |||
(unimplemented & commented out) Presumed to be used to apply random acceleration to the particles. | - | |||
(unimplemented & commented out) Presumed to be used to specify random velocity for the particles upon emission. | - | |||
(unimplemented & commented out) Presumed to be used for implementing "trails" via emitting more particles at shorter bursts. | - | |||
System Presentation | ||||
PSYS_SRC_PATTERN | integer pattern | Specifies the general emission pattern. | 9 | |
V a l u e s |
PSYS_SRC_PATTERN_EXPLODE | Sprays particles outwards in a spherical area. The Initial velocity of each particle is determined by PSYS_SRC_BURST_SPEED_MIN and PSYS_SRC_BURST_SPEED_MAX. The EXPLODE pattern ignores the ANGLE parameters. | 0x02 | |
PSYS_SRC_PATTERN_ANGLE_CONE | Sprays particles outwards in a spherical, sub-spherical, conical or ring shaped area, as defined by the ANGLE parameters PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END. The ANGLE_CONE pattern can be used to imitate the EXPLODE pattern by explicitly setting PSYS_SRC_ANGLE_BEGIN to 0.00000 and PSYS_SRC_ANGLE_END to 3.14159 (or PI) (or vice versa). | 0x08 | ||
PSYS_SRC_PATTERN_ANGLE | Sprays particles outward in a flat circular, semi-circular, arc or ray shaped areas, as defined by PSYS_SRC_ANGLE_BEGIN and PSYS_SRC_ANGLE_END. The circular pattern radiates outwards around the prim's local X axis line. | 0x04 | ||
PSYS_SRC_PATTERN_DROP | Creates particles with no initial velocity. The DROP pattern will overrides any values given for PSYS_SRC_BURST_RADIUS, PSYS_SRC_BURST_SPEED_MIN, and PSYS_SRC_BURST_SPEED_MAX, setting each to 0.00000. (All patterns will behave like the DROP pattern, if RADIUS, SPEED_MIN and SPEED_MAX are explicitly set to 0.0000.) | 0x01 | ||
PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY | (incomplete implementation) acts the same as the PSYS_SRC_PATTERN_DROP pattern, it is believed that the original intention for this pattern was to invert the effect of the ANGLE parameters, making them delineate an area where particles were NOT to be sprayed. (effectively the inverse or opposite of the behavior of the ANGLE_CONE pattern). | 0x10 | ||
PSYS_SRC_BURST_RADIUS | float radius | Specifies the distance from the emitter where particles will be created. This rule is ignored when the PSYS_PART_FOLLOW_SRC_MASK flag is set. A test in http://forums-archive.secondlife.com/327/f5/226722/1.html indicates that the maximum value is 50.00 | 16 | |
PSYS_SRC_ANGLE_BEGIN | float angle_begin | Specifies a half angle, in radians, of a circular or spherical "dimple" or conic section (starting from the emitter facing) within which particles will NOT be emitted. Valid values are the same as for PSYS_SRC_ANGLE_END, though the effects are reversed accordingly. If the pattern is PSYS_SRC_PATTERN_ANGLE, the presentation is a 2D flat circular section. If PSYS_SRC_PATTERN_ANGLE_CONE or PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY is used, the presentation is a 3D spherical section. Note that the value of this parameter and PSYS_SRC_ANGLE_END are internally re-ordered such that this parameter gets the smaller of the two values. | 22 | |
PSYS_SRC_ANGLE_END | float angle_end | Specifies a half angle, in radians, of a circular or spherical "dimple" or conic section (starting from the emitter facing) within which particles will NOT be emitted. Valid values are 0.0, which will result in particles being emitted in a straight line in the direction of the emitter facing, to PI, which will result in particles being emitted in a full circular or spherical arc around the emitter, not including the "dimple" or conic section defined by PSYS_SRC_ANGLE_BEGIN. If the pattern is PSYS_SRC_PATTERN_ANGLE, the presentation is a 2D flat circular section. If PSYS_SRC_PATTERN_ANGLE_CONE or PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY is used, the presentation is a 3D spherical section. Note that the value of this parameter and PSYS_SRC_ANGLE_BEGIN are internally re-ordered such that this parameter gets the larger of the two values. | 23 | |
float angle_inner | DEPRECATED: Use PSYS_SRC_ANGLE_BEGIN instead. Works similar to its replacement rule, except the edge of the section is aligned with the emitter facing, rather than its center. | 10 | ||
float angle_outer | DEPRECATED: Use PSYS_SRC_ANGLE_END instead. Works similar to its replacement rule, except the edge of the section is aligned with the emitter facing, rather than the section's center. | 11 | ||
PSYS_SRC_TARGET_KEY | key target | Specifies the key of a target object, prim, or agent towards which the particles will change course and move. They will attempt to end up at the geometric center of the target at the end of their lifetime. Requires the PSYS_PART_TARGET_POS_MASK flag be set. caveat 4 | 20 | |
Particle Appearance | ||||
PSYS_PART_START_COLOR | vector color_start | A vector specifying the color of the particles upon emission. | 1 | |
PSYS_PART_END_COLOR | vector color_end | A vector specifying the color the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_COLOR_MASK flag is set. | 3 | |
PSYS_PART_START_ALPHA | float alpha_start | Specifies the alpha of the particles upon emission. Valid values are in the range 0.0 to 1.0. Lower values are more transparent; higher ones are more opaque. | 2 | |
PSYS_PART_END_ALPHA | float alpha_end | Specifies the alpha the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_COLOR_MASK flag is set. Valid values are the same as PSYS_PART_START_ALPHA. | 4 | |
PSYS_PART_START_SCALE | vector scale_start | Specifies the scale or size of the particles upon emission. Valid values for each direction are 0.03125 to 4.0, in meters. The actual particle size is always a multiple of 0.03125. Smaller changes don't have any effect. Since particles are essentially 2D sprites, the Z component of the vector is ignored and can be set to 0.0. | 5 | |
PSYS_PART_END_SCALE | vector scale_end | Specifies the scale or size the particles transition to during their lifetime. Only used if the PSYS_PART_INTERP_SCALE_MASK flag is set. Valid values are the same as PSYS_PART_START_SCALE. | 6 | |
PSYS_SRC_TEXTURE | string texture | Specifies the name of a texture in the emitter prim's inventory to use for each particle. Alternatively, you may specify an asset key UUID for a texture. If using llLinkParticleSystem and texture is not a UUID, texture must be in the emitter prim (not necessarily with the script). | 12 | |
Particle Flow | ||||
PSYS_SRC_MAX_AGE | float duration_system | Specifies the length of time, in seconds, that the emitter will operate upon coming into view range (if the particle system is already set) or upon execution of this function (if already in view range). Upon expiration, no more particles will be emitted, except as specified above. Zero will give the particle system an infinite duration. (caveat 1) | 19 | |
PSYS_PART_MAX_AGE | float duration_particle | Specifies the lifetime of each particle emitted, in seconds. Maximum is 30.0 seconds. During this time, the particle will appear, change appearance and move according to the parameters specified in the other sections, and then disappear. | 7 | |
PSYS_SRC_BURST_RATE | float burst_sleep | Specifies the time interval, in seconds, between "bursts" of particles being emitted. Specifying a value of 0.0 will cause the emission of particles as fast as the viewer can do so. | 13 | |
PSYS_SRC_BURST_PART_COUNT | integer burst_particle_count | Specifies the number of particles emitted in each "burst". | 15 | |
Particle Motion | ||||
PSYS_SRC_ACCEL | vector acceleration | Specifies a directional acceleration vector applied to each particle as it is emitted, in meters per second. Valid values are 0.0 to 100.0 for each direction both positive and negative, as region coordinates. | 8 | |
PSYS_SRC_OMEGA | vector omega | Specifies the rotational spin of the emitter in radians per second along each axis. This "unsticks" the emitter facing from the prim's positive Z axis and is noticeable in directional presentations. Prim spin (via llTargetOmega) has no effect on emitter spin. (caveat 2 and caveat 3) | 21 | |
PSYS_SRC_BURST_SPEED_MIN | float speed_min | Specifies the minimum value of a random range of values which is selected for each particle in a burst as its initial speed upon emission, in meters per second. Note that the value of this parameter and PSYS_SRC_BURST_SPEED_MAX are internally re-ordered such that this parameter gets the smaller of the two values. | 17 | |
PSYS_SRC_BURST_SPEED_MAX | float speed_max | Specifies the maximum value of a random range of values which is selected for each particle in a burst as its initial speed upon emission, in meters per second. Note that the value of this parameter and PSYS_SRC_BURST_SPEED_MIN are internally re-ordered such that this parameter gets the larger of the two values. | 18 | |
LL_PART_* constants are only found in viewer - indra/llmessage/llpartdata.h , those flags in red have been commented out. |
deepnotes
Missing 14
There is a missing constant which would have the value 14, the underlying enumeration LLPSScriptFlags has that as LLPS_SRC_BURST_DURATION, the value is used nowhere else in the client source. This isn't surprising considering that the burst duration is dependent on the values of PSYS_SRC_BURST_PART_COUNT and PSYS_SRC_BURST_RATE.
Signature
integer PSYS_PART_FLAGS = 0; integer PSYS_PART_BOUNCE_MASK = 0x004; integer PSYS_PART_EMISSIVE_MASK = 0x100; integer PSYS_PART_FOLLOW_SRC_MASK = 0x010; integer PSYS_PART_FOLLOW_VELOCITY_MASK = 0x020; integer PSYS_PART_INTERP_COLOR_MASK = 0x001; integer PSYS_PART_INTERP_SCALE_MASK = 0x002; integer PSYS_PART_TARGET_LINEAR_MASK = 0x080; integer PSYS_PART_TARGET_POS_MASK = 0x040; integer PSYS_PART_WIND_MASK = 0x008; integer PSYS_SRC_PATTERN = 9; integer PSYS_SRC_PATTERN_EXPLODE = 0x02; integer PSYS_SRC_PATTERN_ANGLE_CONE = 0x08; integer PSYS_SRC_PATTERN_ANGLE = 0x04; integer PSYS_SRC_PATTERN_DROP = 0x01; integer PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 0x10; integer PSYS_SRC_BURST_RADIUS = 16; integer PSYS_SRC_ANGLE_BEGIN = 22; integer PSYS_SRC_ANGLE_END = 23; integer PSYS_SRC_INNERANGLE = 10;//deprecated integer PSYS_SRC_OUTERANGLE = 11;//deprecated integer PSYS_SRC_TARGET_KEY = 20; integer PSYS_PART_START_COLOR = 1; integer PSYS_PART_END_COLOR = 3; integer PSYS_PART_START_ALPHA = 2; integer PSYS_PART_END_ALPHA = 4; integer PSYS_PART_START_SCALE = 5; integer PSYS_PART_END_SCALE = 6; integer PSYS_SRC_TEXTURE = 12; integer PSYS_SRC_MAX_AGE = 19; integer PSYS_PART_MAX_AGE = 7; integer PSYS_SRC_BURST_RATE = 13; integer PSYS_SRC_BURST_PART_COUNT = 15; integer PSYS_SRC_ACCEL = 8; integer PSYS_SRC_OMEGA = 21; integer PSYS_SRC_BURST_SPEED_MIN = 17; integer PSYS_SRC_BURST_SPEED_MAX = 18;