# Solid5 4/8

``` BBS: Inland Empire Archive
Date: 03-21-93 (03:42)             Number: 354
From: RICH GELDREICH               Refer#: NONE
To: ALL                           Recvd: NO
Subj: Solid5 4/8                     Conf: (2) Quik_Bas```
```'Page 4 of SOLID5.BAS begins here.
D1 = 0: D2 = 0: D3 = 0
CASE "0"
R1 = 0: R2 = 0: R3 = 0
D1 = 0: D2 = 0: D3 = 0
CASE "+"
D3 = D3 + 2
CASE "-"
D3 = D3 - 2
CASE CHR\$(27)
END
CASE CHR\$(0) + CHR\$(72)
dz = dz - 20
CASE CHR\$(0) + CHR\$(80)
dz = dz + 20
CASE CHR\$(0) + CHR\$(77)
dx = dx - 20
CASE CHR\$(0) + CHR\$(75)
dx = dx + 20
END SELECT
LOOP

'"Culls" the polygons which aren't visible to the viewer. Also shades
'each polygon using Lambert's law.
SUB CullPolygons
'This algorithm for removing hidden faces was developed by Dave _
Cooper.
'There is another method, by finding the dot product of the
'plane's normal and the viewing vector, but this algorithm is
'much faster because of its simplicity(and lack of floating point
'calculations).
FOR a = 0 TO MaxPolys
P1 = Polys(a).P1
P2 = Polys(a).P2
P3 = Polys(a).P3

IF Points(P1).YView <= Points(P2).YView THEN
IF Points(P3).YView < Points(P1).YView THEN
PTop = P3
PNext = P1
PLast = P2
ELSE
PTop = P1
PNext = P2
PLast = P3
END IF
ELSE
IF Points(P3).YView < Points(P2).YView THEN
PTop = P3
PNext = P1
PLast = P2
ELSE
PTop = P2
PNext = P3
PLast = P1
END IF
END IF

XLow = Points(PTop).XView
YLow = Points(PTop).YView

XNext = Points(PNext).XView
XLast = Points(PLast).XView

IF XNext <= XLow AND XLast >= XLow THEN
Polys(a).Culled = True
ELSEIF XNext >= XLow AND XLast <= XLow THEN
Polys(a).Culled = False
ELSE
YNext = Points(PNext).YView
YLast = Points(PLast).YView
IF ((YNext - YLow) * 256&) \ (XNext - XLow) < ((YLast - _
YLow) * 256&) \ (XLast - XLow) THEN
Polys(a).Culled = False
ELSE
Polys(a).Culled = True
END IF
END IF

NEXT
END SUB

'Enters a line into the edge list. For each scan line, the line's
'X coordinate is found. Notice the lack of floating point math in this
'subroutine.
SUB DrawLine (xs, ys, xe, ye, EdgeList() AS EdgeType)

IF ys > ye THEN SWAP xs, xe: SWAP ys, ye

IF ye < 0 OR ys > 199 THEN EXIT SUB

IF ys < 0 THEN
xs = xs + ((xe - xs) * -ys) \ (ye - ys)
ys = 0
'Continued on page 5

--- MsgToss 2.0b
* Origin: Computer Co-Op - Voorhees, NJ | Ted Hare (1:266/29)
```

Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET