|
 |
On Wed, 6 Mar 2002 18:08:12 +0100, "Hugo" <hua### [at] post3 tele dk> wrote:
> I'd very much like to have the best
> smoothing algoritm in my program..
Algorithm is very simple:
1. start loop on all triangles and calculate
a) triangle has vertices V1,V2,V3
b) normal=vnormalize(vcross(V2-V1,V3-V1))
c) area=triangle_area(V1.x,V1.y,V1.z,V2.x,V2.y,V2.z,V3.x,V3.y,V3.z)
d) multiply above and store area*normal in temporary array
2. start second loop on all vertices
a) for each vertex find all its triangles: triangle1, triangle2, ... triangleN
b) calculate weighted normal with equation:
Normal=(area1*normal1+area2*normal2+...+areaN*normalN)/N
(note all multiplications was precalculated and stored in array)
c) store new weighted normal for triangle
That's all.
Of course there can be variations and optimizations according to particular
situation but it is how it looks in general
ABX
Post a reply to this message
|
 |