在场景中创建 PF Source 节点时,我可以在 maxscript 中选择此系统并使用 for 循环和 pf.particleIndex 遍历所有粒子
但是,当我使用 maxscript 遍历场景中的几何体并为每个对象生成 PF 源时,pf.NumParticles() 返回 0 并且 pf.particleIndex = i 的 pf.particlePosition 返回 0 0 0 for coord.x, .y和.z
geo = #()
for OBJ in Geometry do (
append geo OBJ
)
for OBJ in geo do (
with undo off (
-- define color for current object
r = random 128 192
g = random 128 192
b = random 128 192
-- create a particle system
pf = PF_Source()
pf.Quantity_Viewport = 100
ParticleFlow.BeginEdit()
-- enable render
rp = RenderParticles()
pf.AppendAction rp
-- create birth
a1 = Birth()
a1.Amount = random 1000 2000
a1.Emit_Start = 0
a1.Emit_Stop = 0
-- position to surface of current object
a2 = Position_Object()
a2.Location = 3
a2.Emitter_Objects = #(OBJ)
-- show in viewport
a3 = DisplayParticles()
a3.type = 2
a3.color = (color r g b)
-- add the event to the flow
e1 = Event()
e1.AppendAction a1
e1.AppendAction a2
e1.AppendAction a3
ParticleFlow.EndEdit()
-- create the "complete" particle system
pf.appendInitialActionList e1
-- get particle coordinates
particleAmount = pf.NumParticles()
print particleAmount
for i = 1 to particleAmount do (
pf.particleIndex = i
coord = pf.particlePosition
print coord
)
)
)
-- garbage collection
gc()
有没有办法,我不知道,刷新脚本中的 PF 源,以便它知道系统中有粒子。