Script Test Example

Description:

The following sample script is the default script of the Script Test. It shows how to test particles against a spherical volume.

Can Be Used With:

This script should be used in a Script_Test action.

pview_scriptTest.gif

Effect:

The script goes through all particles, compares the particle position with a radius of 20 and sets the particle’s test status to true when the particle is inside the radius.

In the above setup, the particles that pass through the sphere are sent to the next event where they change their color:

pview_scriptTest_viewport.gif

Sample File:

[3dsmax5]\scenes\particle_flow\maxscript\ScriptTestDefaultExample.max

Example:

--The ChannelsUsed handler defines the channels

--to be made available to the script.

--For the list of all channels, see

--Interface: MaxscriptParticleContainer

--The parameter pCont passed to the handler

--contains the Particle Container the script is applied to

on ChannelsUsed pCont do

(

--Enable the Time channel:

pCont.useTime = true

--Enable the Position channel:

pCont.usePosition = true

)

 

--The Init hander is called on initialization.

--It is not used in this case.

on Init pCont do

(

)

 

--The Proceed handler contains the main script

--applied to the Particles.

--The parameter pCont passed to the handler

--contains the Particle Container the script is applied to:

on Proceed pCont do

(

--get the total number of particles

count = pCont.NumParticles()

--loop through all particles

for i in 1 to count do

(

--Set the particle index in the container to the current i value.

--This makes the i-th particle in the container the current one

pCont.particleIndex = i

-- all particles inside a sphere with radius 20 satisfy the test

if length(pCont.particlePosition) < 20 then

(

--set the Test Status of the particle to True

pCont.particleTestStatus = true

--set the Test Time of the particle to the current Particle Time

pCont.particleTestTime = pCont.particleTime

)

)--end i loop

)

 

--The Release handler is used to do cleanup work.

--Not used in this case.

on Release pCont do

(

)

See also

Interface: MaxscriptParticleContainer

Script_Test : Helper

Using MAXScript in Script Actions

Particle Flow Sample Scripts