Author Topic: Sanctum 3D World by STxAxTIC  (Read 5897 times)

0 Members and 1 Guest are viewing this topic.

Offline The Librarian

  • Moderator
  • Newbie
  • Posts: 39
Sanctum 3D World by STxAxTIC
« on: August 13, 2019, 09:53:46 pm »
Sanctum 3D World

Author: STxAxTIC
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=1600.0
Version: QB64
Tags: [3d] [graphics] [open world]

Description:
Sanctum is an open world 3D engine that makes everything from CIRCLE and LINE. Suggested left hand on "WSAD", and right hand on numeric keypad (hybrid gamer setup)... Discover heaven, discover hell, find the pyramid, find the megalith, blow up the moon, play with blocks.

Source Code:
Code: QB64: [Select]
  1. '$EXEICON:'sanctum.ico'
  2. 'REM $include:'Color32.BI'
  3.  
  4. CONST Aquamarine = _RGB32(127, 255, 212)
  5. CONST Blue = _RGB32(0, 0, 255)
  6. CONST BlueViolet = _RGB32(138, 43, 226)
  7. CONST Chocolate = _RGB32(210, 105, 30)
  8. CONST Cyan = _RGB32(0, 255, 255)
  9. CONST DarkBlue = _RGB32(0, 0, 139)
  10. CONST DarkGoldenRod = _RGB32(184, 134, 11)
  11. CONST DarkGray = _RGB32(169, 169, 169)
  12. CONST DarkKhaki = _RGB32(189, 183, 107)
  13. CONST DeepPink = _RGB32(255, 20, 147)
  14. CONST DodgerBlue = _RGB32(30, 144, 255)
  15. CONST ForestGreen = _RGB32(34, 139, 34)
  16. CONST Gray = _RGB32(128, 128, 128)
  17. CONST Green = _RGB32(0, 128, 0)
  18. CONST Indigo = _RGB32(75, 0, 130)
  19. CONST Ivory = _RGB32(255, 255, 240)
  20. CONST LightSeaGreen = _RGB32(32, 178, 170)
  21. CONST Lime = _RGB32(0, 255, 0)
  22. CONST LimeGreen = _RGB32(50, 205, 50)
  23. CONST Magenta = _RGB32(255, 0, 255)
  24. CONST PaleGoldenRod = _RGB32(238, 232, 170)
  25. CONST Purple = _RGB32(128, 0, 128)
  26. CONST Red = _RGB32(255, 0, 0)
  27. CONST RoyalBlue = _RGB32(65, 105, 225)
  28. CONST SaddleBrown = _RGB32(139, 69, 19)
  29. CONST Sienna = _RGB32(160, 82, 45)
  30. CONST SlateGray = _RGB32(112, 128, 144)
  31. CONST Snow = _RGB32(255, 250, 250)
  32. CONST Sunglow = _RGB32(255, 207, 72)
  33. CONST SunsetOrange = _RGB32(253, 94, 83)
  34. CONST Teal = _RGB32(0, 128, 128)
  35. CONST White = _RGB32(255, 255, 255)
  36. CONST Yellow = _RGB32(255, 255, 0)
  37.  
  38. ' Constants.
  39. pi = 3.1415926536
  40. ee = 2.7182818285
  41.  
  42. ' Scale.
  43. DIM bignumber AS LONG
  44. bignumber = 3000000
  45.  
  46. ' Video.
  47. 'SCREEN _NEWIMAGE(640, 480, 32)
  48. SCREEN _NEWIMAGE(800, 600, 32)
  49. 'SCREEN _NEWIMAGE(1024, 768, 32)
  50. screenwidth = _WIDTH
  51. screenheight = _HEIGHT
  52.  
  53. ' Camera orientation vectors.
  54. DIM uhat(3), vhat(3), nhat(3)
  55.  
  56. ' Basis vectors defined in three-space.
  57. DIM xhat(3), yhat(3), zhat(3)
  58. xhat(1) = 1: xhat(2) = 0: xhat(3) = 0
  59. yhat(1) = 0: yhat(2) = 1: yhat(3) = 0
  60. zhat(1) = 0: zhat(2) = 0: zhat(3) = 1
  61.  
  62. ' Group structure.
  63. TYPE VectorGroupElement
  64.     Identity AS LONG
  65.     Pointer AS LONG
  66.     Lagger AS LONG
  67.     FirstVector AS LONG
  68.     LastVector AS LONG
  69.     GroupName AS STRING * 50
  70.     Visible AS INTEGER
  71.     ForceAnimate AS INTEGER
  72.     COMFixed AS INTEGER
  73.     COMx AS SINGLE ' Center of mass
  74.     COMy AS SINGLE
  75.     COMz AS SINGLE
  76.     ROTx AS SINGLE ' Center of rotation
  77.     ROTy AS SINGLE
  78.     ROTz AS SINGLE
  79.     REVx AS SINGLE ' Revolution speed
  80.     REVy AS SINGLE
  81.     REVz AS SINGLE
  82.     DIMx AS SINGLE ' Maximum volume
  83.     DIMy AS SINGLE
  84.     DIMz AS SINGLE
  85. DIM VectorGroup(bignumber) AS VectorGroupElement
  86.  
  87. ' World vectors.
  88. DIM vec(bignumber, 3) ' Relative Position
  89. DIM vec3Dpos(bignumber, 3) ' Position
  90. DIM vec3Dvel(bignumber, 3) ' Linear velocity
  91. DIM vec3Dacc(bignumber, 3) ' Linear acceleration
  92. DIM vec3Danv(bignumber, 3) ' Angular velocity
  93. DIM vec3Dvis(bignumber) ' Visible toggle
  94. DIM vec2D(bignumber, 2) ' Projection onto 2D plane
  95. DIM vec3Dcolor(bignumber) AS LONG ' Original color
  96. DIM vec2Dcolor(bignumber) AS LONG ' Projected color
  97.  
  98. ' Clipping planes.
  99. DIM nearplane(4), farplane(4), rightplane(4), leftplane(4), topplane(4), bottomplane(4)
  100.  
  101. ' State.
  102. nearplane(4) = 1
  103. farplane(4) = -100
  104. rightplane(4) = 0 '*' fovd * (nhat(1) * rightplane(1) + nhat(2) * rightplane(2) + nhat(3) * rightplane(3))
  105. leftplane(4) = 0
  106. topplane(4) = 0
  107. bottomplane(4) = 0
  108. midscreenx = screenwidth / 2
  109. midscreeny = screenheight / 2
  110. fovd = -256
  111. numgroupvisible = 0
  112. numvectorvisible = 0
  113. groupidticker = 0
  114. vecgroupid = 0
  115. vectorindex = 0
  116. rotspeed = 1 / 33
  117. linspeed = 3 / 2
  118. timestep = .001
  119. camx = -40
  120. camy = 30
  121. camz = 40
  122. uhat(1) = -.2078192: uhat(2) = -.9781672: uhat(3) = 0
  123. vhat(1) = 0: vhat(2) = 0: vhat(3) = 1
  124. toggletimeanimate = 1
  125. toggleinvertmouse = -1
  126. togglehud = 1
  127.  
  128. ' Prime main loop.
  129. GOSUB initialize.objects
  130. GOSUB redraw
  131.  
  132. ' Begin main loop.
  133. fpstimer = INT(TIMER)
  134. fps = 0
  135.     GOSUB redraw
  136.     GOSUB mouseprocess
  137.     GOSUB keyprocess
  138.  
  139.     fps = fps + 1
  140.     tt = INT(TIMER)
  141.     IF tt = fpstimer + 1 THEN
  142.         fpstimer = tt
  143.         fpsreport = fps
  144.         fps = 0
  145.     END IF
  146.  
  147.     _DISPLAY
  148.     _KEYCLEAR
  149.     _LIMIT 30
  150.  
  151.  
  152. ' Gosubs.
  153.  
  154. redraw:
  155. GOSUB normalize.screen.vectors
  156. GOSUB calculate.clippingplanes
  157. GOSUB compute.visible.groups
  158. GOSUB plot.visible.vectors
  159.  
  160. mouseprocess:
  161. 'mx = 0
  162. 'my = 0
  163. 'DO WHILE _MOUSEINPUT
  164. '    mx = mx + _MOUSEMOVEMENTX
  165. '    my = my + _MOUSEMOVEMENTY
  166. '    IF _MOUSEWHEEL > 0 THEN GOSUB rotate.clockwise
  167. '    IF _MOUSEWHEEL < 0 THEN GOSUB rotate.counterclockwise
  168. '    IF mx > 0 THEN
  169. '        GOSUB rotate.uhat.plus: GOSUB normalize.screen.vectors
  170. '    END IF
  171. '    IF mx < 0 THEN
  172. '        GOSUB rotate.uhat.minus: GOSUB normalize.screen.vectors
  173. '    END IF
  174. '    IF my > 0 THEN
  175. '        IF toggleinvertmouse = -1 THEN
  176. '            GOSUB rotate.vhat.plus: GOSUB normalize.screen.vectors
  177. '        ELSE
  178. '            GOSUB rotate.vhat.minus: GOSUB normalize.screen.vectors
  179. '        END IF
  180. '    END IF
  181. '    IF my < 0 THEN
  182. '        IF toggleinvertmouse = -1 THEN
  183. '            GOSUB rotate.vhat.minus: GOSUB normalize.screen.vectors
  184. '        ELSE
  185. '            GOSUB rotate.vhat.plus: GOSUB normalize.screen.vectors
  186. '        END IF
  187. '    END IF
  188. '    mx = 0
  189. '    my = 0
  190. 'LOOP
  191.  
  192. keyprocess:
  193. IF _KEYDOWN(119) = -1 OR _KEYDOWN(18432) = -1 THEN GOSUB strafe.camera.nhat.minus ' w or uparrow
  194. IF _KEYDOWN(115) = -1 OR _KEYDOWN(20480) = -1 THEN GOSUB strafe.camera.nhat.plus ' s or downarrow
  195. IF _KEYDOWN(97) = -1 THEN GOSUB strafe.camera.uhat.minus ' a
  196. IF _KEYDOWN(100) = -1 THEN GOSUB strafe.camera.uhat.plus ' d
  197. IF _KEYDOWN(56) = -1 THEN GOSUB rotate.vhat.plus: GOSUB normalize.screen.vectors ' 8
  198. IF _KEYDOWN(50) = -1 THEN GOSUB rotate.vhat.minus: GOSUB normalize.screen.vectors ' 2
  199. IF _KEYDOWN(19200) = -1 OR _KEYDOWN(52) = -1 THEN GOSUB rotate.uhat.minus: GOSUB normalize.screen.vectors ' 4
  200. IF _KEYDOWN(19712) = -1 OR _KEYDOWN(54) = -1 THEN GOSUB rotate.uhat.plus: GOSUB normalize.screen.vectors ' 6
  201. IF _KEYDOWN(55) = -1 THEN GOSUB rotate.clockwise ' 7
  202. IF _KEYDOWN(57) = -1 THEN GOSUB rotate.counterclockwise ' 9
  203. IF _KEYDOWN(49) = -1 THEN GOSUB rotate.uhat.minus: GOSUB normalize.screen.vectors: GOSUB rotate.clockwise ' 1
  204. IF _KEYDOWN(51) = -1 THEN GOSUB rotate.uhat.plus: GOSUB normalize.screen.vectors: GOSUB rotate.counterclockwise ' 3
  205. IF _KEYDOWN(113) = -1 THEN GOSUB strafe.camera.vhat.minus ' q
  206. IF _KEYDOWN(101) = -1 THEN GOSUB strafe.camera.vhat.plus ' e
  207.  
  208. IF (key$ <> "") THEN
  209.     SELECT CASE key$
  210.         CASE "x"
  211.             uhat(1) = 0: uhat(2) = 1: uhat(3) = 0
  212.             vhat(1) = 0: vhat(2) = 0: vhat(3) = 1
  213.         CASE "X"
  214.             uhat(1) = 0: uhat(2) = -1: uhat(3) = 0
  215.             vhat(1) = 0: vhat(2) = 0: vhat(3) = 1
  216.         CASE "y"
  217.             uhat(1) = -1: uhat(2) = 0: uhat(3) = 0
  218.             vhat(1) = 0: vhat(2) = 0: vhat(3) = 1
  219.         CASE "Y"
  220.             uhat(1) = 1: uhat(2) = 0: uhat(3) = 0
  221.             vhat(1) = 0: vhat(2) = 0: vhat(3) = 1
  222.         CASE "z"
  223.             uhat(1) = 1: uhat(2) = 0: uhat(3) = 0
  224.             vhat(1) = 0: vhat(2) = 1: vhat(3) = 0
  225.             GOSUB normalize.screen.vectors
  226.         CASE "Z"
  227.             uhat(1) = 0: uhat(2) = 1: uhat(3) = 0
  228.             vhat(1) = 1: vhat(2) = 0: vhat(3) = 0
  229.         CASE "]"
  230.             farplane(4) = farplane(4) - 1
  231.         CASE "["
  232.             farplane(4) = farplane(4) + 1
  233.         CASE " "
  234.             togglehud = -togglehud
  235.         CASE "t"
  236.             toggletimeanimate = -toggletimeanimate
  237.         CASE "i"
  238.             toggleinvertmouse = -toggleinvertmouse
  239.         CASE "v"
  240.             OPEN "snapshot-camera.txt" FOR OUTPUT AS #1
  241.             PRINT #1, camx, camy, camz
  242.             PRINT #1, uhat(1), uhat(2), uhat(3)
  243.             PRINT #1, vhat(1), vhat(2), vhat(3)
  244.             CLOSE #1
  245.         CASE CHR$(27)
  246.             SYSTEM
  247.         CASE "n"
  248.             VectorGroup(closestgroup).COMFixed = 1
  249.             FOR vectorindex = VectorGroup(closestgroup).FirstVector TO VectorGroup(closestgroup).LastVector
  250.                 vec3Dvel(vectorindex, 1) = (RND - .5) * 200
  251.                 vec3Dvel(vectorindex, 2) = (RND - .5) * 200
  252.                 vec3Dvel(vectorindex, 3) = (RND - .5) * 200
  253.             NEXT
  254.         CASE "k"
  255.             p = VectorGroup(closestgroup).Pointer
  256.             l = VectorGroup(closestgroup).Lagger
  257.             VectorGroup(l).Pointer = p
  258.             IF (p <> -999) THEN
  259.                 VectorGroup(p).Lagger = l
  260.             END IF
  261.         CASE "b"
  262.             tilesize = 5
  263.             ' Determine last object id.
  264.             p = 1
  265.             DO
  266.                 k = VectorGroup(p).Identity
  267.                 p = VectorGroup(k).Pointer
  268.                 IF (p = -999) THEN EXIT DO
  269.             LOOP
  270.             lastobjectid = k
  271.             vectorindex = VectorGroup(lastobjectid).LastVector
  272.             ' Create new group.
  273.             groupidticker = groupidticker + 1
  274.             vecgroupid = groupidticker
  275.             VectorGroup(vecgroupid).Identity = vecgroupid
  276.             VectorGroup(vecgroupid).Pointer = -999
  277.             VectorGroup(vecgroupid).Lagger = lastobjectid
  278.             VectorGroup(vecgroupid).GroupName = "Block"
  279.             VectorGroup(vecgroupid).Visible = 0
  280.             VectorGroup(vecgroupid).COMFixed = 1
  281.             VectorGroup(vecgroupid).DIMx = tilesize / 2
  282.             VectorGroup(vecgroupid).DIMy = tilesize / 2
  283.             VectorGroup(vecgroupid).DIMz = tilesize / 2
  284.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  285.             FOR r = 1 TO 400
  286.                 vectorindex = vectorindex + 1
  287.                 vec3Dpos(vectorindex, 1) = camx + -20 * nhat(1) + (RND - .5) * tilesize
  288.                 vec3Dpos(vectorindex, 2) = camy + -20 * nhat(2) + (RND - .5) * tilesize
  289.                 vec3Dpos(vectorindex, 3) = camz + -20 * nhat(3) + (RND - .5) * tilesize
  290.                 vec3Dvis(vectorindex) = 0
  291.                 IF RND > .5 THEN
  292.                     vec3Dcolor(vectorindex) = Lime
  293.                 ELSE
  294.                     vec3Dcolor(vectorindex) = Purple
  295.                 END IF
  296.                 GOSUB integratecom
  297.             NEXT
  298.             VectorGroup(vecgroupid).LastVector = vectorindex
  299.             GOSUB calculatecom
  300.             VectorGroup(lastobjectid).Pointer = vecgroupid
  301.     END SELECT
  302.  
  303. convert:
  304. ' Convert graphics from uv-cartesian coordinates to monitor coordinates.
  305. x0 = x: y0 = y
  306. x = x0 + midscreenx
  307. y = -y0 + midscreeny
  308.  
  309. rotate.uhat.plus:
  310. uhat(1) = uhat(1) + nhat(1) * rotspeed
  311. uhat(2) = uhat(2) + nhat(2) * rotspeed
  312. uhat(3) = uhat(3) + nhat(3) * rotspeed
  313.  
  314. rotate.uhat.minus:
  315. uhat(1) = uhat(1) - nhat(1) * rotspeed
  316. uhat(2) = uhat(2) - nhat(2) * rotspeed
  317. uhat(3) = uhat(3) - nhat(3) * rotspeed
  318.  
  319. rotate.vhat.plus:
  320. vhat(1) = vhat(1) + nhat(1) * rotspeed
  321. vhat(2) = vhat(2) + nhat(2) * rotspeed
  322. vhat(3) = vhat(3) + nhat(3) * rotspeed
  323.  
  324. rotate.vhat.minus:
  325. vhat(1) = vhat(1) - nhat(1) * rotspeed
  326. vhat(2) = vhat(2) - nhat(2) * rotspeed
  327. vhat(3) = vhat(3) - nhat(3) * rotspeed
  328.  
  329. rotate.counterclockwise:
  330. v1 = vhat(1)
  331. v2 = vhat(2)
  332. v3 = vhat(3)
  333. vhat(1) = vhat(1) + uhat(1) * rotspeed
  334. vhat(2) = vhat(2) + uhat(2) * rotspeed
  335. vhat(3) = vhat(3) + uhat(3) * rotspeed
  336. uhat(1) = uhat(1) - v1 * rotspeed
  337. uhat(2) = uhat(2) - v2 * rotspeed
  338. uhat(3) = uhat(3) - v3 * rotspeed
  339.  
  340. rotate.clockwise:
  341. v1 = vhat(1)
  342. v2 = vhat(2)
  343. v3 = vhat(3)
  344. vhat(1) = vhat(1) - uhat(1) * rotspeed
  345. vhat(2) = vhat(2) - uhat(2) * rotspeed
  346. vhat(3) = vhat(3) - uhat(3) * rotspeed
  347. uhat(1) = uhat(1) + v1 * rotspeed
  348. uhat(2) = uhat(2) + v2 * rotspeed
  349. uhat(3) = uhat(3) + v3 * rotspeed
  350.  
  351. strafe.camera.uhat.plus:
  352. camx = camx + uhat(1) * linspeed
  353. camy = camy + uhat(2) * linspeed
  354. camz = camz + uhat(3) * linspeed
  355.  
  356. strafe.camera.uhat.minus:
  357. camx = camx - uhat(1) * linspeed
  358. camy = camy - uhat(2) * linspeed
  359. camz = camz - uhat(3) * linspeed
  360.  
  361. strafe.camera.vhat.plus:
  362. camx = camx + vhat(1) * linspeed
  363. camy = camy + vhat(2) * linspeed
  364. camz = camz + vhat(3) * linspeed
  365.  
  366. strafe.camera.vhat.minus:
  367. camx = camx - vhat(1) * linspeed
  368. camy = camy - vhat(2) * linspeed
  369. camz = camz - vhat(3) * linspeed
  370.  
  371. strafe.camera.nhat.plus:
  372. camx = camx + nhat(1) * linspeed
  373. camy = camy + nhat(2) * linspeed
  374. camz = camz + nhat(3) * linspeed
  375.  
  376. strafe.camera.nhat.minus:
  377. camx = camx - nhat(1) * linspeed
  378. camy = camy - nhat(2) * linspeed
  379. camz = camz - nhat(3) * linspeed
  380.  
  381. normalize.screen.vectors:
  382. uhatmag = SQR(uhat(1) * uhat(1) + uhat(2) * uhat(2) + uhat(3) * uhat(3))
  383. uhat(1) = uhat(1) / uhatmag: uhat(2) = uhat(2) / uhatmag: uhat(3) = uhat(3) / uhatmag
  384. vhatmag = SQR(vhat(1) * vhat(1) + vhat(2) * vhat(2) + vhat(3) * vhat(3))
  385. vhat(1) = vhat(1) / vhatmag: vhat(2) = vhat(2) / vhatmag: vhat(3) = vhat(3) / vhatmag
  386. uhatdotvhat = uhat(1) * vhat(1) + uhat(2) * vhat(2) + uhat(3) * vhat(3)
  387. ' The normal vector points toward the eye.
  388. nhat(1) = uhat(2) * vhat(3) - uhat(3) * vhat(2)
  389. nhat(2) = uhat(3) * vhat(1) - uhat(1) * vhat(3)
  390. nhat(3) = uhat(1) * vhat(2) - uhat(2) * vhat(1)
  391. nhatmag = SQR(nhat(1) * nhat(1) + nhat(2) * nhat(2) + nhat(3) * nhat(3))
  392. nhat(1) = nhat(1) / nhatmag: nhat(2) = nhat(2) / nhatmag: nhat(3) = nhat(3) / nhatmag
  393.  
  394. calculate.clippingplanes:
  395. ' Calculate normal vectors to all clipping planes.
  396. h2 = screenheight / 2
  397. w2 = screenwidth / 2
  398. nearplane(1) = -nhat(1)
  399. nearplane(2) = -nhat(2)
  400. nearplane(3) = -nhat(3)
  401. farplane(1) = nhat(1)
  402. farplane(2) = nhat(2)
  403. farplane(3) = nhat(3)
  404. rightplane(1) = h2 * fovd * uhat(1) - h2 * w2 * nhat(1)
  405. rightplane(2) = h2 * fovd * uhat(2) - h2 * w2 * nhat(2)
  406. rightplane(3) = h2 * fovd * uhat(3) - h2 * w2 * nhat(3)
  407. mag = SQR(rightplane(1) * rightplane(1) + rightplane(2) * rightplane(2) + rightplane(3) * rightplane(3))
  408. rightplane(1) = rightplane(1) / mag
  409. rightplane(2) = rightplane(2) / mag
  410. rightplane(3) = rightplane(3) / mag
  411. leftplane(1) = -h2 * fovd * uhat(1) - h2 * w2 * nhat(1)
  412. leftplane(2) = -h2 * fovd * uhat(2) - h2 * w2 * nhat(2)
  413. leftplane(3) = -h2 * fovd * uhat(3) - h2 * w2 * nhat(3)
  414. mag = SQR(leftplane(1) * leftplane(1) + leftplane(2) * leftplane(2) + leftplane(3) * leftplane(3))
  415. leftplane(1) = leftplane(1) / mag
  416. leftplane(2) = leftplane(2) / mag
  417. leftplane(3) = leftplane(3) / mag
  418. topplane(1) = w2 * fovd * vhat(1) - h2 * w2 * nhat(1)
  419. topplane(2) = w2 * fovd * vhat(2) - h2 * w2 * nhat(2)
  420. topplane(3) = w2 * fovd * vhat(3) - h2 * w2 * nhat(3)
  421. mag = SQR(topplane(1) * topplane(1) + topplane(2) * topplane(2) + topplane(3) * topplane(3))
  422. topplane(1) = topplane(1) / mag
  423. topplane(2) = topplane(2) / mag
  424. topplane(3) = topplane(3) / mag
  425. bottomplane(1) = -w2 * fovd * vhat(1) - h2 * w2 * nhat(1)
  426. bottomplane(2) = -w2 * fovd * vhat(2) - h2 * w2 * nhat(2)
  427. bottomplane(3) = -w2 * fovd * vhat(3) - h2 * w2 * nhat(3)
  428. mag = SQR(bottomplane(1) * bottomplane(1) + bottomplane(2) * bottomplane(2) + bottomplane(3) * bottomplane(3))
  429. bottomplane(1) = bottomplane(1) / mag
  430. bottomplane(2) = bottomplane(2) / mag
  431. bottomplane(3) = bottomplane(3) / mag
  432.  
  433. compute.visible.groups:
  434. closestdist2 = 10000000
  435. closestgroup = 1
  436. fp42 = farplane(4) * farplane(4)
  437.  
  438. k = 1
  439. k = VectorGroup(k).Identity
  440. DO ' iterates k
  441.  
  442.     VectorGroup(k).Visible = 0
  443.  
  444.     dx = VectorGroup(k).COMx - camx
  445.     dy = VectorGroup(k).COMy - camy
  446.     dz = VectorGroup(k).COMz - camz
  447.  
  448.     dist2 = dx * dx + dy * dy + dz * dz
  449.  
  450.     IF dist2 < fp42 THEN
  451.  
  452.         groupinview = 1
  453.         IF dx * nearplane(1) + dy * nearplane(2) + dz * nearplane(3) - nearplane(4) < 0 THEN groupinview = 0
  454.         'IF dx * farplane(1) + dy * farplane(2) + dz * farplane(3) - farplane(4) < 0 THEN groupinview = 0
  455.         IF dx * rightplane(1) + dy * rightplane(2) + dz * rightplane(3) - rightplane(4) < 0 THEN groupinview = 0
  456.         IF dx * leftplane(1) + dy * leftplane(2) + dz * leftplane(3) - leftplane(4) < 0 THEN groupinview = 0
  457.         IF dx * topplane(1) + dy * topplane(2) + dz * topplane(3) - topplane(4) < 0 THEN groupinview = 0
  458.         IF dx * bottomplane(1) + dy * bottomplane(2) + dz * bottomplane(3) - bottomplane(4) < 0 THEN groupinview = 0
  459.         IF groupinview = 1 THEN
  460.  
  461.             IF (dist2 < closestdist2) THEN
  462.                 closestdist2 = dist2
  463.                 closestgroup = k
  464.             END IF
  465.  
  466.             VectorGroup(k).Visible = 1
  467.  
  468.             IF (toggletimeanimate = 1) THEN
  469.                 vecgroupid = k
  470.                 GOSUB timeanimate
  471.             END IF
  472.  
  473.             FOR i = VectorGroup(k).FirstVector TO VectorGroup(k).LastVector
  474.                 GOSUB clip.project.vectors
  475.             NEXT
  476.  
  477.         ELSE
  478.             ' Force animation regardless of clipping.
  479.             IF (VectorGroup(k).ForceAnimate = 1) THEN
  480.                 vecgroupid = k
  481.                 GOSUB timeanimate
  482.             END IF
  483.         END IF
  484.     ELSE
  485.         ' Force animation regardless of distance from camera.
  486.         IF (VectorGroup(k).ForceAnimate = 1) THEN
  487.             vecgroupid = k
  488.             GOSUB timeanimate
  489.         END IF
  490.     END IF
  491.     k = VectorGroup(k).Pointer
  492.     IF k = -999 THEN EXIT DO
  493.     k = VectorGroup(k).Identity
  494.  
  495. clip.project.vectors: ' requires i
  496. vec(i, 1) = vec3Dpos(i, 1) - camx
  497. vec(i, 2) = vec3Dpos(i, 2) - camy
  498. vec(i, 3) = vec3Dpos(i, 3) - camz
  499. fogswitch = -1
  500. vec3Dvis(i) = 0
  501. vectorinview = 1
  502. ' Perform view plane clipping.
  503. IF vec(i, 1) * nearplane(1) + vec(i, 2) * nearplane(2) + vec(i, 3) * nearplane(3) - nearplane(4) < 0 THEN vectorinview = 0
  504. IF vec(i, 1) * farplane(1) + vec(i, 2) * farplane(2) + vec(i, 3) * farplane(3) - farplane(4) < 0 THEN vectorinview = 0
  505. IF vec(i, 1) * farplane(1) + vec(i, 2) * farplane(2) + vec(i, 3) * farplane(3) - farplane(4) * .85 < 0 THEN fogswitch = 1
  506. IF vec(i, 1) * rightplane(1) + vec(i, 2) * rightplane(2) + vec(i, 3) * rightplane(3) - rightplane(4) < 0 THEN vectorinview = 0
  507. IF vec(i, 1) * leftplane(1) + vec(i, 2) * leftplane(2) + vec(i, 3) * leftplane(3) - leftplane(4) < 0 THEN vectorinview = 0
  508. IF vec(i, 1) * topplane(1) + vec(i, 2) * topplane(2) + vec(i, 3) * topplane(3) - topplane(4) < 0 THEN vectorinview = 0
  509. IF vec(i, 1) * bottomplane(1) + vec(i, 2) * bottomplane(2) + vec(i, 3) * bottomplane(3) - bottomplane(4) < 0 THEN vectorinview = 0
  510. IF vectorinview = 1 THEN
  511.     vec3Dvis(i) = 1
  512.     ' Project vectors onto the screen plane.
  513.     vec3Ddotnhat = vec(i, 1) * nhat(1) + vec(i, 2) * nhat(2) + vec(i, 3) * nhat(3)
  514.     vec2D(i, 1) = (vec(i, 1) * uhat(1) + vec(i, 2) * uhat(2) + vec(i, 3) * uhat(3)) * fovd / vec3Ddotnhat
  515.     vec2D(i, 2) = (vec(i, 1) * vhat(1) + vec(i, 2) * vhat(2) + vec(i, 3) * vhat(3)) * fovd / vec3Ddotnhat
  516.     IF fogswitch = 1 THEN vec2Dcolor(i) = Gray ELSE vec2Dcolor(i) = vec3Dcolor(i)
  517.  
  518. timeanimate: ' requires vecgroupid
  519. dt = timestep
  520.  
  521. xcom = VectorGroup(vecgroupid).COMx
  522. ycom = VectorGroup(vecgroupid).COMy
  523. zcom = VectorGroup(vecgroupid).COMz
  524. xrot = VectorGroup(vecgroupid).ROTx
  525. yrot = VectorGroup(vecgroupid).ROTy
  526. zrot = VectorGroup(vecgroupid).ROTz
  527. xrev = VectorGroup(vecgroupid).ROTx
  528. yrev = VectorGroup(vecgroupid).ROTy
  529. zrev = VectorGroup(vecgroupid).ROTz
  530. xdim = VectorGroup(vecgroupid).DIMx
  531. ydim = VectorGroup(vecgroupid).DIMy
  532. zdim = VectorGroup(vecgroupid).DIMz
  533.  
  534. IF (VectorGroup(vecgroupid).COMFixed = 0) THEN GOSUB resetcom
  535.  
  536. FOR vectorindex = VectorGroup(vecgroupid).FirstVector TO VectorGroup(vecgroupid).LastVector
  537.  
  538.     ' Linear velocity update
  539.     ax = vec3Dacc(vectorindex, 1)
  540.     ay = vec3Dacc(vectorindex, 2)
  541.     az = vec3Dacc(vectorindex, 3)
  542.     IF (ax <> 0) THEN vec3Dvel(vectorindex, 1) = vec3Dvel(vectorindex, 1) + ax * dt
  543.     IF (ay <> 0) THEN vec3Dvel(vectorindex, 2) = vec3Dvel(vectorindex, 2) + ay * dt
  544.     IF (az <> 0) THEN vec3Dvel(vectorindex, 3) = vec3Dvel(vectorindex, 3) + az * dt
  545.  
  546.     ' Linear position update with periodic boundaries inside group dimension
  547.     vx = vec3Dvel(vectorindex, 1)
  548.     vy = vec3Dvel(vectorindex, 2)
  549.     vz = vec3Dvel(vectorindex, 3)
  550.     IF (vx <> 0) THEN
  551.         px = vec3Dpos(vectorindex, 1) + vx * dt
  552.         IF ABS(px - xcom) > xdim THEN
  553.             IF (px > xcom) THEN
  554.                 px = xcom - xdim
  555.             ELSE
  556.                 px = xcom + xdim
  557.             END IF
  558.         END IF
  559.         vec3Dpos(vectorindex, 1) = px
  560.     END IF
  561.     IF (vy <> 0) THEN
  562.         py = vec3Dpos(vectorindex, 2) + vy * dt
  563.         IF ABS(py - ycom) > ydim THEN
  564.             IF (py > ycom) THEN
  565.                 py = ycom - ydim
  566.             ELSE
  567.                 py = ycom + ydim
  568.             END IF
  569.         END IF
  570.         vec3Dpos(vectorindex, 2) = py
  571.     END IF
  572.     IF (vz <> 0) THEN
  573.         pz = vec3Dpos(vectorindex, 3) + vz * dt
  574.         IF ABS(pz - zcom) > zdim THEN
  575.             IF (pz > zcom) THEN
  576.                 pz = zcom - zdim
  577.             ELSE
  578.                 pz = zcom + zdim
  579.             END IF
  580.         END IF
  581.         vec3Dpos(vectorindex, 3) = pz
  582.     END IF
  583.  
  584.     ' Rotation update
  585.     IF (xrot <> 0) THEN
  586.         anv = vec3Danv(vectorindex, 1)
  587.         yy = vec3Dpos(vectorindex, 2) - yrot
  588.         zz = vec3Dpos(vectorindex, 3) - zrot
  589.         y = yy * COS(timestep * anv) - zz * SIN(timestep * anv)
  590.         z = yy * SIN(timestep * anv) + zz * COS(timestep * anv)
  591.         vec3Dpos(vectorindex, 2) = y + yrot
  592.         vec3Dpos(vectorindex, 3) = z + zrot
  593.     END IF
  594.     IF (yrot <> 0) THEN
  595.         anv = vec3Danv(vectorindex, 2)
  596.         xx = vec3Dpos(vectorindex, 1) - xrot
  597.         zz = vec3Dpos(vectorindex, 3) - zrot
  598.         x = xx * COS(timestep * anv) + zz * SIN(timestep * anv)
  599.         z = -xx * SIN(timestep * anv) + zz * COS(timestep * anv)
  600.         vec3Dpos(vectorindex, 1) = x + xrot
  601.         vec3Dpos(vectorindex, 3) = z + zrot
  602.     END IF
  603.     IF (zrot <> 0) THEN
  604.         anv = vec3Danv(vectorindex, 3)
  605.         xx = vec3Dpos(vectorindex, 1) - xrot
  606.         yy = vec3Dpos(vectorindex, 2) - yrot
  607.         x = xx * COS(timestep * anv) - yy * SIN(timestep * anv)
  608.         y = xx * SIN(timestep * anv) + yy * COS(timestep * anv)
  609.         vec3Dpos(vectorindex, 1) = x + xrot
  610.         vec3Dpos(vectorindex, 2) = y + yrot
  611.     END IF
  612.  
  613.     ' Revolution update
  614.     IF (xrev <> 0) THEN
  615.         anv = xrev
  616.         yy = vec3Dpos(vectorindex, 2) - ycom
  617.         zz = vec3Dpos(vectorindex, 3) - zcom
  618.         y = yy * COS(timestep * anv) - zz * SIN(timestep * anv)
  619.         z = yy * SIN(timestep * anv) + zz * COS(timestep * anv)
  620.         vec3Dpos(vectorindex, 2) = y + ycom
  621.         vec3Dpos(vectorindex, 3) = z + zcom
  622.     END IF
  623.     IF (yrev <> 0) THEN
  624.         anv = yrev
  625.         xx = vec3Dpos(vectorindex, 1) - xcom
  626.         zz = vec3Dpos(vectorindex, 3) - zcom
  627.         x = xx * COS(timestep * anv) + zz * SIN(timestep * anv)
  628.         z = -xx * SIN(timestep * anv) + zz * COS(timestep * anv)
  629.         vec3Dpos(vectorindex, 1) = x + xcom
  630.         vec3Dpos(vectorindex, 3) = z + zcom
  631.     END IF
  632.     IF (zrev <> 0) THEN
  633.         anv = zrev
  634.         xx = vec3Dpos(vectorindex, 1) - xcom
  635.         yy = vec3Dpos(vectorindex, 2) - ycom
  636.         x = xx * COS(timestep * anv) - yy * SIN(timestep * anv)
  637.         y = xx * SIN(timestep * anv) + yy * COS(timestep * anv)
  638.         vec3Dpos(vectorindex, 1) = x + xcom
  639.         vec3Dpos(vectorindex, 2) = y + ycom
  640.     END IF
  641.  
  642.     IF (VectorGroup(vecgroupid).COMFixed = 0) THEN GOSUB integratecom
  643. IF (VectorGroup(vecgroupid).COMFixed = 0) THEN GOSUB calculatecom
  644.  
  645. integratecom: ' requires vecgroupid
  646. VectorGroup(vecgroupid).COMx = vec3Dpos(vectorindex, 1) + VectorGroup(vecgroupid).COMx
  647. VectorGroup(vecgroupid).COMy = vec3Dpos(vectorindex, 2) + VectorGroup(vecgroupid).COMy
  648. VectorGroup(vecgroupid).COMz = vec3Dpos(vectorindex, 3) + VectorGroup(vecgroupid).COMz
  649.  
  650. calculatecom: ' requires vecgroupid
  651. f = 1 + VectorGroup(vecgroupid).LastVector - VectorGroup(vecgroupid).FirstVector
  652. VectorGroup(vecgroupid).COMx = VectorGroup(vecgroupid).COMx / f
  653. VectorGroup(vecgroupid).COMy = VectorGroup(vecgroupid).COMy / f
  654. VectorGroup(vecgroupid).COMz = VectorGroup(vecgroupid).COMz / f
  655.  
  656. resetcom: ' requires vecgroupid
  657. VectorGroup(vecgroupid).COMx = 0
  658. VectorGroup(vecgroupid).COMy = 0
  659. VectorGroup(vecgroupid).COMz = 0
  660.  
  661. plot.visible.vectors:
  662. GOSUB plot.vectors
  663. GOSUB plot.hud
  664.  
  665. plot.vectors:
  666. numgroupvisible = 0
  667. numvectorvisible = 0
  668. k = 1
  669. k = VectorGroup(k).Identity
  670.     IF (VectorGroup(k).Visible = 1) THEN
  671.         numgroupvisible = numgroupvisible + 1
  672.         FOR i = VectorGroup(k).FirstVector TO VectorGroup(k).LastVector - 1
  673.             IF (vec3Dvis(i) = 1) THEN
  674.                 numvectorvisible = numvectorvisible + 1
  675.                 IF k = closestgroup THEN col = Yellow ELSE col = vec2Dcolor(i)
  676.                 x = vec2D(i, 1): y = vec2D(i, 2): GOSUB convert: x1 = x: y1 = y
  677.                 x = vec2D(i + 1, 1): y = vec2D(i + 1, 2): GOSUB convert: x2 = x: y2 = y
  678.                 IF ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) < 225 THEN
  679.                     LINE (x1, y1)-(x2, y2), col
  680.                 ELSE
  681.                     CIRCLE (x1, y1), 1, col
  682.                 END IF
  683.             END IF
  684.         NEXT
  685.     END IF
  686.     k = VectorGroup(k).Pointer
  687.     IF k = -999 THEN EXIT DO
  688.     k = VectorGroup(k).Identity
  689.  
  690. plot.hud:
  691. ' Redraw compass.
  692. x = 30 * (xhat(1) * uhat(1) + xhat(2) * uhat(2) + xhat(3) * uhat(3)): y = 30 * (xhat(1) * vhat(1) + xhat(2) * vhat(2) + xhat(3) * vhat(3)): GOSUB convert
  693. LINE (midscreenx, midscreeny)-(x, y), Red
  694. x = 30 * (yhat(1) * uhat(1) + yhat(2) * uhat(2) + yhat(3) * uhat(3)): y = 30 * (yhat(1) * vhat(1) + yhat(2) * vhat(2) + yhat(3) * vhat(3)): GOSUB convert
  695. LINE (midscreenx, midscreeny)-(x, y), Green
  696. x = 30 * (zhat(1) * uhat(1) + zhat(2) * uhat(2) + zhat(3) * uhat(3)): y = 30 * (zhat(1) * vhat(1) + zhat(2) * vhat(2) + zhat(3) * vhat(3)): GOSUB convert
  697. LINE (midscreenx, midscreeny)-(x, y), Blue
  698. IF togglehud = 1 THEN
  699.     COLOR LimeGreen
  700.     LOCATE 2, 2: PRINT "- View Info -"
  701.     COLOR DarkKhaki
  702.     LOCATE 3, 2: PRINT "FPS:"; fpsreport
  703.     LOCATE 4, 2: PRINT "Vectors:"; numvectorvisible
  704.     LOCATE 5, 2: PRINT "Groups:"; numgroupvisible
  705.     LOCATE 6, 2: PRINT "Depth:"; -farplane(4)
  706.     LOCATE 7, 2: PRINT "Adjust via [ ]"
  707.     COLOR LimeGreen
  708.     LOCATE 9, 2: PRINT "- Camera -"
  709.     COLOR DarkKhaki
  710.     LOCATE 10, 2: PRINT INT(camx); INT(camy); INT(camz)
  711.     COLOR LimeGreen
  712.     LOCATE 12, 2: PRINT "- Closest: -"
  713.     COLOR DarkKhaki
  714.     LOCATE 13, 2: PRINT LTRIM$(RTRIM$(VectorGroup(closestgroup).GroupName))
  715.     COLOR LimeGreen
  716.     a$ = "MOVE - ALIGN": LOCATE 2, screenwidth / 8 - LEN(a$): PRINT a$
  717.     COLOR DarkKhaki
  718.     a$ = "q w e - x y z": LOCATE 3, screenwidth / 8 - LEN(a$): PRINT a$
  719.     a$ = "a s d - X Y Z": LOCATE 4, screenwidth / 8 - LEN(a$): PRINT a$
  720.     a$ = "i = invert ms": LOCATE 5, screenwidth / 8 - LEN(a$): PRINT a$
  721.     COLOR LimeGreen
  722.     a$ = "- ROTATE -": LOCATE 7, screenwidth / 8 - LEN(a$): PRINT a$
  723.     COLOR DarkKhaki
  724.     a$ = "7 8 9 Mouse": LOCATE 8, screenwidth / 8 - LEN(a$): PRINT a$
  725.     a$ = "4 5 6   +  ": LOCATE 9, screenwidth / 8 - LEN(a$): PRINT a$
  726.     a$ = "1 2 3 Wheel": LOCATE 10, screenwidth / 8 - LEN(a$): PRINT a$
  727.     COLOR LimeGreen
  728.     a$ = "- CONTROL -": LOCATE 12, screenwidth / 8 - LEN(a$): PRINT a$
  729.     COLOR DarkKhaki
  730.     a$ = "t = Stop time": LOCATE 13, screenwidth / 8 - LEN(a$): PRINT a$
  731.     a$ = "b = Create": LOCATE 14, screenwidth / 8 - LEN(a$): PRINT a$
  732.     a$ = "n = Destroy": LOCATE 15, screenwidth / 8 - LEN(a$): PRINT a$
  733.     a$ = "k = Delete": LOCATE 16, screenwidth / 8 - LEN(a$): PRINT a$
  734.     COLOR LimeGreen
  735.     a$ = "SPACE = Hide Info": LOCATE (screenheight / 16) - 3, (screenwidth / 8) / 2 - LEN(a$) / 2: PRINT a$
  736.     COLOR LimeGreen
  737.     a$ = "You See: " + LTRIM$(RTRIM$(VectorGroup(closestgroup).GroupName)): LOCATE (screenheight / 16) - 3, (screenwidth / 8) / 2 - LEN(a$) / 2: PRINT a$
  738.  
  739. 'groupidfromname: ' requires n$, returns k
  740. 'k = 1
  741. 'k = VectorGroup(k).Identity
  742. 'DO ' iterates k
  743. '    IF n$ = LTRIM$(RTRIM$(VectorGroup(k).GroupName)) THEN EXIT DO
  744. '    k = VectorGroup(k).Pointer
  745. '    IF k = -999 THEN EXIT DO
  746. '    k = VectorGroup(k).Identity
  747. 'LOOP
  748. 'RETURN
  749.  
  750. ' Data.
  751.  
  752. initialize.objects:
  753. vectorindex = 0
  754. groupidticker = 0
  755. gridsize = 550
  756. tilesize = 15
  757.  
  758. '__AAA
  759. groupidticker = groupidticker + 1
  760. vecgroupid = groupidticker
  761. VectorGroup(vecgroupid).Identity = vecgroupid
  762. VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  763. VectorGroup(vecgroupid).Lagger = vecgroupid - 1 ' Fancy way to say 0.
  764. VectorGroup(vecgroupid).GroupName = "__AAA"
  765. VectorGroup(vecgroupid).Visible = 0
  766. VectorGroup(vecgroupid).COMFixed = 1
  767. VectorGroup(vecgroupid).DIMx = 5
  768. VectorGroup(vecgroupid).DIMy = 5
  769. VectorGroup(vecgroupid).DIMz = 5
  770. VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  771. FOR r = 1 TO 1
  772.     vectorindex = vectorindex + 1
  773.     vec3Dpos(vectorindex, 1) = 0
  774.     vec3Dpos(vectorindex, 2) = 0
  775.     vec3Dpos(vectorindex, 3) = -1000
  776.     vec3Dcolor(vectorindex) = White
  777.     GOSUB integratecom
  778. VectorGroup(vecgroupid).LastVector = vectorindex
  779. GOSUB calculatecom
  780.  
  781. 'Dirt
  782. h = 5
  783. FOR w = 1 TO 5
  784.     FOR u = -gridsize TO gridsize STEP tilesize
  785.         FOR v = -gridsize TO gridsize STEP tilesize
  786.             groupidticker = groupidticker + 1
  787.             vecgroupid = groupidticker
  788.             VectorGroup(vecgroupid).Identity = vecgroupid
  789.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  790.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  791.             VectorGroup(vecgroupid).GroupName = "Dirt"
  792.             VectorGroup(vecgroupid).Visible = 0
  793.             VectorGroup(vecgroupid).COMFixed = 1
  794.             VectorGroup(vecgroupid).DIMx = 35
  795.             VectorGroup(vecgroupid).DIMy = 35
  796.             VectorGroup(vecgroupid).DIMz = 35
  797.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  798.             FOR i = u TO u + tilesize STEP h
  799.                 FOR j = v TO v + tilesize STEP h
  800.                     IF RND > 1 - w / 5 THEN
  801.                         vectorindex = vectorindex + 1
  802.                         vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  803.                         vec3Dpos(vectorindex, 2) = j + RND * h - RND * h
  804.                         vec3Dpos(vectorindex, 3) = -(w - 1) * 70 - RND * 70
  805.                         vec3Dvis(vectorindex) = 0
  806.                         IF RND > .5 THEN
  807.                             vec3Dcolor(vectorindex) = DarkGoldenRod
  808.                         ELSE
  809.                             IF RND > .5 THEN
  810.                                 vec3Dcolor(vectorindex) = SaddleBrown
  811.                             ELSE
  812.                                 vec3Dcolor(vectorindex) = Sienna
  813.                             END IF
  814.                         END IF
  815.                         GOSUB integratecom
  816.                     END IF
  817.                 NEXT
  818.             NEXT
  819.             VectorGroup(vecgroupid).LastVector = vectorindex
  820.             GOSUB calculatecom
  821.         NEXT
  822.     NEXT
  823.  
  824. 'Grass and Puddles
  825. h = 2
  826. FOR u = -gridsize TO gridsize STEP tilesize
  827.     FOR v = -gridsize TO gridsize STEP tilesize
  828.         groupidticker = groupidticker + 1
  829.         vecgroupid = groupidticker
  830.         VectorGroup(vecgroupid).Identity = vecgroupid
  831.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  832.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  833.         VectorGroup(vecgroupid).GroupName = "Grass and Puddles"
  834.         VectorGroup(vecgroupid).Visible = 0
  835.         VectorGroup(vecgroupid).COMFixed = 1
  836.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  837.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  838.         VectorGroup(vecgroupid).DIMz = 3
  839.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  840.         FOR i = u TO u + tilesize STEP h
  841.             FOR j = v TO v + tilesize STEP h
  842.                 vectorindex = vectorindex + 1
  843.                 vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  844.                 vec3Dpos(vectorindex, 2) = j + RND * h - RND * h
  845.                 vec3Dpos(vectorindex, 3) = .5 + 1 * COS((i - 15) * .08) - 1 * COS((j - 6) * .12)
  846.                 vec3Dvis(vectorindex) = 0
  847.                 IF vec3Dpos(vectorindex, 3) > 0 THEN
  848.                     IF RND > .5 THEN
  849.                         vec3Dcolor(vectorindex) = Green
  850.                     ELSE
  851.                         vec3Dcolor(vectorindex) = ForestGreen
  852.                     END IF
  853.                 ELSE
  854.                     vec3Dvel(vectorindex, 1) = (RND - .5) * 20
  855.                     vec3Dvel(vectorindex, 2) = (RND - .5) * 20
  856.                     vec3Dvel(vectorindex, 3) = (RND - .5) * 20
  857.                     IF RND > .2 THEN
  858.                         vec3Dcolor(vectorindex) = LightSeaGreen
  859.                     ELSE
  860.                         vec3Dcolor(vectorindex) = Blue
  861.                     END IF
  862.                 END IF
  863.                 GOSUB integratecom
  864.             NEXT
  865.         NEXT
  866.         VectorGroup(vecgroupid).LastVector = vectorindex
  867.         GOSUB calculatecom
  868.     NEXT
  869.  
  870. 'Grave
  871. thickness = 2.5
  872. span = 20
  873. height = 30
  874. crux = 22
  875. FOR xloc = -90 TO -290 STEP -60
  876.     FOR yloc = 0 TO 180 STEP 45
  877.         FOR k = 0 TO height
  878.             groupidticker = groupidticker + 1
  879.             vecgroupid = groupidticker
  880.             VectorGroup(vecgroupid).Identity = vecgroupid
  881.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  882.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  883.             VectorGroup(vecgroupid).GroupName = "Grave"
  884.             VectorGroup(vecgroupid).Visible = 0
  885.             VectorGroup(vecgroupid).COMFixed = 1
  886.             VectorGroup(vecgroupid).DIMx = thickness
  887.             VectorGroup(vecgroupid).DIMy = thickness
  888.             VectorGroup(vecgroupid).DIMz = thickness
  889.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  890.             FOR i = -thickness TO thickness STEP thickness / 2
  891.                 FOR j = -thickness TO thickness STEP thickness / 2
  892.                     vectorindex = vectorindex + 1
  893.                     vec3Dpos(vectorindex, 1) = xloc + i + (RND - .5) * 2
  894.                     vec3Dpos(vectorindex, 2) = yloc + j + (RND - .5) * 2
  895.                     vec3Dpos(vectorindex, 3) = k + (RND - .5) * 2
  896.                     vec3Dvis(vectorindex) = 0
  897.                     IF RND > .5 THEN
  898.                         vec3Dcolor(vectorindex) = SlateGray
  899.                     ELSE
  900.                         vec3Dcolor(vectorindex) = DarkGray
  901.                     END IF
  902.                     GOSUB integratecom
  903.                 NEXT
  904.             NEXT
  905.             VectorGroup(vecgroupid).LastVector = vectorindex
  906.             GOSUB calculatecom
  907.         NEXT
  908.         FOR j = -span / 2 TO -thickness
  909.             groupidticker = groupidticker + 1
  910.             vecgroupid = groupidticker
  911.             VectorGroup(vecgroupid).Identity = vecgroupid
  912.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  913.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  914.             VectorGroup(vecgroupid).GroupName = "Grave"
  915.             VectorGroup(vecgroupid).Visible = 0
  916.             VectorGroup(vecgroupid).COMFixed = 1
  917.             VectorGroup(vecgroupid).DIMx = thickness
  918.             VectorGroup(vecgroupid).DIMy = thickness
  919.             VectorGroup(vecgroupid).DIMz = thickness
  920.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  921.             FOR k = -thickness TO thickness STEP thickness / 2
  922.                 FOR i = -thickness TO thickness STEP thickness / 2
  923.                     vectorindex = vectorindex + 1
  924.                     vec3Dpos(vectorindex, 1) = xloc + i + (RND - .5) * 2
  925.                     vec3Dpos(vectorindex, 2) = yloc + j + (RND - .5) * 2
  926.                     vec3Dpos(vectorindex, 3) = crux + k + (RND - .5) * 2
  927.                     vec3Dvis(vectorindex) = 0
  928.                     IF RND > .5 THEN
  929.                         vec3Dcolor(vectorindex) = SlateGray
  930.                     ELSE
  931.                         vec3Dcolor(vectorindex) = DarkGray
  932.                     END IF
  933.                     GOSUB integratecom
  934.                 NEXT
  935.             NEXT
  936.             VectorGroup(vecgroupid).LastVector = vectorindex
  937.             GOSUB calculatecom
  938.         NEXT
  939.         FOR j = thickness TO span / 2
  940.             groupidticker = groupidticker + 1
  941.             vecgroupid = groupidticker
  942.             VectorGroup(vecgroupid).Identity = vecgroupid
  943.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  944.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  945.             VectorGroup(vecgroupid).GroupName = "Grave"
  946.             VectorGroup(vecgroupid).Visible = 0
  947.             VectorGroup(vecgroupid).COMFixed = 1
  948.             VectorGroup(vecgroupid).DIMx = thickness
  949.             VectorGroup(vecgroupid).DIMy = thickness
  950.             VectorGroup(vecgroupid).DIMz = thickness
  951.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  952.             FOR k = -thickness TO thickness STEP thickness / 2
  953.                 FOR i = -thickness TO thickness STEP thickness / 2
  954.                     vectorindex = vectorindex + 1
  955.                     vec3Dpos(vectorindex, 1) = xloc + i + (RND - .5) * 2
  956.                     vec3Dpos(vectorindex, 2) = yloc + j + (RND - .5) * 2
  957.                     vec3Dpos(vectorindex, 3) = crux + k + (RND - .5) * 2
  958.                     vec3Dvis(vectorindex) = 0
  959.                     IF RND > .5 THEN
  960.                         vec3Dcolor(vectorindex) = SlateGray
  961.                     ELSE
  962.                         vec3Dcolor(vectorindex) = DarkGray
  963.                     END IF
  964.                     GOSUB integratecom
  965.                 NEXT
  966.             NEXT
  967.             VectorGroup(vecgroupid).LastVector = vectorindex
  968.             GOSUB calculatecom
  969.         NEXT
  970.     NEXT
  971.  
  972. 'Heaven's Bottom Layer
  973. h = 2
  974. FOR u = -gridsize TO gridsize STEP tilesize
  975.     FOR v = -gridsize TO gridsize STEP tilesize
  976.         groupidticker = groupidticker + 1
  977.         vecgroupid = groupidticker
  978.         VectorGroup(vecgroupid).Identity = vecgroupid
  979.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  980.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  981.         VectorGroup(vecgroupid).GroupName = "Heaven's Bottom Layer"
  982.         VectorGroup(vecgroupid).Visible = 0
  983.         VectorGroup(vecgroupid).COMFixed = 1
  984.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  985.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  986.         VectorGroup(vecgroupid).DIMz = 3
  987.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  988.         FOR i = u TO u + tilesize STEP h
  989.             FOR j = v TO v + tilesize STEP h
  990.                 vectorindex = vectorindex + 1
  991.                 vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  992.                 vec3Dpos(vectorindex, 2) = j + RND * h - RND * h
  993.                 vec3Dpos(vectorindex, 3) = 420 - RND
  994.                 vec3Dvis(vectorindex) = 0
  995.                 IF RND > .5 THEN
  996.                     vec3Dcolor(vectorindex) = BlueViolet
  997.                 ELSE
  998.                     vec3Dcolor(vectorindex) = Cyan
  999.                 END IF
  1000.                 GOSUB integratecom
  1001.             NEXT
  1002.         NEXT
  1003.         VectorGroup(vecgroupid).LastVector = vectorindex
  1004.         GOSUB calculatecom
  1005.     NEXT
  1006.  
  1007. 'Hell Spawn
  1008. FOR u = -gridsize TO gridsize STEP tilesize
  1009.     FOR v = -gridsize TO gridsize STEP tilesize
  1010.         groupidticker = groupidticker + 1
  1011.         vecgroupid = groupidticker
  1012.         VectorGroup(vecgroupid).Identity = vecgroupid
  1013.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1014.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1015.         VectorGroup(vecgroupid).GroupName = "Hell Spawn"
  1016.         VectorGroup(vecgroupid).Visible = 0
  1017.         VectorGroup(vecgroupid).COMFixed = 1
  1018.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1019.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1020.         VectorGroup(vecgroupid).DIMz = 35
  1021.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1022.         FOR i = u TO u + tilesize STEP tilesize / 5
  1023.             FOR j = v TO v + tilesize STEP tilesize / 5
  1024.                 vectorindex = vectorindex + 1
  1025.                 vec3Dpos(vectorindex, 1) = i + (RND - .5) * tilesize
  1026.                 vec3Dpos(vectorindex, 2) = j + (RND - .5) * tilesize
  1027.                 vec3Dpos(vectorindex, 3) = -350 - RND * 70
  1028.                 vec3Dvel(vectorindex, 1) = 0
  1029.                 vec3Dvel(vectorindex, 2) = 0
  1030.                 vec3Dvel(vectorindex, 3) = 400 * RND
  1031.                 vec3Dvis(vectorindex) = 0
  1032.                 IF RND > .2 THEN
  1033.                     vec3Dcolor(vectorindex) = Red
  1034.                 ELSE
  1035.                     vec3Dcolor(vectorindex) = DarkGoldenRod
  1036.                 END IF
  1037.                 GOSUB integratecom
  1038.             NEXT
  1039.         NEXT
  1040.         VectorGroup(vecgroupid).LastVector = vectorindex
  1041.         GOSUB calculatecom
  1042.         VectorGroup(vecgroupid).COMz = -350 - 35
  1043.     NEXT
  1044.  
  1045. 'Icewall East
  1046. h = 2
  1047. FOR u = -gridsize TO gridsize STEP tilesize
  1048.     FOR v = 0 TO 70 STEP tilesize
  1049.         groupidticker = groupidticker + 1
  1050.         vecgroupid = groupidticker
  1051.         VectorGroup(vecgroupid).Identity = vecgroupid
  1052.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1053.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1054.         VectorGroup(vecgroupid).GroupName = "Icewall East"
  1055.         VectorGroup(vecgroupid).Visible = 0
  1056.         VectorGroup(vecgroupid).COMFixed = 1
  1057.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1058.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1059.         VectorGroup(vecgroupid).DIMz = tilesize / 2
  1060.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1061.         FOR i = u TO u + tilesize STEP h
  1062.             FOR j = v TO v + tilesize STEP h
  1063.                 vectorindex = vectorindex + 1
  1064.                 vec3Dpos(vectorindex, 1) = gridsize + tilesize / 2
  1065.                 vec3Dpos(vectorindex, 2) = i + RND * h - RND * h
  1066.                 vec3Dpos(vectorindex, 3) = j + RND * h - RND * h
  1067.                 vec3Dvis(vectorindex) = 0
  1068.                 IF RND > .5 THEN
  1069.                     vec3Dcolor(vectorindex) = White
  1070.                 ELSE
  1071.                     vec3Dcolor(vectorindex) = Ivory
  1072.                 END IF
  1073.                 GOSUB integratecom
  1074.             NEXT
  1075.         NEXT
  1076.         VectorGroup(vecgroupid).LastVector = vectorindex
  1077.         GOSUB calculatecom
  1078.     NEXT
  1079.  
  1080. 'Icewall South
  1081. h = 2
  1082. FOR u = -gridsize TO gridsize STEP tilesize
  1083.     FOR v = 0 TO 70 STEP tilesize
  1084.         groupidticker = groupidticker + 1
  1085.         vecgroupid = groupidticker
  1086.         VectorGroup(vecgroupid).Identity = vecgroupid
  1087.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1088.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1089.         VectorGroup(vecgroupid).GroupName = "Icewall South"
  1090.         VectorGroup(vecgroupid).Visible = 0
  1091.         VectorGroup(vecgroupid).COMFixed = 1
  1092.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1093.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1094.         VectorGroup(vecgroupid).DIMz = tilesize / 2
  1095.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1096.         FOR i = u TO u + tilesize STEP h
  1097.             FOR j = v TO v + tilesize STEP h
  1098.                 vectorindex = vectorindex + 1
  1099.                 vec3Dpos(vectorindex, 1) = -gridsize
  1100.                 vec3Dpos(vectorindex, 2) = i + RND * h - RND * h
  1101.                 vec3Dpos(vectorindex, 3) = j + RND * h - RND * h
  1102.                 vec3Dvis(vectorindex) = 0
  1103.                 IF RND > .5 THEN
  1104.                     vec3Dcolor(vectorindex) = White
  1105.                 ELSE
  1106.                     vec3Dcolor(vectorindex) = Ivory
  1107.                 END IF
  1108.                 GOSUB integratecom
  1109.             NEXT
  1110.         NEXT
  1111.         VectorGroup(vecgroupid).LastVector = vectorindex
  1112.         GOSUB calculatecom
  1113.     NEXT
  1114.  
  1115. 'Icewall North
  1116. h = 2
  1117. FOR u = -gridsize TO gridsize STEP tilesize
  1118.     FOR v = 0 TO 70 STEP tilesize
  1119.         groupidticker = groupidticker + 1
  1120.         vecgroupid = groupidticker
  1121.         VectorGroup(vecgroupid).Identity = vecgroupid
  1122.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1123.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1124.         VectorGroup(vecgroupid).GroupName = "Icewall North"
  1125.         VectorGroup(vecgroupid).Visible = 0
  1126.         VectorGroup(vecgroupid).COMFixed = 1
  1127.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1128.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1129.         VectorGroup(vecgroupid).DIMz = tilesize / 2
  1130.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1131.         FOR i = u TO u + tilesize STEP h
  1132.             FOR j = v TO v + tilesize STEP h
  1133.                 vectorindex = vectorindex + 1
  1134.                 vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  1135.                 vec3Dpos(vectorindex, 2) = gridsize + tilesize / 2
  1136.                 vec3Dpos(vectorindex, 3) = j + RND * h - RND * h
  1137.                 vec3Dvis(vectorindex) = 0
  1138.                 IF RND > .5 THEN
  1139.                     vec3Dcolor(vectorindex) = White
  1140.                 ELSE
  1141.                     vec3Dcolor(vectorindex) = Ivory
  1142.                 END IF
  1143.                 GOSUB integratecom
  1144.             NEXT
  1145.         NEXT
  1146.         VectorGroup(vecgroupid).LastVector = vectorindex
  1147.         GOSUB calculatecom
  1148.     NEXT
  1149.  
  1150. 'Icewall West
  1151. h = 2
  1152. FOR u = -gridsize TO gridsize STEP tilesize
  1153.     FOR v = 0 TO 70 STEP tilesize
  1154.         groupidticker = groupidticker + 1
  1155.         vecgroupid = groupidticker
  1156.         VectorGroup(vecgroupid).Identity = vecgroupid
  1157.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1158.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1159.         VectorGroup(vecgroupid).GroupName = "Icewall West"
  1160.         VectorGroup(vecgroupid).Visible = 0
  1161.         VectorGroup(vecgroupid).COMFixed = 1
  1162.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1163.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1164.         VectorGroup(vecgroupid).DIMz = tilesize / 2
  1165.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1166.         FOR i = u TO u + tilesize STEP h
  1167.             FOR j = v TO v + tilesize STEP h
  1168.                 vectorindex = vectorindex + 1
  1169.                 vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  1170.                 vec3Dpos(vectorindex, 2) = -gridsize
  1171.                 vec3Dpos(vectorindex, 3) = j + RND * h - RND * h
  1172.                 vec3Dvis(vectorindex) = 0
  1173.                 IF RND > .5 THEN
  1174.                     vec3Dcolor(vectorindex) = White
  1175.                 ELSE
  1176.                     vec3Dcolor(vectorindex) = Ivory
  1177.                 END IF
  1178.                 GOSUB integratecom
  1179.             NEXT
  1180.         NEXT
  1181.         VectorGroup(vecgroupid).LastVector = vectorindex
  1182.         GOSUB calculatecom
  1183.     NEXT
  1184.  
  1185. 'Lake of Fire
  1186. h = 2
  1187. FOR u = -gridsize TO gridsize STEP tilesize
  1188.     FOR v = -gridsize TO gridsize STEP tilesize
  1189.         groupidticker = groupidticker + 1
  1190.         vecgroupid = groupidticker
  1191.         VectorGroup(vecgroupid).Identity = vecgroupid
  1192.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1193.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1194.         VectorGroup(vecgroupid).GroupName = "Lake of Fire"
  1195.         VectorGroup(vecgroupid).Visible = 0
  1196.         VectorGroup(vecgroupid).COMFixed = 1
  1197.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1198.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1199.         VectorGroup(vecgroupid).DIMz = tilesize / 2
  1200.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1201.         FOR i = u TO u + tilesize STEP h
  1202.             FOR j = v TO v + tilesize STEP h
  1203.                 vectorindex = vectorindex + 1
  1204.                 vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  1205.                 vec3Dpos(vectorindex, 2) = j + RND * h - RND * h
  1206.                 vec3Dpos(vectorindex, 3) = -350 - 70 - RND
  1207.                 vec3Dvis(vectorindex) = 0
  1208.                 IF RND > .2 THEN
  1209.                     vec3Dcolor(vectorindex) = Red
  1210.                 ELSE
  1211.                     vec3Dcolor(vectorindex) = Indigo
  1212.                 END IF
  1213.                 GOSUB integratecom
  1214.             NEXT
  1215.         NEXT
  1216.         VectorGroup(vecgroupid).LastVector = vectorindex
  1217.         GOSUB calculatecom
  1218.     NEXT
  1219.  
  1220. 'Megalith
  1221. ctrx = -90
  1222. ctry = -320
  1223. ctrz = 4
  1224. w = 8
  1225. h = 256
  1226. dens = 100
  1227. FOR k = 1 TO h STEP w
  1228.     FOR i = -h / 20 + k / 20 TO h / 20 - k / 20 STEP w
  1229.         FOR j = -h / 20 + k / 20 TO h / 20 - k / 20 STEP w
  1230.             groupidticker = groupidticker + 1
  1231.             vecgroupid = groupidticker
  1232.             VectorGroup(vecgroupid).Identity = vecgroupid
  1233.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1234.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1235.             VectorGroup(vecgroupid).GroupName = "Megalith"
  1236.             VectorGroup(vecgroupid).Visible = 0
  1237.             VectorGroup(vecgroupid).COMFixed = 1
  1238.             VectorGroup(vecgroupid).DIMx = w / 2
  1239.             VectorGroup(vecgroupid).DIMy = w / 2
  1240.             VectorGroup(vecgroupid).DIMz = w / 2
  1241.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1242.             FOR q = 1 TO dens
  1243.                 vectorindex = vectorindex + 1
  1244.                 vec3Dpos(vectorindex, 1) = ctrx + i + (RND - .5) * w
  1245.                 vec3Dpos(vectorindex, 2) = ctry + j + (RND - .5) * w
  1246.                 vec3Dpos(vectorindex, 3) = ctrz + k + (RND - .5) * w
  1247.                 vec3Dvis(vectorindex) = 0
  1248.                 IF RND > .5 THEN
  1249.                     vec3Dcolor(vectorindex) = Cyan
  1250.                 ELSE
  1251.                     vec3Dcolor(vectorindex) = Teal
  1252.                 END IF
  1253.                 GOSUB integratecom
  1254.             NEXT
  1255.             VectorGroup(vecgroupid).LastVector = vectorindex
  1256.             GOSUB calculatecom
  1257.         NEXT
  1258.     NEXT
  1259.  
  1260. 'Pyramid
  1261. ctrx = -90
  1262. ctry = -120
  1263. ctrz = 4
  1264. w = 8
  1265. h = 56
  1266. dens = 50
  1267. FOR k = 1 TO h STEP w
  1268.     FOR i = -h / 2 + k / 2 TO h / 2 - k / 2 STEP w
  1269.         FOR j = -h / 2 + k / 2 TO h / 2 - k / 2 STEP w
  1270.             groupidticker = groupidticker + 1
  1271.             vecgroupid = groupidticker
  1272.             VectorGroup(vecgroupid).Identity = vecgroupid
  1273.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1274.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1275.             VectorGroup(vecgroupid).GroupName = "Pyramid"
  1276.             VectorGroup(vecgroupid).Visible = 0
  1277.             VectorGroup(vecgroupid).COMFixed = 1
  1278.             VectorGroup(vecgroupid).DIMx = tilesize / 2
  1279.             VectorGroup(vecgroupid).DIMy = tilesize / 2
  1280.             VectorGroup(vecgroupid).DIMz = tilesize / 2
  1281.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1282.             FOR q = 1 TO dens
  1283.                 vectorindex = vectorindex + 1
  1284.                 vec3Dpos(vectorindex, 1) = ctrx + i + (RND - .5) * w
  1285.                 vec3Dpos(vectorindex, 2) = ctry + j + (RND - .5) * w
  1286.                 vec3Dpos(vectorindex, 3) = ctrz + k + (RND - .5) * w
  1287.                 vec3Dvis(vectorindex) = 0
  1288.                 IF RND > .5 THEN
  1289.                     vec3Dcolor(vectorindex) = DarkGoldenRod
  1290.                 ELSE
  1291.                     vec3Dcolor(vectorindex) = GoldenRod
  1292.                 END IF
  1293.                 GOSUB integratecom
  1294.             NEXT
  1295.             VectorGroup(vecgroupid).LastVector = vectorindex
  1296.             GOSUB calculatecom
  1297.         NEXT
  1298.     NEXT
  1299.  
  1300. 'Rain
  1301. FOR u = -gridsize TO gridsize STEP tilesize
  1302.     FOR v = -gridsize TO gridsize STEP tilesize
  1303.         groupidticker = groupidticker + 1
  1304.         vecgroupid = groupidticker
  1305.         VectorGroup(vecgroupid).Identity = vecgroupid
  1306.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1307.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1308.         VectorGroup(vecgroupid).GroupName = "Rain"
  1309.         VectorGroup(vecgroupid).Visible = 0
  1310.         VectorGroup(vecgroupid).COMFixed = 1
  1311.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1312.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1313.         VectorGroup(vecgroupid).DIMz = 35
  1314.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1315.         FOR i = u TO u + tilesize STEP tilesize '/ 3
  1316.             FOR j = v TO v + tilesize STEP tilesize '/ 3
  1317.                 vectorindex = vectorindex + 1
  1318.                 vec3Dpos(vectorindex, 1) = i + (RND - .5) * tilesize
  1319.                 vec3Dpos(vectorindex, 2) = j + (RND - .5) * tilesize
  1320.                 vec3Dpos(vectorindex, 3) = RND * 70
  1321.                 vec3Dvel(vectorindex, 1) = 0
  1322.                 vec3Dvel(vectorindex, 2) = 0
  1323.                 vec3Dvel(vectorindex, 3) = -400 * RND
  1324.                 vec3Dvis(vectorindex) = 0
  1325.                 IF RND > 5 THEN
  1326.                     vec3Dcolor(vectorindex) = Aquamarine
  1327.                 ELSE
  1328.                     vec3Dcolor(vectorindex) = DodgerBlue
  1329.                 END IF
  1330.                 GOSUB integratecom
  1331.             NEXT
  1332.         NEXT
  1333.         VectorGroup(vecgroupid).LastVector = vectorindex
  1334.         GOSUB calculatecom
  1335.         VectorGroup(vecgroupid).COMz = 35
  1336.     NEXT
  1337.  
  1338. 'Sky
  1339. h = 2
  1340. FOR u = -gridsize TO gridsize STEP tilesize
  1341.     FOR v = -gridsize TO gridsize STEP tilesize
  1342.         groupidticker = groupidticker + 1
  1343.         vecgroupid = groupidticker
  1344.         VectorGroup(vecgroupid).Identity = vecgroupid
  1345.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1346.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1347.         VectorGroup(vecgroupid).GroupName = "Sky"
  1348.         VectorGroup(vecgroupid).Visible = 0
  1349.         VectorGroup(vecgroupid).COMFixed = 1
  1350.         VectorGroup(vecgroupid).DIMx = tilesize / 2
  1351.         VectorGroup(vecgroupid).DIMy = tilesize / 2
  1352.         VectorGroup(vecgroupid).DIMz = 3
  1353.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1354.         FOR i = u TO u + tilesize STEP h
  1355.             FOR j = v TO v + tilesize STEP h
  1356.                 vectorindex = vectorindex + 1
  1357.                 vec3Dpos(vectorindex, 1) = i + (RND - RND) * h
  1358.                 vec3Dpos(vectorindex, 2) = j + (RND - RND) * h
  1359.                 vec3Dpos(vectorindex, 3) = 70 + (RND - RND) * h
  1360.                 vec3Dvel(vectorindex, 1) = (RND - RND) * 2
  1361.                 vec3Dvel(vectorindex, 2) = (RND - RND) * 2
  1362.                 vec3Dvel(vectorindex, 3) = (RND - RND) * 2
  1363.                 vec3Danv(vectorindex, 1) = 0
  1364.                 vec3Danv(vectorindex, 2) = 0
  1365.                 vec3Danv(vectorindex, 3) = 0
  1366.                 vec3Dvis(vectorindex) = 0
  1367.                 IF RND > .5 THEN
  1368.                     vec3Dcolor(vectorindex) = Snow
  1369.                 ELSE
  1370.                     vec3Dcolor(vectorindex) = RoyalBlue
  1371.                 END IF
  1372.                 GOSUB integratecom
  1373.             NEXT
  1374.         NEXT
  1375.         VectorGroup(vecgroupid).LastVector = vectorindex
  1376.         GOSUB calculatecom
  1377.     NEXT
  1378.  
  1379. 'Stars
  1380. h = 5
  1381. FOR w = 1 TO 5
  1382.     FOR u = -gridsize TO gridsize STEP tilesize
  1383.         FOR v = -gridsize TO gridsize STEP tilesize
  1384.             groupidticker = groupidticker + 1
  1385.             vecgroupid = groupidticker
  1386.             VectorGroup(vecgroupid).Identity = vecgroupid
  1387.             VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1388.             VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1389.             VectorGroup(vecgroupid).GroupName = "Stars"
  1390.             VectorGroup(vecgroupid).Visible = 0
  1391.             VectorGroup(vecgroupid).COMFixed = 1
  1392.             VectorGroup(vecgroupid).DIMx = tilesize / 2
  1393.             VectorGroup(vecgroupid).DIMy = tilesize / 2
  1394.             VectorGroup(vecgroupid).DIMz = tilesize / 2
  1395.             VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1396.             FOR i = u TO u + tilesize STEP h
  1397.                 FOR j = v TO v + tilesize STEP h
  1398.                     IF RND > 1 - w / 5 THEN
  1399.                         vectorindex = vectorindex + 1
  1400.                         vec3Dpos(vectorindex, 1) = i + RND * h - RND * h
  1401.                         vec3Dpos(vectorindex, 2) = j + RND * h - RND * h
  1402.                         vec3Dpos(vectorindex, 3) = w * 70 + RND * 70
  1403.                         vec3Dvis(vectorindex) = 0
  1404.                         IF RND > .5 THEN
  1405.                             vec3Dcolor(vectorindex) = GhostWhite
  1406.                         ELSE
  1407.                             IF RND > .5 THEN
  1408.                                 vec3Dcolor(vectorindex) = White
  1409.                             ELSE
  1410.                                 vec3Dcolor(vectorindex) = DarkGray
  1411.                             END IF
  1412.                         END IF
  1413.                         GOSUB integratecom
  1414.                     END IF
  1415.                 NEXT
  1416.             NEXT
  1417.             VectorGroup(vecgroupid).LastVector = vectorindex
  1418.             GOSUB calculatecom
  1419.         NEXT
  1420.     NEXT
  1421.  
  1422. 'Sun
  1423. radius = 10
  1424. dx = .0628
  1425. dy = .0628
  1426. xl = 0: xr = 2 * pi
  1427. yl = 0: yr = pi
  1428. xrange = 1 + INT((-xl + xr) / dx)
  1429. yrange = 1 + INT((-yl + yr) / dy)
  1430. FOR i = 1 TO xrange STEP 10
  1431.     FOR j = 1 TO yrange STEP 10
  1432.         groupidticker = groupidticker + 1
  1433.         vecgroupid = groupidticker
  1434.         VectorGroup(vecgroupid).Identity = vecgroupid
  1435.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1436.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1437.         VectorGroup(vecgroupid).GroupName = "Sun"
  1438.         VectorGroup(vecgroupid).Visible = 0
  1439.         VectorGroup(vecgroupid).COMFixed = 1
  1440.         VectorGroup(vecgroupid).DIMx = radius
  1441.         VectorGroup(vecgroupid).DIMy = radius
  1442.         VectorGroup(vecgroupid).DIMz = radius
  1443.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1444.         FOR u = i TO i + 10 STEP 1
  1445.             FOR v = j TO j + 10 STEP 1
  1446.                 vectorindex = vectorindex + 1
  1447.                 theta = u * dx - dx
  1448.                 phi = v * dy - dy
  1449.                 vec3Dpos(vectorindex, 1) = radius * SIN(phi) * COS(theta)
  1450.                 vec3Dpos(vectorindex, 2) = radius * SIN(phi) * SIN(theta)
  1451.                 vec3Dpos(vectorindex, 3) = 90 + radius * COS(phi)
  1452.                 vec3Dvis(vectorindex) = 0
  1453.                 IF RND > .5 THEN
  1454.                     vec3Dcolor(vectorindex) = Sunglow
  1455.                 ELSE
  1456.                     vec3Dcolor(vectorindex) = SunsetOrange
  1457.                 END IF
  1458.                 GOSUB integratecom
  1459.             NEXT
  1460.         NEXT
  1461.         GOSUB integratecom
  1462.         VectorGroup(vecgroupid).LastVector = vectorindex
  1463.         GOSUB calculatecom
  1464.     NEXT
  1465.  
  1466. 'Moon
  1467. radius = 4
  1468. au = 60
  1469. dx = (2 * pi / radius) * .05
  1470. dy = (2 * pi / radius) * .05
  1471. xl = 0: xr = 2 * pi
  1472. yl = 0: yr = pi
  1473. xrange = 1 + INT((-xl + xr) / dx)
  1474. yrange = 1 + INT((-yl + yr) / dy)
  1475. groupidticker = groupidticker + 1
  1476. vecgroupid = groupidticker
  1477. VectorGroup(vecgroupid).Identity = vecgroupid
  1478. VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1479. VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1480. VectorGroup(vecgroupid).GroupName = "Moon"
  1481. VectorGroup(vecgroupid).Visible = 0
  1482. VectorGroup(vecgroupid).ForceAnimate = 1
  1483. VectorGroup(vecgroupid).COMFixed = 0
  1484. VectorGroup(vecgroupid).ROTx = 0
  1485. VectorGroup(vecgroupid).ROTy = 0
  1486. VectorGroup(vecgroupid).ROTz = 90
  1487. VectorGroup(vecgroupid).REVx = 1.5
  1488. VectorGroup(vecgroupid).REVy = 0
  1489. VectorGroup(vecgroupid).REVz = 0
  1490. VectorGroup(vecgroupid).DIMx = 2 * radius + 1
  1491. VectorGroup(vecgroupid).DIMy = 2 * radius + 1
  1492. VectorGroup(vecgroupid).DIMz = 2 * radius + 1
  1493. VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1494. FOR i = 1 TO xrange
  1495.     FOR j = 1 TO yrange
  1496.         vectorindex = vectorindex + 1
  1497.         theta = i * dx - dx
  1498.         phi = j * dy - dy
  1499.         vec3Dpos(vectorindex, 1) = au + radius * SIN(phi) * COS(theta)
  1500.         vec3Dpos(vectorindex, 2) = radius * SIN(phi) * SIN(theta)
  1501.         vec3Dpos(vectorindex, 3) = 90 + radius * COS(phi)
  1502.         vec3Danv(vectorindex, 1) = 0
  1503.         vec3Danv(vectorindex, 2) = 0
  1504.         vec3Danv(vectorindex, 3) = 1.5
  1505.         vec3Dvis(vectorindex) = 0
  1506.         IF RND > .5 THEN
  1507.             vec3Dcolor(vectorindex) = Gray
  1508.         ELSE
  1509.             vec3Dcolor(vectorindex) = PaleGoldenRod
  1510.         END IF
  1511.         GOSUB integratecom
  1512.         VectorGroup(vecgroupid).LastVector = vectorindex
  1513.         GOSUB calculatecom
  1514.     NEXT
  1515.  
  1516. 'Waves or Particles? (1)
  1517. FOR i = 1 TO 5 STEP 1
  1518.     FOR k = 1 TO 5 STEP 1
  1519.         groupidticker = groupidticker + 1
  1520.         vecgroupid = groupidticker
  1521.         VectorGroup(vecgroupid).Identity = vecgroupid
  1522.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1523.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1524.         VectorGroup(vecgroupid).GroupName = "Waves or Particles?"
  1525.         VectorGroup(vecgroupid).Visible = 0
  1526.         VectorGroup(vecgroupid).COMFixed = 1
  1527.         VectorGroup(vecgroupid).DIMx = 4
  1528.         VectorGroup(vecgroupid).DIMy = 1
  1529.         VectorGroup(vecgroupid).DIMz = 4
  1530.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1531.         FOR u = i TO i + 1 STEP .05
  1532.             FOR v = k TO k + 1 STEP .05
  1533.                 vectorindex = vectorindex + 1
  1534.                 vec3Dpos(vectorindex, 1) = 70 + 7 * u
  1535.                 vec3Dpos(vectorindex, 2) = 80 + 1 * COS((u ^ 2 - v ^ 2))
  1536.                 vec3Dpos(vectorindex, 3) = 10 + 7 * v
  1537.                 vec3Dvis(vectorindex) = 0
  1538.                 IF vec3Dpos(vectorindex, 2) < 80 THEN
  1539.                     vec3Dcolor(vectorindex) = DarkBlue
  1540.                 ELSE
  1541.                     vec3Dcolor(vectorindex) = DeepPink
  1542.                 END IF
  1543.                 GOSUB integratecom
  1544.             NEXT
  1545.         NEXT
  1546.         VectorGroup(vecgroupid).LastVector = vectorindex
  1547.         GOSUB calculatecom
  1548.     NEXT
  1549.  
  1550. 'Waves or Particles? (2)
  1551. FOR i = 1 TO 5 STEP 1
  1552.     FOR k = 1 TO 5 STEP 1
  1553.         groupidticker = groupidticker + 1
  1554.         vecgroupid = groupidticker
  1555.         VectorGroup(vecgroupid).Identity = vecgroupid
  1556.         VectorGroup(vecgroupid).Pointer = vecgroupid + 1
  1557.         VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1558.         VectorGroup(vecgroupid).GroupName = "Particles or Waves?"
  1559.         VectorGroup(vecgroupid).Visible = 0
  1560.         VectorGroup(vecgroupid).COMFixed = 1
  1561.         VectorGroup(vecgroupid).DIMx = 4
  1562.         VectorGroup(vecgroupid).DIMy = 1
  1563.         VectorGroup(vecgroupid).DIMz = 4
  1564.         VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1565.         FOR u = i TO i + 1 STEP .05
  1566.             FOR v = k TO k + 1 STEP .05
  1567.                 vectorindex = vectorindex + 1
  1568.                 vec3Dpos(vectorindex, 1) = -7 * u
  1569.                 vec3Dpos(vectorindex, 2) = 80 + 1 * COS(2 * ((u - 7) ^ 2 - (v - 5) ^ 2))
  1570.                 vec3Dpos(vectorindex, 3) = 10 + 7 * v
  1571.                 vec3Dvis(vectorindex) = 0
  1572.                 IF vec3Dpos(vectorindex, 2) < 80 THEN
  1573.                     vec3Dcolor(vectorindex) = Magenta
  1574.                 ELSE
  1575.                     vec3Dcolor(vectorindex) = Chocolate
  1576.                 END IF
  1577.                 GOSUB integratecom
  1578.             NEXT
  1579.         NEXT
  1580.         VectorGroup(vecgroupid).LastVector = vectorindex
  1581.         GOSUB calculatecom
  1582.     NEXT
  1583.  
  1584. '__ZZZ
  1585. groupidticker = groupidticker + 1
  1586. vecgroupid = groupidticker
  1587. VectorGroup(vecgroupid).Identity = vecgroupid
  1588. VectorGroup(vecgroupid).Pointer = -999
  1589. VectorGroup(vecgroupid).Lagger = vecgroupid - 1
  1590. VectorGroup(vecgroupid).GroupName = "__ZZZ"
  1591. VectorGroup(vecgroupid).COMFixed = 1
  1592. VectorGroup(vecgroupid).FirstVector = vectorindex + 1
  1593. FOR r = 1 TO 1
  1594.     vectorindex = vectorindex + 1
  1595.     vec3Dpos(vectorindex, 1) = 0
  1596.     vec3Dpos(vectorindex, 2) = 0
  1597.     vec3Dpos(vectorindex, 3) = -1000
  1598.     vec3Dcolor(vectorindex) = White
  1599.     GOSUB integratecom
  1600. VectorGroup(vecgroupid).LastVector = vectorindex
  1601. GOSUB calculatecom
  1602.  

screenshot.png
* Sanctum.bas (Filesize: 62.07 KB, Downloads: 276)
« Last Edit: August 25, 2019, 12:10:02 am by The Librarian »