Anim8or Community

General Category => ASL Scripts => Topic started by: NickE on June 13, 2009, 12:34:38 am

Title: Simple fluid simulation
Post by: NickE on June 13, 2009, 12:34:38 am
I have been experimenting with trying to simulate fluids using Anim8or:

 youtube.com/watch?v=nRbhXJUqyC4[/youtube]]http://www.
(http://www.[youtube)

The water is a single mesh.  No morph targets were used.  The scene contains only a single copy of the water mesh object and the container mesh object.

Any guesses on how it was done?
Title: Re: Simple fluid simulation
Post by: 3D Joe Wiltshire on June 13, 2009, 01:32:40 am
... I have no idea... but I LOVE YOU!

kidding lol, very nice! would love to see it in dielectric :)
Title: Re: Simple fluid simulation
Post by: Ratticis on June 13, 2009, 05:14:46 am
What kind of sorcery is this?
Title: Re: Simple fluid simulation
Post by: Arik_the_Red on June 13, 2009, 06:47:30 am
Yo that was cool! I'm holding my wife's pet guinea pig hostage, a freshly sharpened blade of grass to its jugular until you share your secret!

And how would that work with raytrace?
Title: Re: Simple fluid simulation
Post by: lynn22 on June 13, 2009, 06:58:01 am
No idea on how it was done but the result is splendid.
Title: Re: Simple fluid simulation
Post by: headwax on June 13, 2009, 08:42:15 am
Pretty amazing,

I'm going to guess you used 9000 bones and had a valve computer the size of a small laundry :)
Title: Re: Simple fluid simulation
Post by: NickE on June 13, 2009, 01:47:24 pm
It turns out that Anim8or is full of surprises.  Did you know that object scripts run asynchronously to the rest of the program, and that scripts continue to run even if you change from object mode to scene mode?  Neither did I, until recently.

I have been playing with writing scripts to simulate fluids and was watching the evolving fluid simulation in object mode.  I was trying to figure out how I could possibly render the simulation.  The possibilities were:

1) Calculate all the frames as separate objects and manually (or by outside program) insert them into a scene, like you have to do to insert video into an animation.  The problem was that it was an enormous number of objects (24 per second), each with thousands of points.  The file would take forever to load and be gigantic!  I never tried that method.

2) Instead of calculating the fluid dynamics on a mesh, use lots of copies of a very small objects in way similar to the way that Terranim8or does particle effects with fire.  That requires an outside program to create an Anim8or file that would be very large with thousands of keyed elements per frame.  I haven't tried that method either.

3) Calculate a single frame at a time on the object and render that in object mode.  I tried to put the render() command into a script, but it crashes Anim8or every time. (I need to report that bug).  That would be a very manually laborious process.

4) Calculate a single frame at a time on the object and render that in scene mode.  Well, that would be as bad as (3) above, but I happened to change into scene mode while a script was running...Behold! the object changed in scene mode as the script continued.  By timing how long Anim8or took to render a frame, and by putting a delay loop in the script so that the next frame is not calculated until the previous frame is rendered, and by post-processing to remove duplicate frames, I was able to produce a fluid simulation that was completely done in Anim8or!

The interesting part is that since this functionality already exists in Anim8or, only a tiny change in the program is required for Steve to make this functionality formal.

I would like to request that an "object script" controller be added with access to the scene variables of time and frame.  If this were done, the full range of physics would be possible in Anim8or!

----

I have attached the ripple script and the project used to generate the above animation.  This test script requires a plane of 100 by 100 points, with the points numbered sequentially.  I will be posting a more complete version that will work with generic meshes soon.  It will be able to do non-planes (spheres, arbitrary solids, even cloth).
Title: Re: Simple fluid simulation
Post by: xalener on June 14, 2009, 01:50:33 am
Well... CAN it be controlled with morph targets?
Title: Re: Simple fluid simulation
Post by: NickE on June 14, 2009, 01:31:06 pm
Theoretically, you could accomplish the same thing as this demo by using a script to precalculate a few dozen morph targets.  You would have to run the script one morph target at a time and end up with a huge an8 file that would take forever to load.
Title: Re: Simple fluid simulation
Post by: xalener on June 14, 2009, 10:59:06 pm
Huh... Yeah...

I just don't like the way it HAS to be rendered while it's working otherwise you're screwed.
I'd want to scrub through the animation. :/

It's a big leap in the program, though...
Title: Re: Simple fluid simulation
Post by: NickE on June 14, 2009, 11:53:01 pm
Yes, it is far from perfect and a bit of a pain to get timed out.  To be broadly useful, object scripts would have to have access to the frame or time variable from scene mode or scene controller scripting would have to be enhanced to support the object scripting abilities to manipulate meshes.

Title: Re: Simple fluid simulation
Post by: Maximilianibus on August 14, 2010, 01:58:46 am
how could i create own fluids? i mean, how to number the points? ???
this is one of the BEST scripts in anim8or i've ever seen!
even your hair script is awesome! ;D
Title: Re: Simple fluid simulation
Post by: NickE on August 14, 2010, 02:16:13 pm
The script and project included above is just a demonstration of the capabilities and to point out the "quirk" of Anim8or of running scripts asynchronously to the rest of the program.

The script above requires a mesh named "s1" of 100 by 100 points.  The points have to be numbered in order of the mesh from 0 to 9999.  The points with Y-coordinates not equal to zero have "excitation", will move up and down, and gradually dampen to zero.  This script only moves the points up-and-down and expects the points to be equal distances away from each other (like a perfect plane)

I've attached a project that has a "blank" water field.  You can try the different kind of rippling, like from the corner, a wave that covers a whole edge, starting the "excitation" above or below the plane, etc.

To render your animation, you have to start the script in object mode, switch quickly to the scene mode and start the render.  The "delay" variable in the script is to allow time for Anim8or to render the frame before the script calculates the next frame.  It takes some experimentation to hone in on a proper delay value for the scene and your computer.  While hunting the proper delay value, set the number of frames variable to just a few frames because you will have to wait for the script to finish to adjust it.

Thank you for your interest.



Title: Re: Simple fluid simulation
Post by: cooldude234 on August 15, 2010, 02:32:47 am
Whoa! I seen that video on anim8or before, but I thought you just used a lot of morphs, seems I was wrong. Now I have to test this script out sometime!

THANK YOU!!
Title: Re: Simple fluid simulation
Post by: Bugtrooper on September 12, 2010, 09:04:45 am
Awesome!!! Some of you're really upgrading anim8or. I only can spend a little amount of time for anim8or, but I want to upgrade it too. Looks like I have to learn first. :D
And again.......GREAT ANIMATION!