Particle

Return to Introduction  Previous page  Next page

A particle is a very basic object that can be used in particle systems.

 

Properties

 

pos

Current position of the particle.

posVelocity

Position velocity of the particle - the amount the position should be adjusted by every second.

visibleDir

A Vector used with visibleFOV to determine a direction from which the particle must be viewed from to be visible.

visibleFOV

A floating point value that defaults to zero (always visible).  If greater than zero, this determines the angle of visibility about the Vector visibleDir in degrees (360 degrees is visible all around, 180 degrees is a hemisphere, etc).

visible

Simple boolean property that defaults to true.  Even if this is true, visibleFOV could make the particle invisible.

maxDistance

The furthest the camera can be away from the particle to still see it.

scaleX

Screen space X scaling (float).

scaleY

Screen space Y scaling (float).

opacity

Current opacity between 0 and 1 (float).

 

Methods

 

destroy()

Call this method to destroy the particle immediately.

attach(objid,subgroupid,attachpos,attachrot)

Attaches the pos/rot/scale of this particle to an object (with optional subgroup - set to an empty string to be the top level). The optional booleans attachpos/attachrot define which properties from the target are used (defaults to true).

 

Examples

 

// Simple particle creation example

// This code should be attached to a moving object, and 'particle_1' should be defined in the 'Particles' window.

 

var period=0.1; // create a particle every 0.1 of a second

 

function onUpdate()

{

       if (object.timer>period)

       {

               object.timer-=period;

               var p=new Particle("particle_1");  // create a new Particle object based on the 'particle_1' definition.

               p.pos=object.pos;      // set the particle's position to be the same as this object's.

               p.posVelocity=new Vector(0,-10,0);  // the particle will fly downwards as it fades away.

       }

}

 

See Also

 

Script Reference



Copyright ©2004 Worldweaver Ltd. DX Studio Home