Author Topic: MAPTRIANGLE in 3D  (Read 26613 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D: textured roller or cone
« Reply #15 on: November 27, 2018, 03:06:50 pm »
Hi.

In sample examples, textured blocks are already available. I was thinking about how to make a textured cylinder. Finally, the program can handle both a textured disk, a cylinder and a cone. The number of cone sides is determined by the Segments variable in the program. The higher Segments is, the body is finer and the texture is more faithful (and the program more demanding). The variables in the Celo0 and Celo1 fields contain the values ​​of the vertices of the individual triangles in the sense of rotation (because the object is a rotating body), celo0 is one untextured side of the cylinder, the cello1 is the second untextured side of the cylinder (bottom). Use the 1,2 keys to change the speed or direction of rotation, 3,4 to move the face to the X axis, 5,6 to move the Y axis, 7,8 to move the X axis to the second bottom, 9, Q to shift the Y axis of the second end, W, E for changing the diameter of the cylinder face, R, T for changing the diameter of the second face of the cylinder, A, S for the zoom, D, F for displacement in the Z axis of the first face, and G, H for the Z axis cell. A beautiful effect can be achieved by using the Stars image by Johnno56. I have one question for developers - why is this happening:

Use the T / R or W / E key to open the cone so that it is a hollow cylinder. Press C. This will enable the _CLOCKWISE parameter. The picture then has a lot of noise. Now close the cylinder (do the cone) (one radius is set to zero), the noise disappears. Why?


Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2.  
  3. TYPE crc
  4.     x AS SINGLE
  5.     y AS SINGLE
  6.  
  7. DIM SHARED Segments, R1, R2, Z1, Z2, Efect, OldX, OldY
  8.  
  9. 'Warning! Segments variable muss be dividible by 2!
  10. Segments = 314: R1 = .1: R2 = 2: Z1 = -1: Z2 = -2
  11. im = _LOADIMAGE("abcde 066.jpg", 32)
  12.  
  13. restart:
  14. REDIM s(Segments + 1) AS LONG, celo0(Segments + 1) AS crc, celo1(Segments + 1) AS crc
  15.  
  16. divideimage s(), im
  17. SETCelo R1, celo0()
  18. SETCelo R2, celo1()
  19. S = Segments
  20. rd = .01
  21. PrintIT = 1
  22.     Quad celo0(1).x, celo0(1).y, Z1, celo0(S).x, celo0(S).y, Z1, celo1(1).x, celo1(1).y, Z2, celo1(S).x, celo1(S).y, Z2, s(1)
  23.     FOR d = 2 TO Segments
  24.         Quad celo0(d - 1).x, celo0(d - 1).y, Z1, celo0(d).x, celo0(d).y, Z1, celo1(d - 1).x, celo1(d - 1).y, Z2, celo1(d).x, celo1(d).y, Z2, s(d)
  25.     NEXT d
  26.  
  27.  
  28.     i$ = INKEY$
  29.  
  30.     SELECT CASE UCASE$(i$)
  31.         CASE "1": rd = rd + .001
  32.         CASE "2": rd = rd - .001
  33.         CASE "3": c0x = c0x + .01
  34.         CASE "4": c0x = c0x - .01
  35.         CASE "5": c0y = c0y + .01
  36.         CASE "6": c0y = c0y - .01
  37.  
  38.         CASE "7": c1x = c1x + .01
  39.         CASE "8": c1x = c1x - .01
  40.         CASE "9": c1y = c1y + .01
  41.         CASE "Q": c1y = c1y - .01
  42.  
  43.         CASE "W": R1 = R1 - .01: SETCelo R1, celo0()
  44.         CASE "E": R1 = R1 + .01: SETCelo R1, celo0()
  45.         CASE "R": R2 = R2 - .01: SETCelo R2, celo1()
  46.         CASE "T": R2 = R2 + .01: SETCelo R2, celo1()
  47.  
  48.  
  49.         CASE "A": Z1 = Z1 + .01: Z2 = Z2 + .01
  50.         CASE "S": Z1 = Z1 - .01: Z2 = Z2 - .01
  51.  
  52.         CASE "D": Z1 = Z1 + .01
  53.         CASE "F": Z1 = Z1 - .01
  54.  
  55.         CASE "G": Z2 = Z2 + .01
  56.         CASE "H": Z2 = Z2 - .01
  57.  
  58.         CASE "C": IF Efect = 0 THEN Efect = 1 ELSE Efect = 0: _DELAY .2
  59.         CASE CHR$(27):
  60.             FOR freemem = 1 TO Segments
  61.                 _FREEIMAGE s(freemem)
  62.             NEXT
  63.             SYSTEM
  64.  
  65.     END SELECT
  66.  
  67.  
  68.     i = 0: rot = rot + rd
  69.  
  70.  
  71.     FOR f = 360 / Segments TO 360 STEP (360 / Segments)
  72.         i = i + 1
  73.         rad = _D2R(f)
  74.         celo0(i).x = SIN(rad + rot) * R1 + c0x
  75.         celo0(i).y = COS(rad + rot) * R1 + c0y
  76.  
  77.         celo1(i).x = SIN(rad + rot) * R2 + c1x
  78.         celo1(i).y = COS(rad + rot) * R2 + c1y
  79.  
  80.  
  81.     NEXT
  82.  
  83.     IF PrintIT THEN
  84.         LOCATE 1
  85.         PRINT "Press 1,2 for rotation, 3,4 for radius 1 X pos, 5,6 for radius 1 Y pos, 7,8 for radius 2 X pos, 9,Q for radius 2 Y pos, W,E for radius 1, R,T for radius 2, A,S for zoom, D,F for depth 1, G,H for depth 2"
  86.         PRINT "Segments in use: "; Segments
  87.         PrintIT = 0
  88.     END IF
  89.  
  90.     _DISPLAY
  91.     _LIMIT 55
  92.  
  93.  
  94. SUB SETCelo (radius AS INTEGER, arr() AS crc)
  95.     FOR f = 0 TO 360 STEP (360 / Segments)
  96.         i = i + 1
  97.         rad = _D2R(f)
  98.         arr(i).x = SIN(rad) * radius
  99.         arr(i).y = COS(rad) * radius
  100.     NEXT
  101.  
  102.  
  103. SUB divideimage (s() AS LONG, source AS LONG) 'divide image to more images in X
  104.     sir = _WIDTH(source) / UBOUND(S)
  105.     FOR r = 0 TO Segments
  106.         i = i + 1
  107.         s(i) = _NEWIMAGE(sir, _HEIGHT(source), 32)
  108.         _PUTIMAGE (0, 0)-(sir, _HEIGHT(source)), source, s(i), (sirka, 0)-(sirka + sir, _HEIGHT(source))
  109.         s(i) = _COPYIMAGE(s(i), 33)
  110.         sirka = sirka + sir
  111.     NEXT r
  112.  
  113. SUB Quad (dx1, dy1, dz1, dx2, dy2, dz2, dx3, dy3, dz3, dx4, dy4, dz4, imag&)
  114.     W = _WIDTH(imag&)
  115.     H = _HEIGHT(imag&)
  116.  
  117.     IF Efect THEN
  118.         _MAPTRIANGLE _CLOCKWISE (0, 0)-(W, 0)-(0, H), imag& TO(dx1, dy1, dz1)-(dx2, dy2, dz2)-(dx3, dy3, dz3), 0
  119.         _MAPTRIANGLE _CLOCKWISE (W, 0)-(0, H)-(W, H), imag& TO(dx2, dy2, dz2)-(dx3, dy3, dz3)-(dx4, dy4, dz4), 0
  120.     ELSE
  121.         _MAPTRIANGLE (0, 0)-(W, 0)-(0, H), imag& TO(dx1, dy1, dz1)-(dx2, dy2, dz2)-(dx3, dy3, dz3), 0
  122.         _MAPTRIANGLE (W, 0)-(0, H)-(W, H), imag& TO(dx2, dy2, dz2)-(dx3, dy3, dz3)-(dx4, dy4, dz4), 0
  123.     END IF
  124.  
abcde 066.jpg
* abcde 066.jpg (Filesize: 1.91 MB, Dimensions: 2304x1728, Views: 565)
« Last Edit: November 27, 2018, 03:08:37 pm by Petr »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D - ROTATION
« Reply #16 on: January 06, 2019, 11:08:18 am »
Hi. Next demo show rotation in 3D using MAPTRIANGLE 3D, none direct OpenGL statements.

Code: QB64: [Select]
  1. _TITLE "Next MAPTRIANGLE 3D demo"
  2.  
  3. k = _PI(2) / 4
  4.  
  5.     x AS INTEGER
  6.     y AS INTEGER
  7.  
  8. '------------
  9. DIM SHARED texture AS LONG, rot
  10. DIM i AS LONG, i2 AS LONG
  11.  
  12.     x AS SINGLE
  13.     y AS SINGLE
  14.     z AS SINGLE
  15.  
  16. DIM SHARED T(18 * 110) AS T
  17.  
  18. init
  19. '---------------------
  20.  
  21.  
  22.  
  23. SCREEN _NEWIMAGE(800, 600, 32)
  24. CLS , _RGB32(127, 127, 188)
  25.  
  26.  
  27. DIM B(3) AS b
  28.  
  29.  
  30. B(0).x = -1: B(0).y = -1
  31. B(1).x = 1: B(1).y = -1
  32. B(2).x = -1: B(2).y = -1
  33. B(3).x = 1: B(3).y = -1
  34.  
  35. w = _WIDTH(i)
  36. h = _HEIGHT(i)
  37.  
  38.     IF i THEN _FREEIMAGE i
  39.     j = _NEWIMAGE(150, 100, 32)
  40.     _DEST j
  41.     CLS , _RGBA32(0, 50, 127, 100)
  42.     clock 0, 0
  43.     _DEST 0
  44.  
  45.     i = _COPYIMAGE(j, 33)
  46.     _FREEIMAGE j
  47.  
  48.     clock 0, 0
  49.  
  50.     texture& = i
  51.     '--------------------
  52.  
  53.     FOR Ys = 0 TO 17
  54.         zz2 = zz2 + .01
  55.         FOR Xs = 0 TO 50
  56.             IF T(i4).x > 0 THEN
  57.                 X = T(i4).x + 70
  58.                 Y = T(i4).y
  59.                 z = T(i4).z - 70
  60.                 kostka X - zz2, Y, z - 15 + zz2
  61.             END IF
  62.             i4 = i4 + 1
  63.     NEXT Xs, Ys
  64.     i4 = 0
  65.     IF zz2 > 140 THEN zz2 = -50
  66.     '-----------------------------
  67.  
  68.  
  69.     Sx = (200 + 600) / 2: Rx = (600 - 200) / 2
  70.     Sy = (400 + 200) / 2: Ry = (400 - 200) / 2
  71.     rot = rot + .01
  72.  
  73.     Sx = 0
  74.     Sz = -2.5
  75.     Sy = -1
  76.  
  77.  
  78.     Rx = 1
  79.     Ry = -1
  80.     Rz = 1
  81.     ' info for rotation. To rotate the bodies, you must have all the points that are rotating in the same center. For this demo, it is easy to specify the radius of rotation,
  82.     ' because all the points are just as far from the center as the cube is a symmetrical body. But if you want to write a 3D game, then if you want to write with MAPTRIANGLE,
  83.     ' you need to map the floor using 4 triangles and calculate the radius for the points on the edges using the Pythagoras theorem:
  84.     '
  85.     '       A--------------------------B     x is your position, as you see, all points use different radius
  86.     '       I\\\                   Y / I     Y is your triangle side 1, next is floor height - Y
  87.     '       I   \\\\\\             Y/  I     X is your triangle side 2, next is floor width - X
  88.     '       I          \\\\\\\\/// xXXXI     third sides calculate using Pythagoras.
  89.     '       I       ////////////    \  I
  90.     '       I //////                 \ I
  91.     '       C--------------------------D
  92.     '
  93.     x1 = Sx + SIN(rot) * Rx: z1 = Sz + COS(rot) * Rz: y1R = Sy + SIN(rot) * Ry
  94.     x2 = Sx + SIN(rot + k) * Rx: z2 = Sz + COS(rot + k) * Rz: y2R = Sy + SIN(rot + k) * Ry
  95.  
  96.     x4 = Sx + SIN((2 * k) + rot) * Rx: z4 = Sz + COS((2 * k) + rot) * Rz: y3R = Sy + SIN((3 * k) + rot) * Ry
  97.     x3 = Sx + SIN((3 * k) + rot) * Rx: z3 = Sz + COS((3 * k) + rot) * Rz: y4R = Sy + SIN((4 * k) + rot) * Ry
  98.  
  99.     y1 = B(0).y
  100.     y2 = B(1).y
  101.     y4 = B(2).y
  102.     y3 = B(3).y
  103.  
  104.  
  105.  
  106.  
  107.     y5 = y1 + 1.5
  108.     y6 = y2 + 1.5
  109.     y7 = y3 + 1.5
  110.     y8 = y4 + 1.5
  111.  
  112.  
  113.     _MAPTRIANGLE (0, h)-(w, h)-(0, 0), i TO(x1, y1, z1)-(x2, y2, z2)-(x3, y3, z3) 'podlaha                 floor
  114.     _MAPTRIANGLE (w, h)-(0, 0)-(w, 0), i TO(x2, y2, z2)-(x3, y3, z3)-(x4, y4, z4) 'podlaha
  115.  
  116.  
  117.     _MAPTRIANGLE (0, h)-(w, h)-(0, 0), i TO(x1, y5, z1)-(x2, y6, z2)-(x3, y7, z3) 'strop                   roof
  118.     _MAPTRIANGLE (w, h)-(0, 0)-(w, 0), i TO(x2, y6, z2)-(x3, y7, z3)-(x4, y8, z4) 'strop
  119.  
  120.     _MAPTRIANGLE (0, h)-(w, h)-(0, 0), i TO(x1, y1, z1)-(x2, y2, z2)-(x1, y5, z1) 'prava stena             right wall
  121.     _MAPTRIANGLE (w, h)-(0, 0)-(w, 0), i TO(x2, y2, z2)-(x1, y5, z1)-(x2, y6, z2) 'prava stena
  122.  
  123.  
  124.     _MAPTRIANGLE (w, h)-(0, h)-(w, 0), i TO(x3, y3, z3)-(x4, y4, z4)-(x3, y7, z3) 'leva stena              left wall
  125.     _MAPTRIANGLE (0, h)-(w, 0)-(0, 0), i TO(x4, y4, z4)-(x3, y7, z3)-(x4, y8, z4) 'leva stena
  126.  
  127.  
  128.     _MAPTRIANGLE (w, h)-(0, h)-(w, 0), i TO(x1, y1, z1)-(x3, y3, z3)-(x1, y5, z1) 'zadni stena             back wall
  129.     _MAPTRIANGLE (0, h)-(w, 0)-(0, 0), i TO(x3, y3, z3)-(x1, y5, z1)-(x3, y7, z3) 'zadni stena
  130.  
  131.  
  132.     _MAPTRIANGLE (0, h)-(w, h)-(0, 0), i TO(x2, y2, z2)-(x4, y4, z4)-(x2, y6, z2) 'predni stena            front wall
  133.     _MAPTRIANGLE (w, h)-(0, 0)-(w, 0), i TO(x4, y4, z4)-(x2, y6, z2)-(x4, y8, z4) 'zadni stena
  134.  
  135.  
  136.     _DISPLAY
  137.     _LIMIT 50
  138.  
  139. SUB kostka (x, y, z) 'zadavas levy horni predni roh ,udela kostku v zadane x,y,z                         x y z are coordinates for left upper corner, do cube on this place
  140.  
  141.  
  142.     W = _WIDTH(texture&)
  143.     H = _HEIGHT(texture&)
  144.  
  145.     '                g                       h                                e                  f
  146.     MAPQUAD x + -1.5, y + 1.5, z + -1.5, x + .5, y + 1.5, z + -1.5, x + -1.5, y + -.5, z + -1.5, x + .5, y + -.5, z - 1.5, texture&
  147.     MAPQUAD x + -1, y + 1, z + -1, x + 1, y + 1, z + -1, x + -1.5, y + 1.5, z + -1.5, x + .5, y + 1.5, z + -1.5, texture&
  148.     MAPQUAD x + -1.5, y + -.5, z + -1.5, x + .5, y + -.5, z - 1.5, x + -1, y + -1, z + -1, x + 1, y - 1, z - 1, texture& '
  149.     MAPQUAD x + -1, y + 1, z + -1, x + -1.5, y + 1.5, z + -1.5, x + -1, y + -1, z + -1, x + -1.5, y + -.5, z + -1.5, texture&
  150.     MAPQUAD x + .5, y + 1.5, z + -1.5, x + .5, y + -.5, z - 1.5, x + 1, y - 1, z - 1, x + 1, y + 1, z + -1, texture&
  151.     '                a                     b                    c                       d
  152.     MAPQUAD x + -1, y + 1, z + -1, x + 1, y + 1, z + -1, x + -1, y + -1, z + -1, x + 1, y - 1, z - 1, texture&
  153.  
  154.  
  155.  
  156.  
  157.  
  158. SUB MAPQUAD (x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, texture AS LONG)
  159.     W = _WIDTH(texture&)
  160.     H = _HEIGHT(texture&)
  161.     GOTO nerot 'comment it for show, how it hat not to see...
  162.  
  163.     po = _PI(2) / 4
  164.  
  165.     s1 = SIN(rot + (1 * po)) * x1
  166.     c1 = COS(rot + (1 * po)) * y1
  167.  
  168.     s2 = SIN(rot + (2 * po)) * x2
  169.     c2 = COS(rot + (2 * po)) * y2
  170.  
  171.     s3 = SIN(rot + (3 * po)) * x3
  172.     c3 = COS(rot + (3 * po)) * y3
  173.  
  174.     s4 = SIN(rot + (4 * po)) * x4
  175.     c4 = COS(rot + (4 * po)) * y4
  176.  
  177.     x1 = x1 + s1: y1 = y1 + c1
  178.     x3 = x3 + s3: y3 = y3 + c3
  179.  
  180.     x2 = x2 + s2: y2 = y2 + c2
  181.     x4 = x4 + s4: y4 = y4 + c4
  182.  
  183.     nerot:
  184.     _MAPTRIANGLE (0, 0)-(W, 0)-(0, H), texture& TO(x1, y1, z1)-(x2, y2, z2)-(x3, y3, z3)
  185.     _MAPTRIANGLE (W, 0)-(0, H)-(W, H), texture& TO(x2, y2, z2)-(x3, y3, z3)-(x4, y4, z4)
  186.  
  187. SUB init
  188.     text$ = " Petr" 'width = 32 pixels (records)
  189.  
  190.     virtual& = _NEWIMAGE(100, 100, 256)
  191.     _DEST virtual&
  192.     PRINT text$
  193.     _SOURCE virtual&
  194.     i = 0
  195.     FOR Y = 17 TO 0 STEP -1
  196.         FOR X = 0 TO 50
  197.             IF POINT(X, Y) <> 0 THEN
  198.                 T(i).x = (-8.5 + X)
  199.                 T(i).y = -18 + (16 - Y) * 2
  200.                 T(i).z = -5 - X
  201.             END IF
  202.             i = i + 1
  203.     NEXT X, Y
  204.     _DEST 0: _SOURCE 0: _FREEIMAGE virtual&
  205.     i = 0
  206.  
  207.  
  208. SUB clock (x, y)
  209.     de = _DEST
  210.     clocka& = _NEWIMAGE(100, 100, 32)
  211.     _DEST clocka&
  212.     vterina = VAL(RIGHT$(TIME$, 2))
  213.     hodina = VAL(LEFT$(TIME$, 2))
  214.     minuta = VAL(MID$(TIME$, 4, 2))
  215.  
  216.     IF hodina > 12 THEN hodina = hodina - 12
  217.     hodina = hodina + (1 / 59) * minuta
  218.  
  219.  
  220.     vt = vterina + 45
  221.     ho = hodina + 45
  222.     mi = minuta + 45
  223.  
  224.     pozicevterina = _PI(2) / 60 * vt
  225.     poziceminuta = _PI(2) / 60 * ho * 5
  226.     pozicehodina = _PI(2) / 60 * mi
  227.  
  228.     xs = 50 + COS(pozicevterina) * 30
  229.     ys = 50 + SIN(pozicevterina) * 30
  230.  
  231.     xm = 50 + COS(poziceminuta) * 35
  232.     ym = 50 + SIN(poziceminuta) * 35
  233.  
  234.     xh = 50 + COS(pozicehodina) * 40
  235.     yh = 50 + SIN(pozicehodina) * 40
  236.  
  237.     FOR n = 1 TO 100
  238.         LINE (n, 0)-(n, 99), _RGB32(127 - n, n, 27 + n), BF
  239.     NEXT n
  240.     LINE (0, 0)-(99, 99), _RGB32(255, 255, 255), B
  241.  
  242.     COLOR _RGBA32(127, 127, 127, 150)
  243.     _PRINTSTRING (35, 45), "QB64"
  244.     COLOR _RGB32(255, 255, 255)
  245.  
  246.  
  247.     LINE (50, 50)-(xh, yh), _RGB32(255, 255, 0)
  248.     LINE (50, 50)-(xm, ym), _RGB32(255, 255, 0)
  249.     LINE (50, 50)-(xs, ys), _RGB32(0, 255, 255)
  250.     m = 0
  251.     FOR kruh = 0 TO _PI(2) STEP _PI(2) / 60
  252.         PSET (50 + COS(kruh) * 47, 50 + SIN(kruh) * 47)
  253.         IF m MOD 5 = 0 THEN LINE (50 + COS(kruh) * 47, 50 + SIN(kruh) * 47)-(50 + COS(kruh) * 44, 50 + SIN(kruh) * 44), , BF
  254.         m = m + 1
  255.     NEXT kruh
  256.     _DEST de
  257.     _SETALPHA 100, , clocka&
  258.     _PUTIMAGE (x, y), clocka&, de
  259.     _FREEIMAGE clocka&
  260.  

rotation 3D.JPG
* rotation 3D.JPG (Filesize: 48.3 KB, Dimensions: 818x636, Views: 517)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #17 on: January 09, 2019, 05:37:38 am »
Hi Petr! It is nicely done... 3D Text Effect is awesome! I like how the texture changes in real-time.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #18 on: January 09, 2019, 10:51:04 am »
Thank you, Ashish. I'm glad you like it.

FellippeHeitor

  • Guest
Re: MAPTRIANGLE in 3D
« Reply #19 on: January 09, 2019, 11:11:00 am »
Oh! No SUB _GL! That's impressive.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #20 on: January 09, 2019, 03:23:49 pm »
Petr,

Most of 'how that works' is WAY over my head... I, for one, didn't think these types of effects could be done using only Basic. Well done! I'm impressed! Brilliant!

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #21 on: January 09, 2019, 08:54:35 pm »
Another awesome effort Petr, I like how you made block letters from a 2D print and used live clocks for a texture.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #22 on: January 10, 2019, 03:52:11 pm »
Thank you all very much for your feedback. :-D

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #23 on: January 13, 2019, 12:22:46 pm »
very cool this 3d demo (more the last without gl)
Programming isn't difficult, only it's  consuming time and coffee

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D: ROOM
« Reply #24 on: February 01, 2019, 04:32:56 pm »
So if you liked the previous program, I wonder what you will say about this. Exactly in this style like this program I will continue. The program will allow you a virtual tour of my kitchen where I write programs. Excuse the exaggerated size of the room, in fact it's half, I guessed it. Textures are only approximate. If anyone would like to explain some details of this program, ask, I will to answer later.
This whole program is written again without OpenGL commands, only with MAPTRIANGLE 3D. Use arrows to control, end with Esc.

Code: QB64: [Select]
  1. DIM SHARED lX, lY, rXx, rY, mX, mY, ballX AS INTEGER, ballY AS INTEGER, m&, leftplr, rightplr
  2. m& = _NEWIMAGE(320, 240, 32)
  3. lX = 10: lY = 10: rxX = 310: rY = 10
  4. ballX = 160: ballY = 10: mY = -1: IF RND * 10 > 5 THEN mX = 1 ELSE mX = -1
  5. DIM SHARED dub AS LONG, aluminium as long
  6.  
  7.  
  8.  
  9. print "Loading textures..."
  10. extractpmf ("textures.pmf")
  11.  
  12. aluminium& = hload("alum.jpg")
  13. podl& = Hload("plovoucka.jpg")
  14. str& = strop&
  15. tokno& = okno&
  16. dvere& = spajz_dvere&
  17. lednice& = Hload("lednice2.jpg")
  18. orech& = Hload("dekor orech.jpg")
  19. orechsv& = Zesvetli("dekor orech.jpg")
  20. polstr& = Hload("polstr.jpg")
  21. dub& = Hload("dub.jpg")
  22. tdub& = Ztmav("dub.jpg")
  23.  
  24. pc& = SHload("pccs.png")
  25. kbd& = SHload("kbd.jpg")
  26. mys& = SHload("mys.jpg")
  27. woof& = SHload("repro.png")
  28. speak& = Hload("speaker.jpg")
  29. dlazba& = Hload("obklad.jpg")
  30. dlazba2& = Hload("obklad 2.jpg")
  31. sporakcelo = Hload("sporak-celo.jpg")
  32. sporakvrch = Hload("sporak-vrch.jpg")
  33. mikro& = SHload("mikro2.jpg")
  34.  
  35.  
  36. SCREEN _NEWIMAGE(800, 600, 32)
  37.  
  38. CX = 0: CY = 0: CZ = -1 '
  39. N = 1116 'used quads (also this room contains 2232 triangles)
  40.  
  41.  
  42.     X AS SINGLE '                                                                  source X points in standard view
  43.     Y AS SINGLE '                                                                  source Y points in standard view
  44.     Z AS SINGLE '                                                                  not use yet
  45.     pi AS SINGLE '                                                                 start draw position on radius
  46.     piH as single '
  47.     Radius AS SINGLE '                                                             radius (every point use own, but if is CX and CY in middle, are all the same)
  48.     RadiusH as single
  49.     wX AS SINGLE '                                                                 working coordinates
  50.     wY AS SINGLE
  51.     wZ AS SINGLE
  52.  
  53.     T AS LONG '                                                                    texture number for current triangle
  54.     Tm AS SINGLE '                                                                 texture multiplicier. 1 for one.
  55.  
  56.  
  57. DIM SHARED v(1 TO N) AS V
  58.  
  59. '         A          B        C         D
  60. DATA -10,-2,-5,-10,-2,10,10,-2,-5,10,-2,10: ' floor coordinates
  61. DATA -10,2,-5,-10,2,10,10,2,-5,10,2,10: '     roof coordinates
  62. DATA -10,-2,-5,-10,-2,10,-10,2,-5,-10,2,10: ' wall + window
  63. DATA -5,-2,8,-10,-2,8,-5,2,8,-10,2,8
  64. 'refrigerator
  65. DATA -5,-2,8,-5,-2.1,10,-5,2.1,8,-5,2,10
  66. DATA -5,-3,10,10,-3,10,-5,3,10,10,3,10
  67. DATA -4.8,-2,8,-3,-2,8,-4.8,1,8,-3,1,8
  68. DATA -5,1,8,-3,1,8,-5,1,10,-3,1,10
  69. DATA -3,1,8,-3,1,10,-3,-2,8,-3,-2,10
  70. DATA -4.8,1,8,-4.8,1,10,-4.8,-2,8,-4.8,-2,10
  71. 'bench
  72. DATA -2.8,-1.5,8,-2.8,-1.5,9,-2.8,-2,8,-2.8,-2,9
  73. DATA -2.7,-1.5,8,-2.7,-1.5,9,-2.7,-2,8,-2.7,-2,9
  74. DATA 0.8,-1.5,8,0.8,-1.5,9,0.8,-2,8,0.8,-2,9
  75. DATA 0.7,-1.5,8,0.7,-1.5,9,0.7,-2,8,0.7,-2,9
  76. DATA 0.7,-1.5,8,0.8,-1.5,8,.7,-2,8,0.8,-2,8
  77. DATA -2.7,-1.5,8,-2.8,-1.5,8,-2.7,-2,8,-2.8,-2,8
  78. DATA 2,-1.5,8,-3.0,-1.5,8,2,-1.5,10.5,-3.0,-1.5,10.5
  79. DATA 4.39,-1.5,9.5,-3,-1.5,9.5,4.39,0,10,-3,0,10
  80. DATA 1.9,-1.5,10,4.4,-1.5,10,1.9,-1.5,3,4.4,-1.5,3
  81. DATA 3.9,-1.5,10,3.9,-1.5,3,4.4,0,10,4.4,0,3
  82. DATA 1.9,-1.5,8,3.9,-1.5,8,1.9,-2,8,3.9,-2,8
  83. DATA 1.9,-1.5,7.9,3.9,-1.5,7.9,1.9,-2,7.9,3.9,-2,7.9
  84. DATA 1.9,-1.5,8,1.9,-1.5,7.9,1.9,-2,8,1.9,-2,7.9
  85. DATA 1.9,-2,3,4.4,-2,3,1.9,-1.5,3,4.4,-1.5,3
  86. DATA 1.9,-2,3.1,4.4,-2,3.1,1.9,-1.5,3.1,4.4,-1.5,3.1
  87. DATA 4.4,-2,3.1,4.4,-2,3,4.4,-1.5,3.1,4.4,-1.5,3
  88. DATA 1.9,-2,3.1,1.9,-2,3,1.9,-1.5,3.1,1.9,-1.5,3
  89. DATA 3.9,-1.5,3,4.4,-1.5,3,4.4,0,3,4.4,0,3
  90. DATA 4.4,-2,10,4.4,-2,3,4.4,0,10,4.4,0,3
  91. DATA 1.5,-2,7.5,1.7,-2,7.5,1.5,-1,7.5,1.7,-1,7.5
  92. DATA 1.5,-2,7.3,1.7,-2,7.3,1.5,-1,7.3,1.7,-1,7.3
  93. DATA 1.5,-2,7.3,1.5,-1,7.3,1.5,-2,7.5,1.5,-1,7.5
  94. DATA 1.7,-2,7.3,1.7,-1,7.3,1.7,-2,7.5,1.7,-1,7.5
  95. DATA -2,-2,7.5,-2.2,-2,7.5,-2,-1,7.5,-2.2,-1,7.5
  96. DATA -2,-2,7.3,-2.2,-2,7.3,-2,-1,7.3,-2.2,-1,7.3
  97. DATA -2,-2,7.3,-2,-1,7.3,-2,-2,7.5,-2,-1,7.5
  98. DATA -2.2,-2,7.3,-2.2,-1,7.3,-2.2,-2,7.5,-2.2,-1,7.5
  99. DATA 1.5,-2,3.5,1.7,-2,3.5,1.5,-1,3.5,1.7,-1,3.5
  100. DATA 1.5,-2,3.7,1.7,-2,3.7,1.5,-1,3.7,1.7,-1,3.7
  101. DATA 1.5,-2,3.7,1.5,-1,3.7,1.5,-2,3.5,1.5,-1,3.5
  102. DATA 1.7,-2,3.7,1.7,-1,3.7,1.7,-2,3.5,1.7,-1,3.5
  103. DATA -2,-2,3.5,-2.2,-2,3.5,-2,-1,3.5,-2.2,-1,3.5
  104. DATA -2,-2,3.7,-2.2,-2,3.7,-2,-1,3.7,-2.2,-1,3.7
  105. DATA -2,-2,3.7,-2,-1,3.7,-2,-2,3.5,-2,-1,3.5
  106. DATA -2.2,-2,3.7,-2.2,-1,3.7,-2.2,-2,3.5,-2.2,-1,3.5
  107. DATA 1.5,-1,3.5,-2,-1,3.5,1.5,-1.1,3.5,-2,-1.1,3.5
  108. DATA 1.5,-1,7.5,-2,-1,7.5,1.5,-1.1,7.5,-2,-1.1,7.5
  109. DATA 1.7,-1,3.5,1.7,-1,7.5,1.7,-1.1,3.5,1.7,-1.1,7.5
  110. DATA -2.2,-1,3.5,-2.2,-1,7.5,-2.2,-1.1,3.5,-2.2,-1.1,7.5
  111. 'desk
  112. DATA 1.8,-1,3.4,-2.3,-1,3.4,1.8,-1,7.6,-2.3,-1,7.6
  113. DATA 1.8,-.9,3.4,-2.3,-.9,3.4,1.8,-.9,7.6,-2.3,-.9,7.6
  114. DATA 1.8,-.9,3.4,-2.3,-.9,3.4,1.8,-1,3.4,-2.3,-1,3.4
  115. DATA 1.8,-.9,7.6,-2.3,-.9,7.6,1.8,-1,7.6,-2.3,-1,7.6
  116. DATA 1.8,-.9,3.4,1.8,-1,3.4,1.8,-.9,7.6,1.8,-1,7.6
  117. DATA -2.3,-.9,3.4,-2.3,-1,3.4,-2.3,-.9,7.6,-2.3,-1,7.6
  118. 'chair
  119. DATA .3,-2,3.9,.4,-2,3.9,.3,-1.5,3.9,.4,-1.5,3.9
  120. DATA .3,-2,3.8,.4,-2,3.8,.3,-1.5,3.8,.4,-1.5,3.8
  121. DATA .3,-2,3.8,.3,-2,3.9,.3,-1.5,3.8,.3,-1.5,3.9
  122. DATA .4,-2,3.8,.4,-2,3.9,.4,-1.5,3.8,.4,-1.5,3.9
  123. DATA -.7,-2,3.9,-.8,-2,3.9,-.7,-1.5,3.9,-.8,-1.5,3.9
  124. DATA -.7,-2,3.8,-.8,-2,3.8,-.7,-1.5,3.8,-.8,-1.5,3.8
  125. DATA -.7,-2,3.8,-.7,-2,3.9,-.7,-1.5,3.8,-.7,-1.5,3.9
  126. DATA -.8,-2,3.8,-.8,-2,3.9,-.8,-1.5,3.8,-.8,-1.5,3.9
  127. DATA .3,-2,3,.4,-2,3,.3,-1.5,3,.4,-1.5,3
  128. DATA .3,-2,3.1,.4,-2,3.1,.3,-1.5,3.1,.4,-1.5,3.1
  129. DATA .3,-2,3.1,.3,-2,3,.3,-1.5,3.1,.3,-1.5,3
  130. DATA .4,-2,3.1,.4,-2,3,.4,-1.5,3.1,.4,-1.5,3
  131. DATA -.7,-2,3,-.8,-2,3,-.7,-1.5,3,-.8,-1.5,3
  132. DATA -.7,-2,3.1,-.8,-2,3.1,-.7,-1.5,3.1,-.8,-1.5,3.1
  133. DATA -.7,-2,3.1,-.7,-2,3,-.7,-1.5,3.1,-.7,-1.5,3
  134. DATA -.8,-2,3.1,-.8,-2,3,-.8,-1.5,3.1,-.8,-1.5,3
  135. DATA .5,-1.5,4.1,-.9,-1.5,4.1,.5,-1.5,2.9,-.9,-1.5,2.9
  136. DATA .5,-1.4,4.1,-.9,-1.4,4.1,.5,-1.4,2.9,-.9,-1.4,2.9
  137. DATA .5,-1.5,4.1,-.9,-1.5,4.1,.5,-1.4,4.1,-.9,-1.4,4.1
  138. DATA .5,-1.5,2.9,-.9,-1.5,2.9,.5,-1.4,2.9,-.9,-1.4,2.9
  139. DATA -.9,-1.5,2.9,-.9,-1.4,2.9,-.9,-1.5,4.1,-.9,-1.4,4.1
  140. DATA .5,-1.5,2.9,.5,-1.4,2.9,.5,-1.5,4.1,.5,-1.4,4.1
  141. DATA -.9,-1.5,2.9,.5,-1.5,2.9,-.9,0,2.7,.5,0,2.7
  142. DATA -.9,-1.5,3,.5,-1.5,3,-.9,0,2.8,.5,0,2.8
  143. DATA -.9,-1.5,2.9,-.9,-1.5,3,-.9,0,2.7,-.9,0,2.8
  144. DATA -.9,0,2.9,.5,0,2.9,-.9,0,2.7,.5,0,2.7
  145. DATA .5,-1.5,2.9,.5,-1.5,3,.5,0,2.7,.5,0,2.8
  146.  
  147. 'chair 2
  148. DATA -1.3,-2,4.9,-1.4,-2,4.9,-1.3,-1.5,4.9,-1.4,-1.5,4.9
  149. DATA -1.3,-2,4.8,-1.4,-2,4.8,-1.3,-1.5,4.8,-1.4,-1.5,4.8
  150. DATA -1.3,-2,4.8,-1.3,-2,4.9,-1.3,-1.5,4.8,-1.3,-1.5,4.9
  151. DATA -1.4,-2,4.8,-1.4,-2,4.9,-1.4,-1.5,4.8,-1.4,-1.5,4.9
  152. DATA -1.3,-2,5.9,-1.4,-2,5.9,-1.3,-1.5,5.9,-1.4,-1.5,5.9
  153. DATA -1.3,-2,5.8,-1.4,-2,5.8,-1.3,-1.5,5.8,-1.4,-1.5,5.8
  154. DATA -1.3,-2,5.8,-1.3,-2,5.9,-1.3,-1.5,5.8,-1.3,-1.5,5.9
  155. DATA -1.4,-2,5.8,-1.4,-2,5.9,-1.4,-1.5,5.8,-1.4,-1.5,5.9
  156. DATA -2.3,-2,4.9,-2.4,-2,4.9,-2.3,-1.5,4.9,-2.4,-1.5,4.9
  157. DATA -2.3,-2,4.8,-2.4,-2,4.8,-2.3,-1.5,4.8,-2.4,-1.5,4.8
  158. DATA -2.3,-2,4.8,-2.3,-2,4.9,-2.3,-1.5,4.8,-2.3,-1.5,4.9
  159. DATA -2.4,-2,4.8,-2.4,-2,4.9,-2.4,-1.5,4.8,-2.4,-1.5,4.9
  160. DATA -2.3,-2,5.9,-2.4,-2,5.9,-2.3,-1.5,5.9,-2.4,-1.5,5.9
  161. DATA -2.3,-2,5.8,-2.4,-2,5.8,-2.3,-1.5,5.8,-2.4,-1.5,5.8
  162. DATA -2.3,-2,5.8,-2.3,-2,5.9,-2.3,-1.5,5.8,-2.3,-1.5,5.9
  163. DATA -2.4,-2,5.8,-2.4,-2,5.9,-2.4,-1.5,5.8,-2.4,-1.5,5.9
  164. DATA -1.2,-1.5,4.7,-2.5,-1.5,4.7,-1.2,-1.5,6,-2.5,-1.5,6
  165. DATA -1.2,-1.4,4.7,-2.5,-1.4,4.7,-1.2,-1.4,6,-2.5,-1.4,6
  166. DATA -1.2,-1.5,4.7,-2.5,-1.5,4.7,-1.2,-1.4,4.7,-2.5,-1.4,4.7
  167. DATA -1.2,-1.5,6,-2.5,-1.5,6,-1.2,-1.4,6,-2.5,-1.4,6
  168. DATA -1.2,-1.5,4.7,-1.2,-1.4,4.7,-1.2,-1.5,6,-1.2,-1.4,6
  169. DATA -2.5,-1.5,4.7,-2.5,-1.4,4.7,-2.5,-1.5,6,-2.5,-1.4,6
  170. DATA -2.3,-1.5,4.7,-2.3,-1.5,6,-2.5,0,4.7,-2.5,0,6
  171. DATA -2.4,-1.5,4.7,-2.4,-1.5,6,-2.6,0,4.7,-2.6,0,6
  172. DATA -2.3,-1.5,4.7,-2.5,-1.5,4.7,-2.5,0,4.7,-2.7,0,4.7
  173. DATA -2.3,-1.5,6,-2.5,-1.5,6,-2.5,0,6,-2.7,0,6
  174. 'here is wall at the computer
  175. DATA 10,-2,-5,10,-2,0,10,2.1,-5,10,2.1,0
  176. DATA 10,-2,5,10,-2,0,10,2,5,10,2,0
  177. DATA 10,-2,10,10,-2,5,10,2.1,10,10,2.1,5
  178. 'here is the PC table
  179. DATA 10,-2,8,9.8,-2,8,10,-.7,8,9.8,-.7,8
  180. DATA 9.8,-2,8,9.8,-.7,8,9.8,-2,10,9.8,-.7,10
  181. DATA 4.4,-2,8,4.6,-2,8,4.4,-.7,8,4.6,-.7,8
  182. DATA 4.6,-2,8,4.6,-.7,8,4.6,-2,10,4.6,-.7,10
  183. DATA 9.8,-.7,9.8,4.6,-.7,9.8,9.8,-1.5,9.8,4.6,-1.5,9.8
  184. DATA 9.8,-1.5,9.8,4.6,-1.5,9.8,9.8,-1.5,10,4.6,-1.5,10
  185. dATA 7.5,-2,8,7.7,-2,8,7.5,-.7,8,7.7,-.7,8
  186. DATA 7.5,-2,8,7.5,-.7,8,7.5,-2,9.8,7.5,-.7,9.8
  187. DATA 7.7,-2,8,7.7,-.7,8,7.7,-2,9.8,7.7,-.7,9.8
  188. DATA 9.8,-2,8.3,7.5,-2,8.3,9.8,-1.8,8.3,7.5,-1.8,8.3
  189. DATA 9.8,-1.75,8.1,7.5,-1.75,8.1,9.8,-1.25,8.1,7.5,-1.25,8.1
  190. DATA 9.8,-1.2,8.1,7.5,-1.2,8.1,9.8,-.9,8.1,7.5,-.9,8.1
  191. DATA 9.8,-1.75,8.1,7.5,-1.75,8.1,9.8,-1.75,9,7.5,-1.75,9
  192. DATA 9.8,-1.2,8.1,7.5,-1.2,8.1,9.8,-1.2,9,7.5,-1.2,9
  193. DATA 9.8,-.9,8.1,7.5,-.9,8.1,9.8,-.9,9,7.5,-.9,9
  194. DATA 9.8,-2,9.8,7.5,-2,9.8,9.8,-.7,9.8,7.5,-.7,9.8
  195. DATA 10,-.7,7.9,4.4,-.7,7.9,10,-.5,7.9,4.4,-.5,7.9
  196. DATA 10,-.7,7.9,4.4,-.7,7.9,10,-.7,10,4.4,-.7,10
  197. DATA 10,-.5,7.9,4.4,-.5,7.9,10,-.5,10,4.4,-.5,10
  198. 'compputer
  199. DATA 5,-2,8,5,-2,8.5,5,-1.5,8,5,-1.5,8.5
  200. DATA 5,-1.5,8,5,-1.5,8.5,4.7,-1.5,8,4.7,-1.5,8.5
  201. DATA 4.7,-2,8,4.7,-2,8.5,4.7,-1.5,8,4.7,-1.5,8.5
  202. DATA 4.7,-2,8,5,-2,8,4.7,-1.5,8,5,-1.5,8
  203. 'monitor
  204. DATA 9.7,-.3,8.5,     7.7,-.3,9.6,   9.7,1,8.5,     7.7,1,9.6
  205. DATA 9.7,-.3,8.6,9.7,1,8.6,7.7,-.3,9.7,7.7,1,9.7
  206. DATA 7.7,-.3,9.6,7.7,1,9.6,7.7,-.3,9.7,7.7,1,9.7
  207. DATA 9.7,-.3,8.6,9.7,-.5,8.6,7.7,-.3,9.7,7.7,-.5,9.7
  208. DATA 9.2,-.49,8.6,8.2,-.49,8.6,9.2,-.49,10,8.2,-.49,10
  209. 'keyboard
  210. DATA 6.5,-.45,7.9,5.7,-.45,7.9,6.5,-.39,8.2,5.7,-.39,8.2: 'just shifted in space a 2D texture, not really 3D
  211. DATA 5.3,-.45,7.9,5,-.45,7.9,5.3,-.39,8,5,-.39,8: 'mouse - as keyboard
  212. 'subwoofer
  213. DATA 7.4,-2,9.8,7.4,-2,9,7.4,-1.5,9.8,7.4,-1.5,9
  214. DATA 7,-2,9.8,7,-2,9,7,-1.5,9.8,7,-1.5,9
  215. DATA 7.4,-2,9.8,7,-2,9.8,7.4,-1.5,9.8,7,-1.5,9.8
  216. DATA 7.4,-1.5,9.8,7,-1.5,9.8,7.4,-1.5,9,7,-1.5,9
  217. DATA 7.4,-2,9,7,-2,9,7.4,-1.5,9,7,-1.5,9
  218. 'speaker right
  219. DATA 4.7,-.5,10,4.7,0,10,4.7,-.5,9.7,4.7,0,9.7
  220. DATA 4.41,-.5,10,4.41,0,10,4.41,-.5,9.7,4.41,0,9.7
  221. DATA 4.41,0,10,4.41,0,9.7,4.7,0,10,4.7,0,9.7
  222. DATA 4.7,-.5,9.7,4.41,-.5,9.7,4.7,0,9.7,4.41,0,9.7
  223. 'speaker left
  224. DATA 6.7,-.5,10,6.7,0,10,6.7,-.5,9.7,6.7,0,9.7
  225. DATA 6.41,-.5,10,6.41,0,10,6.41,-.5,9.7,6.41,0,9.7
  226. DATA 6.41,0,10,6.41,0,9.7,6.7,0,10,6.7,0,9.7
  227. DATA 6.7,-.5,9.7,6.41,-.5,9.7,6.7,0,9.7,6.41,0,9.7
  228.  
  229. 'wall with kitchen unit, again walls with doors first
  230. DATA 10,-2,-5,5,-2,-5,10,2,-5,5,2,-5
  231. DATA -10,-2,-4.99,7,-2,-4.99,-10,1,-4.99,7,1,-4.99
  232. DATA -10,2,-4.99,7,2,-4.99,-10,1,-4.99,7,1,-4.99
  233. DATA 5,-2,-3.5,7,-2,-3.5,5,-0.5,-3.5,7,-0.5,-3.5
  234. DATA 5,-.5,-3.5,7,-.5,-3.5,5,-.5,-4.9,7,-.5,-4.9
  235. DATA 5,-2,-3.5,5,-.5,-3.5,5,-2,-4.9,5,-.5,-4.9
  236. DATA 7,-2,-3.5,7,-.5,-3.5,7,-2,-4.9,7,-.5,-4.9
  237. DATA 5,-2,-4.9,7,-2,-4.9,5,-0.5,-4.9,7,-0.5,-4.9
  238.  
  239. 'gas cooker
  240. DATA 4.9,-2,-4.9,4.9,-.5,-4.9,4.9,-2,-3.5,4.9,-.5,-3.5
  241. DATA 4.9,-.5,-3.4,-2.99,-.5,-3.4,4.9,-.5,-4.9,-2.99,-.5,-4.9
  242. DATA 4.9,-.6,-3.4,-2.99,-.6,-3.4,4.9,-.6,-4.9,-2.99,-.6,-4.9
  243. DATA 4.9,-.6,-3.4,-2.99,-.6,-3.4,4.9,-.5,-3.4,-2.99,-.5,-3.4
  244. DATA 4.9,1.6,-3.7,-9.99,1.6,-3.7,4.9,1.6,-4.9,-9.99,1.6,-4.9
  245. DATA 4.9,1.7,-3.7,-9.99,1.7,-3.7,4.9,1.7,-4.9,-9.99,1.7,-4.9
  246. DATA 4.9,1.7,-3.7,-9.99,1.7,-3.7,4.9,1.6,-3.7,-9.99,1.6,-3.7
  247. DATA 4.9,.6,-3.7,-9.99,.6,-3.7,4.9,.6,-4.9,-9.99,.6,-4.9
  248. DATA 4.9,.7,-3.7,-9.99,.7,-3.7,4.9,.7,-4.9,-9.99,.7,-4.9
  249. DATA 4.9,.7,-3.7,-9.99,.7,-3.7,4.9,.6,-3.7,-9.99,.6,-3.7
  250. DATA 4.9,-2,-3.5,4.9,-.5,-3.5,4.8,-2,-3.5,4.8,-.5,-3.5
  251. DATA 4.9,1.7,-3.7,4.9,.6,-3.7,4.9,1.7,-4.9,4.9,.6,-4.9
  252. DATA 4.9,1.7,-3.7,4.9,.6,-3.7,4.8,1.7,-3.7,4.8,.6,-3.7
  253. DATA 1.9,1.7,-3.7,1.9,.6,-3.7,1.8,1.7,-3.7,1.8,.6,-3.7
  254. DATA 1.9,-2,-3.7,1.9,-.6,-3.7,1.8,-2,-3.7,1.8,-.6,-3.7
  255. DATA 2.9,1.7,-3.7,2.9,.6,-3.7,2.8,1.7,-3.7,2.8,.6,-3.7
  256. DATA 2.9,-2,-3.7,2.9,-.6,-3.7,2.8,-2,-3.7,2.8,-.6,-3.7
  257. DATA 3.9,1.7,-3.7,3.9,.6,-3.7,3.8,1.7,-3.7,3.8,.6,-3.7
  258. DATA 3.9,-2,-3.7,3.9,-.6,-3.7,3.8,-2,-3.7,3.8,-.6,-3.7
  259. DATA 0.9,1.7,-3.7,0.9,.6,-3.7,0.8,1.7,-3.7,0.8,.6,-3.7
  260. DATA 0.9,-2,-3.7,0.9,-.6,-3.7,0.8,-2,-3.7,0.8,-.6,-3.7
  261. DATA -5.9,1.7,-3.7,-5.9,.6,-3.7,-5.8,1.7,-3.7,-5.8,.6,-3.7
  262. DATA -5.9,-2,-3.7,   -5.9,-.6,-3.7,    -5.8,-2,-3.7,    -5.8,-.6,-3.7
  263. DATA -1.9,1.7,-3.7,-1.9,.6,-3.7,-1.8,1.7,-3.7,-1.8,.6,-3.7
  264. DATA -1.9,-2,-3.7,-1.9,-.6,-3.7,-1.8,-2,-3.7,-1.8,-.6,-3.7
  265. DATA -2.9,1.7,-3.7,-2.9,.6,-3.7,-2.8,1.7,-3.7,-2.8,.6,-3.7
  266. DATA -2.9,-2,-3.7,-2.9,-.6,-3.7,-2.8,-2,-3.7,-2.8,-.6,-3.7
  267. DATA -3.9,1.7,-3.7,-3.9,.6,-3.7,-3.8,1.7,-3.7,-3.8,.6,-3.7
  268. DATA -3.9,-2,-3.7,-3.9,-.6,-3.7,-3.8,-2,-3.7,-3.8,-.6,-3.7
  269. DATA -4.9,1.7,-3.7,-4.9,.6,-3.7,-4.8,1.7,-3.7,-4.8,.6,-3.7
  270. DATA -4.9,-2,-3.7,-4.9,-.6,-3.7,-4.8,-2,-3.7,-4.8,-.6,-3.7
  271. DATA -0.9,1.7,-3.7,-0.9,.6,-3.7,-0.8,1.7,-3.7,-0.8,.6,-3.7
  272. DATA -0.9,-2,-3.7,-0.9,-.6,-3.7,-0.8,-2,-3.7,-0.8,-.6,-3.7
  273. DATA -5.9,1.7,-3.7,-5.9,.6,-3.7,-5.8,1.7,-3.7,-5.8,.6,-3.7
  274. DATA -5.9,-2,-3.7,-5.9,-.6,-3.7,-5.8,-2,-3.7,-5.8,-.6,-3.7
  275. DATA -6.9,1.7,-3.7,-6.9,.6,-3.7,-6.8,1.7,-3.7,-6.8,.6,-3.7
  276. DATA -6.9,-2,-3.7,-6.9,-.6,-3.7,-6.8,-2,-3.7,-6.8,-.6,-3.7
  277. DATA -9.99,-.5,-3.4,-3.7,-.5,-3.4,-9.99,-.5,-4.9,-3.7,-.5,-4.9
  278. DATA -9.99,-.6,-3.4,-3.7,-.6,-3.4,-9.99,-.6,-4.9,-3.7,-.6,-4.9
  279. DATA -9.99,-.6,-3.4,-3.7,-.6,-3.4,-9.99,-.5,-3.4,-3.7,-.5,-3.4
  280. DATA -3.7,-.6,-3.4,-2.99,-.6,-3.4,-3.7,-.5,-3.4,-2.99,-.5,-3.4
  281. DATA -3.7,-.5,-3.4,-2.99,-.5,-3.4,-3.7,-.5,-3.75,-2.99,-.5,-3.75
  282. DATA -3.7,-.5,-4.7,-2.99,-.5,-4.7,-3.7,-.5,-4.9,-2.99,-.5,-4.9
  283. 'SINK:
  284. DATA -3.7,-.5,-3.75,-2.99,-.5,-3.75,-3.7,-.9,-3.75,-2.99,-.9,-3.75
  285. DATA -3.7,-.5,-4.7,-2.99,-.5,-4.7,-3.7,-.9,-4.7,-2.99,-.9,-4.7
  286. DATA -3.7,-.5,-3.75,-3.7,-.5,-4.7,-3.7,-.9,-3.75,-3.7,-.9,-4.7
  287. DATA -2.99,-.5,-3.75,-2.99,-.5,-4.7,-2.99,-.9,-3.75,-2.99,-.9,-4.7
  288. DATA -3.7,-.9,-3.75,-3.7,-.9,-4.7,-2.99,-.9,-3.75,-2.99,-.9,-4.7
  289.  
  290.  
  291. DATA -3.2,-.1,-4.89,-3.5,-.1,-4.89,-3.2,-.1,-4.69,-3.5,-.1,-4.69
  292. DATA -3.2,-.2,-4.89,-3.5,-.2,-4.89,-3.2,-.2,-4.69,-3.5,-.2,-4.69
  293. DATA -3.2,-.1,-4.69,-3.5,-.1,-4.69,-3.2,-.2,-4.69,-3.5,-.2,-4.69
  294. DATA -3.2,-.1,-4.69,-3.2,-.2,-4.69,-3.2,-.1,-4.89,-3.2,-.2,-4.89
  295. DATA -3.5,-.1,-4.69,-3.5,-.2,-4.69,-3.5,-.1,-4.89,-3.5,-.2,-4.89
  296.  
  297. DATA -10.1,-2,-4.9,4.9,-2,-4.9,-10.1,-.49,-4.9,4.9,-.49,-4.9
  298. DATA -10.1,-1.99,-5,4.9,-1.99,-5,-10.1,-1.99,-3.7,4.9,-1.99,-3.7
  299. DATA -10.1,.8,-4.9,4.9,.8,-4.9,-10.1,1.6,-4.9,4.9,1.6,-4.9
  300. 'cabinet doors
  301. DATA 1.85,1.55,-3.71,1.85,0.6,-3.71,2.8,1.55,-3.71,2.8,0.6,-3.71
  302. DATA 1.85,-1.9,-3.71,1.85,-0.6,-3.71,2.8,-1.9,-3.71,2.8,-.6,-3.71
  303. DATA 2.85,1.55,-3.71,2.85,0.6,-3.71,3.8,1.55,-3.71,3.8,0.6,-3.71
  304. DATA 2.85,-1.9,-3.71,2.85,-0.6,-3.71,3.8,-1.9,-3.7,3.8,-.6,-3.71
  305. DATA 3.85,1.55,-3.71,3.85,0.6,-3.71,4.8,1.55,-3.71,4.8,0.6,-3.71
  306. DATA 3.85,-1.9,-3.71,3.85,-0.6,-3.71,4.8,-1.9,-3.71,4.8,-.6,-3.71
  307. DATA .85,1.55,-3.71,.85,0.6,-3.71,1.8,1.55,-3.71,1.8,0.6,-3.71
  308. DATA .85,-1.9,-3.71,.85,-0.6,-3.71,1.8,-1.9,-3.71,1.8,-.6,-3.71
  309. DATA -1.85,1.55,-3.71,-1.85,0.6,-3.71,-2.8,1.55,-3.71,-2.8,0.6,-3.71
  310. DATA -1.85,-1.9,-3.71,-1.85,-0.6,-3.71,-2.8,-1.9,-3.71,-2.8,-.6,-3.71
  311. DATA -2.85,1.55,-3.71,-2.85,0.6,-3.71,-3.8,1.55,-3.71,-3.8,0.6,-3.71
  312. DATA -2.85,-1.9,-3.71,-2.85,-0.6,-3.71,-3.8,-1.9,-3.7,-3.8,-.6,-3.71
  313. DATA -3.85,1.55,-3.71,-3.85,0.6,-3.71,-4.8,1.55,-3.71,-4.8,0.6,-3.71
  314. DATA -3.85,-1.9,-3.71,-3.85,-0.6,-3.71,-4.8,-1.9,-3.71,-4.8,-.6,-3.71
  315. DATA -.85,1.55,-3.71,-.85,0.6,-3.71,-1.8,1.55,-3.71,-1.8,0.6,-3.71
  316. DATA -.85,-1.9,-3.71,-.85,-0.6,-3.71,-1.8,-1.9,-3.71,-1.8,-.6,-3.71
  317. DATA -4.85,1.55,-3.71,-4.85,0.6,-3.71,-5.8,1.55,-3.71,-5.8,0.6,-3.71
  318. DATA -4.85,-1.9,-3.71,-4.85,-0.6,-3.71,-5.8,-1.9,-3.7,-5.8,-.6,-3.71
  319. DATA -5.85,1.55,-3.71,-5.85,0.6,-3.71,-6.8,1.55,-3.71,-6.8,0.6,-3.71
  320. DATA -5.85,-1.9,-3.71,-5.85,-0.6,-3.71,-6.8,-1.9,-3.71,-6.8,-.6,-3.71
  321. DATA -6.85,1.55,-3.71,-6.85,0.6,-3.71,-7.8,1.55,-3.71,-7.8,0.6,-3.71
  322. DATA -6.85,-1.9,-3.71,-6.85,-0.6,-3.71,-7.8,-1.9,-3.71,-7.8,-.6,-3.71
  323. DATA -9.98,-2,-5,-9.98,1,-5,-9.98,-2,0,-9.98,1,0
  324. DATA -9.97,-0.5,-3.4,-8.47,-.5,-3.4,-9.97,-0.5,0,-8.47,-.5,0
  325. DATA -9.97,-0.6,-3.4,-8.47,-.6,-3.4,-9.97,-0.6,0,-8.47,-.6,0
  326. DATA -9.97,.6,-3.7,-8.77,.6,-3.7,-9.97,.6,0,-8.77,.6,0
  327. DATA -9.97,.7,-3.7,-8.77,.7,-3.7,-9.97,.7,0,-8.77,.7,0
  328. DATA -9.97,1.6,-3.7,-8.77,1.6,-3.7,-9.97,1.6,0,-8.77,1.6,0
  329. DATA -9.97,1.7,-3.7,-8.77,1.7,-3.7,-9.97,1.7,0,-8.77,1.7,0
  330. DATA -9.97,-2,0,-8.77,-2,0,-9.97,-0.6,0,-8.77,-0.6,0
  331. DATA -9.97,1.6,0,-8.77,1.6,0,-9.97,0.7,0,-8.77,0.7,0
  332. DATA -9.97,-2,-.2,-8.77,-2,-.2,-9.97,-0.6,-.2,-8.77,-0.6,-.2
  333. DATA -9.97,1.6,-.2,-8.77,1.6,-.2,-9.97,0.7,-.2,-8.77,0.7,-.2
  334. DATA -9.97,1.7,0,-8.77,1.7,0,-9.97,1.6,0,-8.77,1.6,0
  335. DATA -9.97,-.5,0,-8.47,-.5,0,-9.97,-.6,0,-8.47,-.6,0
  336. DATA -9.97,.6,0,-8.77,.6,0,-9.97,.7,0,-8.77,.7,0
  337. DATA -8.77,1.7,0,-8.77,1.6,0,-8.77,1.7,-3.7,-8.77,1.6,-3.7
  338. DATA -8.47,-.5,0,-8.47,-.6,0,-8.47,-0.5,-3.7,-8.47,-0.6,-3.7
  339. DATA -8.77,.7,0,-8.77,.6,0,-8.77,.7,-3.7,-8.77,.6,-3.7
  340. DATA -8.77,-2,0,-8.77,-.6,0,-8.77,-2,-0.2,-8.77,-.6,-0.2
  341. DATA -8.77,1.6,0,-8.77,.7,0,-8.77,1.6,-0.2,-8.77,.7,-0.2
  342. DATA -8.77,-2,-1.9,-8.77,-.6,-1.9,-8.77,-2,-2,-8.77,-.6,-2
  343. DATA -8.77,1.6,-1.9,-8.77,.7,-1.9,-8.77,1.6,-2,-8.77,.7,-2
  344. DATA -8.77,-1.99,0,-9.97,-1.99,0,-8.77,-1.99,-3.7,-9.97,-1.99,-3.7
  345. DATA -9.97,-2,0,-9.97,-2,-4.9,-9.97,-.5,0,-9.97,-.5,-4.9
  346. dATA -9.97,1.6,0,-9.97,1.6,-4.9,-9.97,.6,0,-9.97,.6,-4.9
  347. DATA -8.77,-2,-3.7,-8.77,-.6,-3.7,-8.77,-2,-3.6,-8.77,-.6,-3.6
  348. DATA -8.77,1.6,-3.7,-8.77,.7,-3.7,-8.77,1.6,-3.6,-8.77,.7,-3.6
  349.  
  350. DATA -8.77,-1.9,-2,-8.77,-.6,-2,-8.77,-1.9,-3.6,-8.77,-.6,-3.6
  351. DATA -8.77,1.6,-2,-8.77,.7,-2,-8.77,1.6,-3.6,-8.77,.7,-3.6
  352.  
  353. DATA -8.77,-1.9,-.2,-8.77,-.6,-.2,-8.77,-1.9,-1.9,-8.77,-.6,-1.9
  354. DATA -8.77,1.6,-.2,-8.77,.7,-.2,-8.77,1.6,-1.9,-8.77,.7,-1.9: 'glased doors
  355. dATA -7.85,1.55,-3.71,-7.85,0.6,-3.71,-8.8,1.55,-3.71,-8.8,0.6,-3.71
  356. DATA -7.85,-1.9,-3.71,-7.85,-0.6,-3.71,-8.8,-1.9,-3.71,-8.8,-.6,-3.71
  357. DATA .85,1.55,-3.71,.85,0.6,-3.71,-.85,1.55,-3.71,-.85,0.6,-3.71
  358. DATA .85,-1.9,-3.71,.85,-0.6,-3.71,-.85,-1.9,-3.71,-.85,-.6,-3.71
  359.  
  360. 'microwave
  361.  
  362. DATA -9,-.5,-4.1,-8,-.5,-4.1,-9,0,-4.1,-8,0,-4.1
  363. DATA -9,-.5,-4.9,-8,-.5,-4.9,-9,0,-4.9,-8,0,-4.9
  364. DATA -9,0,-4.1,-8,0,-4.1,-9,0,-4.9,-8,0,-4.9
  365. DATA -9,0,-4.1,-9,-.5,-4.1,-9,0,-4.9,-9,-.5,-4.9
  366. DATA -8,0,-4.1,-8,-.5,-4.1,-8,0,-4.9,-8,-.5,-4.9
  367.  
  368.  
  369.  
  370. FOR r = 1 TO N
  371.    READ v(r).X, v(r).Y, v(r).Z 'all is placed on the same Y = the same floor
  372.  
  373. Set_texture podl&, 1, 4, 15 'set image img as texture for bottom  (triangles 1 to 4)
  374. Set_texture str&, 5, 8, 3
  375. Set_texture tokno&, 9, 12, 1
  376. Set_texture dvere&, 13, 16, 1
  377. Set_texture white&, 17, 20, 1
  378. Set_texture white&, 21, 24, 1 'wall at pc
  379. Set_texture lednice&, 25, 28, 1
  380. Set_texture white&, 29, 32, 1
  381. Set_texture Swhite&, 33, 36, 1
  382. Set_texture Swhite&, 37, 40, 1
  383. Set_texture orech&, 41, 44, 10
  384. Set_texture orech&, 45, 48, 10
  385.  
  386. Set_texture orech&, 49, 52, 10
  387. Set_texture orech&, 53, 56, 10
  388. Set_texture orech&, 57, 60, 10
  389. Set_texture orech&, 61, 64, 10
  390. Set_texture polstr&, 65, 68, 3
  391.  
  392. Set_texture polstr&, 69, 72, 3
  393. Set_texture polstr&, 73, 76, 3
  394. Set_texture polstr&, 77, 80, 3
  395. Set_texture orech&, 81, 84, 10
  396. Set_texture orech&, 85, 88, 10
  397. Set_texture orech&, 89, 92, 10
  398. Set_texture orech&, 93, 96, 3
  399. Set_texture orech&, 97, 100, 3
  400. Set_texture orech&, 101, 104, 1
  401. Set_texture orech&, 105, 108, 1
  402. Set_texture orech&, 109, 112, 1
  403. Set_texture orech&, 113, 116, 7
  404.  
  405. Set_texture orech&, 117, 120, 1
  406. Set_texture orech&, 121, 204, 2
  407. Set_texture orechsv&, 205, 220, 1
  408. Set_texture orech&, 221, 292, 1
  409.  
  410. Set_texture orechsv&, 293, 308, 1
  411. Set_texture orech&, 309, 316, 1
  412. Set_texture orechsv&, 317, 328, 1
  413. Set_texture orech&, 329, 400, 1
  414. Set_texture orechsv&, 401, 416, 1
  415. Set_texture orech&, 417, 424, 1
  416. Set_texture orechsv&, 425, 432, 1
  417. 'po upgradu
  418. Set_texture white&, 433, 437, 1 'wall
  419. Set_texture dvere&, 437, 440, 1
  420. Set_texture white&, 441, 444, 1
  421. Set_texture dub&, 445, 453, 1 'pc desk
  422. Set_texture tdub&, 454, 462, 1 'pc desk back
  423. Set_texture dub&, 463, 480, 1
  424. Set_texture tdub&, 481, 484, 1
  425. Set_texture dub&, 485, 492, 1
  426. Set_texture tdub&, 493, 512, 1
  427. Set_texture dub&, 513, 520, 1
  428. Set_texture Black&, 521, 524, 1
  429. Set_texture SBlack&, 525, 528, 1
  430. Set_texture Black&, 529, 532, 1
  431. Set_texture pc&, 533, 536, 1
  432. Set_texture SBlack&, 537, 540, 1 'MONITOR
  433. Set_texture Black&, 541, 548, 1 'MONITOR
  434. Set_texture Noha&, 549, 552, 1 'MONITOR
  435. Set_texture Black&, 553, 556, 1
  436. Set_texture kbd&, 557, 560, 1 'keyboard
  437. Set_texture mys&, 561, 564, 1 'keyboard
  438. Set_texture Black, 565, 576, 1 'woof
  439. Set_texture SBlack, 577, 580, 1 'subwoofer
  440. Set_texture woof&, 581, 584, 1 'subwoofer
  441. Set_texture Black, 585, 596, 1 'speakers
  442. Set_texture speak&, 597, 600, 1
  443. Set_texture Black, 601, 612, 1
  444. Set_texture speak&, 613, 616, 1
  445. 'strana s linkou
  446. Set_texture dvere&, 617, 620, 1 'doors
  447. Set_texture dlazba&, 621, 624, 10
  448. Set_texture white&, 625, 628, 1
  449. Set_texture sporakcelo, 629, 632, 1
  450. Set_texture sporakvrch, 633, 636, 1
  451. Set_texture white&, 637, 648, 1
  452. Set_texture dub&, 649, 652, 1
  453. Set_texture tdub&, 653, 656, 5
  454. Set_texture dub&, 657, 676, 5
  455. Set_texture tdub&, 677, 680, 5
  456. Set_texture dub&, 681, 796, 5
  457. Set_texture tdub&, 797, 800, 5
  458. Set_texture dub&, 801, 809, 5
  459. Set_texture dub&, 809, 812, 5
  460. Set_texture tdub&, 813, 816, 5
  461. Set_texture tdub&, 817, 820, 5
  462. Set_texture Silver&, 821, 836, 1
  463. Set_texture SilverC&, 837, 840, 1
  464. Set_texture SilverB&, 841, 860, 1
  465. Set_texture dub&, 861, 872, 1
  466. Set_texture tdub&, 873, 960, 1
  467. Set_texture dlazba2&, 961, 964, 10
  468. Set_texture tdub&, 965, 1004, 1
  469. Set_texture dub&, 1005, 1064, 1
  470. Set_texture tdub&, 1065, 1076, 1
  471. Set_texture Sklo&, 1077, 1080, 1
  472. Set_texture tdub&, 1081, 1096, 1
  473. Set_texture mikro&, 1097, 1100, 1
  474. Set_texture SilverB&, 1101, 1116, 1
  475.  
  476.  
  477. valec -1, -.8, 4.7, -.6, 10, SilverB& ' vase
  478. valec 6, -.5, 9, -.35, 10, Silver&
  479.  
  480. valec -3.35, -.2, -4.8, -.3, 40, SilverB& 'water pipe
  481. Zvalec -3.35, -.3, -4.8, -4.1, 40, SilverB& 'water pipe
  482. valec -3.35, -.29, -4.1, -.4, 40, SilverB& 'water pipe
  483.  
  484.  
  485. 'this three vase are in cabinet with glased door
  486. talir -9.1, .8, -1.45
  487. talir -9.1, .8, -1.05
  488. talir -9.1, .8, -.65
  489.  
  490. 'cabinet handles
  491. madlo -7.9,   .8,  -3.6
  492. madlo -7.45,  .8,  -3.6
  493. madlo -7.9, -.8,  -3.4
  494. madlo -7.45,-.8,  -3.4
  495.  
  496. madlo -6,   -.8,  -3.4
  497. madlo -5.45,-.8,  -3.4
  498. madlo -6,     .8,  -3.6
  499. madlo -5.45,  .8,  -3.6
  500.  
  501. madlo -4.1, -.8  ,-3.4
  502. madlo -3.45,-.8,  -3.4
  503. madlo -4.1,   .8,  -3.6
  504. madlo -3.45,  .8,  -3.6
  505.  
  506. madlo -2.2, -.8  ,-3.4
  507. madlo -1.45,-.8,  -3.4
  508. madlo -2.2,   .8,  -3.6
  509. madlo -1.45,  .8,  -3.6
  510.  
  511. madlo -.3, -.8  ,-3.4
  512. madlo -.3,   .8,  -3.6
  513. madlo 1,-.8,  -3.4
  514. madlo 1,  .8,  -3.6
  515. madlo 2,-.8,  -3.4
  516. madlo 2,  .8,  -3.6
  517. madlo 3,-.8,  -3.4
  518. madlo 3,  .8,  -3.6
  519. madlo 4,-.8,  -3.4
  520. madlo 4,  .8,  -3.6
  521. madlo 8.5, -1, 7.9
  522. madlo 8.5, -1.3, 7.9
  523. zmadlo -8.77,.8,-1
  524. zmadlo -8.77,.8,-2.75
  525. zmadlo -8.77,-.8,-1
  526. zmadlo -8.77,-.8,-2.75
  527.  
  528. minRadius = 1000
  529.     DO
  530.         i$ = INKEY$
  531.         start = 0
  532.         FOR r = 1 TO N
  533.             LenX = v(r).X - CX
  534.             LenY = v(r).Y - CY
  535.             LenZ = v(r).Z - CZ
  536.  
  537.             radius = SQR(LenX ^ 2 + LenZ ^ 2)
  538.             if minradius < .4 then minradius = 1000
  539.             if minradius > radius then minradius = radius
  540.             radiusH =  sqr(lenY^2 + lenz^2)
  541.             v(r).Radius = radius
  542.             v(r).radiusH = radiusH
  543.             v(r).pi = JK!(CX, CZ, v(r).X, v(r).Z, radius)
  544.             v(r).pih = jk! (cy,cz,v(r).y, v(r).z, radiusH)
  545.            NEXT r
  546.       IF ABS(rot) > _PI(2) THEN rot = 0
  547.     oldposZ = posZ
  548.     oldposX = posX
  549.     SELECT CASE i$
  550.         CASE CHR$(0) + CHR$(72): posz = posz + COS(rot) / 2: posx = posx + -sin(rot) / 2: posy = posy  + -sin(roth)/2 'up
  551.         CASE CHR$(0) + CHR$(80): posz = posz - COS(rot) / 2: posx = posx - -sin(rot) / 2 : posy = posy - -sin(roth)/2 'dn
  552.         CASE CHR$(0) + CHR$(75): rot = rot - .05
  553.         CASE CHR$(0) + CHR$(77): rot = rot + .05
  554.         case chr$(27) : destructor ("textures.pmf") : system
  555.         END SELECT
  556.  
  557. '------------------------------
  558. iF posz > 3 THEN posz = 3
  559. IF posz < -7 THEN posz = -7
  560. IF posx < -7 THEN posx = -7
  561. IF posx > 7 THEN posx = 7
  562.  
  563.  
  564. case -7 to -5: if posZ < -7 then posX = oldposx: posz = oldposz
  565. case -5 to 3: if posZ < -2 then posX = oldposx: posz = oldposz
  566. case 3 to 6: if posZ< -7 then posX = oldposx: posz = oldposz
  567. '-----------------------------
  568.     CZ = -posz
  569.     CX = -posx
  570.     CY = -posY
  571.  
  572.     FOR r = 1 TO N
  573.         x = CX + SIN(rot + v(r).pi) * v(r).Radius
  574.         y = CY + sin (rotH + v(r).piH) * v(r).radiusH
  575.         z =  CZ + cos(rot +v(r).pi) * v(r).Radius
  576.         v(r).wX = x + posx
  577.         v(r).wY = y + posY
  578.         v(r).wZ = z + posz
  579.     NEXT r
  580.     minigame
  581.     m33& = _COPYIMAGE(m&, 33)
  582.     Set_texture m33&, 537, 540, 1
  583.  
  584.     FOR zz = 1 TO N STEP 4
  585.          IF v(zz).T THEN
  586.             img& = v(zz).T
  587.             w = _WIDTH(img&)
  588.             h = _HEIGHT(img&)
  589.             num = v(zz).Tm
  590.             IF num = 0 THEN num = 1
  591.             _MAPTRIANGLE (0, h * num)-(w * num, h * num)-(0, 0), img& TO(v(zz).wX, v(zz).wY, v(zz).wZ)-(v(zz + 1).wX, v(zz + 1).wY, v(zz + 1).wZ)-(v(zz + 2).wX, v(zz + 2).wY, v(zz + 2).wZ), 0, _SMOOTH
  592.             _MAPTRIANGLE (w * num, h * num)-(0, 0)-(w * num, 0), img& TO(v(zz + 1).wX, v(zz + 1).wY, v(zz + 1).wZ)-(v(zz + 2).wX, v(zz + 2).wY, v(zz + 2).wZ)-(v(zz + 3).wX, v(zz + 3).wY, v(zz + 3).wZ), 0, _SMOOTH
  593.         END IF
  594.     NEXT zz
  595.  
  596. REM    infobox posx, posy, posz, rot, minradius
  597.  
  598.     _DISPLAY
  599.     _FREEIMAGE m33&
  600.     _LIMIT 30
  601.  
  602.  
  603. sub INFOBOX (posx, posy, posz, rot, u)
  604. nfo& = _newimage (640, 480, 32)
  605. W = 639 : H = 479: X = -.5: Y = 0 : Z = -1
  606. de = _dest
  607. _dest nfo&
  608. color _rgb32(22, 61, 78)
  609. print "INFOBOX:"
  610. print "Position X: "; posx
  611. print "Position Y: "; posy
  612. print "Position Z: "; posz
  613. print "Angle: "; abs(_r2d(rot))
  614.  
  615. hnfo& = _copyimage (nfo&, 33)
  616. _maptriangle (0,0) - (w, 0) - (0, h), hnfo& to (-2+x, 2+Y, -2+z) - (2+x, 2+y, -2+z) - (-2+x, -2+y, -2+z)
  617. _maptriangle (w, 0) - (0, h) - (w,h), hnfo& to (2+x, 2+y, -2+z) - (-2+x, -2+y, -2+z) - (2+x, -2+y, -2+z)
  618.  
  619.  
  620.  
  621.  
  622.  
  623. sub madlo (x,y,z)
  624. tt = UBOUND(v) + 1
  625. REDIM _PRESERVE v(1 TO tt - 1 + 12) AS V
  626. N = N + 12
  627. if sgn(x)>= 0 then x2 = x + .2 else x2 = x -.2
  628. if sgn(y) =>0 then y2 = y + .05 else y2 = y -.05
  629. if sgn(z) < 0 then z2 = z -.1 else z2 = z + .1
  630.  
  631.  v(tt).x = x
  632.  v(tt).y = y
  633.  v(tt).z = z
  634.  
  635.  v(tt+1).x = x
  636.  v(tt+1).y = y2
  637.  v(tt+1).z = z
  638.  
  639.  v(tt+2).x = x2
  640.  v(tt+2).y = y
  641.  v(tt+2).z = z
  642.  
  643.  v(tt+3).x = x2
  644.  v(tt+3).y = y2
  645.  v(tt+3).z = z
  646.  
  647. '------------
  648.  
  649.  v(tt+4).x = x
  650.  v(tt+4).y = y
  651.  v(tt+4).z = z
  652.  
  653.  v(tt+5).x = x
  654.  v(tt+5).y = y2
  655.  v(tt+5).z = z
  656.  
  657.  v(tt+6).x = x
  658.  v(tt+6).y = y
  659.  v(tt+6).z = z2
  660.  
  661.  v(tt+7).x = x
  662.  v(tt+7).y = y2
  663.  v(tt+7).z = z2
  664.  
  665. '------------
  666.  
  667.  v(tt+8).x = x2
  668.  v(tt+8).y = y
  669.  v(tt+8).z = z
  670.  
  671.  v(tt+9).x = x2
  672.  v(tt+9).y = y2
  673.  v(tt+9).z = z
  674.  
  675.  v(tt+10).x = x2
  676.  v(tt+10).y = y
  677.  v(tt+10).z = z2
  678.  
  679.  v(tt+11).x = x2
  680.  v(tt+11).y = y2
  681.  v(tt+11).z = z2
  682.  
  683.  set_texture aluminium&, tt-1, tt+11,1
  684.  
  685.  
  686.  
  687. sub Zmadlo (x,y,z)
  688.     tt = UBOUND(v) + 1
  689.     REDIM _PRESERVE v(1 TO tt - 1 + 12) AS V
  690.     N = N + 12
  691.  
  692. if sgn(z)<= 0 then z2 = z - .2 else z2 = z +.2
  693. if sgn(y) =>0 then y2 = y + .05 else y2 = y -.05
  694. if sgn(x) <= 0 then x2 = x+.1 else x2 = x - .1
  695.  
  696. 'predni obdelnik
  697.  v(tt).x = x2
  698.  v(tt).y = y
  699.  v(tt).z = z
  700.  
  701.  v(tt+1).x = x2
  702.  v(tt+1).y = y2
  703.  v(tt+1).z = z
  704.  
  705.  v(tt+2).x = x2
  706.  v(tt+2).y = y
  707.  v(tt+2).z = z2
  708.  
  709.  v(tt+3).x = x2
  710.  v(tt+3).y = y2
  711.  v(tt+3).z = z2
  712.  
  713. '------------
  714.  
  715.  v(tt+4).x = x
  716.  v(tt+4).y = y2
  717.  v(tt+4).z = z
  718.  
  719.  v(tt+5).x = x2
  720.  v(tt+5).y = y2
  721.  v(tt+5).z = z
  722.  
  723.  v(tt+6).x = x
  724.  v(tt+6).y = y
  725.  v(tt+6).z = z
  726.  
  727.  v(tt+7).x = x2
  728.  v(tt+7).y = y
  729.  v(tt+7).z = z
  730.  
  731. '------------
  732.  
  733.  v(tt+8).x = x
  734.  v(tt+8).y = y2
  735.  v(tt+8).z = z2
  736.  
  737.  v(tt+9).x = x2
  738.  v(tt+9).y = y2
  739.  v(tt+9).z = z2
  740.  
  741.  v(tt+10).x = x
  742.  v(tt+10).y = y
  743.  v(tt+10).z = z2
  744.  
  745.  v(tt+11).x = x2
  746.  v(tt+11).y = y
  747.  v(tt+11).z = z2
  748.  
  749.   set_texture aluminium&, tt-1, tt+11,1
  750.  
  751. SUB Set_texture (num, start, eend, much)
  752.     FOR s = start TO eend
  753.         v(s).T = num
  754.         v(s).Tm = much
  755.     NEXT s
  756.  
  757.  
  758. FUNCTION Hload& (fileName AS STRING)
  759.     h& = _LOADIMAGE(fileName$, 32)
  760.     Hload& = _COPYIMAGE(h&, 33)
  761.     _FREEIMAGE h&
  762.  
  763.  
  764. FUNCTION SHload& (fileName AS STRING)
  765.     h& = _LOADIMAGE(fileName$, 32)
  766.     _SETALPHA 0, _RGB32(255, 255, 255) TO _RGB32(200, 200, 200), h&
  767.     SHload& = _COPYIMAGE(h&, 33)
  768.     _FREEIMAGE h&
  769.  
  770. FUNCTION strop&
  771.     lamp& = _LOADIMAGE("bodovka mala.jpg", 32)
  772.     strop& = _NEWIMAGE(1024, 768, 32)
  773.     de = _DEST
  774.     _DEST strop&
  775.     CLS , _RGB32(255, 255, 255)
  776.     rX = 1024 / 4
  777.     rY = 768 / 3
  778.     FOR x = rX TO 1024 - rX STEP rX
  779.         FOR y = rY TO 768 - rY STEP rY
  780.             _PUTIMAGE (rX, rY), lamp&, strop&
  781.     NEXT y, x
  782.     _DEST de
  783.     _FREEIMAGE lamp&
  784.     strop& = _COPYIMAGE(strop&, 33)
  785.  
  786. FUNCTION okno&
  787.     ok& = _LOADIMAGE("okn.jpg", 32)
  788.     topco& = _LOADIMAGE("topco.jpg", 32)
  789.     okno& = _NEWIMAGE(1024, 512, 32)
  790.     de = _DEST
  791.     _DEST okno&
  792.     CLS , _RGB32(250, 245, 255)
  793.     _PUTIMAGE (512 - 150, 206 - 132), ok&, okno&
  794.  
  795.     _PUTIMAGE (380, 370), topco&, okno&
  796.     _DEST de
  797.     _FREEIMAGE ok&
  798.     _FREEIMAGE topco&
  799.     okno& = _COPYIMAGE(okno&, 33)
  800.  
  801. FUNCTION white&
  802.     IF white& = 0 THEN
  803.         whit& = _NEWIMAGE(100, 100, 32)
  804.         de = _DEST
  805.         _DEST whit&
  806.         CLS , _RGB32(250, 240, 250)
  807.         _DEST de
  808.         white& = _COPYIMAGE(whit&, 33)
  809.         _FREEIMAGE whit&
  810.     END IF
  811.  
  812. FUNCTION Swhite&
  813.     IF Swhite& = 0 THEN
  814.         whit& = _NEWIMAGE(100, 100, 32)
  815.         de = _DEST
  816.         _DEST whit&
  817.         CLS , _RGB32(255, 255, 255)
  818.         _DEST de
  819.         Swhite& = _COPYIMAGE(whit&, 33)
  820.         _FREEIMAGE whit&
  821.     END IF
  822.  
  823.  
  824. FUNCTION Braun&
  825.     IF Braun& = 0 THEN
  826.         brau& = _NEWIMAGE(100, 100, 32)
  827.         de = _DEST
  828.         _DEST brau&
  829.         CLS , _RGB32(111, 17, 39)
  830.         _DEST de
  831.         Braun& = _COPYIMAGE(brau&, 33)
  832.         _FREEIMAGE brau&
  833.     END IF
  834.  
  835.  
  836. FUNCTION Black&
  837.     IF Black& = 0 THEN
  838.         blk& = _NEWIMAGE(100, 100, 32)
  839.         de = _DEST
  840.         _DEST blk&
  841.         CLS , _RGB32(6, 17, 28)
  842.         _DEST de
  843.         Black& = _COPYIMAGE(blk&, 33)
  844.         _FREEIMAGE blk&
  845.     END IF
  846.  
  847. FUNCTION SBlack&
  848.     IF SBlack& = 0 THEN
  849.         blk& = _NEWIMAGE(100, 100, 32)
  850.         de = _DEST
  851.         _DEST blk&
  852.         CLS , _RGB32(33, 28, 28)
  853.         _DEST de
  854.         SBlack& = _COPYIMAGE(blk&, 33)
  855.         _FREEIMAGE blk&
  856.     END IF
  857.  
  858. FUNCTION Silver&
  859.     IF Silver& = 0 THEN
  860.         blk& = _NEWIMAGE(100, 100, 32)
  861.         de = _DEST
  862.         _DEST blk&
  863.         e = 127 / 100
  864.         FOR l = 0 TO 99
  865.             LINE (0, l)-(99, l), _RGB32(255 - f, 255 - f, 255 - f)
  866.             f = f + e
  867.         NEXT l
  868.         _DEST de
  869.         Silver& = _COPYIMAGE(blk&, 33)
  870.         _FREEIMAGE blk&
  871.     END IF
  872.  
  873. FUNCTION SilverB&
  874.     IF SilverB& = 0 THEN
  875.         blk& = _NEWIMAGE(100, 100, 32)
  876.         de = _DEST
  877.         _DEST blk&
  878.         e = 127 / 50
  879.         FOR l = 0 TO 50
  880.             LINE (l, l)-(100 - l, 100 - l), _RGB32(127 + f, 127 + f, 127 + f), B
  881.             f = f + e
  882.         NEXT l
  883.         _DEST de
  884.         SilverB& = _COPYIMAGE(blk&, 33)
  885.         _FREEIMAGE blk&
  886.     END IF
  887.  
  888.  
  889. FUNCTION SilverC&
  890.     IF SilverC& = 0 THEN
  891.         blk& = _NEWIMAGE(100, 100, 32)
  892.         de = _DEST
  893.         _DEST blk&
  894.         e = 127 / 50
  895.         FOR l = 0 TO 50
  896.             LINE (l, l)-(100 - l, 100 - l), _RGB32(255 - f, 255 - f, 255 - f), B
  897.             f = f + e
  898.         NEXT l
  899.         _DEST de
  900.         SilverC& = _COPYIMAGE(blk&, 33)
  901.         _FREEIMAGE blk&
  902.     END IF
  903.  
  904.  
  905. FUNCTION spajz_dvere&
  906.     dv& = _LOADIMAGE("dvere.jpg", 32) '192 x 426
  907.     de = _DEST
  908.     spajz_dvere32& = _NEWIMAGE(640, 480, 32)
  909.     _DEST spajz_dvere32&
  910.     CLS , _RGB32(241, 244, 251)
  911.     _PUTIMAGE (140, 54), dv&
  912.     _DEST de
  913.     spajz_dvere& = _COPYIMAGE(spajz_dvere32&, 33)
  914.     _FREEIMAGE spajz_dvere32&
  915.  
  916. FUNCTION Zesvetli& (file AS STRING)
  917.     t& = _LOADIMAGE(file$, 32)
  918.     IF Zesvetli& < -1 THEN _FREEIMAGE Zesvetli&
  919.     w = _WIDTH(t&)
  920.     h = _HEIGHT(t&)
  921.     zesvetli32& = _NEWIMAGE(w, h, 32)
  922.     de = _DEST
  923.     _DEST zesvetli32&
  924.     _PUTIMAGE , t&, zesvetli32&
  925.     LINE (0, 0)-(w - 1, h - 1), _RGBA32(255, 255, 255, 30), BF
  926.     _DEST de
  927.  
  928.     Zesvetli& = _COPYIMAGE(zesvetli32&, 33)
  929.     _FREEIMAGE t&
  930.     _FREEIMAGE zesvetli32&
  931.  
  932. FUNCTION Ztmav& (file AS STRING)
  933.     t& = _LOADIMAGE(file$, 32)
  934.     IF Ztmav& < -1 THEN _FREEIMAGE Ztmav&
  935.     w = _WIDTH(t&)
  936.     h = _HEIGHT(t&)
  937.     ztmav32& = _NEWIMAGE(w, h, 32)
  938.     de = _DEST
  939.     _DEST ztmav32&
  940.     _PUTIMAGE , t&, ztmav32&
  941.     LINE (0, 0)-(w - 1, h - 1), _RGBA32(0, 0, 0, 30), BF
  942.     _DEST de
  943.  
  944.     Ztmav& = _COPYIMAGE(ztmav32&, 33)
  945.     _FREEIMAGE t&
  946.     _FREEIMAGE ztmav32&
  947.  
  948. FUNCTION Noha&
  949.     IF Noha& = 0 THEN
  950.         de = _DEST
  951.         noh& = _NEWIMAGE(100, 100, 32)
  952.         _DEST noh&
  953.         LINE (0, 40)-(100, 60), _RGB32(0, 22, 32), BF
  954.         _CLEARCOLOR _RGB32(0, 0, 0), noh&
  955.         _DEST de
  956.         Noha& = _COPYIMAGE(noh&, 33)
  957.         _FREEIMAGE noh&
  958.     END IF
  959.  
  960. FUNCTION Noha2&
  961.     IF Noha2& = 0 THEN
  962.         de = _DEST
  963.         noh& = _NEWIMAGE(100, 100, 32)
  964.         _DEST noh&
  965.         LINE (30, 30)-(70, 70), _RGB32(0, 2, 12), BF
  966.         _CLEARCOLOR _RGB32(0, 0, 0), noh&
  967.         _DEST de
  968.         Noha2& = _COPYIMAGE(noh&, 33)
  969.         _FREEIMAGE noh&
  970.     END IF
  971.  
  972.  
  973. FUNCTION JK! (cx, cy, px, py, R)' based on binary circle definition
  974.     LenX = cx - px
  975.     LenY = cy - py
  976.     jR = 1 / R
  977.  
  978.     jX = LenX * jR
  979.     jY = LenY * jR
  980.  
  981.     sinusAlfa = jX
  982.     Alfa = ABS(_ASIN(sinusAlfa))
  983.  
  984.     Q = 1
  985.     IF px >= cx AND py =< cy THEN Q = 1 ' select angle to quadrant
  986.     IF px >= cx AND py =< cy THEN Q = 2
  987.     IF px =< cx AND py <= cy THEN Q = 3
  988.     IF px =< cx AND py >= cy THEN Q = 4
  989.     SELECT CASE Q
  990.         CASE 1: alfaB = Alfa
  991.         CASE 2: alfaB = _PI / 2 + (_PI / 2 - Alfa)
  992.         CASE 3: alfaB = _PI + Alfa
  993.         CASE 4: alfaB = _PI(1.5) + (_PI / 2 - Alfa)
  994.     END SELECT
  995.     JK! = alfaB
  996.  
  997. SUB valec (xs, ys, zs, ye, R, t&)
  998.     tt = UBOUND(v) + 1
  999.     polomer = R
  1000.     REDIM _PRESERVE v(1 TO tt - 1 + 64) AS V
  1001.     polo = _PI(2) / 16
  1002.     N = N + 64
  1003.  
  1004.     FOR s = 0 TO _PI(2) STEP polo
  1005.         ott = tt
  1006.         v(tt).X = xs + SIN(s) / polomer
  1007.         v(tt).Y = ys
  1008.         v(tt).Z = zs + COS(s) / polomer
  1009.         tt = tt + 1
  1010.         v(tt).X = xs + SIN(s) / polomer
  1011.         v(tt).Y = ye
  1012.         v(tt).Z = zs + COS(s) / polomer
  1013.         tt = tt + 1
  1014.         v(tt).X = xs + SIN(s + polo) / polomer
  1015.         v(tt).Y = ys
  1016.         v(tt).Z = zs + COS(s + polo) / polomer
  1017.         tt = tt + 1
  1018.         v(tt).X = xs + SIN(s + polo) / polomer
  1019.         v(tt).Y = ye
  1020.         v(tt).Z = zs + COS(s + polo) / polomer
  1021.         Set_texture t&, ott, tt, 1
  1022.         tt = tt + 1
  1023.     NEXT
  1024.  
  1025. SUB Zvalec (xs, ys, zs, ze, R, t&)
  1026.     tt = UBOUND(v) + 1
  1027.     polomer = R
  1028.  
  1029.     REDIM _PRESERVE v(1 TO tt - 1 + 64) AS V
  1030.  
  1031.     polo = _PI(2) / 16
  1032.     N = N + 64
  1033.  
  1034.     FOR s = 0 TO _PI(2) STEP polo
  1035.         ott = tt
  1036.         v(tt).X = xs + SIN(s) / polomer
  1037.         v(tt).Y = ys + COS(s) / polomer
  1038.         v(tt).Z = zs
  1039.         tt = tt + 1
  1040.         v(tt).X = xs + SIN(s) / polomer
  1041.         v(tt).Y = ys + COS(s) / polomer
  1042.         v(tt).Z = ze
  1043.         tt = tt + 1
  1044.         v(tt).X = xs + SIN(s + polo) / polomer
  1045.         v(tt).Y = ys + COS(s + polo) / polomer
  1046.         v(tt).Z = zs
  1047.         tt = tt + 1
  1048.         v(tt).X = xs + SIN(s + polo) / polomer
  1049.         v(tt).Y = ys + COS(s + polo) / polomer
  1050.         v(tt).Z = ze
  1051.         Set_texture t&, ott, tt, 1
  1052.         tt = tt + 1
  1053.     NEXT
  1054.  
  1055. SUB talir (x, y, z)
  1056.     radius0 = 0
  1057.     radius1 = .05
  1058.     radius2 = .1
  1059.     radius3 = .2
  1060.     ys = -ABS(y)
  1061.     ye = y - .1
  1062.     ys2 = ye
  1063.     ye2 = y + .2
  1064.  
  1065.     tt = UBOUND(v) + 1
  1066.     REDIM _PRESERVE v(1 TO tt - 1 + 64) AS V '16 a 16
  1067.         polo = _PI(2) / 16
  1068.     N = N + 64
  1069.  
  1070.     FOR s = 0 TO _PI(2) STEP polo
  1071.         ott = tt
  1072.         IF SGN(x) >= 0 THEN v(tt).X = x + (SIN(s) * radius2 + SIN(s) * radius0) ELSE v(tt).X = x - (SIN(s) * radius2 - SIN(s) * radius0)
  1073.         v(tt).Y = ys2
  1074.         IF SGN(z) >= 0 THEN v(tt).Z = z + (COS(s) * radius2 + COS(s) * radius0) ELSE v(tt).Z = z - (COS(s) * radius2 - COS(s) * radius0)
  1075.         tt = tt + 1
  1076.         IF SGN(x) >= 0 THEN v(tt).X = x + (SIN(s) * radius3 + SIN(s) * radius1) ELSE v(tt).X = x - (SIN(s) * radius3 - SIN(s) * radius1)
  1077.         v(tt).Y = ye2
  1078.         IF SGN(z) >= 0 THEN v(tt).Z = z + (COS(s) * radius3 + COS(s) * radius1) ELSE v(tt).Z = z - (COS(s) * radius3 - COS(s) * radius1)
  1079.         tt = tt + 1
  1080.         IF SGN(x) >= 0 THEN v(tt).X = x + (SIN(s + polo) * radius2 + SIN(s + polo) * radius0) ELSE v(tt).X = x - (SIN(s + polo) * radius2 - SIN(s + polo) * radius0)
  1081.         v(tt).Y = ys2
  1082.         IF SGN(z) >= 0 THEN v(tt).Z = z + (COS(s + polo) * radius2 + COS(s + polo) * radius0) ELSE v(tt).Z = z - (COS(s + polo) * radius2 - COS(s + polo) * radius0)
  1083.         tt = tt + 1
  1084.         IF SGN(x) >= 0 THEN v(tt).X = x + (SIN(s + polo) * radius3 + SIN(s + polo) * radius1) ELSE v(tt).X = x - (SIN(s + polo) * radius3 - SIN(s + polo) * radius1)
  1085.         v(tt).Y = ye2
  1086.         IF SGN(z) >= 0 THEN v(tt).Z = z + (COS(s + polo) * radius3 + COS(s + polo) * radius1) ELSE v(tt).Z = z - (COS(s + polo) * radius3 - COS(s + polo) * radius1)
  1087.         tt = tt + 1
  1088.         Set_texture SilverC&, ott, tt - 1, 1
  1089.     NEXT
  1090.  
  1091. FUNCTION Sklo&
  1092.     IF Sklo& = 0 THEN
  1093.         de = _DEST
  1094.         skl = _NEWIMAGE(150, 100, 32)
  1095.         _DEST skl
  1096.         alfa = 127 / 25
  1097.         a = 120
  1098.         FOR x = 1 TO 50
  1099.             a = a - alfa
  1100.             LINE (0, x)-(150, x), _RGBA32(127, 127, 127, a)
  1101.         NEXT x
  1102.  
  1103.         FOR x = 50 TO 100
  1104.             a = a + alfa
  1105.             LINE (0, x)-(150, x), _RGBA32(127, 127, 127, a)
  1106.         NEXT x
  1107.         _DEST de
  1108.         Sklo& = _COPYIMAGE(skl, 33)
  1109.         _FREEIMAGE skl
  1110.     END IF
  1111.  
  1112. SUB minigame
  1113.     de = _DEST
  1114.     _DEST m&
  1115.     CLS , _RGB32(127, 120, 120)
  1116.             IF ballX > 160 THEN
  1117.         IF rY + 25 < ballY THEN rY = rY + 1 ELSE rY = rY - 1
  1118.         IF ballX > (rxX - 10) THEN
  1119.             IF ballY > rY AND ballY < rY + 50 THEN mX = mX * -1
  1120.         END IF
  1121.     END IF
  1122.  
  1123.     IF ballX < 160 THEN
  1124.         IF lY + 25 < ballY THEN lY = lY + 1 ELSE lY = lY - 1
  1125.         IF ballX < 20 THEN
  1126.  
  1127.             IF ballY > lY AND ballY < lY + 50 THEN mX = mX * -1
  1128.  
  1129.         END IF
  1130.     END IF
  1131.  
  1132.     ballX = ballX + mX
  1133.     ballY = ballY + mY
  1134.  
  1135.     IF ballX > 315 THEN mX = mX * -1: rightplr = rightplr + 1: ballX = ballX + mX + SIN(_ATAN2(ballY, ballX))
  1136.     IF ballX < 5 THEN mX = mX * -1: leftplr = leftplr + 1: ballY = ballY + mY + COS(_ATAN2(ballY, ballX))
  1137.  
  1138.     IF ballY > 235 THEN mY = mY * -1 - _ATAN2(ballY, ballX) / 2: ballY = ballY + mY
  1139.     IF ballY < 5 THEN mY = mY * -1 + _ATAN2(ballY, ballX) / 2: ballY = ballY + mY
  1140.  
  1141.  
  1142.     IF ballY >= lY AND ballY <= lY + 60 AND ballX <= 10 THEN mY = mY * -1: ballY = ballY + mY - _ATAN2(ballY, ballX)
  1143.     IF ballY >= rY AND ballY <= rY + 60 AND ballX >= 300 THEN mY = mY * -1: ballY = ballY + mY + _ACOS(_ATAN2(ballY, ballX))
  1144.  
  1145.     IF lY > 180 THEN lY = 180
  1146.     IF lY < 10 THEN lY = 10
  1147.     IF rY > 180 THEN rY = 180
  1148.     IF rY < 10 THEN rY = 10
  1149.  
  1150.     IF ballX - 2 > lX AND ballX + 2 < lX + 10 AND ballY - 2 >= lY AND ballY + 2 <= lY + 50 THEN COLOR _RGB32(255, 0, 0): _PRINTSTRING (130, 112), "ERROR!!!!": COLOR _RGB32(255, 255, 255)
  1151.     IF ballX - 2 > rX - 10 AND ballX + 2 < rX AND ballY - 2 >= rY AND ballY + 2 <= rY + 50 THEN COLOR _RGB32(255, 0, 0): _PRINTSTRING (130, 112), "ERROR!!!!": COLOR _RGB32(255, 255, 255)
  1152.  
  1153.     IF ABS(mX) > 2 THEN mX = mX / 2
  1154.     IF ABS(mY) > 2 THEN mY = mY / 2
  1155.  
  1156.  
  1157.     IF ballX > 157 AND ballX < 163 THEN
  1158.         IF ballY > 60 AND ballY < 180 THEN mX = mX * -1
  1159.         IF ballY = 64 OR ballY = 180 THEN mY = mY * -1
  1160.     END IF
  1161.     LINE (ballX - 2, ballY - 2)-(ballX + 2, ballY + 2), , B
  1162.     LINE (3, 3)-(317, 237), , B
  1163.     LINE (lX, lY)-(lX + 10, lY + 50), , B
  1164.     LINE (rXx, rY)-(rxX - 10, rY + 50), , B
  1165.     LINE (160, 60)-(160, 180)
  1166.     popis = _PRINTWIDTH(STR$(leftplr) + " - " + STR$(rightplr))
  1167.  
  1168.     _PRINTSTRING (160 - popis / 2, 5), STR$(leftplr) + " - " + STR$(rightplr)
  1169.     _DEST de
  1170.  
  1171. SUB ExtractPMF (Vystup AS STRING) ' here insert PMF file name for extracting files
  1172.     if _fileexists (vystup) then
  1173.     PRINT "Extracting files from "; Vystup$
  1174.     TYPE head
  1175.         identity AS STRING * 16
  1176.         much AS LONG
  1177.     END TYPE
  1178.     DIM head AS head
  1179.     e = FREEFILE
  1180.     OPEN Vystup$ FOR BINARY AS #e
  1181.     GET #e, , head
  1182.     IF head.identity = "Petr's MultiFile" THEN PRINT "Head PASS" ELSE PRINT "Head Failure": SLEEP 3: END
  1183.     PRINT "Total records in file:"; head.much
  1184.     DIM starts(head.much) AS LONG
  1185.  
  1186.     FOR celek = 1 TO head.much
  1187.         GET #e, , starts(celek)
  1188.     NEXT
  1189.  
  1190.     SEEK #e, 21 + head.much * 4 ' start DATA area
  1191.     FOR total = 1 TO head.much
  1192.         IF total = 1 THEN velikost& = starts(1) - (21 + head.much * 4) ELSE velikost& = starts(total) - starts(total - 1)
  1193.         record$ = SPACE$(velikost&)
  1194.         GET #e, , record$
  1195.         i = FREEFILE
  1196.         jmeno$ = "$Ext" + LTRIM$(STR$(total))
  1197.         OPEN jmeno$ FOR OUTPUT AS #i: CLOSE #i: OPEN jmeno$ FOR BINARY AS #i
  1198.         PUT #i, , record$
  1199.         CLOSE #i
  1200.     NEXT total
  1201.  
  1202.     DIM NamesLenght(head.much) AS INTEGER
  1203.     FOR NameIt = 1 TO head.much
  1204.         GET #e, , NamesLenght(NameIt)
  1205.     NEXT NameIt
  1206.  
  1207.     CLOSE #i
  1208.     FOR Name2 = 1 TO head.much
  1209.         s$ = SPACE$(NamesLenght(Name2))
  1210.         GET #e, , s$
  1211.         jm$ = "$Ext" + LTRIM$(STR$(Name2))
  1212.         erh:
  1213.         IF _FILEEXISTS(s$) THEN
  1214.             BEEP: INPUT "Warnig! Extracted file the same name already exists!!!! (O)verwrite, (R)ename or (E)xit? "; er$
  1215.             SELECT CASE LCASE$(er$)
  1216.                 CASE "o": KILL s$: NAME jm$ AS s$
  1217.                 CASE "r": INPUT "Input new name"; s$: GOTO erh
  1218.                 CASE "e": SYSTEM
  1219.             END SELECT
  1220.         ELSE
  1221.             NAME jm$ AS s$
  1222.         END IF
  1223.     NEXT Name2
  1224.     CLOSE #e
  1225.     PRINT "All ok."
  1226.    else
  1227.    print "File "; vystup$; " not found.": end
  1228.  
  1229. SUB Destructor (vystup AS STRING) 'delete files created by ExtractPMF
  1230.     TYPE head2
  1231.         identity AS STRING * 16
  1232.         much AS LONG
  1233.     END TYPE
  1234.     IF INSTR(1, LCASE$(vystup$), ".pmf") THEN ELSE vystup$ = vystup$ + ".PMF"
  1235.     IF _FILEEXISTS(vystup$) THEN
  1236.         CLOSE
  1237.         DIM head AS head2
  1238.         e = FREEFILE
  1239.         OPEN vystup$ FOR BINARY AS #e
  1240.         GET #e, , head
  1241.         DIM starts(head.much) AS LONG
  1242.  
  1243.         FOR celek = 1 TO head.much
  1244.             GET #e, , starts(celek)
  1245.         NEXT
  1246.  
  1247.         SEEK #e, starts(head.much) ' start DATA area
  1248.         DIM NamesLenght(head.much) AS INTEGER
  1249.         FOR NameIt = 1 TO head.much
  1250.             GET #e, , NamesLenght(NameIt)
  1251.         NEXT NameIt
  1252.         FOR Name2 = 1 TO head.much
  1253.             s$ = SPACE$(NamesLenght(Name2))
  1254.             GET #e, , s$
  1255.             IF _FILEEXISTS(s$) THEN KILL s$
  1256.         NEXT Name2
  1257.         CLOSE #e
  1258.     ELSE
  1259.         PRINT "Specified file not found": SLEEP 3
  1260.     END IF
  1261.  
* textures.pmf (Filesize: 847.03 KB, Downloads: 251)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #25 on: February 01, 2019, 04:42:33 pm »
That is an amazing effort! and no shortage of cabinets I see. ;)

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #26 on: February 01, 2019, 08:19:44 pm »
Hat tip to you Petr. My mind was blown when I realized you could use arrow keys to look around.

Looks like we have more than one person who can crack the 3D problem on this site. Believe me, I know the struggle and the satisfaction of getting MAPTRIANGLE to do your bidding in 3D.

... And I could answer this by studying the code, but for the sake of having this information on public display, I figured I would ask a few questions...

* How do you deal with graphics that have coordinates outside the viewing window? Does MAPTRIANGLE let you just ignore that issue, or did you have to clip at each view plane?

* How does this thing scale? That is, if we were to make a whole house or even a whole town, is the mini-game on the computer still going on? Does the whole world crank through the main loop?

* What's the end-game for this graphics demo?

* Can you swivel the view up and down along with left-right?

* Same question for movement - can we strafe instead of just swivel?

Respond however you'd like. I'm just thrilled that someone knows whats up in all three dimensions.
« Last Edit: February 02, 2019, 11:34:43 am by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #27 on: February 01, 2019, 10:22:57 pm »
Settle down Bill. It's just a simulation. Everybody knows, or will know in the next decade, the universe is flat.

Hey graphic guys. Where are the image files needed to run this demo?

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #28 on: February 02, 2019, 08:04:38 am »
Hi STxAxTIC, I will prepare a detailed answer, which I will publish as soon as possible. Pete, all the necessary files are contained in the enclosed PMF file.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: MAPTRIANGLE in 3D
« Reply #29 on: February 03, 2019, 06:06:01 am »
So I'm back, yesterday we had a family celebration so I could not answer.

So, from the beginning.
How do you deal graphic coordinates, which are out of the monitor?

Not solved. This is not needed for this small program, but it can be solved for the size of the large space according to the size of the radius (I will explain below).

How is this thing measured?

According to Pythagoras' theorem. Take your paper to your hand. Paste a pencil into one of its places (preferably out of center). The point where the pencil penetrates the paper is where the camera is in the program. What happens when you turn the paper around this point where the pencil is stuck? The individual corners of the paper describe a circle with a common center that is not in the middle, that is, each circle has its own radius. How do we calculate this radius?
That's what I drew on the enclosed picture.

These calculations allow us to assemble off-center rotation, as shown in the ollowing program (in 2D). Use A, S and mouse:


Code: QB64: [Select]
  1.  
  2. 'program for  points EXCENTRIC rotation. Please NOT USE this PI solution, its my first and very BAD method!
  3. SCREEN _NEWIMAGE(800, 600, 256)
  4.  
  5.  
  6. CX = 330: CY = 350 '                                                                rotation center point
  7. N = 6
  8.  
  9.  
  10.  
  11.  
  12.     X AS SINGLE '                                                                  source X points in standard view
  13.     Y AS SINGLE '                                                                  source Y points in standard view
  14.     Z AS SINGLE '                                                                  not use yet
  15.     pi AS SINGLE '                                                                 start draw position on radius
  16.     Radius AS SINGLE '                                                             radius (every point use own, but if is CX and CY in middle, are all the same)
  17.  
  18.  
  19. DIM v(1 TO N) AS V
  20.  
  21.  
  22. '       D      C        A       B     extra point
  23. DATA 450,450,450,200,200,200,200,450,500,500,5000,5000: '                                            Quad data: X4, Y4, X3, Y3, X1, Y1, X2, Y2, extrapoint5x, y
  24. FOR r = 1 TO N
  25.     READ v(r).X, v(r).Y
  26.  
  27.  
  28.     LenX = v(r).X - CX '                                                           calculate line lenght between CX and X - point (X1, X2...)
  29.     LenY = v(r).Y - CY '                                                           calculate line lenght between CY (center Y) and Y - point
  30.  
  31.  
  32.     Radius = SQR(LenX ^ 2 + LenY ^ 2) '                                            calculate radius using Pythagoras
  33.  
  34.  
  35.  
  36.  
  37.     'urceni pi
  38.     '----------------------
  39.     ok = 0 '                                                                       THIS IS OLD FIRST METHOD! USE JK! FUNCTION FOR THIS!, its from developing time! JK! function is in previous program.
  40.     FOR O = 0 TO _PI(2) STEP .0001 '
  41.         X = CX + SIN(O) * Radius '                                                 Points in V array are the same as original draw contained in DATA.
  42.         Y = CY + COS(O) * Radius
  43.         IF CINT(X) = CINT(v(r).X) AND CINT(Y) = CINT(v(r).Y) THEN
  44.             v(r).pi = O: ok = 1: EXIT FOR
  45.         END IF
  46.     NEXT O
  47.     '----------------------
  48.     IF ok = 0 THEN PRINT "ERROR": SLEEP
  49.     v(r).Radius = Radius
  50. oldrot = 1
  51.         CX = _MOUSEX: CY = _MOUSEY
  52.         FOR r = 1 TO N
  53.             LenX = v(r).X - CX '                                                           calculate line lenght between CX and X - point (X1, X2...)
  54.             LenY = v(r).Y - CY '                                                           calculate line lenght between CY (center Y) and Y - point
  55.             '
  56.             Radius = SQR(LenX ^ 2 + LenY ^ 2) '                                            calculate radius using Pythagoras
  57.             v(r).Radius = Radius
  58.  
  59.  
  60.  
  61.  
  62.             ok = 0 '
  63.             FOR O = 0 TO _PI(4) STEP .0001 '
  64.                 X = CX + SIN(O) * Radius '
  65.                 Y = CY + COS(O) * Radius
  66.                 IF CINT(X) = CINT(v(r).X) AND CINT(Y) = CINT(v(r).Y) THEN v(r).pi = O: ok = 1: EXIT FOR
  67.             NEXT O
  68.             '----------------------
  69.             IF ok = 0 THEN PRINT "ERROR": SLEEP
  70.         NEXT r
  71.     END IF
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.     CLS
  81.     i$ = INKEY$
  82.     SELECT CASE i$
  83.         CASE "a", "A": rot = rot - .1 '                                            rotate with N points using "A" or "a"  and "S" or "s"
  84.         CASE "s", "S": rot = rot + .1
  85.     END SELECT
  86.  
  87.  
  88.     IF oldrot <> rot THEN
  89.         FOR r = 1 TO N
  90.             LOCATE 1, 1: PRINT rot
  91.             X = CX + SIN(rot + v(r).pi) * v(r).Radius
  92.             Y = CY + COS(rot + v(r).pi) * v(r).Radius
  93.  
  94.  
  95.             PSET (v(r).X, v(r).Y)
  96.  
  97.  
  98.             '        _PRINTSTRING (x, y), STR$(r)
  99.             PSET (X, Y)
  100.             CIRCLE (CX, CY), 3, 14
  101.         NEXT r
  102.     ELSE
  103.         oldrot = rot
  104.     END IF
  105.     _DISPLAY
  106.  

So we already know how to work. Now a mathematical problem follows. We know by which circle and with which center a particular point should be moved, but we do not know which of the points on the circle is our right one. That's what the JK! function do in program. So, to understand how it works, I've written another sample program (2D). An important point is to know how to rotate the picture. The absolute base is to rotate the image of the SIN and COS functions by center.
The mathematical result of JK!  must be absolutely accurate, otherwise the space will deform. This whole function is based on the definition of the Sinus and Cosinus functions using a circle unit. I think the picture will tell you more:
https://www.e-matematika.cz/stredni-skoly/karta-goniometricke-funkce-na-jednotkove-kruznici.php


In this source code you program show angle in radians between center and point on circle. Use mouse, move to circle radius,
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 256)
  2. radius = 200
  3.  
  4.  
  5.  
  6.     mx = _MOUSEX
  7.     my = _MOUSEY
  8.     cx = 400
  9.     cy = 300
  10.  
  11.  
  12.     CLS
  13.     FOR old = 0 TO _PI(2) STEP .001
  14.         oldX = cx + SIN(old) * radius
  15.         oldY = cy + COS(old) * radius
  16.         IF CINT(oldX) = mx AND CINT(oldY) = my THEN
  17.             PRINT "Old method - PI:"; old
  18.             PRINT "New - JK method - PI:"; JK(cx, cy, mx, my, radius)
  19.             EXIT FOR
  20.         END IF
  21.         PSET (oldX, oldY)
  22.     NEXT
  23.     _DISPLAY
  24.  
  25. 'pokus s jednotkovou kruznici! it is named english correctly as "binary circle"?
  26.  
  27.  
  28. FUNCTION JK! (cx, cy, px, py, R)
  29.     '  podle definice jednotkove kruznice musim nejprve hodnoty prevest na rozsah od -1 do 1 pro x i pro y.
  30.     '  R urcuje velikost kruznice, cili jR bude 1/R
  31.     LenX = cx - px
  32.     LenY = cy - py
  33.     jR = 1 / R
  34.  
  35.     jX = LenX * jR
  36.     jY = LenY * jR
  37.  
  38.     sinusAlfa = jX
  39.     Alfa = ABS(_ASIN(sinusAlfa))
  40.  
  41.     Q = 1
  42.     IF px >= cx AND py <= cy THEN Q = 1 'ok
  43.     IF px >= cx AND py <= cy THEN Q = 2 'ok
  44.  
  45.     IF px < cx AND py <= cy THEN Q = 3
  46.     IF px < cx AND py > cy THEN Q = 4
  47.     SELECT CASE Q
  48.         CASE 1: alfaB = Alfa
  49.         CASE 2: alfaB = _PI / 2 + (_PI / 2 - Alfa)
  50.         CASE 3: alfaB = _PI + Alfa
  51.         CASE 4: alfaB = _PI(1.5) + (_PI / 2 - Alfa)
  52.     END SELECT
  53.     JK! = alfaB
  54.  

In order to get the correct ratio (it has transferred the space to the space of the circle) it is sufficient to divide the number 1 by a radius.

What is the end of the game for this graphical demo?
 None. The minigame on the monitor is used only as animation, it goes to infinity. But in a next 3D program, I'll really be able to play minigame when switching from 3D to 2D, because the QB64 has tremendous power and performance, and it's totally in the possibilities of that language. It only depends on the programmer.

Can you rotate the view up / down?
That's what I'm working on. The principle will be the same as for rotation in XZ, only the radius is counted against the Z and Y, not the distance to the depth Z and the distance left - right X.
I assume that first rotation is done in X / Z and then another, in Y / Z. I want to solve this in the next program, so I'm going to solve this now.

I do not understand the last question, you probably ask for the moving aside.
 Yes, you can do it very easily. Only add or subtract POSx or POSz according to the angle of the current rotation.
Easy. It all looks easy when it's done ...
pic01.png
* pic01.png (Filesize: 7.98 KB, Dimensions: 457x396, Views: 250)