particleVector サンプル スクリプト
説明:
次のサンプル スクリプトは、particleVector チャネルにベクター値を割り当てます。
用途:
Script_Operator内で使用して、Find_Target テストのターゲット ポイントの位置をコントロールできます。
効果:
シーン ジオメトリ オブジェクトの最初の頂点の位置を取得し、ランダム オフセットを追加して、すべてのパーティクルの particleVector チャネルに割り当てます。その結果、Find_Target
が particleVector チャネルを読み取り、すべてのパーティクルをチャネル内の頂点に設定されます。このため、すべてのパーティクルが頂点に向かうようになります。
例:
|
--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 Vector channel:
pCont.useVector = true
)
--The Init handler is called on initialization.
--It is not used in this case.
on Init pCont do
(
--Define a global variable with unique name and store the
--scene object which also has a unique name in it
global obj_19680217 = $Sphere_19680217
--If the scene object does not exist, create a sphere,
--give it the unique name and assign to the global variable
if obj_19680217 == undefined then
obj_19680217 = Sphere name:"Sphere_19680217"
)
--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 current number of particles
count = pCont.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
pCont.particleIndex = i
--Get the position of the first vertex of the scene object.
vpos = (getVert obj_19680217.mesh 1)
--Add a random variation between -1 and +1 to all 3 axes
vpos += random [-1,-1,-1] [1,1,1]
--Set the particleVector channel value to the calculated value
pCont.particleVector = vpos
)--end i loop
)--end Proceed
--The Release handler is used to do cleanup work.
--Not used in this case.
on Release pCont do
(
)
|