説明:
次の例では、詳細コメント付きで既定の更新したステップ毎スクリプトを示しています。
用途:
既定値の更新したステップ毎スクリプトとして PF_Source によって使用されます。
効果:
このスクリプトによってパーティクルの速度と方向が修正され、パーティクルがらせんのパスを追跡するようになります。
例:
--Get the current particle system executing the script pf_node_current = particleFlow.scriptRunner() --In case the current particle system is a valid node if (pf_node_current != undefined) then ( --Get the total number of particles count = pf_node_current.NumParticles() --Loop from 1 to the number of 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: pf_node_current.particleIndex = i --Get the age of the particle, multiply by 5 and use as angle --to define the particle speed --Decreasing the constant 5 will slow down the rotation --Increasing the constant will speed up the rotation age = 5*pf_node_current.particleAge --Calculate the speed of the particle using the --function of the circle. --Info: In general, a circle can be drawn using an Angle --going from 0 to 2*Pi and the following functions for X and Y: --X = CenterX+Radius*Cos(Angle) --Y = CenterY+Radius*Sin(Angle) --In our case, CenterX and CenterY are 0, Radius is 0.05 units, --and Angle is based on the Age of the particles (see above). --Changing the constant 0.05 will change the radius of the path. --Changing the -0.05 (Z speed) will change the height of the spiral. pf_node_current.particleSpeed = [0.05*cos(age), 0.05*sin(age), -0.05] )--end i loop )--end if