Page 1 of 1

Spinning Tunnel

Posted: Wed Dec 31, 2014 2:55 pm
by DrChip
'playing with the 3d tunnel v.2
REM
REM 3d Bumpy Tunnel v.2
REM v.2 changed color scheme
REM iPhone 6 plus / 8.2 b3
REM

'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
pi=3.1415
graphics

'init
lines = 0 ' 0 - wiggly, 1 straight
rings=25
DIM rx(rings+1)
DIM ry(rings+1)
DIM rz(rings+1)

DIM orx(1441)
DIM ory(1441)


'full rotation, 720 would work but not as nice.
DIM circx(1441)
DIM circy(1441)

offs=-1
FOR a=1 TO 1440
circx(a)=2900*SIN(a*PI/720)
circy(a)=2900*COS(a*PI/720)
NEXT a

move=0.0
zsp=rings*2
gadd=0
FOR a=1 TO rings
IF lines = 0 THEN
rx(a)=180 *SIN(gadd/5)
ry(a)=180 *SIN(gadd/7)
ELSE
rx(a)=180 '*SIN(gadd/5)
ry(a)=180 '*SIN(gadd/7)
END IF
rz(a)=(zsp+3)
zsp=zsp-2
gadd=gadd+5
NEXT a

' main routine
main:

refresh off
graphics clear 0,0,0
GOSUB draw_rings
refresh on

GOTO main

draw_rings:
move=move+.5 ' speed 0.1 - 2.0
offs=offs+10
IF offs>160 THEN
offs=offs-160
END IF

FOR a=1 TO rings -1
tx=(rx(a)/(rz(a)-move))+csw
ty=(ry(a)/(rz(a)-move))+csh
tx2=(rx(a+1)/(rz(a+1)-move))+csw
ty2=(ry(a+1)/(rz(a+1)-move))+csh
clr=a * 10

bmm=(INT(-rz(a)+53)) * 10

FOR z=offs TO 1280+offs STEP 160
IF a<rings THEN
ttx3=(circx(z)/(rz(a+1)-move))+tx2
tty3=(circy(z)/(rz(a+1)-move))+ty2
END IF
ttx1=(circx(z)/(rz(a)-move))+tx
tty1=(circy(z)/(rz(a)-move))+ty
IF z<=1280 THEN
ttx2=(circx(z+160)/(rz(a)-move))+tx
tty2=(circy(z+160)/(rz(a)-move))+ty
ELSE
ttx2=(circx(offs)/(rz(a)-move))+tx
tty2=(circy(offs)/(rz(a)-move))+ty
END IF

draw COLOR .clr,.clr,.clr
draw size 1
draw LINE ttx1,tty1 to ttx2,tty2

IF a<rings THEN
draw COLOR .clr,.clr,.clr
draw size 2
draw LINE ttx1,tty1 to ttx3,tty3
END IF
NEXT z
NEXT a

IF move>2 THEN
gadd=gadd-130

FOR a=1 TO rings
IF lines = 0 THEN
rx(a)=180 *SIN(gadd/5)
ry(a)=180 *SIN(gadd/7)
ELSE
rx(a)=180 '*SIN(gadd/5)
ry(a)=180 '*SIN(gadd/7)
END IF
gadd=gadd+5
NEXT a
move=move-2
END IF
RETURN

Re: Spinning Tunnel

Posted: Wed Dec 31, 2014 3:06 pm
by Mr. Kibernetik
My modification:

Code: Select all

'playing with the 3d tunnel v.2
REM
REM 3d Bumpy Tunnel v.2
REM v.2 changed color scheme
REM iPhone 6 plus / 8.2 b3 
REM

'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
pi=3.1415
graphics

'init
lines = 0 ' 0 - wiggly, 1 straight 
rings=25
DIM rx(rings+1) 
DIM ry(rings+1) 
DIM rz(rings+1) 

DIM orx(1441)
DIM ory(1441) 


'full rotation, 720 would work but not as nice.
DIM circx(1441) 
DIM circy(1441) 

offs=-1
FOR a=1 TO 1440
circx(a)=2900*SIN(a*PI/720)
circy(a)=2900*COS(a*PI/720)
NEXT a

move=0.0
zsp=rings*2
gadd=0
FOR a=1 TO rings
IF lines = 0 THEN
rx(a)=180 *SIN(gadd/5)
ry(a)=180 *SIN(gadd/7)
ELSE 
rx(a)=180 '*SIN(gadd/5)
ry(a)=180 '*SIN(gadd/7)
END IF 
rz(a)=(zsp+3)
zsp=zsp-2
gadd=gadd+5
NEXT a

' main routine
main:

refresh off
graphics clear 0,0,0
GOSUB draw_rings
refresh on 

GOTO main 

draw_rings:
move=move+.5 ' speed 0.1 - 2.0
offs=offs+10
IF offs>160 THEN 
offs=offs-160
END IF 

FOR a=1 TO rings -1
tx=(rx(a)/(rz(a)-move))+csw
ty=(ry(a)/(rz(a)-move))+csh
tx2=(rx(a+1)/(rz(a+1)-move))+csw
ty2=(ry(a+1)/(rz(a+1)-move))+csh
clr=a/rings

bmm=(INT(-rz(a)+53)) * 10

FOR z=offs TO 1280+offs STEP 160
IF a<rings THEN 
ttx3=(circx(z)/(rz(a+1)-move))+tx2
tty3=(circy(z)/(rz(a+1)-move))+ty2
END IF
ttx1=(circx(z)/(rz(a)-move))+tx
tty1=(circy(z)/(rz(a)-move))+ty
IF z<=1280 THEN
ttx2=(circx(z+160)/(rz(a)-move))+tx
tty2=(circy(z+160)/(rz(a)-move))+ty
ELSE
ttx2=(circx(offs)/(rz(a)-move))+tx
tty2=(circy(offs)/(rz(a)-move))+ty
END IF

draw COLOR clr,clr,clr
draw size 1
draw LINE ttx1,tty1 to ttx2,tty2

IF a<rings THEN
draw size 2
draw LINE ttx1,tty1 to ttx3,tty3
END IF
NEXT z
NEXT a

IF move>2 THEN
gadd=gadd-130

FOR a=1 TO rings 
IF lines = 0 THEN
rx(a)=180 *SIN(gadd/5)
ry(a)=180 *SIN(gadd/7)
ELSE 
rx(a)=180 '*SIN(gadd/5)
ry(a)=180 '*SIN(gadd/7)
END IF 
gadd=gadd+5
NEXT a
move=move-2
END IF
RETURN

Re: Spinning Tunnel

Posted: Wed Dec 31, 2014 3:10 pm
by DrChip
Nice! Thanks!!!