PDA

View Full Version : Kill Stray Particles


graygiant
10-15-2009, 04:21 PM
I need some help in figuring 2 things out...

1) How can I kill any particles outside a volume?
2) How can I kill stray particles that have no close neighbors?

Thanks!

JoshM
10-15-2009, 05:02 PM
1) How can I kill any particles outside a volume?

Create a field for the volume. I usually use a Uniform field for this, but it doesn't matter. In the fields attributes turn on Volume Exclusion, that way the field is only applied outside of the volume. Make sure it has some magnitude so it applies a force to the particles. Also check the connections on this field and see what inputForce[] it is being applied to in the particle shape.

In the particle shape turn the lifespan to lifespanPP. Create a runtime expression and apply the following code:
//fill ? with the plug value that you found from checking the connections of the field
if ( mag(inputPlug[?]) > 0 ) lifespanPP = 0;


2) How can I kill stray particles that have no close neighbors?

This would be very similar to the previous example. But apply a radial field to the particles and make sure it is using 'Apply Per-Vertex'. Make sure to use the 'Use Max Distance' option and set the distance appropriately for the size of the particles. Then in a runtime expression check that the mag > 0. If it isn't set its lifespanPP to 0.

Hope that helps,
Josh

graygiant
10-15-2009, 07:09 PM
Thanks Josh! Both worked perfect, just a note though...for the second one you have to choose the particles as "Use selected as source of field", that threw me off for a minute. Thanks again.

JoshM
10-15-2009, 07:22 PM
Oh yeah. You need to set the particle shape as the source of the field. So just select the Radial field and particle shape then use Fields -> Use Selected as Source of Field. That should allow you to enable 'Apply Per-Vertex'.

HTH,
Josh

CGTalk Moderation
10-15-2009, 07:22 PM
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.