発生スクリプトの例

 

   

パーティクル フロー クイック ナビゲーション

説明:

次の例では、既定値の Birth_Script スクリプト (詳細コメント付き) を示します。

用途:

このスクリプトは、Birth_Script アクション内の既定値のスクリプトとして使用されます。

効果:

このスクリプトによって、きれいなパーティクル パターン(正弦カーブによって作成されたらせんなど)が生成されます。このスクリプトによる効果を確認するには、以下を実行します。

例:

--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--enable the Time channel
pCont.useAge = true--enable the Age channel
pCont.usePosition = true--enable the Position channel
pCont.useSpeed = true--enable the Speed channel
)
 
--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 Start Time as float. This converts the time to ticks.
t1 = pCont.getTimeStart() as float
--Get the End Time as float. This converts the time to ticks.
t2 = pCont.getTimeEnd() as float
 
--Clamp negative time values to 0
if (t1 < 0)then(t1 = 0)
 
--If the end time is less than 100 frames
--(100 frames * 160 ticks per frame in 30 fps NTSC)
if (t2 < 100*160) do
(
--then do a loop using the time values divided by 8
--this way a particle will be created every 8 ticks
for i in (t1/8+1) to (t2/8) do
(
--set the variable curTime to the actual time in ticks
curTime = 8*i as float
--give birth to a new particle
pCont.AddParticle()
--get the index of the last particle that was added
pCont.particleIndex = pCont.NumParticles()
--set the current time of the particle in frames
--(160 ticks in one frame at 30 fps NTSC animation)
pCont.particleTime = curTime/160
--Set the age of the particle to 0 - newborn!
pCont.particleAge = 0
--Define a radius variable based on the sine of the current time
sh = 2*sin(5*curTime)
--Define an angle variable based on the current time
ang = 0.2*curTime
--Set the particle position using the above variables
pCont.particlePosition = [sh*sin(ang), sh*cos(ang), 0]
--Define the speed using the same variables and falling down along Z
pCont.particleSpeed = [0.01*sin(ang), 0.01*cos(ang), -0.005]
)
)
)
 
--The Release handler is used to do cleanup work.
--Not used in this case.
on Release pCont do
(
)

関連事項