[Closed] PFlow scatter
I need to scatter xref objects to a surface so I thought of creating my own scatter tool using maxscript with pflow. Well creating actual scatter flow with maxscript is easy, but a problem comes when I need to actually place to objects in scene. I can’t use shape instance and mesher compound because it kills all xref related stuff.
First thing that came to my mind is just loop thru all particle positions and place objects that way. Problem is that I need to align my objects to that surface and so far I havent figured out how to get normal from each particle. I could use intersectray to find face normal, but how do I know which direction ray needs to be shot from each particle position?
Oh damn I thought I could just use particlePos() to get positions but it doesnt work with PFlow. Looks like I need to do some more reading about PFlow and maxscript integration.
Well got it working. Although I need to do completeRedraw() before looping thru particles, otherwise it doesn’t find them. Any idea why is that?
(
delete objects
local sp = Sphere radius:50 segments:32
local pf=pf_source logosize:10 name:"pf" Quantity_Viewport:100
particleFlow.beginEdit()
local rendParticles=renderParticles()
pf.appendAction(rendParticles)
local pCount = 40
local evt = event()
local birthAction = birth amount:pCount emit_start:0 emit_stop:0
local positionObjectAction = position_object emitter_Objects:#(sp) location:3 Random_Seed:(random 0 10000)
local speedBySurfaceAction = speed_by_surface surface_objects:#(sp) direction_type:0
local rotationAction = rotation direction:3 euler_y:90
local speedAction = speed speed:0
particleFlow.endEdit()
evt.appendAction birthAction
evt.appendAction positionObjectAction
evt.appendAction speedBySurfaceAction
evt.appendAction rotationAction
evt.appendAction speedAction
pf.appendInitialActionList evt
completeRedraw()
for i=1 to pf.numParticles() do
(
local pos = pf.getParticlePosition i
local tm = pf.getParticleTM i
local t = teapot pos:pos radius:5
t.transform = tm
)
completeRedraw()
)
Now I just gotta do some collision tests and maybe even create some slope test so user can decide if particles are placed on steep surfaces.