Document some 3D animations
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 30 May 2025 21:02:18 +0000 (00:02 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 30 May 2025 21:02:18 +0000 (00:02 +0300)
.gitignore
3D GFX/tank on the bridge.bas [deleted file]
3D GFX/tank on the bridge.webm [deleted file]
3D GFX/tank.bas [new file with mode: 0755]
3D GFX/tank.webm [new file with mode: 0644]
index.org

index dba9fbd..17a01d0 100644 (file)
@@ -9,3 +9,4 @@
 /Graphics/Spirals/index.html
 /Graphics/index.html
 /2D GFX/Animations/index.html
+/3D GFX/3D Synthezier/index.html
\ No newline at end of file
diff --git a/3D GFX/tank on the bridge.bas b/3D GFX/tank on the bridge.bas
deleted file mode 100755 (executable)
index 6b34f9f..0000000
+++ /dev/null
@@ -1,792 +0,0 @@
-' Program to render animated 3D tank that drives back and forth on the 3D bridge.
-' Notably, tracks on the tank are properly synchronized with the tank movement.
-' User can freely look and fly around in the space.
-'
-' By Svjatoslav Agejenko.
-' Email: svjatoslav@svjatoslav.eu
-' Homepage: http://www.svjatoslav.eu
-'
-' Changelog:
-' 2000, Initial version
-' 2024, Improved program readability using AI
-
-' Use keys to move around:
-' Left, Right, Up, Down   look around
-' + move forward
-' - move back
-' q quit
-' <space> - stop
-
-DECLARE SUB start ()
-DECLARE SUB savepos (x1%, y1%, x2%, y2%)
-DECLARE SUB teemaad ()
-DECLARE SUB setTracks ()
-DECLARE SUB getTracks ()
-DECLARE SUB getTracks1 (x1%, y1%, x2%, y2%)
-DECLARE SUB kiri ()
-DECLARE SUB getcor ()
-DECLARE SUB mulcor ()
-DECLARE SUB nait3d ()
-DECLARE SUB calcsin ()
-DEFINT A-Y
-DIM SHARED xn(1000), yn(1000), czn(1000) ' points transformed to on-screen coordinates
-DIM SHARED pointX(1000), pointY(1000), pointZ(1000) ' points in 3D space
-DIM SHARED Xs1(1000), Ys1(1000), Xe1(1000), Ye1(1000) ' Old rotated points
-DIM SHARED pointers1(1000), pointers2(1000)   ' Connected points
-DIM SHARED cosine&(360), sine&(360)    ' SIN & COS table
-DIM SHARED np, nl
-
-DIM SHARED Tracksx(1 TO 1000)
-DIM SHARED Tracksy(1 TO 1000)
-DIM SHARED mitTracks
-DIM SHARED smes
-
-' Pointers to the beginning of the tank tracks, this is needed to animate tank tracks
-DIM SHARED TracksBeginp ' point index
-DIM SHARED TracksBeginl ' line index
-
-' Pointers to the beginning of the bridge
-DIM SHARED BridgeBeginp    ' point index
-DIM SHARED BridgeBeginl    ' line index  
-
-DIM SHARED Tracksxp
-DIM SHARED myx, myy, myz
-DIM SHARED myxp, myyp, myzp
-
-DIM SHARED deg1, deg2, deg3
-DIM SHARED speed
-
-DIM SHARED ssu
-
-start
-
-nait3d
-
-DATA -10,-30,-20
-DATA 30,-30,-20
-DATA 30,-10,-20
-DATA -10,-10,-20
-
-DATA -10,-30,20
-DATA 30,-30,20
-DATA 30,-10,20
-DATA -10,-10,20
-
-DATA -10,-40,-15
-DATA 30,-40,-15
-DATA -10,-40,15
-DATA 30,-40,15
-
-DATA -20,-30,-15
-DATA -20,-30, 15
-
-DATA -70,-10,-50
-DATA 60,-10, -50
-DATA 70,  0, -50
-DATA 70, 20, -50
-DATA 60, 30, -50
-DATA -70,30, -50
-DATA -80,20, -50
-DATA -80, 0, -50
-
-DATA -70,-10,-30
-DATA 60,-10, -30
-DATA 70,  0, -30
-DATA 70, 20, -30
-DATA 60, 30, -30
-DATA -70,30, -30
-DATA -80,20, -30
-DATA -80, 0, -30
-
-DATA -70,-10, 50
-DATA 60,-10,  50
-DATA 70,  0,  50
-DATA 70, 20,  50
-DATA 60, 30,  50
-DATA -70,30,  50
-DATA -80,20,  50
-DATA -80, 0,  50
-
-DATA -70,-10, 30
-DATA 60,-10,  30
-DATA 70,  0,  30
-DATA 70, 20,  30
-DATA 60, 30,  30
-DATA -70,30,  30
-DATA -80,20,  30
-DATA -80, 0,  30
-
-DATA -50,-7,-30
-DATA  50,-7,-30
-DATA  50, 15,-30
-DATA -50, 15,-30
-
-DATA -50,-7, 30
-DATA  50,-7, 30
-DATA  50, 15,30
-DATA -50, 15,30
-
-DATA -20,-20,-5
-DATA -20,-20, 5
-DATA -20,-30, 5
-DATA -20,-30,-5
-
-DATA -100,-30,-5
-DATA -100,-30, 5
-DATA -100,-40, 5
-DATA -100,-40,-5
-
-DATA 999,999,999
-
-DATA 0,1
-DATA 1,2
-DATA 2,3
-DATA 3,0
-
-DATA 4,5
-DATA 5,6
-DATA 6,7
-DATA 7,4
-
-DATA 0,8
-DATA 1,9
-DATA 4,10
-DATA 5,11
-
-DATA 0,12
-DATA 4,13
-DATA 12,8
-DATA 13,10
-
-DATA 8,9
-DATA 10,11
-DATA 8,10
-DATA 9,11
-
-DATA 12,13
-DATA 12,3
-DATA 13,7
-DATA 3,7
-DATA 1,5
-DATA 2,6
-
-DATA 14,15
-DATA 15,16
-DATA 16,17
-DATA 17,18
-DATA 18,19
-DATA 19,20
-DATA 20,21
-DATA 21,14
-
-DATA 22,23
-DATA 23,24
-DATA 24,25
-DATA 25,26
-DATA 26,27
-DATA 27,28
-DATA 28,29
-DATA 29,22
-
-DATA 30,31
-DATA 31,32
-DATA 32,33
-DATA 33,34
-DATA 34,35
-DATA 35,36
-DATA 36,37
-DATA 37,30
-
-DATA 38,39
-DATA 39,40
-DATA 40,41
-DATA 41,42
-DATA 42,43
-DATA 43,44
-DATA 44,45
-DATA 45,38
-
-DATA 46,47
-DATA 47,48
-DATA 48,49
-DATA 49,46
-
-DATA 50,51
-DATA 51,52
-DATA 52,53
-DATA 53,50
-
-DATA 50,46
-DATA 51,47
-DATA 52,48
-DATA 53,49
-
-DATA 54,55
-DATA 55,56
-DATA 56,57
-DATA 57,54
-
-DATA 54,58
-DATA 55,59
-DATA 56,60
-DATA 57,61
-
-DATA 58,59
-DATA 59,60
-DATA 60,61
-DATA 61,58
-
-DATA 54,3
-DATA 55,7
-
-DATA 999, 999
-'                                                          BRIDGE
-'                                                 right handlebars
-DATA 100,0,100
-DATA 100,50,100
-
-DATA 50,0,100
-DATA 50,50,100
-
-DATA 0,0,100
-DATA 0,50,100
-
-DATA -50,0,100
-DATA -50,50,100
-
-DATA -100,0,100
-DATA -100,50,100
-                       ' 5
-DATA -150,0,100
-DATA -150,50,100
-
-DATA -200,0,100
-DATA -200,50,100
-
-DATA -250,0,100
-DATA -250,50,100
-
-DATA -300,0,100
-DATA -300,50,100
-
-DATA -350,0,100
-DATA -350,50,100
-                           ' 10
-
-DATA -400,0,100
-DATA -400,50,100
-
-DATA -450,0,100
-DATA -450,50,100
-
-DATA -500,0,100
-DATA -500,50,100
-
-DATA -550,0,100
-DATA -550,50,100
-
-DATA -600,0,100
-DATA -600,50,100
-
-DATA -650,0,100
-DATA -650,50,100
-
-                    ' left handlebars
-DATA 100,0,-100
-DATA 100,50,-100
-
-DATA 50,0,-100
-DATA 50,50,-100
-
-DATA 0,0,-100
-DATA 0,50,-100
-
-DATA -50,0,-100
-DATA -50,50,-100
-
-DATA -100,0,-100
-DATA -100,50,-100
-                       ' 5
-DATA -150,0,-100
-DATA -150,50,-100
-
-DATA -200,0,-100
-DATA -200,50,-100
-
-DATA -250,0,-100
-DATA -250,50,-100
-
-DATA -300,0,-100
-DATA -300,50,-100
-
-DATA -350,0,-100
-DATA -350,50,-100
-                           ' 10
-
-DATA -400,0,-100
-DATA -400,50,-100
-
-DATA -450,0,-100
-DATA -450,50,-100
-
-DATA -500,0,-100
-DATA -500,50,-100
-
-DATA -550,0,-100
-DATA -550,50,-100
-
-DATA -600,0,-100
-DATA -600,50,-100
-
-DATA -650,0,-100
-DATA -650,50,-100
-                '   bottom line
-DATA 100,75,-100
-DATA -650,75,-100
-
-DATA 100,75,100
-DATA -650,75,100
-                ' shore
-DATA 75,75,-100
-DATA 75,75,100
-                   'right
-DATA -50,200,-100
-DATA -50,200,100
-
-DATA  75,200,-190
-DATA  75,200, 190
-                   'left
-DATA -525,200,-100
-DATA -525,200, 100
-
-DATA -600,200,-190
-DATA -600,200, 190
-
-'
-
-DATA 999,999,999
-
-                 'right handlebars
-
-DATA 2,3
-DATA 4,5
-DATA 6,7
-DATA 8,9
-
-DATA 10,11
-DATA 12,13
-DATA 14,15
-DATA 16,17
-DATA 18,19
-
-DATA 20,21
-DATA 22,23
-DATA 24,25
-DATA 26,27
-DATA 28,29
-
-
-                   'left handlebars
-DATA 34,35
-DATA 36,37
-DATA 38,39
-DATA 40,41
-
-DATA 42,43
-DATA 44,45
-DATA 46,47
-DATA 48,49
-DATA 50,51
-
-DATA 52,53
-DATA 54,55
-DATA 56,57
-DATA 58,59
-DATA 60,61
-
-'          long features
-DATA 0,4
-DATA 4,8
-DATA 8,12
-DATA 12,16
-DATA 16,20
-DATA 20,24
-DATA 24,28
-DATA 28,30
-
-DATA 1,5
-DATA 5,9
-DATA 9,13
-DATA 13,17
-DATA 17,21
-DATA 21,25
-DATA 25,29
-DATA 29,31
-
-DATA 32,36
-DATA 36,40
-DATA 40,44
-DATA 44,48
-DATA 48,52
-DATA 52,56
-DATA 56,60
-DATA 60,62
-
-DATA 33,37
-DATA 37,41
-DATA 41,45
-DATA 45,49
-DATA 49,53
-DATA 53,57
-DATA 57,61
-DATA 61,63
-
-'
-
-'  end
-
-DATA 1,33
-DATA 31,63
-
-DATA 64,65
-DATA 66,67
-DATA 64,66
-DATA 65,67
-
-DATA 0,66
-DATA 32,64
-DATA 30,67
-DATA 62,65
-            ' shore
-DATA 68,69
-DATA 70,71
-DATA 68,70
-DATA 69,71
-
-DATA 72,70
-DATA 72,68
-
-DATA 73,71
-DATA 73,69
-           'left
-DATA 74,76
-DATA 75,77
-DATA 74,75
-
-DATA 74,65
-DATA 76,65
-
-DATA 75,67
-DATA 77,67
-
-DATA 999, 999
-
-DEFINT Z
-SUB calcsin
-' precalculating sine and cosine tables
-
-FOR a! = 0 TO 359 / 57.29577951# STEP 1 / 57.29577951#
-    cosine&(a) = INT(.5 + COS(a!) * 1024)
-    sine&(a) = INT(.5 + SIN(a!) * 1024)
-    a = a + 1
-NEXT
-CLS
-END SUB
-
-DEFSNG Z
-SUB getcor
-' Loading original points and connected points
-FOR a = 0 TO 10000
-    READ pointX(a), pointY(a), pointZ(a)
-    IF pointX(a) = 999 THEN pointX(a) = 0: pointY(a) = 0: pointZ(a) = 0: GOTO 1
-NEXT
-1
-np = a
-FOR a = 0 TO 10000
-    READ pointers1(a), pointers2(a)
-    IF pointers1(a) = 999 THEN GOTO 2
-NEXT
-2
-nl = a
-
-TracksBeginp = np
-TracksBeginl = nl
-
-' Initializing connected points
-FOR a = 1 TO 48
-pointers1(nl) = np
-np = np + 1
-pointers2(nl) = np
-np = np + 1
-nl = nl + 1
-NEXT a
-
-END SUB
-
-DEFINT Z
-SUB getTracks
-
-' Initialize the number of segments
-mitTracks = 1
-getTracks1 -70, -10, -80, 0
-getTracks1 -80, 0, -80, 20
-getTracks1 -80, 20, -70, 30
-getTracks1 -70, 30, 60, 30
-getTracks1 60, 30, 70, 20
-getTracks1 70, 20, 70, 0
-getTracks1 70, 0, 60, -10
-getTracks1 60, -10, -70, -10
-
-END SUB
-
-DEFSNG Z
-SUB getTracks1 (x1%, y1%, x2%, y2%)
-REM Calculating points for a segment
-z1 = ABS(x1 - x2)
-z2 = ABS(y2 - y1)
-mi = SQR(z1 ^ 2 + z2 ^ 2) * 1.017142857#
-
-' Calculating direction vectors
-zxp = (x1 - x2) / mi
-zyp = (y2 - y1) / mi
-zx = x1
-zy = y1
-
-FOR a = 1 TO mi
-    zx = zx - zxp
-    zy = zy + zyp
-    Tracksx(mitTracks) = zx
-    Tracksy(mitTracks) = zy
-    mitTracks = mitTracks + 1
-NEXT a
-
-END SUB
-
-
-
-DEFSNG Z
-SUB nait3d
-' Main loop to render the scene
-DO
-
-    setTracks
-
-    ' Updating rotation angles
-    deg1 = deg1 + d1
-    deg2 = deg2 + d2
-    deg3 = deg3 + d3
-
-    ' Normalizing angles
-    IF deg1 <= 0 THEN deg1 = deg1 + 360
-    IF deg2 <= 0 THEN deg2 = deg2 + 360
-    IF deg3 <= 0 THEN deg3 = deg3 + 360
-
-    IF deg1 >= 360 THEN deg1 = deg1 - 360
-    IF deg2 >= 360 THEN deg2 = deg2 - 360
-    IF deg3 >= 360 THEN deg3 = deg3 - 360
-
-    ' sine and cosine values lookup
-    c1& = cosine&(deg1)
-    s1& = sine&(deg1)
-    c2& = cosine&(deg2)
-    s2& = sine&(deg2)
-    c3& = cosine&(deg3)
-    S3& = sine&(deg3)
-
-    ' Updating tank position
-    myx = myx - (s1& * speed / 100)
-    myy = myy - (c1& * speed / 100)
-    myz = myz - (s2& * speed / 100)
-
-    ' Rotating points
-    FOR a = 0 TO np - 1
-        x1 = pointX(a) + myx
-        y1 = pointY(a) + myz
-        pz1 = pointZ(a) + myy
-
-        ' Applying rotation matrix
-        x2 = (x1 * c1& - pz1 * s1&) \ 1024
-        pz2 = (x1 * s1& + pz1 * c1&) \ 1024
-
-        y2 = (y1 * c2& - pz2 * s2&) \ 1024
-        pz3 = (y1 * s2& + pz2 * c2&) \ 1024
-
-        x3 = (y2 * c3& - x2 * S3&) \ 1024
-        y3 = (y2 * S3& + x2 * c3&) \ 1024
-
-        ' Checking if point is within view
-        IF pz3 > 10 THEN
-            xn(a) = 320 + (x3 / pz3 * 500)
-            yn(a) = 240 + (y3 / pz3 * 500)
-        ELSE
-            xn(a) = -1
-        END IF
-    NEXT
-
-    ' Drawing lines between connected points
-    FOR a1 = 0 TO nl - 1
-        f1 = pointers1(a1)
-        s1 = pointers2(a1)
-
-        xn = xn(f1)
-        yn = yn(f1)
-
-        x1 = xn(s1)
-        y1 = yn(s1)
-
-        ' Drawing lines
-        IF Xs1(a1) = -1 OR Xe1(a1) = -1 THEN
-            ELSE
-                LINE (Xs1(a1), Ys1(a1))-(Xe1(a1), Ye1(a1)), 0
-        END IF
-
-        IF x1 = -1 OR xn = -1 THEN
-            ELSE
-                LINE (x1, y1)-(xn, yn), 15
-        END IF
-
-        ' Updating old rotated points
-        Xs1(a1) = x1
-        Ys1(a1) = y1
-
-        Xe1(a1) = xn
-        Ye1(a1) = yn
-    NEXT
-
-    ' Handling user input
-    k$ = INKEY$
-    IF k$ <> "" THEN
-
-        SELECT CASE k$
-
-            CASE CHR$(0) + "M"
-                d1 = d1 - 1
-
-            CASE CHR$(0) + "K"
-                d1 = d1 + 1
-
-            CASE CHR$(0) + "P"
-                d2 = d2 + 1
-
-            CASE CHR$(0) + "H"
-                d2 = d2 - 1
-
-            CASE "w"
-                d3 = d3 - 1
-
-            CASE "z"
-                d3 = d3 + 1
-
-            CASE "-"
-                speed = speed - 1
-
-            CASE "+"
-                speed = speed + 1
-
-            CASE " "
-                d1 = 0
-                d2 = 0
-                d3 = 0
-                speed = 0
-
-            CASE CHR$(27)
-                SYSTEM
-
-        END SELECT
-        k$ = ""
-    END IF
-LOOP
-END SUB
-
-SUB setTracks
-' Updating tank position
-Tracksxp = Tracksxp + ssu
-smes = smes + ssu
-IF smes > 15 THEN smes = 1
-IF smes < 1 THEN smes = 15
-b = smes
-
-FOR a = TracksBeginp TO TracksBeginp + 48 STEP 2
-    pointX(a) = Tracksx(b) - Tracksxp
-    pointY(a) = Tracksy(b)
-    pointZ(a) = 50
-    pointX(a + 1) = Tracksx(b) - Tracksxp
-    pointY(a + 1) = Tracksy(b)
-    pointZ(a + 1) = 30
-    b = b + 15
-NEXT a
-
-b = smes
-FOR a = TracksBeginp + 48 TO TracksBeginp + 94 STEP 2
-    pointX(a) = Tracksx(b) - Tracksxp
-    pointY(a) = Tracksy(b)
-    pointZ(a) = -50
-    pointX(a + 1) = Tracksx(b) - Tracksxp
-    pointY(a + 1) = Tracksy(b)
-    pointZ(a + 1) = -30
-    b = b + 15
-NEXT a
-
-REM Moving the tank
-FOR a = 0 TO 84
-    pointX(a) = pointX(a) - ssu
-NEXT a
-
-IF pointX(84) > 0 THEN ssu = 1
-IF pointX(83) < -400 THEN ssu = -1
-
-END SUB
-
-SUB start
-' Initializing the program
-SCREEN 12
-CLS
-speed = 0
-
-deg1 = 210
-deg2 = 20
-deg3 = 90
-
-smes = 1
-Tracksxp = 0
-
-myxp = 0
-myyp = 0
-myzp = 0
-myx = 0
-myy = -300
-myz = 100
-smes = 1
-
-ssu = 1
-
-calcsin
-
-getcor
-teemaad
-getTracks
-
-END SUB
-
-SUB teemaad
-' Adding new points and connected points
-BridgeBeginl = nl
-np = np + 0
-BridgeBeginp = np
-
-5
-READ pointX(np), pointY(np), pointZ(np)
-IF pointX(np) = 999 THEN pointX(np) = 0: pointY(np) = 0: pointZ(np) = 0: GOTO 3
-np = np + 1
-GOTO 5
-
-3
-READ pointers1(nl), pointers2(nl)
-IF pointers1(nl) = 999 THEN GOTO 4
-pointers1(nl) = pointers1(nl) + BridgeBeginp
-pointers2(nl) = pointers2(nl) + BridgeBeginp
-nl = nl + 1
-GOTO 3
-4
-
-END SUB
diff --git a/3D GFX/tank on the bridge.webm b/3D GFX/tank on the bridge.webm
deleted file mode 100644 (file)
index 4d5e603..0000000
Binary files a/3D GFX/tank on the bridge.webm and /dev/null differ
diff --git a/3D GFX/tank.bas b/3D GFX/tank.bas
new file mode 100755 (executable)
index 0000000..6b34f9f
--- /dev/null
@@ -0,0 +1,792 @@
+' Program to render animated 3D tank that drives back and forth on the 3D bridge.
+' Notably, tracks on the tank are properly synchronized with the tank movement.
+' User can freely look and fly around in the space.
+'
+' By Svjatoslav Agejenko.
+' Email: svjatoslav@svjatoslav.eu
+' Homepage: http://www.svjatoslav.eu
+'
+' Changelog:
+' 2000, Initial version
+' 2024, Improved program readability using AI
+
+' Use keys to move around:
+' Left, Right, Up, Down   look around
+' + move forward
+' - move back
+' q quit
+' <space> - stop
+
+DECLARE SUB start ()
+DECLARE SUB savepos (x1%, y1%, x2%, y2%)
+DECLARE SUB teemaad ()
+DECLARE SUB setTracks ()
+DECLARE SUB getTracks ()
+DECLARE SUB getTracks1 (x1%, y1%, x2%, y2%)
+DECLARE SUB kiri ()
+DECLARE SUB getcor ()
+DECLARE SUB mulcor ()
+DECLARE SUB nait3d ()
+DECLARE SUB calcsin ()
+DEFINT A-Y
+DIM SHARED xn(1000), yn(1000), czn(1000) ' points transformed to on-screen coordinates
+DIM SHARED pointX(1000), pointY(1000), pointZ(1000) ' points in 3D space
+DIM SHARED Xs1(1000), Ys1(1000), Xe1(1000), Ye1(1000) ' Old rotated points
+DIM SHARED pointers1(1000), pointers2(1000)   ' Connected points
+DIM SHARED cosine&(360), sine&(360)    ' SIN & COS table
+DIM SHARED np, nl
+
+DIM SHARED Tracksx(1 TO 1000)
+DIM SHARED Tracksy(1 TO 1000)
+DIM SHARED mitTracks
+DIM SHARED smes
+
+' Pointers to the beginning of the tank tracks, this is needed to animate tank tracks
+DIM SHARED TracksBeginp ' point index
+DIM SHARED TracksBeginl ' line index
+
+' Pointers to the beginning of the bridge
+DIM SHARED BridgeBeginp    ' point index
+DIM SHARED BridgeBeginl    ' line index  
+
+DIM SHARED Tracksxp
+DIM SHARED myx, myy, myz
+DIM SHARED myxp, myyp, myzp
+
+DIM SHARED deg1, deg2, deg3
+DIM SHARED speed
+
+DIM SHARED ssu
+
+start
+
+nait3d
+
+DATA -10,-30,-20
+DATA 30,-30,-20
+DATA 30,-10,-20
+DATA -10,-10,-20
+
+DATA -10,-30,20
+DATA 30,-30,20
+DATA 30,-10,20
+DATA -10,-10,20
+
+DATA -10,-40,-15
+DATA 30,-40,-15
+DATA -10,-40,15
+DATA 30,-40,15
+
+DATA -20,-30,-15
+DATA -20,-30, 15
+
+DATA -70,-10,-50
+DATA 60,-10, -50
+DATA 70,  0, -50
+DATA 70, 20, -50
+DATA 60, 30, -50
+DATA -70,30, -50
+DATA -80,20, -50
+DATA -80, 0, -50
+
+DATA -70,-10,-30
+DATA 60,-10, -30
+DATA 70,  0, -30
+DATA 70, 20, -30
+DATA 60, 30, -30
+DATA -70,30, -30
+DATA -80,20, -30
+DATA -80, 0, -30
+
+DATA -70,-10, 50
+DATA 60,-10,  50
+DATA 70,  0,  50
+DATA 70, 20,  50
+DATA 60, 30,  50
+DATA -70,30,  50
+DATA -80,20,  50
+DATA -80, 0,  50
+
+DATA -70,-10, 30
+DATA 60,-10,  30
+DATA 70,  0,  30
+DATA 70, 20,  30
+DATA 60, 30,  30
+DATA -70,30,  30
+DATA -80,20,  30
+DATA -80, 0,  30
+
+DATA -50,-7,-30
+DATA  50,-7,-30
+DATA  50, 15,-30
+DATA -50, 15,-30
+
+DATA -50,-7, 30
+DATA  50,-7, 30
+DATA  50, 15,30
+DATA -50, 15,30
+
+DATA -20,-20,-5
+DATA -20,-20, 5
+DATA -20,-30, 5
+DATA -20,-30,-5
+
+DATA -100,-30,-5
+DATA -100,-30, 5
+DATA -100,-40, 5
+DATA -100,-40,-5
+
+DATA 999,999,999
+
+DATA 0,1
+DATA 1,2
+DATA 2,3
+DATA 3,0
+
+DATA 4,5
+DATA 5,6
+DATA 6,7
+DATA 7,4
+
+DATA 0,8
+DATA 1,9
+DATA 4,10
+DATA 5,11
+
+DATA 0,12
+DATA 4,13
+DATA 12,8
+DATA 13,10
+
+DATA 8,9
+DATA 10,11
+DATA 8,10
+DATA 9,11
+
+DATA 12,13
+DATA 12,3
+DATA 13,7
+DATA 3,7
+DATA 1,5
+DATA 2,6
+
+DATA 14,15
+DATA 15,16
+DATA 16,17
+DATA 17,18
+DATA 18,19
+DATA 19,20
+DATA 20,21
+DATA 21,14
+
+DATA 22,23
+DATA 23,24
+DATA 24,25
+DATA 25,26
+DATA 26,27
+DATA 27,28
+DATA 28,29
+DATA 29,22
+
+DATA 30,31
+DATA 31,32
+DATA 32,33
+DATA 33,34
+DATA 34,35
+DATA 35,36
+DATA 36,37
+DATA 37,30
+
+DATA 38,39
+DATA 39,40
+DATA 40,41
+DATA 41,42
+DATA 42,43
+DATA 43,44
+DATA 44,45
+DATA 45,38
+
+DATA 46,47
+DATA 47,48
+DATA 48,49
+DATA 49,46
+
+DATA 50,51
+DATA 51,52
+DATA 52,53
+DATA 53,50
+
+DATA 50,46
+DATA 51,47
+DATA 52,48
+DATA 53,49
+
+DATA 54,55
+DATA 55,56
+DATA 56,57
+DATA 57,54
+
+DATA 54,58
+DATA 55,59
+DATA 56,60
+DATA 57,61
+
+DATA 58,59
+DATA 59,60
+DATA 60,61
+DATA 61,58
+
+DATA 54,3
+DATA 55,7
+
+DATA 999, 999
+'                                                          BRIDGE
+'                                                 right handlebars
+DATA 100,0,100
+DATA 100,50,100
+
+DATA 50,0,100
+DATA 50,50,100
+
+DATA 0,0,100
+DATA 0,50,100
+
+DATA -50,0,100
+DATA -50,50,100
+
+DATA -100,0,100
+DATA -100,50,100
+                       ' 5
+DATA -150,0,100
+DATA -150,50,100
+
+DATA -200,0,100
+DATA -200,50,100
+
+DATA -250,0,100
+DATA -250,50,100
+
+DATA -300,0,100
+DATA -300,50,100
+
+DATA -350,0,100
+DATA -350,50,100
+                           ' 10
+
+DATA -400,0,100
+DATA -400,50,100
+
+DATA -450,0,100
+DATA -450,50,100
+
+DATA -500,0,100
+DATA -500,50,100
+
+DATA -550,0,100
+DATA -550,50,100
+
+DATA -600,0,100
+DATA -600,50,100
+
+DATA -650,0,100
+DATA -650,50,100
+
+                    ' left handlebars
+DATA 100,0,-100
+DATA 100,50,-100
+
+DATA 50,0,-100
+DATA 50,50,-100
+
+DATA 0,0,-100
+DATA 0,50,-100
+
+DATA -50,0,-100
+DATA -50,50,-100
+
+DATA -100,0,-100
+DATA -100,50,-100
+                       ' 5
+DATA -150,0,-100
+DATA -150,50,-100
+
+DATA -200,0,-100
+DATA -200,50,-100
+
+DATA -250,0,-100
+DATA -250,50,-100
+
+DATA -300,0,-100
+DATA -300,50,-100
+
+DATA -350,0,-100
+DATA -350,50,-100
+                           ' 10
+
+DATA -400,0,-100
+DATA -400,50,-100
+
+DATA -450,0,-100
+DATA -450,50,-100
+
+DATA -500,0,-100
+DATA -500,50,-100
+
+DATA -550,0,-100
+DATA -550,50,-100
+
+DATA -600,0,-100
+DATA -600,50,-100
+
+DATA -650,0,-100
+DATA -650,50,-100
+                '   bottom line
+DATA 100,75,-100
+DATA -650,75,-100
+
+DATA 100,75,100
+DATA -650,75,100
+                ' shore
+DATA 75,75,-100
+DATA 75,75,100
+                   'right
+DATA -50,200,-100
+DATA -50,200,100
+
+DATA  75,200,-190
+DATA  75,200, 190
+                   'left
+DATA -525,200,-100
+DATA -525,200, 100
+
+DATA -600,200,-190
+DATA -600,200, 190
+
+'
+
+DATA 999,999,999
+
+                 'right handlebars
+
+DATA 2,3
+DATA 4,5
+DATA 6,7
+DATA 8,9
+
+DATA 10,11
+DATA 12,13
+DATA 14,15
+DATA 16,17
+DATA 18,19
+
+DATA 20,21
+DATA 22,23
+DATA 24,25
+DATA 26,27
+DATA 28,29
+
+
+                   'left handlebars
+DATA 34,35
+DATA 36,37
+DATA 38,39
+DATA 40,41
+
+DATA 42,43
+DATA 44,45
+DATA 46,47
+DATA 48,49
+DATA 50,51
+
+DATA 52,53
+DATA 54,55
+DATA 56,57
+DATA 58,59
+DATA 60,61
+
+'          long features
+DATA 0,4
+DATA 4,8
+DATA 8,12
+DATA 12,16
+DATA 16,20
+DATA 20,24
+DATA 24,28
+DATA 28,30
+
+DATA 1,5
+DATA 5,9
+DATA 9,13
+DATA 13,17
+DATA 17,21
+DATA 21,25
+DATA 25,29
+DATA 29,31
+
+DATA 32,36
+DATA 36,40
+DATA 40,44
+DATA 44,48
+DATA 48,52
+DATA 52,56
+DATA 56,60
+DATA 60,62
+
+DATA 33,37
+DATA 37,41
+DATA 41,45
+DATA 45,49
+DATA 49,53
+DATA 53,57
+DATA 57,61
+DATA 61,63
+
+'
+
+'  end
+
+DATA 1,33
+DATA 31,63
+
+DATA 64,65
+DATA 66,67
+DATA 64,66
+DATA 65,67
+
+DATA 0,66
+DATA 32,64
+DATA 30,67
+DATA 62,65
+            ' shore
+DATA 68,69
+DATA 70,71
+DATA 68,70
+DATA 69,71
+
+DATA 72,70
+DATA 72,68
+
+DATA 73,71
+DATA 73,69
+           'left
+DATA 74,76
+DATA 75,77
+DATA 74,75
+
+DATA 74,65
+DATA 76,65
+
+DATA 75,67
+DATA 77,67
+
+DATA 999, 999
+
+DEFINT Z
+SUB calcsin
+' precalculating sine and cosine tables
+
+FOR a! = 0 TO 359 / 57.29577951# STEP 1 / 57.29577951#
+    cosine&(a) = INT(.5 + COS(a!) * 1024)
+    sine&(a) = INT(.5 + SIN(a!) * 1024)
+    a = a + 1
+NEXT
+CLS
+END SUB
+
+DEFSNG Z
+SUB getcor
+' Loading original points and connected points
+FOR a = 0 TO 10000
+    READ pointX(a), pointY(a), pointZ(a)
+    IF pointX(a) = 999 THEN pointX(a) = 0: pointY(a) = 0: pointZ(a) = 0: GOTO 1
+NEXT
+1
+np = a
+FOR a = 0 TO 10000
+    READ pointers1(a), pointers2(a)
+    IF pointers1(a) = 999 THEN GOTO 2
+NEXT
+2
+nl = a
+
+TracksBeginp = np
+TracksBeginl = nl
+
+' Initializing connected points
+FOR a = 1 TO 48
+pointers1(nl) = np
+np = np + 1
+pointers2(nl) = np
+np = np + 1
+nl = nl + 1
+NEXT a
+
+END SUB
+
+DEFINT Z
+SUB getTracks
+
+' Initialize the number of segments
+mitTracks = 1
+getTracks1 -70, -10, -80, 0
+getTracks1 -80, 0, -80, 20
+getTracks1 -80, 20, -70, 30
+getTracks1 -70, 30, 60, 30
+getTracks1 60, 30, 70, 20
+getTracks1 70, 20, 70, 0
+getTracks1 70, 0, 60, -10
+getTracks1 60, -10, -70, -10
+
+END SUB
+
+DEFSNG Z
+SUB getTracks1 (x1%, y1%, x2%, y2%)
+REM Calculating points for a segment
+z1 = ABS(x1 - x2)
+z2 = ABS(y2 - y1)
+mi = SQR(z1 ^ 2 + z2 ^ 2) * 1.017142857#
+
+' Calculating direction vectors
+zxp = (x1 - x2) / mi
+zyp = (y2 - y1) / mi
+zx = x1
+zy = y1
+
+FOR a = 1 TO mi
+    zx = zx - zxp
+    zy = zy + zyp
+    Tracksx(mitTracks) = zx
+    Tracksy(mitTracks) = zy
+    mitTracks = mitTracks + 1
+NEXT a
+
+END SUB
+
+
+
+DEFSNG Z
+SUB nait3d
+' Main loop to render the scene
+DO
+
+    setTracks
+
+    ' Updating rotation angles
+    deg1 = deg1 + d1
+    deg2 = deg2 + d2
+    deg3 = deg3 + d3
+
+    ' Normalizing angles
+    IF deg1 <= 0 THEN deg1 = deg1 + 360
+    IF deg2 <= 0 THEN deg2 = deg2 + 360
+    IF deg3 <= 0 THEN deg3 = deg3 + 360
+
+    IF deg1 >= 360 THEN deg1 = deg1 - 360
+    IF deg2 >= 360 THEN deg2 = deg2 - 360
+    IF deg3 >= 360 THEN deg3 = deg3 - 360
+
+    ' sine and cosine values lookup
+    c1& = cosine&(deg1)
+    s1& = sine&(deg1)
+    c2& = cosine&(deg2)
+    s2& = sine&(deg2)
+    c3& = cosine&(deg3)
+    S3& = sine&(deg3)
+
+    ' Updating tank position
+    myx = myx - (s1& * speed / 100)
+    myy = myy - (c1& * speed / 100)
+    myz = myz - (s2& * speed / 100)
+
+    ' Rotating points
+    FOR a = 0 TO np - 1
+        x1 = pointX(a) + myx
+        y1 = pointY(a) + myz
+        pz1 = pointZ(a) + myy
+
+        ' Applying rotation matrix
+        x2 = (x1 * c1& - pz1 * s1&) \ 1024
+        pz2 = (x1 * s1& + pz1 * c1&) \ 1024
+
+        y2 = (y1 * c2& - pz2 * s2&) \ 1024
+        pz3 = (y1 * s2& + pz2 * c2&) \ 1024
+
+        x3 = (y2 * c3& - x2 * S3&) \ 1024
+        y3 = (y2 * S3& + x2 * c3&) \ 1024
+
+        ' Checking if point is within view
+        IF pz3 > 10 THEN
+            xn(a) = 320 + (x3 / pz3 * 500)
+            yn(a) = 240 + (y3 / pz3 * 500)
+        ELSE
+            xn(a) = -1
+        END IF
+    NEXT
+
+    ' Drawing lines between connected points
+    FOR a1 = 0 TO nl - 1
+        f1 = pointers1(a1)
+        s1 = pointers2(a1)
+
+        xn = xn(f1)
+        yn = yn(f1)
+
+        x1 = xn(s1)
+        y1 = yn(s1)
+
+        ' Drawing lines
+        IF Xs1(a1) = -1 OR Xe1(a1) = -1 THEN
+            ELSE
+                LINE (Xs1(a1), Ys1(a1))-(Xe1(a1), Ye1(a1)), 0
+        END IF
+
+        IF x1 = -1 OR xn = -1 THEN
+            ELSE
+                LINE (x1, y1)-(xn, yn), 15
+        END IF
+
+        ' Updating old rotated points
+        Xs1(a1) = x1
+        Ys1(a1) = y1
+
+        Xe1(a1) = xn
+        Ye1(a1) = yn
+    NEXT
+
+    ' Handling user input
+    k$ = INKEY$
+    IF k$ <> "" THEN
+
+        SELECT CASE k$
+
+            CASE CHR$(0) + "M"
+                d1 = d1 - 1
+
+            CASE CHR$(0) + "K"
+                d1 = d1 + 1
+
+            CASE CHR$(0) + "P"
+                d2 = d2 + 1
+
+            CASE CHR$(0) + "H"
+                d2 = d2 - 1
+
+            CASE "w"
+                d3 = d3 - 1
+
+            CASE "z"
+                d3 = d3 + 1
+
+            CASE "-"
+                speed = speed - 1
+
+            CASE "+"
+                speed = speed + 1
+
+            CASE " "
+                d1 = 0
+                d2 = 0
+                d3 = 0
+                speed = 0
+
+            CASE CHR$(27)
+                SYSTEM
+
+        END SELECT
+        k$ = ""
+    END IF
+LOOP
+END SUB
+
+SUB setTracks
+' Updating tank position
+Tracksxp = Tracksxp + ssu
+smes = smes + ssu
+IF smes > 15 THEN smes = 1
+IF smes < 1 THEN smes = 15
+b = smes
+
+FOR a = TracksBeginp TO TracksBeginp + 48 STEP 2
+    pointX(a) = Tracksx(b) - Tracksxp
+    pointY(a) = Tracksy(b)
+    pointZ(a) = 50
+    pointX(a + 1) = Tracksx(b) - Tracksxp
+    pointY(a + 1) = Tracksy(b)
+    pointZ(a + 1) = 30
+    b = b + 15
+NEXT a
+
+b = smes
+FOR a = TracksBeginp + 48 TO TracksBeginp + 94 STEP 2
+    pointX(a) = Tracksx(b) - Tracksxp
+    pointY(a) = Tracksy(b)
+    pointZ(a) = -50
+    pointX(a + 1) = Tracksx(b) - Tracksxp
+    pointY(a + 1) = Tracksy(b)
+    pointZ(a + 1) = -30
+    b = b + 15
+NEXT a
+
+REM Moving the tank
+FOR a = 0 TO 84
+    pointX(a) = pointX(a) - ssu
+NEXT a
+
+IF pointX(84) > 0 THEN ssu = 1
+IF pointX(83) < -400 THEN ssu = -1
+
+END SUB
+
+SUB start
+' Initializing the program
+SCREEN 12
+CLS
+speed = 0
+
+deg1 = 210
+deg2 = 20
+deg3 = 90
+
+smes = 1
+Tracksxp = 0
+
+myxp = 0
+myyp = 0
+myzp = 0
+myx = 0
+myy = -300
+myz = 100
+smes = 1
+
+ssu = 1
+
+calcsin
+
+getcor
+teemaad
+getTracks
+
+END SUB
+
+SUB teemaad
+' Adding new points and connected points
+BridgeBeginl = nl
+np = np + 0
+BridgeBeginp = np
+
+5
+READ pointX(np), pointY(np), pointZ(np)
+IF pointX(np) = 999 THEN pointX(np) = 0: pointY(np) = 0: pointZ(np) = 0: GOTO 3
+np = np + 1
+GOTO 5
+
+3
+READ pointers1(nl), pointers2(nl)
+IF pointers1(nl) = 999 THEN GOTO 4
+pointers1(nl) = pointers1(nl) + BridgeBeginp
+pointers2(nl) = pointers2(nl) + BridgeBeginp
+nl = nl + 1
+GOTO 3
+4
+
+END SUB
diff --git a/3D GFX/tank.webm b/3D GFX/tank.webm
new file mode 100644 (file)
index 0000000..4d5e603
Binary files /dev/null and b/3D GFX/tank.webm differ
index e77f547..781692c 100644 (file)
--- a/index.org
+++ b/index.org
@@ -190,6 +190,134 @@ surface placed in 3D world.
 
 [[file:3D%20GFX/3D%20life.bas][Source code]]
 
+*3D text in a room*
+
+Wireframe 3D text hanging in a wireframe 3D room. User can look and
+fly around in all directions.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/3D text.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/3D%20text.bas][Source code]]
+
+*3D bouncing cubes on grid floor*
+
+3D wireframe cubes bouncing on a grid floor, creating an immersive and
+dynamic visual effect.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/bouncing cubes.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/bouncing%20cubes.bas][Source code]]
+
+*Attracted particles*
+
+3D simulation of particles attracted to each other. When particles get
+too close, stronger repulsive force takes over. There is also
+friction. Eventually after some bouncing, particles settle in
+equilibrium state.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/gravity particles.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/gravity%20particles.bas][Source code]]
+
+*Matrix math for rotation in 3D space*
+
+Instead of combining simple 2D rotors, pixels in this 3D space are
+rotated by using matrix multiplications.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/matrix math.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/matrix%20math.bas][Source code]]
+
+
+*Rocket simulator*
+
+Attempt to simulate rocket taking off from the surface of the earth
+and flying into space.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/rocket simulator.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/rocket%20simulator.bas][Source code]]
+
+*Screensaver to display animation of flying through the star field*
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/stars.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/stars.bas][Source code]]
+
+*Tank animation*
+
+Animated tank driving through the bridge back and forward. User can
+look and fly around in all directions.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/tank.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/tank.bas][Source code]]
+
+*tiled room*
+
+Room with some tiles on the wall and on the floor. User can freely fly
+around.
+
+#+begin_export html
+<div class="flex-center">
+  <video controls loop autoplay>
+    <source src="3D GFX/tiled room.webm" type="video/webm">
+    Your browser does not support the video tag.
+  </video>
+</div>
+#+end_export
+
+[[file:3D%20GFX/tiled%20room.bas][Source code]]
+
 
 * Misc
 :PROPERTIES: