Nice blog Albert.
Shaun
Kill particles inside Object
Re: Kill particles inside Object
Tried making this work in 2013:
1: the scene.getEmitter() function does not exist in 2013. you will need to use scene.get_PB_Emitter() (this took quite a while to realize)
2: when a particle gets too close to the kill geometry (from the outside) it is killed before impact. this means that the particles do not interact with it at all. i have changed the flag condition to be greater than -0.3 instead of greater than 0.0. essentially this means that the script will allow slight penetration but i find it preferable to killing the particles before impact. it seems that there is an offset in the dot product calculation. does any one have any idea why?
3: i have an issue with the whole concept. this could work great for a cube for example however in complex shapes you could quite easily be inside the geometry and still have the flag set by positive dot products (meaning normals that are pointing in the same direction as the v2pvect. a very simple example of this would be a ring. am i missing something?
quite surprised the software doesn't come with one such daemon. i could have used it on my last 3 projects.
Any help will be greatly appreciated!
here is the code i ran:
def onSimulationStep():
em =scene.get_PB_Emitter("Circle01")
obj = scene.getObject("Cube01")
vertlist = obj.getVertices()
particle = em.getFirstParticle()
while particle:
nextparticle = particle.getNextParticle()
flag = 1
for v in vertlist:
v2pvec = particle.getPosition() - v.getPosition()
vnorm = v.getNormal()
dotprod = vnorm * v2pvec
#scene.message("dot product of "+str(particle.getId())+ " is "+str(dotprod))
if dotprod > -0.3:
#scene.message("setting flag for "+str(particle.getId())+ " is "+str(dotprod))
flag = 0
if flag:
scene.message("Removing"+str(particle.getId()))
em.removeParticle(particle.getId())
particle = nextparticle
1: the scene.getEmitter() function does not exist in 2013. you will need to use scene.get_PB_Emitter() (this took quite a while to realize)
2: when a particle gets too close to the kill geometry (from the outside) it is killed before impact. this means that the particles do not interact with it at all. i have changed the flag condition to be greater than -0.3 instead of greater than 0.0. essentially this means that the script will allow slight penetration but i find it preferable to killing the particles before impact. it seems that there is an offset in the dot product calculation. does any one have any idea why?
3: i have an issue with the whole concept. this could work great for a cube for example however in complex shapes you could quite easily be inside the geometry and still have the flag set by positive dot products (meaning normals that are pointing in the same direction as the v2pvect. a very simple example of this would be a ring. am i missing something?
quite surprised the software doesn't come with one such daemon. i could have used it on my last 3 projects.
Any help will be greatly appreciated!
here is the code i ran:
def onSimulationStep():
em =scene.get_PB_Emitter("Circle01")
obj = scene.getObject("Cube01")
vertlist = obj.getVertices()
particle = em.getFirstParticle()
while particle:
nextparticle = particle.getNextParticle()
flag = 1
for v in vertlist:
v2pvec = particle.getPosition() - v.getPosition()
vnorm = v.getNormal()
dotprod = vnorm * v2pvec
#scene.message("dot product of "+str(particle.getId())+ " is "+str(dotprod))
if dotprod > -0.3:
#scene.message("setting flag for "+str(particle.getId())+ " is "+str(dotprod))
flag = 0
if flag:
scene.message("Removing"+str(particle.getId()))
em.removeParticle(particle.getId())
particle = nextparticle
Re: Kill particles inside Object
anybody know how it work in RF 2014 ?
I tried to use the script but it doesn't work
I need the same like kVolume daemon but with an option to use object volume instead of container only
can anybody help with it
thanks
I tried to use the script but it doesn't work
I need the same like kVolume daemon but with an option to use object volume instead of container only
can anybody help with it
thanks
Re: Kill particles inside Object
I'd go for Script nodes, as they are a lot faster. Here is how I'd approach the problem (no time for testing right now, maybe tomorrow):
1. Sample object as Signed Distance Field (see description for nodes of type Field in order to be doing so)
2. This will create a volume out of your object. With that volume it is easy to determine if a particle's position is inside or outside that volume (if it is in that Field's nagative or positive area)
3. Delete if it is inside.
You will have to look at the docs a bit, but it shouldn't be too difficult. As I said, if I find some time, I might be looking into that, but I cannot promise.
1. Sample object as Signed Distance Field (see description for nodes of type Field in order to be doing so)
2. This will create a volume out of your object. With that volume it is easy to determine if a particle's position is inside or outside that volume (if it is in that Field's nagative or positive area)
3. Delete if it is inside.
You will have to look at the docs a bit, but it shouldn't be too difficult. As I said, if I find some time, I might be looking into that, but I cannot promise.
Re: Kill particles inside Object
but can you explain more about this step3. Delete if it is inside.
just how ? )
I'm a python noob
but It's strange
industry standard simulation software don't have something like kObject tool in-box (
Who is online
Users browsing this forum: No registered users and 0 guests