Normals for Metaballs

Started by
11 comments, last by Xeno 20 years, 9 months ago
>another question i would like to add is , how can i check
>whether my generated triangle in the marching cubes algorithm
>is a fornt face triangle or not without using cross product to
>check the sign of its normal... is there any other way?

This depends completely on the way you''re computing the triangles!

I suggest using some precalculated triangle table for this purpose, for example the tables on Paul Bourke''s site

>about the second one , i think its nice one , but i thought
>about another one... some triangles share 2 vertiecs , so whats
>happening is that sometimes i calcuate the normal for the same
>vertex twise instead of once... what i can do is to check
>whether i already calculated the normal in this vertex or
>not... it would save some CPU time.

Here''s a good trick from "the good ol'' days":

The problem with checking is that you first need to reinitialize the test array per frame. To overcome N^3 iterations, initialize an array that tells on which frame a cell has been checked for the last time. If you ever encounter "the current frame" in some particulal cell, you can assume that it has been already checked on the current frame.

You might use values of -1 for initializing this table, and use the largest possible datatype in hand. Even int is good because you probably won''t compute more than 2,000,000,000 frames of animation...

- Mikko Kauppila
Advertisement
but im not using any tables... im using tetrahedrons to draw the cubes...

------------------------------- Goblineye Entertainment------------------------------

What's the tangent vector of a surface Xeno ? How would you define it ? This is meaningless unless you define a plane that cuts the surface in two halves. The gradient IS parallel to your normal vector.

As you wrote (that's called the partial derivative in x)
d/dx(1/R^2) = -(d/dx(R^2))/R^4 that is -2x/R^4.

Can't you see that if (x,y,z) is a point of your sphere (you supposed center is {0,0,0} ) then the normal is parallel to {x,y,z}. Damn the normal to a point of the sphere is parallel to the radius that joins the center to the point ! lol

Gradient(1/R^2) = -2/R^4 * {x,y,z } that is -2/R^3 * N where N is the normal.

and this -2/R^3 represents a kind of inverse volume related to the "curve" at the point.


Now your implicit surface looks like : k1*f(d1) + k2*f(d2) + ... + kn*f(dn) = k0

f(d) being 1/d^2 and d1, d2, ...., dn being the respective distances of the ball centers to the point {x,y,z} : di^2 = (x-xi)^2 + (y-yi)^2 + (z-zi)^2

So you just have to sum the gradients for each ball and you'll get the gradient of your metaball since derivation is a linear application. ( (u+v)'=u'+v' )

Just normalize and change sign. There is no real problem I can see.


[edited by - Charles B on July 11, 2003 7:31:13 PM]
"Coding math tricks in asm is more fun than Java"

This topic is closed to new replies.

Advertisement