BBC BASIC for Windows
Programming >> Graphics and Games >> The Knight Rider effect( 3D light project)
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1458778709

The Knight Rider effect( 3D light project)
Post by michael on Mar 24th, 2016, 12:18am

This is a conversion of the beginning of a project I envisioned.
The idea:
1) start from the ground up
2) define lighting (custom area)
3) work object up (width is manageable with this tool)
4) lighting is affected by object width sections
In theory, any complex object could be made to look 3D with the proper lighting..
This advances further than my 3D spheres and other emulated 3D objects, because it truly can have limitless possibilities.

Example: if you wanted to make facial contours you could define the depth/lighting for different regions using similar methods
OR
A side view of an object, ( like a 3D vase) could be made)
A chess piece could easily be made using this tool (with modification, as it isn't perfected..
BUT OH MAN!! This is A LOT faster on BBC !!!! :)
Code:
   
   REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      VDU 5
      OFF
      GCOL 1
      s=0

      x=0:y=0
      d=0
      e=90
      rate = 10 REM CYCLE RATE
      (cycle)
      IF d=0 AND s>e THEN (skip)
      IF d=1 AND s<e THEN (skip)
      PROC_ultimate(100,104,s,104)
      PROC_ultimate(100,100,s,100)
      PROC_ultimate(102,98,s,98)
      PROC_ultimate(104,96,s,96)
      PROC_ultimate(102,98,s,94)
      PROC_ultimate(104,96,s,92)
      (skip)
      IF d=0 THEN s=s+rate
      IF d=1 THEN s=s-rate
      IF d=0 AND s>e THEN d=1:e=0:GOTO (jmp)
      IF d=1 AND s<e THEN d=0:e=90:GOTO (jmp)

      (jmp)
      REM CLS
      GOTO (cycle)
      (mou)
      WAIT 0 : REM just wait, nothing to do !
      GOTO (mou)

      DEF PROC_ultimate(x,y,light,width) REM x,y,light startx,width of line
      r=250:g=250:b=250
      IF light>width THEN light=width
      origin=x+light
      FOR mov=origin TO x STEP -1
        COLOUR 0,r,g,b
        GCOL 0
        MOVE x+mov,y:DRAW x+mov,y
        r=r -2
        g=g -2
        b=b -2
        IF r<2 THEN r=2
        IF g<2 THEN g=2
        IF b<2 THEN g=2
      NEXT mov
      r=250:g=250:b=250
      destination=x+width
      FOR mov=origin TO destination STEP 1
        COLOUR 0,r,g,b
        GCOL 0
        MOVE x+mov,y:DRAW x+mov,y
        r=r -2
        g=g -2
        b=b -2
        IF r<2 THEN r=2
        IF g<2 THEN g=2
        IF b<2 THEN g=2
      NEXT mov
      ENDPROC