Add Foam/bubbles per Object

Discussion about scripting with Python
fatsumo
Posts: 44
Joined: Tue May 15, 2007 11:24 am
Contact:

Add Foam/bubbles per Object

Postby fatsumo » Tue Oct 02, 2007 9:38 am

Hi Guys,

for my champagne project im doing, im trying to emulate the foam
and bubbles that appear when pouring into a glass.
Im looking at the beerfoam script which is great, but as I understand
only works on a one object basis, i.e. the null controls the foam on
the object. How could this be adapted to have seperate controllers
for each glass in the stack. And also to have a collision event to release
bubbles that would rise and sit on the top?

Hope i've explained this okay.
would be a great help.


shaun_michael
Posts: 4766
Joined: Sun Sep 10, 2006 8:04 am

Add Foam/bubbles per Object

Postby shaun_michael » Tue Oct 02, 2007 7:10 pm

This is a fun one to get the old noggin around so I'll have a crack at it in the hope that if I'm wrong a python guru can then point us both in the right direction.

As far as I remember the beer foam-type scripts work using collision (and velocity if neccesary) to convert to foam and a velocity threshold to convert back to the original fluid.

So, firstly if you wish your foam to remain, you would look at changing the velocity threshold so that more foam stayed as foam without being converted back to fluid (ie by lowering the velocity at which foam is returned to its original emitter and thus its original state).

In your sim, I imagine, the glass eventually overflows and thus both fluid and foam will be displaced. What you need now is another condition that allows the collision detection to happen again for particles that have already met it, and to happen for the first time for particles that haven't collided (in other words, those particles that collided with other particles and not geometry).

So, assuming that your glasses are stacked up and they are stemmed champagne flutes, you could introduce a height condition into your script that says "If the particles fall below this height [dictated by a null set below the bowl and above the glass below] move them from the emitter they're in to another dummy emitter that will contain particles that you can now put through another collision detection routine on the second tier of glasses, or the second level if you have just one helix of glasses.

What you'd also like to do, I imagine, is decide on whether your want the foam particles that overflow to remain foam, or, based on something like age are also converted to the second dummy emitter.

Does any of that make any sense :o

Shaun

fatsumo
Posts: 44
Joined: Tue May 15, 2007 11:24 am
Contact:

Add Foam/bubbles per Object

Postby fatsumo » Wed Oct 03, 2007 9:09 am

Hi Shaun,

As always, your help is very much appreciated.
The Solution sounds exactly spot on.
Let me know how you get on, going to give a
shot aswell!

Just out of curiosity are you UK Based?

shaun_michael
Posts: 4766
Joined: Sun Sep 10, 2006 8:04 am

Add Foam/bubbles per Object

Postby shaun_michael » Wed Oct 03, 2007 10:17 am

Just out of curiosity are you UK Based?

I am indeed :)

Shaun

User avatar
tsn
Posts: 915
Joined: Fri Oct 27, 2006 10:36 am

Add Foam/bubbles per Object

Postby tsn » Thu Oct 04, 2007 7:13 am

I think the problem is also related to the question, whether the particles are inside or outside of a champagne glass. Otherwise you´d get new foam particles everywhere, no matter where they´re located. Such a face test might take a while to implement and to simulate.

The generation of particles itself isn´t limited to one object. The getParticlesColliding() statement gathers all particles, independet from their source. Maybe a pressure test is better suited for your needs, than a velocity approach. With champagne´s foam, I´d also say that age is very important factor, too.

shaun_michael
Posts: 4766
Joined: Sun Sep 10, 2006 8:04 am

Add Foam/bubbles per Object

Postby shaun_michael » Thu Oct 04, 2007 8:23 am

I think the problem is also related to the question, whether the particles are inside or outside of a champagne glass

You know, I was thinking about that too, but then I thought, well, whether it's inside the glass or not, if the "Champagne" collides with the geometry be it inside or not, you would still want some sort of foam no? After all, champagne is only chanpagne (apart from the region of France it comes from) if it has thousands of bubbles (ie gas) inside it. So if it hits the outside of a glas, or the inside, would you not still want foam creation? Also, if it doesn't hit any geometry, well then I guess that doesn't matter so much as they can be dealt with in other ways.

Am I thinking along totally the wrong lines here?

Shaun

User avatar
tsn
Posts: 915
Joined: Fri Oct 27, 2006 10:36 am

Add Foam/bubbles per Object

Postby tsn » Thu Oct 04, 2007 8:32 am

shaun_michael wrote: Am I thinking along totally the wrong lines here?

No, no! We´re exactly on the same wavelength : - )
I was also asking myself, whether I should write this or not. Of course you´re right: Champagne bubbles wherever you pour it. I was just thinking about possibilities to reduce the amount of foam particles a little, but with a combined age/height detection this would be easier and faster to check.

fatsumo
Posts: 44
Joined: Tue May 15, 2007 11:24 am
Contact:

Add Foam/bubbles per Object

Postby fatsumo » Thu Oct 04, 2007 8:58 am

Hey guys, thanks for the think tank on this.. be great to see how this goes..
Filmed some reference the other day (Cava instead of the expensive stuff :)
and there was quite alot more foam than expected, which over time of course returned
to its liquid state. There were only lots of bubbles in the first glass in the stack aswell.
Anyway, will try upload the clip we shot.

Kris

fatsumo
Posts: 44
Joined: Tue May 15, 2007 11:24 am
Contact:

Add Foam/bubbles per Object

Postby fatsumo » Mon Oct 08, 2007 4:20 pm

hey guys,

worked it out..

have it so it happens on colliding and then returns to liquid
based on age. experimenting with adding another new particle
on collision so I can hide the original emitter so it appears as
if filling up (thus solving the 100 glass conudrum)! so far it's working
but i've had to piece together my ropey knowledge of python!

Cheers

shaun_michael
Posts: 4766
Joined: Sun Sep 10, 2006 8:04 am

Add Foam/bubbles per Object

Postby shaun_michael » Mon Oct 08, 2007 5:46 pm

Good job Kris. Fancy sharing the script?

Shaun


Return to “Python-Scripting”

Who is online

Users browsing this forum: No registered users and 4 guests