Detection particle collision with an object

Discussion about scripting with Python
bmecohen
Posts: 28
Joined: Thu Sep 27, 2012 12:55 pm

Detection particle collision with an object

Postby bmecohen » Tue Nov 13, 2012 6:51 pm

Hello!

I am currently working on a scene, where I would like to separate the particles, which is collide with an object, and I would like to ask your help. I have a Square emitter, and a Container and an object which is moving.
When the Square emitter particle collide with the object, transfer it to the Container emitter. If there is some filter daemon option or other possible solution without python it would also be great.
I attach my basics of the code:

Code: Select all

obj1 = scene.getObject("obj1")
emitter = scene.getEmitter("Square01")
container_emitter = scene.getEmitter("Container01")

particle = emitter.getFirstParticle()
while (particle):
 
??
  particle = particle.getNextParticle()


I don't know which code will do this for me in the loop. I checked the scripting reference, but I can't find anything good in PB Emitter page.

Thank you, and have a great day!


User avatar
Otuama
Posts: 1155
Joined: Fri Apr 02, 2010 12:56 am
Location: Swansea
Contact:

Re: Detection particle collision with an object

Postby Otuama » Tue Nov 13, 2012 10:28 pm

You can do it either way. The filter daemon would be faster in most cases.

I think the filter daemon settings should be something like:

Source Emitters: Square
Target Emitters: Container
Condition: On particle collision

--------

If this doesn't work for you I'll complete your script.
Otuama - Vimeo
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi
'Realism is in the eye of the beholder' - Me ;)

bmecohen
Posts: 28
Joined: Thu Sep 27, 2012 12:55 pm

Re: Detection particle collision with an object

Postby bmecohen » Wed Nov 14, 2012 1:49 am

I tried it, but I had problems. The whole project is going on inside a cube. Therefore, the particles will collide with the inside parts of the cube. I tried to make exemtions with many filter daemon to this way:

1. Filter - On particle collision from the Square to the Container
2. Filter - If the particle get lower/greater than a specified X/Y/Z value, than send back from Container to the Square. /this xyz values are close to the inside borders of the cube/

All the emitters have the same parameters in everything, but when I did it this way, the particles will explode in some areas even high substep values. Can I use some options in the filter daemon, to consider just the wanted obejct in collision detection?

User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Re: Detection particle collision with an object

Postby bolek » Wed Nov 14, 2012 12:17 pm

____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/

bmecohen
Posts: 28
Joined: Thu Sep 27, 2012 12:55 pm

Re: Detection particle collision with an object

Postby bmecohen » Wed Nov 14, 2012 3:15 pm

thanks bolek. I watched all of the sources you gave.
I would like to use filter daemon, because of the simulation speed. I attached a sample file, when I get the problem. I use two filters. First one is particle collide, and the other one is a posY filter, to send back the particles which is collide with the floor. As you can see, the particles until colliding to the sphere is good, but after that some particles will explode. Do you know why?

I would like to do it with filters, instead of the slow python version, but if I don't have a chance to do it this way, I will get a deeper look at the scripted version.
Attachments
test.rar
test scene
(41.75 KiB) Downloaded 89 times

chrispan
Posts: 118
Joined: Fri Jan 28, 2011 2:23 pm

Re: Detection particle collision with an object

Postby chrispan » Thu Nov 15, 2012 12:30 pm

or maybe check this one: viewtopic.php?f=34&t=8288
It's an really easy script and it's based on an example script from the manual.
It is example 3 in the pb_particle scripting reference.

bmecohen
Posts: 28
Joined: Thu Sep 27, 2012 12:55 pm

Re: Detection particle collision with an object

Postby bmecohen » Fri Nov 16, 2012 8:13 am

thanks chrispan! I have done it that way, and it worked! It is a little bit slower but much easier method. I think the filter daemon is a really awesome feature, but it would be better, if the colliding objects could be selected.

chrispan
Posts: 118
Joined: Fri Jan 28, 2011 2:23 pm

Re: Detection particle collision with an object

Postby chrispan » Fri Nov 16, 2012 10:59 am

cool. yeah I thought the same about the filter. maybe some changes in RF 2013

IoSim
Posts: 328
Joined: Tue Jan 13, 2009 8:09 am

Re: Detection particle collision with an object

Postby IoSim » Fri Nov 16, 2012 3:37 pm

Hi

cool. yeah I thought the same about the filter. maybe some changes in RF 2013


This is also why I added that feature in the IoKillObject plugin. In the current verison one object can be selected and particles can either be killed or transferred, but you can instead apply multiple plugins to the same emitter.

The next version however will support multiple objects and also other emitters.

-Cheers Ole
Ole Lemming
RealFlow plugin developer
IoSim, Creative Thinking Lab
www.iosim.dk


Return to “Python-Scripting”

Who is online

Users browsing this forum: No registered users and 2 guests