A flat polygon situated in 3-D Coordinate Space necessarily has an orientation. It faces some unique direction. An imaginary ray pointing out from the surface of the polygon, and perpendicular to that surface, is called the normal of the polygon.
As there will always be two normals, one on each side of the surface, and pointing in opposing directions, the choice of the side from which the normal projects defines the front or "face" of the polygon. In 3-D computer graphics, as opposed to the physical world, it is usual for a polygon to have only one face or side, and therefore only one normal. This is because polygons are typically used to create a closed mesh representing the surface of a 3-D object and the back side of the polygon is therefore hidden inside the object. To save render time, polygons are kept single-sided and the normal projects from only the exposed face. However, occasionally it is necessary to create double-sided polygons that have normals pointing from both sides, and which therefore can be rendered from both sides as the different sides come into view during the course of an animation. The face side of a polygon is typically established in a Model file by the order in which the vertices of the polygon are listed, clockwise or counterclockwise around the facing (normal) side.
Normals can be associated not only with the flat surfaces of the polygons, but also with the individual points that make up the vertices where polygons meet on the surface of a model. This technique is used in rendering to create the appearance of curved surfaces rather that flat, faceted sides. Such vertex normals can be directly assigned in the model file, but are usually computed during rendering by averaging the normals of the adjacent polygons. This rather subtle idea is described and illustrated in the Lesson 3 tutorial.
But what relationship does "length of its normal" have towards the polygons state/look?
I am a visual learner
Gosub Setup
Do
CX#=Camera Angle X(): CY#=Camera Angle Y(): CZ#=Camera Angle Z()
CY#=Wrapvalue(CY#+mousemovex())
CX#=Wrapvalue(CX#+mousemovey())
Rotate Camera CX#,CY#,CZ#
If MouseClick()=1 Then Move Camera 10
If MouseClick()=2 Then Move Camera -10
If Scancode() Then Normalise(1)
Sync
Center Text 400,5,"Press Any Key To Apply Normalization"
Loop
Rem **************************************************
Rem Smooth Matrix
Rem **************************************************
Smooth:
Rem Averages matrix heights to remove jagged edges
for Z=0 to 70
for X=0 to 70
P0#=Get Matrix Height(1,X,Z): Rem Current point height
Rem Get 4 adjoining points heights (if they exist)
If Z-1>=0
P1#=Get Matrix Height(1,X,Z-1)
Else
P1#=P0#
Endif
If X+1<=TilesX
P2#=Get Matrix Height(1,X+1,Z)
Else
P2#=P0#
Endif
If Z+1<=TilesZ
P3#=Get Matrix Height(1,X,Z+1)
Else
P3#=P0#
Endif
If X-1>=0
P4#=Get Matrix Height(1,X-1,Z)
Else
P4#=P0#
Endif
Average#=(P0#+P1#+P2#+P3#+P4#)/5: Rem Av height of other points
RHeight#=Average#
Set Matrix Height 1,x,z,RHeight#
Next x
Next z
Update Matrix 1
Return
Setup:
Set Display Mode 800,600,32
Sync On: Sync Rate 0: CLS 0: Sync
AutoCam Off
Set Camera Range 1.0, 100000.0
Hide Mouse
Create Bitmap 1,1024,1024
Rem ********************
Rem Matrix Texture
Rem ********************
Ink RGB(0,110,0),0
Box 0,0,1023,1023
For N=1 To 15000
Ink RGB(0,Rnd(150)+50,0),0
Dot Rnd(512),Rnd(512)
Next N
Blur Bitmap 1,1
Sync
Get Image 100,0,0,512,512,1
Sync
Rem ********************
Rem Matrix
Rem ********************
Make Matrix 1,7000,7000,70,70: Rem 1 Tile = 100
Prepare Matrix Texture 1,100,70,70
Randomize Matrix 1,2000.0
For N=1 To 40
X=Rnd(66)+2: Z=Rnd(66)+2
Set Matrix Height 1,X,Z,7000.0
Next N
For N=1 To 15
Gosub Smooth
Next N
t=1
For z=69 to 0 Step -1
For x=0 to 69
Set Matrix Tile 1,x,z,t
Inc t
Next x
Next z
Update Matrix 1
Set Current Bitmap 0
Delete Bitmap 1
Position Camera 0,3000,0
Point Camera 3500,0,3500
Ink RGB(255,255,255),0
Return
Rem *********************************************************
Rem *** FUNCTIONS ***
Rem *********************************************************
Function Normalise(MatNum)
Rem By Lee Bamber From DB Example - Adds shaded areas to matrix to give depth
For z=1 to 70
For x=1 to 70
h8#=get matrix height(MatNum,x,z-1)
h4#=get matrix height(MatNum,x-1,z)
h#=get matrix height(MatNum,x,z)
h2#=get matrix height(MatNum,x,z)
x1#=(x-1)*25.0
y1#=h#
x2#=(x+0)*25.0
y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
z1#=(z-1)*25.0
y1#=h2#
z2#=(z+0)*25.0
y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
nx#=sin(ax#)
ny#=cos(ax#)
nz#=sin(az#)
Set matrix normal MatNum,x,z,nx#,ny#,nz#
next x
next z
Update Matrix MatNum
EndFunction
sync on
make object sphere 1, 1.0
Increased = 0
do
if spacekey() = 1 and Increased = 0
Increased = 1
lock vertexdata for limb 1, 0
for i = 0 to get vertexdata vertex count()-1
set vertexdata normals i, get vertexdata normals x(i) * 1.1, get vertexdata normals y(i) * 1.1, get vertexdata normals z(i) * 1.1
next
unlock vertexdata
else
if spacekey() = 0 then Increased = 0
endif
if upkey() = 1 then SET NORMALIZATION ON
if downkey() = 1 then SET NORMALIZATION OFF
sync
loop