説明:
次のサンプル スクリプトは、Script Test の既定のスクリプトです。球状のボリュームに対してパーティクルをテストする方法を示します。
用途:
このスクリプトは、Script_Test アクション内で使用する必要があります。
効果:
スクリプトは、すべてのパーティクルの位置を半径 20 と比較し、パーティクルが半径内にある場合はパーティクルのテスト状態を true
に設定します。
上記の設定では、球を通り抜けるパーティクルが次のイベントに送信され、そこでカラー変更が行われます。
例:
--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 handler 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 ( )