--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
(
pCont.useTime = true
pCont.usePosition = true
)
--The Init hander is called on initialization.
--In this case, it is used to define the offset parameters
on Init pContdo
(
--Data paramters definition
struct paramsStruct (cond_less, axis, testpos, offset)
global paramsData = paramsStruct()
--true means less than, false means greater then
paramsData_offset.cond_less = true
--Axis option: x=1, y=2, z=3
paramsData_offset.axis = 3
--When set to true, the offset test is relative
--When set to false, the offset test is absolute.
paramsData_offset.offset = true
--Set the offset value to test for
paramsData_offset.testpos = -100
-- collects inital pos of each particle for offset test
global pos_init_array =#()
)
--In the Proceed handler, the actual testing is performed
on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
-- get ID of active particle
id = pCont.getParticleID pCont.particleIndex
if paramsData.cond_less == true then
(
if paramsData.offset == true then
(
-- collect initial pos for new born particle
if pCont.particleNew == true then
append pos_init_array pCont.particlePosition[paramsData.axis]
pos_id = pCont.GetParticlePositionByID id
if pos_id[paramsData.axis] < (pos_init_array[id] +paramsData.testpos) then
testSatisfied = true
)
else
(
if pCont.particlePosition[paramsData.axis] < paramsData.testpos then
testSatisfied = true
)
)
else
(
if paramsData.offset == true then
(
-- collect initial pos for new born particle
ifpCont.particleNew == truethen
append pos_init_array pCont.particlePosition[paramsData.axis]
pos_id = pCont.GetParticlePositionByID id
ifpos_id[paramsData.axis] > (pos_init_array[id] + paramsData.testpos)then
testSatisfied = true
)
else
(
ifpCont.particlePosition[paramsData.axis] > paramsData.testposthen
testSatisfied = true
)
)
iftestSatisfied == truethen
(
pCont.particleTestStatus = true
pCont.particleTestTime = pCont.particleTime
)
)
)
onRelease pContdo
(
)
|