Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Particle System Template

Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
07-28-2006 04:02
This is a nice and easy to use Particle system template.

CODE

// Particle System Template.
// Derived from Jopsy's Particle System Template, which is derived from Ama Omega's Particle script.


// Appearance - how each particle looks.
// Start & End refers to the birth & death of each particle.

string Texture = "6c9f8c0c-3728-1b9c-af59-402496b79491";

integer Interpolate_Scale = TRUE; // Turns on or off interpolating scale.
vector Start_Scale = < 0.04, 0.2, 0.0 >; // Particle height & width, from 0.04 to 4.0.
vector End_Scale = < 0.04, 4.0, 0.0 >; // No depth; Z is ignored.

integer Interpolate_Colour = TRUE; // Turns on or off interpolating colour.
vector Start_Colour = < 1.0, 0.0, 0.0 >; // Colour vector: <R, G, B>.
vector End_Colour = < 0.0, 0.0, 0.0 >; // 1.0 = Full colour; 0.0 = Zero colour.

float Start_Alpha = 1.0; // Sets transparency, from invisible = 0.0 to opaque = 1.0.
float End_Alpha = 0.0;

integer Emissive = TRUE;


// Flow - these settings affect how many, how quickly and for how long particles are present.

float Age = 1.0; // How many seconds each particle lives for: 0.1 to 60.0 seconds.
float Rate = 0.01; // Seconds between particle bursts, 0.0 to 60.
integer Count = 1; // Number of particles per burst, 1 to 4096.
float Life = 0.0; // Number of seconds to wait before shutting off, 0.1 to 60. 0.0 never stops.


// Placement - where new particles are created and what direction are they facing?

// Pattern must be set to one of the following:
// PSYS_SRC_PATTERN_EXPLODE // Sends particles in all directions.
// PSYS_SRC_PATTERN_DROP // Ignores Speed.
// PSYS_SRC_PATTERN_ANGLE_CONE // Uses Angle values to make rings & cones.
// PSYS_SRC_PATTERN_ANGLE // Uses ___ to make flat wedges.

integer Pattern = PSYS_SRC_PATTERN_ANGLE;

float Radius = 0.0; // Distance between emitter and each new particle, 0.0 to 64?

float Begin_Angle = 0.0; // 0 - PI (3.14159).
float End_Angle = 0.0; // 0 - PI (3.14159).

vector Omega = < 0.0, 0.0, 0.0 >; // How much to rotate the emitter around the X, Y & Z axes after each burst.


// Movement - moving the particles after they're created.

integer Follow_Source = TRUE; // Moves particles when emitter moves. Disables Radius.
integer Follow_Velocity = TRUE; // Particles rotate towards their heading.
integer Wind = FALSE; // Sim's wind will push particles.
integer Bounce = FALSE; // Make particles bounce above the Z altitude of emitter.

float Minimum_Speed = 4.0; // 0.01 to ?, slowest speed of new particles.
float Maximum_Speed = 4.0; // 0.01 to ?, fastest speed of new particles.
// Speed is ignore by PSYS_SRC_PATTERN_DROP Pattern.

vector Acceleration = < 0.00, 0.00, 0.00 >; // A continous force pushed on particles. Use small settings for long lived particles.

integer Target = FALSE; // Turns on or off targeting of particles.
key Target_Key = NULL_KEY; // Not sure.
// key Target_Key = llGetKey (); // Particles return to the emitter.
// key Target_Key = llGetOwner (); // Particles target the owner.
// You can have another object llSay (999, llGetKey ());
// and grab the key for that object by using the listen () event handler.

Particle_System ()
{
list Parameters =
[
PSYS_PART_FLAGS,
(
(Emissive * PSYS_PART_EMISSIVE_MASK) |
(Bounce * PSYS_PART_BOUNCE_MASK) |
(Interpolate_Colour * PSYS_PART_INTERP_COLOR_MASK) |
(Interpolate_Scale * PSYS_PART_INTERP_SCALE_MASK) |
(Wind * PSYS_PART_WIND_MASK) |
(Follow_Source * PSYS_PART_FOLLOW_SRC_MASK) |
(Follow_Velocity * PSYS_PART_FOLLOW_VELOCITY_MASK) |
(Target * PSYS_PART_TARGET_POS_MASK)
),
PSYS_PART_START_COLOR, Start_Colour,
PSYS_PART_END_COLOR, End_Colour,
PSYS_PART_START_ALPHA, Start_Alpha,
PSYS_PART_END_ALPHA, End_Alpha,
PSYS_PART_START_SCALE, Start_Scale,
PSYS_PART_END_SCALE, End_Scale,
PSYS_SRC_PATTERN, Pattern,
PSYS_SRC_BURST_PART_COUNT, Count,
PSYS_SRC_BURST_RATE, Rate,
PSYS_PART_MAX_AGE, Age,
PSYS_SRC_ACCEL, Acceleration,
PSYS_SRC_BURST_RADIUS, Radius,
PSYS_SRC_BURST_SPEED_MIN, Minimum_Speed,
PSYS_SRC_BURST_SPEED_MAX, Maximum_Speed,
PSYS_SRC_TARGET_KEY, Target_Key,
PSYS_SRC_ANGLE_BEGIN, Begin_Angle,
PSYS_SRC_ANGLE_END, End_Angle,
PSYS_SRC_OMEGA, Omega,
PSYS_SRC_MAX_AGE, Life,
PSYS_SRC_TEXTURE, Texture
];
llParticleSystem (Parameters); // Turns on the particle system.
integer Particles = (integer) (Age * (float) Count / Rate);
if (4096 < Particles)
{
llOwnerSay ("Emitter creates too many particles!");
}
llOwnerSay ("Emitter produces " + (string) Particles + " concurrent particles.");
}

default
{
state_entry ()
{
Particle_System ();
}
touch_end (integer i)
{
Particle_System ();
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
07-29-2006 08:49
/54/bd/125259/1.html
_____________________
i've got nothing. ;)