From d9c21c15e5e42b0f645792e223ae422dbf764cdc Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sat, 26 Oct 2024 21:53:44 +0300 Subject: [PATCH] Improving comments. --- Graphics/3D/3dtest.bas | 181 ----------------------------------------- Graphics/3D/3dtext.bas | 27 ++++-- 2 files changed, 18 insertions(+), 190 deletions(-) delete mode 100755 Graphics/3D/3dtest.bas diff --git a/Graphics/3D/3dtest.bas b/Graphics/3D/3dtest.bas deleted file mode 100755 index 76df756..0000000 --- a/Graphics/3D/3dtest.bas +++ /dev/null @@ -1,181 +0,0 @@ -' 3D math test. -' By Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' 2003.12, Initial version -' 2024.08, Improved program readability using AI - - -DECLARE SUB Star (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) -DECLARE SUB Gp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) -DECLARE SUB Stic (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) -DECLARE SUB Gc (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat, z1AsFloat) -DECLARE SUB Gcp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) -DECLARE SUB Setan (alpAsFloat, betAsFloat, gamAsFloat) -DECLARE SUB Start () -DECLARE SUB Drawscr () - -DIM SHARED mx1AsFloat, my1AsFloat, mz1AsFloat -DIM SHARED mx2AsFloat, my2AsFloat, mz2AsFloat -DIM SHARED mx3AsFloat, my3AsFloat, mz3AsFloat - -DIM SHARED frmAsInteger, piAsDouble - -Start - -1 - -Drawscr -frmAsInteger = frmAsInteger + 1 -GOTO 1 - -SUB Drawscr - -an1AsFloat = SIN(frmAsInteger / 50) / 2 -an2AsFloat = SIN(frmAsInteger / 23) / 2 - .5 -an3AsFloat = 0 - -' Set the rotation angles -Setan an1AsFloat, an2AsFloat, an3AsFloat - -FOR xAsInteger = -100 TO 100 STEP 10 - FOR zAsInteger = 0 TO 200 STEP 10 - Gcp xAsInteger, -90, zAsInteger, x1AsFloat, y1AsFloat - PSET (x1AsFloat, y1AsFloat), 15 - NEXT zAsInteger -NEXT xAsInteger - -Gc -70, -90, 150, x1AsFloat, y1AsFloat, z1AsFloat - -' Calculate star position and draw it -Stic x1AsFloat, y1AsFloat, z1AsFloat, an1AsFloat, an2AsFloat, an3AsFloat - -' Copy screen and clear for the next frame -PCOPY 0, 1 -CLS -END SUB - -SUB Gc (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat, z1AsFloat) -x1AsFloat = xAsFloat * mx1AsFloat + yAsFloat * my1AsFloat + zAsFloat * mz1AsFloat -y1AsFloat = xAsFloat * mx2AsFloat + yAsFloat * my2AsFloat + zAsFloat * mz2AsFloat -z1AsFloat = xAsFloat * mx3AsFloat + yAsFloat * my3AsFloat + zAsFloat * mz3AsFloat -END SUB - -SUB Gcp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) - -rxAsFloat = xAsFloat * mx1AsFloat + yAsFloat * my1AsFloat + zAsFloat * mz1AsFloat ' Matrix transformation -ryAsFloat = xAsFloat * mx2AsFloat + yAsFloat * my2AsFloat + zAsFloat * mz2AsFloat -rzAsFloat = xAsFloat * mx3AsFloat + yAsFloat * my3AsFloat + zAsFloat * mz3AsFloat - -rzAsFloat = rzAsFloat + 100 ' Perspective calculation -x1AsFloat = rxAsFloat / rzAsFloat * 120 -y1AsFloat = ryAsFloat / rzAsFloat * 120 -END SUB - -SUB Gp (xAsFloat, yAsFloat, zAsFloat, x1AsFloat, y1AsFloat) -' Apply perspective calculation -rzAsFloat = zAsFloat + 100 -x1AsFloat = xAsFloat / rzAsFloat * 120 -y1AsFloat = yAsFloat / rzAsFloat * 120 -END SUB - -SUB Setan (alpAsFloat, betAsFloat, gamAsFloat) -' Calculate the rotation matrix -mx1AsFloat = SIN(gamAsFloat) * SIN(betAsFloat) * SIN(alpAsFloat) + COS(gamAsFloat) * COS(alpAsFloat) -my1AsFloat = COS(betAsFloat) * SIN(alpAsFloat) -mz1AsFloat = SIN(gamAsFloat) * COS(alpAsFloat) - COS(gamAsFloat) * SIN(betAsFloat) * SIN(alpAsFloat) - -mx2AsFloat = SIN(gamAsFloat) * SIN(betAsFloat) * COS(alpAsFloat) - COS(gamAsFloat) * SIN(alpAsFloat) -my2AsFloat = COS(betAsFloat) * COS(alpAsFloat) -mz2AsFloat = -COS(gamAsFloat) * SIN(betAsFloat) * COS(alpAsFloat) - SIN(gamAsFloat) * SIN(alpAsFloat) - -mx3AsFloat = -SIN(gamAsFloat) * COS(betAsFloat) -my3AsFloat = SIN(betAsFloat) -mz3AsFloat = COS(gamAsFloat) * COS(betAsFloat) -END SUB - -SUB Star (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) -' Calculate angles for the star points -nan1AsFloat = an1AsFloat -nan2AsFloat = an2AsFloat -nan3AsFloat = an3AsFloat - -' Set the rotation angles -Setan nan1AsFloat, nan2AsFloat, nan3AsFloat - -' Apply perspective transformation -Gp xAsFloat, yAsFloat, zAsFloat, rx1AsFloat, ry1AsFloat - -FOR nAsInteger = 0 TO piAsDouble * 2 - .1 STEP piAsDouble / 5 - x1AsFloat = SIN(nAsInteger) * 20 - y1AsFloat = COS(nAsInteger) * 20 - - ' Apply matrix transformation to the star point - Gc x1AsFloat, y1AsFloat, 0, x2AsFloat, y2AsFloat, z2AsFloat - Gp x2AsFloat + xAsFloat, y2AsFloat + yAsFloat, z2AsFloat + zAsFloat, rx2AsFloat, ry2AsFloat -CIRCLE (rx2AsFloat, ry2AsFloat), 1, 14 -LINE (rx2AsFloat, ry2AsFloat)-(rx1AsFloat, ry1AsFloat), 1 -NEXT nAsInteger - -END SUB - -SUB Start -' Set up the screen and window -SCREEN 7, , , 1 -WINDOW (-160, -100)-(160, 100) - -piAsDouble = 3.141592 - -END SUB - -SUB Stic (xAsFloat, yAsFloat, zAsFloat, an1AsFloat, an2AsFloat, an3AsFloat) -' Calculate angles for the star points -nan1AsFloat = an1AsFloat -nan2AsFloat = an2AsFloat -nan3AsFloat = an3AsFloat + frmAsInteger / 50 - -' Set the rotation angles -Setan nan1AsFloat, nan2AsFloat, nan3AsFloat - -' Apply perspective transformation -Gp xAsFloat, yAsFloat, zAsFloat, rx1AsFloat, ry1AsFloat - -DIM tmpx(0 TO 5) -DIM tmpy(0 TO 5) -DIM tmpz(0 TO 5) - -DIM tmprx(0 TO 5) -DIM tmpry(0 TO 5) -pAsInteger = 0 - -FOR nAsInteger = 0 TO piAsDouble * 2 - .5 STEP piAsDouble / 3 - x1AsFloat = SIN(nAsInteger) * 100 - z1AsFloat = COS(nAsInteger) * 100 - - ' Apply matrix transformation to the star point - Gc x1AsFloat, 100, z1AsFloat, x2AsFloat, y2AsFloat, z2AsFloat - tmpx(pAsInteger) = x2AsFloat + xAsFloat - tmpy(pAsInteger) = y2AsFloat + yAsFloat - tmpz(pAsInteger) = z2AsFloat + zAsFloat - Gp x2AsFloat + xAsFloat, y2AsFloat + yAsFloat, z2AsFloat + zAsFloat, rx2AsFloat, ry2AsFloat - tmprx(pAsInteger) = rx2AsFloat - tmpry(pAsInteger) = ry2AsFloat - LINE (rx1AsFloat, ry1AsFloat)-(rx2AsFloat, ry2AsFloat), 15 - - pAsInteger = pAsInteger + 1 -NEXT nAsInteger - -LINE (tmprx(0), tmpry(0))-(tmprx(2), tmpry(2)), 10 -LINE (tmprx(2), tmpry(2))-(tmprx(4), tmpry(4)), 10 -LINE (tmprx(4), tmpry(4))-(tmprx(0), tmpry(0)), 10 - -LINE (tmprx(1), tmpry(1))-(tmprx(3), tmpry(3)), 12 -LINE (tmprx(3), tmpry(3))-(tmprx(5), tmpry(5)), 12 -LINE (tmprx(5), tmpry(5))-(tmprx(1), tmpry(1)), 12 - -Star tmpx(0), tmpy(0), tmpz(0), nan1AsFloat, nan2AsFloat, nan3AsFloat - -END SUB - diff --git a/Graphics/3D/3dtext.bas b/Graphics/3D/3dtext.bas index ed71abc..945be4f 100755 --- a/Graphics/3D/3dtext.bas +++ b/Graphics/3D/3dtext.bas @@ -1,8 +1,21 @@ -' 3D text -' made by Svjatoslav Agejenko -' in 2003.12 -' H-Page: svjatoslav.eu -' E-Mail: svjatoslav@svjatoslav.eu +' Renders 3D text within 3D room. +' User can freely fly around the room and observe the text from different angles. +' +' By Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2003, Initial version +' 2024, Improved program readability using AI +' +' Keyboard controls: +' cursor keys and to z, w - rotate +' - slow down +' q and - quit program +' + / - - move up / down + + DECLARE SUB prn (x!, y!, a$) DECLARE SUB pch (x!, y!, a$) @@ -12,9 +25,6 @@ DECLARE SUB ruut (x!, y!, z!, s!) DECLARE SUB kuus (x, y, z, s) DECLARE SUB porand () DECLARE SUB addp (x, y, z) -' kursor keys and to z, w - rotate -' - speed down -' q - quit DECLARE SUB start () DECLARE SUB addsq (x1%, y1%, z1%) @@ -555,4 +565,3 @@ readfnt getcor END SUB - -- 2.20.1