theory behind metaballs?

Started by
56 comments, last by deryk 20 years, 8 months ago
>> the problem i'm encountering is that the movement of the blobs are confined in such a small area. is there anyway to make their area of movement any larger?

Yup, the movement of the balls is restricted to the area you are scanning with your cubes. Or to be more precise: You only get polygons in the area you are scanning so if the ball moves out you won´t render it anymore. Increase the scanning-range (it was GRIDROOT in the sample source you presented before) so you can increase the area where the balls can be in. This will not affect your polycount but it will still affect speed since you have to compute a lot more gridpoints if you stay at the same resolution (being 1 in your sample code).
This is where optimisation can start. All I said above was about polygonizing isosurfaces of ANY scalar field. Once you restrict the ANY you can use these restrictions for optimizing. Let´s for example say that your scalar field f is the sum of N scalar fields fi(x,y,z) = ri/((x-xi)²+(y-yi)²+(z-zi)²) with all ri>0 and xi,yi,zi being the position of ball i :

In this case you know where you expect your surface so you only calculate cubes in that area. Imho best way of doing this:
a) There is a closed isosurface around every (xi,yi,zi)
b) If the ball i is isolated you know the distance r0i your surface would have from the origin (depends on ri and what you had called THRESHOLD). Since all ri>0 the actual distance of the isosurface can only be bigger. So you start checking a cube with a distance of r0i from (xi,yi,zi). If this cube isn´t intersected by the isosurface continue going outwards. a) will ensure you that you will hit a cube that is intersected by the isosurface. Mark all cubes claculated as being calculated
c) If you hit a cube that is intersected by the isosurface and not already been calculated then draw the polygon mark the cube as calculated and calculate all neighbouring cubes.
d) repeat c) until all cubes are calculated (you don´t have to go outwards further once you hit a cube intersected).
e) repeat b) until you did it for all balls. You can skip this step if you know that you isosurface is a single entity (the balls do not seperate).

This would be a first idea on optimizing. Further analytical threatment (knowing how many/which seperate blobs you have for example) might optimize this further.
The basic concept -only calculate the cubes than can be intersected- depends on the type of scalar field you want to polygonize.


>> my current blob structure only keeps track of the blob coordinates. what can i add to this to control, for example, the length and width of the blob?

Not quite sure what you mean by that but: I think you currently have each ball (=blob?) defined by a scalar field of r = 1.0/((x-x0)²+(y-y0)²+(z-z0)²) where (x0,y0,z0) is the position of your ball. First thing you might change is the 1.0 to be any real value X (even negative ones - this results in cavities). X would be something like the radius of the ball. However f = 1/R² (R = SQUAREROOT(x²+y²+z²)) isn´t THE equation to render a ball. Any equation that is raising or falling (falling if you want a result like the balls merging) as a function of only R will do this (X*exp(-R) for example).


[edited by - Atheist on July 31, 2003 9:53:38 AM]
Advertisement
Again i agree completely with Atheist.
Im not as good in explaining things

To scale the blobs, multiply the coefficients of the distance checking code with the desired scale factors, therefore effectively scaling them in x,y or z.
_And_ you could run the corner checking thru any matrix, for example rotation, to use any transform on the blobs.

I'm very happy for you to have gotten this far!
Nik

[edited by - Nik02 on July 31, 2003 6:36:16 PM]

Niko Suni

Marching cube is a pretty bad algo for real time. Wasting a volume of memory and processing while it''s all about surface rendering sucks. And there is a patent by General Electrics, ROFL. With a little imagination, solutions of linear complexity can be easilly found.
"Coding math tricks in asm is more fun than Java"
Linear to what ?
quote:Original post by Charles B
Wasting a volume of memory and processing while it's all about surface rendering sucks.


But if you do have a volume of data that you want to visualize, there does not exist a more straightforward visualization method than to scan the volume with the cubes.

I don't really follow you, Charles

And volume scanning is a trilinear algorithm, in it's purest sense!

[edited by - Nik02 on August 2, 2003 11:42:21 AM]

Niko Suni

K here is my secret. Space/time coherency. Put all the metaballs on the same center. That''s a sphere. Simple to tesselate. Then move semi "continuously" and try to match the new shape eventually adding triangles here and there. Follow the normals, use error based on difference of potential. With several optimizations I wont explain here, this will be linear per vertex.

Newt you can animate the blob with the same algo.

The hard thing is to detect when the blob is split in two closed shapes.

If I was a pig I would patent all my 3D ideas as the guys of General electrics.

Now if anyone is courageous enough he could try to implement this idea. I will anyway.
"Coding math tricks in asm is more fun than Java"
The beauty in marching cubes is that you can visualize any volume, not just spherical potential fields.

However, not a bad idea, Charles! Let''s exchange implementation progress in this forum

Now, good night to all! Goin out for the saturday night with my friends...

Niko Suni

Exact, but marching cubes use a VOLUME (3D grid n*n*n) to render an implicit SURFACE (n*n). Each cube cell holds zero (most often that's where it hurts), one, 2 or 3 triangles. That's why I simply write n do describe complexity.

F(x,y,z) = 0

Apart the start with a sphere my algo would also work for any implict surface. But anyway any "normal" closed surface is topologically equivalent to a sphere. So I let you find the answer ... You could also let cubes march to start and use my algo for real time animation.

Good night

[edited by - Charles B on August 2, 2003 7:03:44 PM]
"Coding math tricks in asm is more fun than Java"

This topic is closed to new replies.

Advertisement