First, I'd like to correct a typo in my previous message.
"facted" was really supposed to be "faceted".
And now to my main subject, which is how the normal options
work. I had been very sketchy about this matter in my previous
message, but I've decided to expand on that matter in more detail.
A normal vector is a perpendicular vector to a surface, and
this sort of vector is used to calculate the lighting that a surface
receives. These are commonly stored with each vertex, and the
appearance of curvature can be created by interpolating the normals
between vertices and calculating the lighting at each point with them
(a light shining from a slant will make weaker illumination than one
shining straight down). The newest 3D-capable video cards support
this, but the older ones require shortcuts like calculating the
lighting for each vertex and then interpolating (vertex lighting) or
using a precalculated light-map image file. I'm only supporting
vertex lighting because it's relatively simple to implement, and
because it looks OK with diffuse lighting.
As to 3D-model file-format support, that is somewhat spotty;
Alias|Wavefront and QD3D support normals, 3D Studio Max does not seem
to. And even if a file format supports normals, a model may omit
them. So that's why I've set up the option of generating the normals
from other model information. One problem there is that one may want
the model to look faceted or flat-surfaced rather than curved, and
I've added an option to make that possible -- and to make some areas
look curved and some look faceted.
The attribute norm_type of <model> of <opengl> has these
possible values:
0: Use no normals (no directional lighting)
1: Use model's original normals, if present
2: Reverse the direction of the model's original normals
3: Make the normals point in the clockwise direction of each of the surfaces
4: Like above, but in the counterclockwise direction
The attribute norm_split of <model> of <opengl> is for
determining which of the vertices must be split; if a vertex is
split, then each neighboring polygon gets one of the new vertices,
complete with its normal, which is that polygon's normal. Otherwise,
it will use the normal calculated for that vertex, which is the
average of those neighboring normals. Splitting will make the
polygons look flat, giving a faceted look, while not splitting will
give a smooth look.
The splitting decision is made by calculating the standard
deviation of the neighboring polygons' normals and checking on
whether it is greater than this threshold. If it is small, then a
surface may reasonably be considered smooth; otherwise, it may be
reasonable to treat polygon boundaries as sharp corners.
I hope that this is at least half-intelligible, especially
for those who are not familiar with the mathematics of 3D modeling.
--
Loren Petrich -- petrich@...
http://www.petrich.com/home.html
Happiness is a fast Macintosh
And a fast train
|