POV-Ray : Newsgroups : povray.general : Is this an optimum outline for Mesh_Smoothing macro? : Is this an optimum outline for Mesh_Smoothing macro? Server Time
6 Aug 2024 23:22:07 EDT (-0400)
  Is this an optimum outline for Mesh_Smoothing macro?  
From: Shay
Date: 28 Dec 2001 15:45:12
Message: <3c2cd9d8$1@news.povray.org>
I was looking at bicubic patches, but they seem pretty limiting so I want to
try modeling with mesh2. I want to write a macro that will figure the normal
vertices. I am assuming that I created the triangles myself, so all faces
will be defined clockwise. This is the best idea I could come up with. Is
there a faster way? Unfortunately, I know very little of programming outside
of Povray.


#macro Mesh_Smooth (VERTICES_array, FACES_array)

Make a 1D array (VCOUNT_array) to store the number of times each element in
VERTICES_array appears in FACES_array

Make a 1D array (NFACES_array) to store the normals of each face in
FACES_array

Make a 1D array (CHECKED_array) to store the number of times a faces normal
has been used to determine a vertex normal

************

Start with VERTICES_array[n]

Create 1D array (USEDFACES_array) with VCOUNT_array[n] elements to store the
NFACES.array positions used in determining the vertex normal

Create 1D array (FVNORMS_array) with VCOUNT_array[n] elements to store the
NFACES.array content used in determining the vertex normal

Make a loop from 0 to VCOUNT_array[n]-1

Search in FACES_array for occurances of VERTEX_array[n]

When found, check for normal in NFACES_array and if not present, calculate
the normal of the face and store it in NFACES_array and in FVNORMS._array.
Also, increase CHECKED_array[n] by one and store "n" in USEDFACES_array.

When appropriate number of faces have been calculated, calculate vertex
normal and output it to a file

Use USEDFACES_array to check CHECKED_array for faces which have been used
three times. Remove any which have from FACES_array, NFACES_array, and
CHECKED_array.

Repeat.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.