説明:
独自の機能をシミュレートする Script オペレータ の例を、Speed オペレータ を作成して示します。この方法で複数の標準オペレータを作成し、Init ブロックにそれらのプロパティを設定し、引き続き Proceed ブロックで使用することができます。
用途:
Script_Operator オペレータで使用する必要があります。
効果:
基本的には、Speed オペレータをラップしたスクリプトです。スクリプト オペレータは、その内部にカプセル化された Speed オペレータと同様の機能を持ちます。これを開始点にしてスクリプトを拡張し、既存のオペレータにスクリプト化された機能を追加することができます。
例:
--The ChannelsUsed handler defines the channels --to be made available to the script. on ChannelsUsed pCont do ( -- No channels specified because the script doesn't make direct -- access to particle data ) --The Init handler is called on initialization. --It is used to get the Speed action or create a new one --if there is not an existing one on Init pCont do ( --Get an existing Speed Action by its unique name. bb = $Speed74b93a88 --If the unique action does not exist, create one and give it --the unique name. If you are reusing the code in multiple --Script Operators, change the name to have a unique ID! if (bb == undefined) then ( ParticleFlow.BeginEdit() bb = Speed() bb.name ="Speed74b93a88" bb.speed = 100 ParticleFlow.EndEdit() ) initActions = pCont.getInitActions() --Call the Init method in the Speed Action and pass --the Particle container, Particle System object and node --and the init action objects and nodes from the Scripted Operator. bb.Init (pCont.getParticleContainer()) (pCont.getParticleSystem()) (pCont.getParticleSystemNode()) (pCont.getInitActions()) (pCont.getInitActionNodes()) ) --In the Proceed handler, we can call the .Proceed method --of the Operator Interface and pass the container, --particle system object and node, and --the Init Action objects and nodes --This means that the external Speed action will proceed whenever --the Script_Operator does. on Proceed pCont do ( t_start = pCont.GetTimeStart() as time t_end = pCont.GetTimeEnd() as time bb = $Speed74b93a88 if (bb != undefined) then ( bb.Proceed (pCont.getParticleContainer()) t_start &t_end (pCont.getParticleSystem()) (pCont.getParticleSystemNode()) bb (pCont.GetIntegrator()) ) pCont.SetTimeEnd t_end ) --In the Release hander of the Script_Operator, --call the.Release method and pass the container of the --Script_Operator. on Release pCont do ( bb = $Speed74b93a88 if (bb != undefined) then bb.Release(pCont.getParticleContainer()) )