Results 1 to 15 of 15
  1. #1
    Member
    Join Date
    Aug 2007
    Location
    brazil
    Posts
    81

    Fluid particles to mesh - python script




    this is a very "beta" script and itīs made for a very specific project and it has a lot of room for improvement,

    the script is divided in three parts, the first one creates a sequence of meshes from the particles. and the second one tells the selected object that on every frame change, use the corespondent baked mesh, the third one is just a tool to change some attrib on every mesh

    first part:
    from start_frame to end_frame:
    ->creates a meta ball
    ->tell the some Particle system to draw the Meta ball
    ->convert the metaball to a mesh, and save it as a fake user

    second part:
    on every frame change:
    ->object = selected.object
    ->object.mesh = "Baked Mesh" + current_frame

    third part:
    if you didnīt like the result you can use the "reset.py" script to make the meshes not use a fake user, them save the .blend file and open it again. You use this code to change the material o

    hereīs a video of the result:
    https://vimeo.com/40721951

    some thoughts:
    • The script works best with fast moving particles...
    • Itīs a little bit confusing at first....
    • maybe saving the meshes as an external file is better? i donīt know...
    • Remember to toggle console to see in what frame the script is running, if there are a lot of particles things can get pretty slow
    • Use a smooth modifier to make the fluid better looking
    • There is a command at line X in the MakeMeshes.py that scales the metaball, you can change that if it better suits your needs, but a rather small number you make a mesh with no vertices


    I tried to upload the blend file, but that is taking a long time, so here are the scripts:

    MakeMesh.py - Bakes the surface and makes the frame change operator (see part two)
    http://www.pasteall.org/31080/python

    AnimateMesh.py - makes the object mesh change every frame keep this one register so the mesh is animated on startup
    http://www.pasteall.org/31081

    DeleteMesh.py - makes every baked mesh not fake user, ypu can use this to change the material of every mesh also (just change the code)
    http://www.pasteall.org/31082
    Last edited by Hperigo; 20-Apr-12 at 12:40.



  2. #2
    Member ldh1109's Avatar
    Join Date
    May 2011
    Location
    Massachusetts
    Posts
    1,560
    could you make a video tutorial
    I don't know what Im doing wrong



  3. #3
    Member
    Join Date
    Aug 2007
    Location
    brazil
    Posts
    81
    ummm... I can do a video tutorial, but itīs going o take a while because I'm a little busy with commercial work,

    but try this:
    -> Toggle system console.
    -> Make a particle system, name it ParticleSettings.001.
    -> Make sure there is a material named Material in your scene, this one is going to be applied to every created mesh.
    -> Create an mesh object (a cube, sphere, circle, does not matter what shape), make sure itīs the active object.
    -> run the MakeMesh.py script.
    -> press Alt+A to see the result
    -> (optional) you can use a Smooth modifier to make the fluid look better.


    tip1: at first, make a particle system with low particle emission (but try to keep them together), and a rather small animation start/end, just to make the baking processes faster
    tip2: some times when you change the object layer, or re-opens the file the simulation doesn't play, for that run the script AnimateMesh.py

    tip3: if you want to start again, run DeleteMesh.py then save and re-open the file.

    IMPORTANT: watch the console to see the baking process, a Cyclic dependency error is expected, but it isn't a problem (I think, heheh), if you get any other error, please post it here =)


    I hope this helps, I know the process is confusing but thats how I got it to make this work, maybe someone with more coding experience can help out =)



  4. #4
    Member Mitsuma's Avatar
    Join Date
    Feb 2011
    Location
    Germany
    Posts
    41
    How well does it work with lots of particles?
    (e.g. 3.000.000 or more?)



  5. #5
    very impressive!



  6. #6
    Member Mitsuma's Avatar
    Join Date
    Feb 2011
    Location
    Germany
    Posts
    41
    It's not really fast and takes some time for 300 frames and 5k particles but it's pretty good.
    Too bad it only uses one core of my CPU.

    And why does it create this big blob where the highlighted object was?



  7. #7
    Member
    Join Date
    Aug 2007
    Location
    brazil
    Posts
    81
    @Mitsuma: On my machine it works very well on a high particle count , the only thing that changes is baking time, that can go up to some hours, and I also have no idea on how to make the scipt use more processing power.
    The "big blob" is the original metaball that is used as a draw object on the particle system. One way to overcome this, is to bake the particles far from the scene origin and mask it with another object (very hackish/stupid, i know).

    @blenderificus: Thanks! I still got some issues like:
    *the original metaball that is used as a "draw object" in the particle system and I have no Idea how to delete it after the metaball is converted to a mesh.
    *making this more user friendly
    *maybe the final baked mesh should be an external file like blender fluid system?
    *I made this script basically for two reasons: you canīt use metaballs as draw objects in blender anymore (I think this was possible in 2.4..) and you can't apply modifiers in metaball objects to make the mesh smoother



  8. #8
    @Hperigo, still though, this is impressive. I hope to see this addon develop further. If you need more functionality in python that the current API allows, maybe a request to Campbell on the Blender Dev IRC channel would be worth your time



  9. #9
    that look pertty neat(haven't tried it yet), but the video looks cool
    it would look neat with the material being a fire emission look like a fireball!



  10. #10
    Member bashi's Avatar
    Join Date
    Oct 2010
    Location
    Bern, Switzerland
    Posts
    876
    Hey Hperigo, nice Script.

    I've made something similar "Particle Fluid Tools" a while ago. My Mesh generation is much much slower, due to (probably wrong) python un/knowledge.

    Edit: Just made some further Tests. On osx your script unfortunately doesn't work well, it just generates one Big Metaball... might be wrong usage though. But your approach gave me a new Idea, and another approach: Generate a Point Cloud from the Particles and Parent-DupliVert the Metaballs, which seems to be not to slow. I'll go make some test in this direction. Thanks for your script and impulse again.


    I have some basic Speed-Stretching for "flatten/make longer" fast moving particles...

    I don't care who makes it in the End, i just want to have a solution for Particle Fluids Meshing. ;-)
    Last edited by bashi; 30-Apr-12 at 12:06. Reason: Further Info
    bwide.wordpress.com - Free NodePack, 70+ Cycles + Compositor
    Happy Destruction with: Bullet Constraints Tools



  11. #11
    Member
    Join Date
    Aug 2007
    Location
    brazil
    Posts
    81
    hey holyenigma74 & blenderificus, thanks for the good feedback! I'm getting a little bit more excited about this script!

    blenderificus: I dont think that the blender python API needs more then it already has, itīs only a matter of me understanding it more =) maybe someone in the IRC (or here) chat can help me out with one or other technical difficulties =)

    @bashi: oh I knew i had seen something like that before! but I didnīt remember what it was hehehe
    about the "Generate a Point Cloud from the Particles and Parent-DupliVert the Metaballs". The script does already does that, I think that the "draw object"in the particles system is a kind-of duplivert of the Mball object... so maybe generating a point cloud is an unnecessary step, unless it get rid of the original metaball when converting it to a mesh...

    some thoughts:
    ->the system is fast because itīs using blender internal c++ stuff to generate the metaballs.. and in the end you can use a Smooth modifier to make the mesh smoother (dãr), which is very fast and interective also, in the end the python stuff is only using a bunch of operators (mostly). But Iīm glad it made you look in this subject again =), keep the ideas coming!
    -> about the bug in the OSX, did you try to make the size of the particles bigger? so that the metaballs can touch each other? the probrem with that, is that it affects the simulation fluid simulation (not if you are using standard physics), another way to overcome this is to change the scale of the MBall at line 33



  12. #12
    Member Illusionist's Avatar
    Join Date
    Apr 2010
    Location
    Vancouver, B.C.
    Posts
    313
    Very interesting. I've been waiting forever for fluid meshing. Thanks for making this Hperigo, I'll check out the python script!
    Latest Project: Large Hadron Collider
    Latest Tutorial: How To Create Demonic Ink
    Latest Animation: Poor Suzanne!



  13. #13
    very interesting, how do you create the movement of the particles in your video?



  14. #14
    Member
    Join Date
    Aug 2007
    Location
    brazil
    Posts
    81
    hey guys!
    thanks for the good feedback!
    Iīve managed to make an add-on of this script, go to this thred to learn more:
    http://blenderartists.org/forum/show...articles/page2

    @flecheria:
    thanks! go to the thread that I linked in the post, itīs better explained there



  15. #15
    thanks and good work (and sorry for the delay)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •