   Realtime Slime    
  I've been toying with a method for creating real-time metaballs recently.  There is a Gamasutra article which uses marching cubes to step through an energy field and determine the threshold surface; my approach creates a mesh for each sphere and deforms them based on attraction to each-other with an exponential fall-off function (which the Gamasutra article used too if I'm not mistaken).  I did a search on our friendly neighborhood Google and didn't come up with many programming resources (there were alot of 3dsMax turtorials); the only thing I found was the Gamasutra article, so I was wondering is this method new?  I've become kind of cynical lately so I have a hard time believing this; I suspect (A) the information is well hidden, (B) there's a good reason people don't use my method, or (C) metaballs are considered too processor-intensive for games so my method was never considered.  Which do you think it is; if you've written code to create metaballs, what algorithm did you use?Just in case you're not familiar with metaballs, they're sphere's that "grow" together (a film begins to fill the space between them) as they are brought into proximity with one another.[edited by - bob_the_third on January 29, 2003 12:19:14 AM]
  nah, metaballs have been used for ages in demos. if i remember correctly, since 96/97.. so it cannot be too cpu intensive.. i''ve never seen them in games tho.. there is plenty of info on the net. even full sourcecodes. especially on the marchingcubes algo, since this is quite old, but also on the metaball field itself (tho i discovered the info isn''t always accurate!).i recommend some more googling.however, i don''t think i use your method.. basicly i add the fields of each sphere, add those.. and then i use marchingcubes.which to me sounds like a more simple way of doing it?earx;  I think the advantages of mine are speed and flexibility.  It iterates through a vertex list instead of a 2D or 3D space, so you don''t have those granularity problems (especially if you use adaptative subdivision) and you can create groups of influence so that, for example, the ear would be a group and it wouldn''t be deformed at all by any other part of the body except at the point(s) where it attaches to the head.  This allows for both an optimization and a modeling advantage.  ;  Can you give any screenshots of this working. And a bit more detailed description would be welcome.    You should never let your fears become the boundaries of your dreams.  ;  I'll try to get some screenshots posted somewhere (do you know of a free hosting service I could use; Homestead went pay.).  A more detailed description follows:Without diagrams this is tough to explain; let's see.  Each metaball is made up of an inner and an outer circle.  The radius of the outer circle is equal to the (1+GOO_FACTOR) times the radius of the inner_circle.  An algorithm in pseudo-code follows:For each metaball M  For each vertex V in M.outer_circle do    D=f(GOO_FACTOR), where GOO_FACTOR determines the metaballs' affinity to eachother (0,+infinity)    For each metaball N such that M<>N do let d=distance(V,N.center)-N.inner_radius D=D+f(d), where f(x) is the weighting function    End For   let w=f(d1)/D, where w is the weight used in the interpolation.x=w*M.inner_circle.xy=w*M.inner_circle.y    For each metaball N such that M<>N do  let d2=distance(V,N.center)-N.inner_radius  w=f(d2)/D  let p2 be a vector equal to N.center+unit_vector(V-N.center)*N.inner_radius  x=x+w*p2.x  y=y+w*p2.yEnd forplot x, y  End forEnd for   Note that this pseudo-code does not take into account some artifacts such as the special case when outer circle point is within the outer circle of a metaball; however I didn't feel like typing that much.  I'll save that for an article if there's any interest.[edited by - bob_the_third on January 23, 2003 4:01:08 PM];  when ever you have some image or smaller file to post, go to http://davepermen.net click on free and upload there, then copy the link in here..this was a shameless plug (and don''t tell me i don''t update anymore. i''m currently less at home than sleeping, okay?:D)    "take a look around" - limp bizkitwww.google.com  ;  Thanks davepermen!  That's awesome.  Okay, I've got screenshots now.  Maybe this will make more sense!  Above is a screenshot of my current 2D metaball demo.  It's not totally finished; I'm going to remove all the inside stuff and leave only the outer surface eventually.Okay the diagram above should clear up some details of my algorithm.  1.  Take any one of the red dots.  2.  Find the distance between the red dot and the inner circle of each of the other undeformed metaballs.  3.  Generate a weight for each metaball using the function (1.1^d)/D where d are the distances we just calculated, and D is the sum over all metaballs.  4.  Now using the weight for each metaball and the corresponding BLUE point on the inner circle, interpolate to find the coordinates for the vertex in the metaball mesh after deformation.  As you can see from the diagram, the smaller the difference between the outer radius and the inner radius of a metaball, the greater the influence that metaball has on its own vertices and the less affinity metaballs will have toward each other; the greater the difference, the higher the affinity.  [edited by - bob_the_third on January 24, 2003 12:06:39 PM];  I guess they ain''t too popular, eh?    ;AFAICS your method does not produce "real" metaballs. When you use marching cubes, you get a continous surface. Your algorithm produces three surfaces so there will be a crease where they intersect.  ;  Should be able to smooth the seams if necessary; however I think they look pretty good as is even if they''re not pure metaballs.  