views:

86

answers:

4

What kind of algorithms would generate random "goo balls" like those in World of Goo. I'm using Proccesing, but any generic algorithm would do.

I guess it boils down to how to "randomly" make balls that are kind of round, but not perfectly round, and still looking realistic?

Thanks in advance!

+1  A: 

Not sure if this is what you're looking for since I can't look at that site from work. :)

A circle is just a special case of an ellipse, where the major and minor axes are equal. A squished ball shape is an ellipse where one of the axes is longer than the other. You can generate different lengths for the axes and rotate the ellipse around to get these kinds of irregular shapes.

Mike Daniels
Thanks for the response. But I think it's more than varied ellipses, because some of the goo balls look asymmetrical to me.
tomato
+2  A: 

The thing that makes objects realistic in World of Goo is not their shape, but the fact that the behavior of objects is a (more or less) realistic simulation of 2D physics, especially

  • bending, stretching, compressing (elastic deformation)
  • breaking due to stress
  • and all of the above with proper simulation of dynamics, with no perceivable shortcuts

So, try to make the behavior of your objects realistic and that will make them look (feel) realistic.

Unreason
A: 

As Unreason said, World of Goo is not so much about shape, but physics simulation.

But an easy way to create ball-like irregular shapes could be to start with n vertices (points) V_1, V_2 ... V_n on a circle and apply some random deformation to it. There are many ways to do that, going from simply moving around some single vertices to complex physical simulations.

Some ideas:

1) Chose a random vertex V_i, chose a random vector T, apply that vector as a translation (movement) to V_i, apply T to all other vertices V_j, too, but scaled down depending on the "distance" from V_i (where distance could be the absolute differenece between j and i, or the actual geometric distance of V_j to V_i). For the scaling factor you could use any function f that is 1 for f(0) and decreasing for increasing distances (basically a radial basis function).

for each V_j
   V_j = scalingFactor(distance(V_i, V_j)) * translationVector + V_j

2) You move V_i as in 1, but now you simulate springlike connections between all neigbouring vertices and iteratively move all vertices based on the forces created by stretched springs.

3) For more round shapes you can do 1) or 2) on the control points of a B-spline curve.

Beware of self-intersections when you move vertices too much.

Just some rough ideas, not tested...

Sebastian N.
A: 

Maybe Metaballs (wiki) are something to start from.. but I'm not sure.

Otherwise I would suggest a particle approach in which a ball is composed by many particles that stick together, giving an irregularity (mind that this needs a minimal physical engine to handle the spring body that keeps all particles together).

Jack