nmode(3G)nmode(3G)NAMEnmode - specify renormalization of normals
C SPECIFICATION
void nmode(mode)
long mode;
PARAMETERS
mode expects a symbolic constant. There are two defined constants for
this parameter:
NAUTO causes normals to be renormalized only if the current
ModelView matrix is not orthonormal. (default)
NNORMALIZE causes normals to always be renormalized, regardless of
the current ModelView matrix.
DESCRIPTION
IRIS systems transform vertex normals from object-coordinates to eye-
coordinates before doing lighting calculations. While the matrix mode is
MVIEWING, a separate Normal matrix is maintained to support this
transformation. The Normal matrix is the inverse transpose of the
upper-left 3 x 3 portion of the ModelView matrix.
Transformed normals must be unit length if the lighting calculations are
to be meaningful. Transformed normals will be unit length if 1) they
were unit length in object-coordinates, and 2) the current Normal matrix
is orthonormal (see notes). If one or both of these conditions are not
met, the normal must be normalized (corrected to have unit length) after
it is transformed. nmode helps the system determine when normalization
is required.
Each time the ModelView matrix is changed, the IRIS determines whether
the resulting (inverse-transpose) Normal matrix is orthonormal or not,
and saves the result of the test as a flag. After each normal is
transformed, both this flag and the nmode flag are tested. If nmode is
NAUTO, the normal is normalized if and only if the flag is set (i.e. the
ModelView matrix is not orthonormal). NAUTO mode is appropriate when the
model normals are known to be unit length. If nmode is NNORMALIZE, the
normal is normalized unconditionally. NNORMALIZE mode is appropriate
when the model normals may not be unit length.
NAUTO is the default nmode.
Because normalization involves division by a computed square root, it can
adversely affect system performance.
SEE ALSO
mmode, loadmatrix, multmatrix, rot, scale, translate, lmbind
Page 1
nmode(3G)nmode(3G)NOTES
IRIS-4D G, GT, and GTX models, and the Personal Iris, do not support
nmode.
nmode cannot be used while draw mode is MSINGLE.
On Impact and Infinite Reality NAUTO is not supported. Normals are
always normalized.
For our purposes a matrix is orthogonal if it transforms normals to the
same length regardless of their direction, and it is orthonormal if this
length is the same as the untransformed length. Rotation matrixes are
always orthonormal. Scale matrixes are orthogonal but not orthonormal if
the three scale values are identical, neither orthogonal nor orthonormal
otherwise. Uniform scale ModelView matrices can be normalized to the
identity matrix, and are therefore ignored by the Normal matrix.
Translations do not affect the upper-left 3x3 ModelView matrix, and are
therefore also ignored by the Normal matrix.
The length of a normal is the square root of its dot product with itself.
Page 2