URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       techno game dev forum
  HTML https://technogamedevforum.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Tutorials
       *****************************************************
       #Post#: 112--------------------------------------------------
       Topic: more on Graphics: 3-D
       By: mr why Date: May 21, 2012, 9:41 am
       ---------------------------------------------------------
       One of the first things most of us want to do is make things
       look three-dimensional, real and solid, despite only having a
       flat screen.
       I will illustrate three ways to help do this, using the programs
       I did to draw knots and find out when they were actually knotted
       - not just tangled loops
       1. Use colour to indicate depth (like on a contour map)
       2. Make distant things smaller
       3  SHIFT distant things BEHIND near things as you move your
       eye-position
       By doing 3 (parallelax shift) alternately back and forth birds
       judge distance very accurtely. Also, for us things that change
       once-a-second get immediately noticed!
       This prog is best run in qb64 (screen resolution and speed)
       [code]
       DEFDBL A-Z
       _FULLSCREEN
       SCREEN _NEWIMAGE(1000, 730, 256)
       WINDOW (0, 0)-(1000, 730)
       DIM wx(710), wy(710), wz(710)
       dt = 710
       FOR n = 1 TO dt
       wx(n) = 1 + SIN(n / 30 - 1.8)
       wy(n) = 1 + SIN(n / 41 + .7)
       wz(n) = 1 + SIN(n / 50 - .3)
       NEXT n
       PRINT "Here is a piece of bent wire tied in a knot"
       FOR n = 1 TO dt
       x = 60 + 100 * wx(n)
       y = 700 - 120 * wy(n)
       z = 1 + 7 * wz(n)
       CIRCLE (x, y), z / 3 + 1, z
       NEXT n
       LOCATE 9, 1: PRINT "xy view"
       LOCATE 9, 45: PRINT "xz view"
       FOR n = 1 TO dt
       x = 400 + 120 * wz(n)
       y = 700 - 120 * wy(n)
       z = 1 + 7 * wx(n)
       CIRCLE (x, y), (z + 3) / 3 + 1, z
       NEXT n
       FOR n = 1 TO dt
       x = 50 + 100 * wx(n)
       y = 280 - 120 * wz(n)
       z = 1 + 7 * wy(n)
       CIRCLE (x, y), (z + 3) / 3 + 1, z
       NEXT n
       LOCATE 40, 1: PRINT "zy view"
       LOCATE 5, 20: PRINT "A"
       LOCATE 14, 9: PRINT "B"
       LOCATE 14, 61: PRINT "B"
       LOCATE 5, 81: PRINT "A"
       LOCATE 34, 6: PRINT "B"
       LOCATE 44, 20: PRINT "A"
       LOCATE 38, 54: PRINT "B"
       LOCATE 30, 68: PRINT "A"
       LOCATE 45, 50: PRINT " View from alternating x-positions";
       again:
       PSET (400, 300), 0
       FOR n = 1 TO dt
       x = 420 + 100 * wx(n)
       y = 310 - 120 * wy(n)
       z = 1 + 7 * wz(n)
       CIRCLE (x, y), z / 3 + 1, z
       NEXT n
       GOSUB pause
       FOR n = 1 TO dt
       x = 420 + 100 * wx(n)
       y = 310 - 120 * wy(n)
       z = 1 + 7 * wz(n)
       CIRCLE (x, y), z / 3 + 1, 0
       NEXT n
       FOR n = 1 TO dt
       x = 420 + 100 * wx(n) + 15 / (2.4 - wz(n))
       y = 310 - 120 * wy(n)
       z = 1 + 7 * wz(n)
       CIRCLE (x, y), z / 3 + 1, z
       NEXT n
       GOSUB pause
       FOR n = 1 TO dt
       x = 420 + 100 * wx(n) + 15 / (2.4 - wz(n))
       y = 310 - 120 * wy(n)
       z = 1 + 7 * wz(n)
       CIRCLE (x, y), z / 3 + 1, 0
       NEXT n
       GOTO again:
       pause:
       DO
       _LIMIT 20
       kk = kk + 1
       IF kk > 30 THEN kk = 0: RETURN
       GOTO pause
       LOOP
       END
       [/code]
       #Post#: 113--------------------------------------------------
       Re: Topic: more on Graphics: 3-D
       By: axlyon Date: May 21, 2012, 1:23 pm
       ---------------------------------------------------------
       i get it. like the kind of thing they did with StarFox on the
       SNES
       #Post#: 114--------------------------------------------------
       Re: Topic: more on Graphics: 3-D
       By: johnfree Date: May 21, 2012, 2:12 pm
       ---------------------------------------------------------
       Yes, no need for all 3 ideas at once
       For finest resolution (and speed) do not show size the way done
       in the above example (coiled coils are very slow)
       For smoothness colour-code for depth with GRADUAL and
       prpportional colour changes
       Instead of jumping between two views a smooth change of
       eye-position can be used.
       Just use the ideas best for YOU in YOUR program
       #Post#: 115--------------------------------------------------
       Re: Topic: more on Graphics: 3-D
       By: axlyon Date: May 21, 2012, 2:58 pm
       ---------------------------------------------------------
       this looks cool.
       wow, the first time i run QB64 code after i update my security
       pack and microsoft thinks QB64 progs are a threat!
       #Post#: 116--------------------------------------------------
       Re: Topic: more on Graphics: 3-D
       By: johnfree Date: May 21, 2012, 4:22 pm
       ---------------------------------------------------------
       Don't worry abt that!
       Someone will tell 'em sooner or later and their silliness will
       stop.
       (Actually qb64 is a threat as it is far better than their junk -
       for example always works versus "sometimes")
       *****************************************************