Stick and stay put script?

Discussion about scripting with Python
User avatar
Oldcode
Posts: 715
Joined: Thu Nov 03, 2011 11:28 pm

Stick and stay put script?

Postby Oldcode » Thu Jan 10, 2013 2:40 am

Hi Everybody,

Just wanted to know if there is a script out there that will make particles stick to the surface of a polygon and stay there, kind of like mud being thrown at and sticking to a wall?

I know Wet Works has plugin that would do the job, but I don't have $500 dollars US to spend on something like that.

Thanks in advance,

Cheers!
"My sword and my service are yours."

"Then forever remind him of his vow, Knight of the Old Code."


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

Re: Stick and stay put script?

Postby Otuama » Thu Jan 10, 2013 4:08 am

Code: Select all

emitter = scene.getEmitter("Circle01")

collision = emitter.getParticlesColliding()

for particle in collision:

   particle.freeze()


It should be something like that.

However, for this sim ( http://vimeo.com/44053138 ) I had the object's sticky at 1000 and it's roughness as 1.0. For the emitter I had a res of 15, viscosity of 80 & surface tension of 60. These values were based on a default scene scale & circle emitter size.
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 ;)

User avatar
Oldcode
Posts: 715
Joined: Thu Nov 03, 2011 11:28 pm

Re: Stick and stay put script?

Postby Oldcode » Thu Jan 10, 2013 4:24 am

Hey Otuama,

Thanks so much!!!! That movie was awesome. That's just what I want to do. Now, the embarrassing part... :oops:

I've never used a script before so I have no idea how to install or use it.

So, do I take the code you've provided and put it into a text file?

Circle01 is the name of whatever emitter produced the particles?

Is there somewhere in the code where I put the name of the object I want the particles to stick to?

Thanks in advance. :mrgreen:
"My sword and my service are yours."

"Then forever remind him of his vow, Knight of the Old Code."

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

Re: Stick and stay put script?

Postby Otuama » Thu Jan 10, 2013 8:12 pm

The code I posted was only a quick example. For the mud gun video I didn't use any script for the sticking on the wall. I just used the values I posted earlier. The only script I used with that sim was an emitter tracking a null ( https://vimeo.com/39926708 ).

It worked very well without scripting and can just be used with a stream of particles from an emitter.
Last edited by Otuama on Thu Jan 10, 2013 8:56 pm, edited 1 time in total.
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 ;)

User avatar
Oldcode
Posts: 715
Joined: Thu Nov 03, 2011 11:28 pm

Re: Stick and stay put script?

Postby Oldcode » Thu Jan 10, 2013 8:56 pm

Very cool!

What I'm trying to do is have an object dunked in a fluid about half way, like a car being stuck in the mud, and when the car is pulled, the wheels and other parts of the car have the mud particles stuck to the car's polygons.

Do you think these settings would work for something like that?

Thanks in advance,
"My sword and my service are yours."

"Then forever remind him of his vow, Knight of the Old Code."

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

Re: Stick and stay put script?

Postby Otuama » Thu Jan 10, 2013 9:01 pm

I don't see why not. Actually, using a script to do it may not be as good as the mud gun version because only the particles touching the object will freeze.

Give it a try.

For the mud gun one I think I used a substeps of 300/400.
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 ;)

User avatar
Oldcode
Posts: 715
Joined: Thu Nov 03, 2011 11:28 pm

Re: Stick and stay put script?

Postby Oldcode » Fri Jan 11, 2013 12:16 am

Thank you! I'll try that and let you know what happens.
"My sword and my service are yours."

"Then forever remind him of his vow, Knight of the Old Code."

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

Re: Stick and stay put script?

Postby Otuama » Fri Jan 11, 2013 1:12 pm

I just did a test with 4 cylinders (wheels?) going half way into a container of particles.

I used the exact values I told you earlier.

But, it didn't work. The wheels went in but when they came up the particles stuck to them but the particles then detached from the wheels. This it probably due to the viscosity; the particles are trying to stick to the wheels but they are trying harder to stick with the rest of the particles. Of course, the surface tension also is to blame.

I've upped the wheels stickiness to 50k to see what happens.

It just goes to show the amount of tweaking fluid stuff takes, even with setting which work.
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 ;)

User avatar
Oldcode
Posts: 715
Joined: Thu Nov 03, 2011 11:28 pm

Re: Stick and stay put script?

Postby Oldcode » Fri Jan 11, 2013 1:30 pm

Thanks Otuama,

I'm running a test as we speak and mine is not working either. I think the problem is if the object in the fluid is moving, the particles sticking to the object tend to migrate their way up the surface of the object in an unrealistic way.

For example, if you stick your arm into a vat full of mud, when you pull the arm out, it should be coated with mud, but the mud should not crawl its way up your arm.

That's the effect I'm looking for.
"My sword and my service are yours."

"Then forever remind him of his vow, Knight of the Old Code."

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

Re: Stick and stay put script?

Postby Otuama » Fri Jan 11, 2013 1:49 pm

I've just realised something which may be the cause of my problem. I had a plane at the top of the container to block particles coming out. Ummm, I forgot to turn it off. No wonder the particles are leaving the wheels because the plane is pushing them down. Doh!!
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 ;)


Return to “Python-Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest