PDA

View Full Version : Particleflow stick and roll


d0c
10-06-2010, 10:26 PM
Hey,

I was wondering if someone can tell me how I can make a particle flow setup so that my particles will make contact with a surface and stick to it and run roll a bit before passing through the surface.

I can get teh particle to collide with a U deflector but I can't figure out how to have them stick to the surface instead of just bouncing off until they eventually disappear.

Thank you.

HornBerger
10-07-2010, 10:24 AM
here is a scripted approach (its a rolling snowball done with scripting, it shows how sticky particles can be achieved without using any operators) its a slow solution and not the best one, i did this long back as a pet project and the file is in 2010 so i just quickly copied a similar setup in 2009 so it can run your machine, to get speed and reality out of a rolling snowball you will need box2 and max 2010. Anyways here's the setup and the script(s):

in summary : the birth grid script places particles on a plane surface (like a rectangle shape) the script test operator shoots rays from each particle towards the center of the sphere if the length of this ray is lesser than 1 then the face and barry coordinates are stored in the particleinteger, particlevector channel and the particles are passed to the next event where the script operator uses the information in the particleinteger and the particlevector channel to position the particles correctly as the sphere rolls down the hill (it also scales the particles over time, this was done to cheat the growing snow ball effect) (Still confused? look up the mxs help file for intersectrayex function)

1) particle flow setup
http://img337.imageshack.us/img337/9858/snowballpfs.jpg

2) Birth Grid Script:
on ChannelsUsed pCont do
(
pCont.useTM = true
pCont.usePosition = true
)

on Init pCont do
(

)

on Proceed pCont do
(
currentTick = pcont.gettimeEnd()
if currentTick == 0 then
(
for x = -$rectangle.width/2 to $rectangle.width/2 by 2 do
(
for y = -$rectangle.length/2 to $rectangle.length/2 by 2 do
(
pcont.addparticle()
pcont.particleindex = pcont.numparticles()
pcont.particleTM = $rectangle.transform
pcont.particleposition = ($rectangle.transform.row1 * x) + ($rectangle.transform.row2 * y) + $rectangle.pivot

)
)
)

)

3) script test operator (particles close to snow ball?)

on ChannelsUsed pCont do
(
pCont.useInteger = true
pCont.useVector = true
pCont.usePosition = true
)

on Init pCont do
(

)

on Proceed pCont do
(

for i = 1 to pcont.numparticles() do
(
pcont.particleindex = i
--if ((distance pcont.particleposition $sphere.pos) < ($sphere.radius)) do
--(
particleRay = ray pcont.particleposition (normalize ($sphere.center - pcont.particleposition))
resultArray = (intersectRayEx $sphere particleRay)
if (distance resultArray[1].pos pcont.particleposition) < 2 do
(
pcont.particleInteger = resultArray[2]
pcont.particleVector = resultArray[3]
pcont.particleteststatus = true
)
--)
)
)

on Release pCont do
(

)
4) script operator (glued particles follow snow ball)

on ChannelsUsed pCont do
(
pCont.useInteger = true
pCont.useVector = true
pCont.usePosition = true
pCont.useScale = true
)

on Init pCont do
(

)

on Proceed pCont do
(
local sphereMesh
currenttick = pcont.gettimeend()
at time currenttick
(
sphereMesh = snapshotasmesh $sphere
)
for i in 1 to pCont.NumParticles() do
(
pCont.particleIndex = i
faceVerts = (getface spheremesh pcont.particleinteger)
particlePosition = [0,0,0]

particlePosition = particlePosition + ((getvert spheremesh faceVerts.x)*pcont.particlevector.x)
particlePosition = particlePosition + ((getvert spheremesh faceVerts.y)*pcont.particlevector.y)
particlePosition = particlePosition + ((getvert spheremesh faceVerts.z)*pcont.particlevector.z)

pcont.particleposition = particleposition
if (pcont.gettimeend() as float) < (ticksperframe * 70.0) do
pcont.particlescale = ((pcont.gettimeend() as float) / animationrange.end.ticks)*12
)
)


the script can definitely be improved and made much more efficient and less memory consuming... (for example you could shoot rays only when particles are close to the bounding box of the geometry) or maybe use a totally different method of computing ray intersections instead of intersectray which is very slow

here is a viewport grab:
http://img825.imageshack.us/img825/1232/snowball.jpg
[attached max 2009 file]

cheers! :)

haavard
10-07-2010, 01:06 PM
If you have the lock bond operator in particle flow you could this with just particles or with particles selecting meshes with the volume select modifier. E.g. spawn particles on a plane and have the ball roll over the plane while the particles stick to the ball as they collide with it. Duplicate the ball and the plane and add modifiers to them so they are only visible when particles touch them.
I did a quick preview (http://folk.ntnu.no/havardsc/misc/particleTrailSnowBall.MP4).
http://folk.ntnu.no/havardsc/img/scenegrab.png
Larger image (http://folk.ntnu.no/havardsc/img/scenegrab.png)
Max scene (2011) (http://folk.ntnu.no/havardsc/misc/snowball.max)

d0c
10-07-2010, 04:24 PM
Wow that is amazing!

Thank you for taking the time to put this together. I will take a look at it when I get home, but from seeing the screen grabs and video... My hat goes off to you.

Thank you!

HornBerger
10-08-2010, 08:18 AM
If you have the lock bond operator in particle flow you could this with just particles or with particles selecting meshes with the volume select modifier. E.g. spawn particles on a plane and have the ball roll over the plane while the particles stick to the ball as they collide with it. Duplicate the ball and the plane and add modifiers to them so they are only visible when particles touch them.
I did a quick preview (http://folk.ntnu.no/havardsc/misc/particleTrailSnowBall.MP4).

cool (nice technique :thumbsup:), maybe you could animate the shell amount to make the snow ball grow in size as it rolls

cheers!:)

CGTalk Moderation
10-08-2010, 08:18 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.