''version 20 aug 2010''demonstation of scripting of''a simple scene''whit a animation''and a jointed limonerrorgoto[error]dim mv(64,5), sk(64,2), cam(6), pen(5)dim pal(255)global number , pi , frame , cubo$
pi =atn(1)*4
frame =0WindowWidth=DisplayWidthWindowHeight=DisplayHeightglobal black , red , green , yellow
global blue , magenta , cyan , white
global pink , orange , gray , purple
black = rgb( 000 , 000 , 000 )
red = rgb(255, 000 , 000 )
green = rgb( 000 ,255, 000 )
yellow = rgb(255,255, 000 )
blue = rgb( 000 , 000 ,255)
magenta = rgb(255, 000 ,255)
cyan = rgb( 000 ,255,255)
white = rgb(255,255,255)
pink = rgb(255,127,127)
orange = rgb(255,127, 000 )
gray = rgb(127,127,127)
purple = rgb(127, 000 ,127)''load freeshape object sript
cubo$ = loadscript$("lino-cubo.txt")nomainwinopen"lino3D"forgraphicsas#m
print#m ,"trapclose [quit]"timer250,[tmr]wait[tmr]#m "fill black"
frame = frame +3
q =sin(rad(frame)*2)*200''set place and orientation of camaracall camara 0,0,0,0,0,0,1call setpen 0,0,0, frame,0,0''set index colors of scriptcall palette 1, red
call palette 2, red
call palette 3, red
call palette 4, magenta
''run script and scale itcall freeshape cubo$ ,1,1,1call setpen 0,0,0, frame,0,0call movepen 150,0,0,0,frame*2,0''set index colors of scriptcall palette 1, blue
call palette 2, blue
call palette 3, blue
call palette 4, cyan
''run script and scale itcall freeshape cubo$ ,.5,.5,.5
print#m ,"flush"wait''3d engine stuf''================================================sub setpen x , y , z , xz , yz , xy
pen(0)= x
pen(1)= y
pen(2)= z
pen(3)= xz mod360
pen(4)= yz mod360
pen(5)= xy mod360endsubsub movepen x , y , z , xz , yz , xy
call rotate x , y , pen(5)call rotate y , z , pen(4)call rotate x , z , pen(3)
pen(0)= x + pen(0)
pen(1)= y + pen(1)
pen(2)= z + pen(2)
pen(3)= xz + pen(3)
pen(4)= yz + pen(4)
pen(5)= xy + pen(5)endsubsub link no , x , y , z , xz , yz , xy , p
if no <1or no >64thenexitsubif p <0or p >64thenexitsubif n = p thenexitsubcall rotate x , y , mv( p ,5)call rotate y , z , mv( p ,4)call rotate x , z , mv( p ,3)
mv( no ,0)= x + mv( p ,0)
mv( no ,1)= y + mv( p ,1)
mv( no ,2)= z + mv( p ,2)
mv( no ,3)= xz + mv( p ,3)
mv( no ,4)= yz + mv( p ,4)
mv( no ,5)= xy + mv( p ,5)
number = no
endsubsub child no , x , y , z , lim , p
if lim <1or lim >64thenexitsubcall link no , x , y , z _
, sk( lim ,1) _
, sk( lim ,0) _
, sk( lim ,2), p
endsubsub spot byref x ,byref y ,byref z
call rotate x , y , pen(5)call rotate y , z , pen(4)call rotate x , z , pen(3)if cam(6)=0then cam(6)=1
x =( x + pen(0)- cam(0))
y =( y + pen(1)- cam(1))
z =( z + pen(2)- cam(2))call rotate x , z ,0- cam(3)call rotate y , z ,0- cam(4)call rotate x , y ,0- cam(5)
x = x * cam(6)
y = y * cam(6)
z = z * cam(6)endsubsub camara x , y , z , xz , yz , xy , zoom
cam(0)= x
cam(1)= y
cam(2)= z
cam(3)= xz
cam(4)= yz
cam(5)= xy
cam(6)= zoom
endsubsub angle no , ax , deg
if no <1or no >64thenexitsubif ax <0or ax >2thenexitsub
sk( no , ax )= deg
endsubsub rotate byref k ,byref l , deg
s =sin( rad( deg mod360))
c =cos( rad( deg mod360))
kh = k * c - l * s
lh = k * s + l * c
k = kh
l = lh
endsubfunction rad( x )
rad = x * pi /180endfunction''=================================================''end 3d engine stuf''graphicsfunction loadscript$( file$ )
file$ =DefaultDir$;"\scripts\";file$
open file$ forinputas#in
txt$ =input$(#in ,lof(#in ))close#in
loadscript$ = txt$
endfunction[error]close#in
noticeErr$endsub palette no , clr
pal( no )= clr
endsubsub freeshape obj$ , sx , sy , sz
ifword$( obj$ ,1)<>"lino3D"thenexitsub
pointer =2whileword$( obj$ , pointer )<>"end"
comand$ =word$( obj$ , pointer )selectcase comand$
case"lino"
x1 =val(word$( obj$ , pointer +1))
y1 =val(word$( obj$ , pointer +2))
z1 =val(word$( obj$ , pointer +3))
x2 =val(word$( obj$ , pointer +4))
y2 =val(word$( obj$ , pointer +5))
z2 =val(word$( obj$ , pointer +6))
clr$ =word$( obj$ , pointer +7)ifval( clr$ )<0then
c = pal(abs(val( clr$ )))else
c = dec( clr$ )endifcall lino x1*sx , y1*sy , z1*sz _
, x2*sx , y2*sy , z2*sz ,3, c
pointer = pointer +8case"rotate"
pan =val(word$( obj$ , pointer +1))* frame
tilt =val(word$( obj$ , pointer +2))* frame
rol =val(word$( obj$ , pointer +3))* frame
call setpen pen(0),pen(1),pen(2),pan,tilt,rol
pointer = pointer +4caseelse:exitsubendselectwendendsubfunction dec( h$ )''i m testing this in justbasic so this has to beiflen( h$ )>6then dec =0iflen( h$ )<1then dec =0
som =0for i =1tolen( h$ )
digit =instr("123456789abcdef",mid$( h$ , i ,1))
som = som + digit *16 ^ (len( h$ )- i )next i
dec = som
endfunctionsub cubo mx , my , mz , dx , dy , dz , dik , kl
call lino mx - dx , my - dy , mz - dz _
, mx + dx , my - dy , mz - dz , dik , kl
call lino mx - dx , my + dy , mz - dz _
, mx + dx , my + dy , mz - dz , dik , kl
call lino mx - dx , my - dy , mz + dz _
, mx + dx , my - dy , mz + dz , dik , kl
call lino mx - dx , my + dy , mz + dz _
, mx + dx , my + dy , mz + dz , dik , kl
call lino mx - dx , my - dy , mz - dz _
, mx - dx , my + dy , mz - dz , dik , kl
call lino mx + dx , my - dy , mz - dz _
, mx + dx , my + dy , mz - dz , dik , kl
call lino mx - dx , my - dy , mz + dz _
, mx - dx , my + dy , mz + dz , dik , kl
call lino mx + dx , my - dy , mz + dz _
, mx + dx , my + dy , mz + dz , dik , kl
call lino mx - dx , my - dy , mz - dz _
, mx - dx , my - dy , mz + dz , dik , kl
call lino mx + dx , my - dy , mz - dz _
, mx + dx , my - dy , mz + dz , dik , kl
call lino mx - dx , my + dy , mz - dz _
, mx - dx , my + dy , mz + dz , dik , kl
call lino mx + dx , my + dy , mz - dz _
, mx + dx , my + dy , mz + dz , dik , kl
endsubsub okto x , y , z , dx , dy , dz , t , kl
call lino x,y+dy,z,x,y,z+dz,t,kl
call lino x,y,z+dz,x,y-dy,z,t,kl
call lino x,y-dy,z,x,y,z-dz,t,kl
call lino x,y,z-dz,x,y+dy,z,t,kl
call lino x+dx,y,z,x,y,z+dz,t,kl
call lino x,y,z+dz,x-dx,y,z,t,kl
call lino x-dx,y,z,x,y,z-dz,t,kl
call lino x,y,z-dz,x+dx,y,z,t,kl
call lino x+dx,y,z,x,y+dy,z,t,kl
call lino x,y+dy,z,x-dx,y,z,t,kl
call lino x-dx,y,z,x,y-dy,z,t,kl
call lino x,y-dy,z,x+dx,y,z,t,kl
endsubsub opo x , y , z , d , sides , t , kl
if sides <3then sides =3if sides >24then sides =24for i =0to sides
a=i*pi*2/sides
b=(i+1)*pi*2/sides
call lino sin(a)*d+x ,cos(a)*d+y , z _
,sin(b)*d+x ,cos(b)*d+y , z _
, t , kl
next i
endsubsub lino x1 , y1 , z1 , x2 , y2 , z2 , dik , kl
r =int( kl )and255
g =int( kl /256)and255
b =int( kl /256/256)and255
dx =WindowWidth
dy =WindowHeightcall spot x1 , y1 , z1
call spot x2 , y2 , z2
ax = dx /2+ x1 /( z1 +1000)*1000
ay = dy /2- y1 /( z1 +1000)*1000
bx = dx /2+ x2 /( z2 +1000)*1000
by = dy /2- y2 /( z2 +1000)*1000#m "size "; dik
#m "color "; r ;" "; g ;" "; b
#m "down"#m "line "; ax ;" "; ay ;" "; bx ;" "; by
#m "up"endsubsub bol x , y , z , d , dik , kl
call spot x , y , z
d = d * cam(6)
r =int( kl and255)
g =int( kl /256)and255
b =int( kl /256/256)and255#m "color "; r ;" "; g ;" "; b
#m "backcolor " ; r ; " " ; g ; " " ; b
d = d /( z +1000)*1000
dx =WindowWidth
dy =WindowHeight
x = dx /2+ x /( z +1000)*1000
y = dy /2- y /( z +1000)*1000#m "size " ; dik
#m "go "; x ;" "; y
#m "down"#m "ellipse " ; d ; " " ; d
#m "up"endsubfunction rainbow( x )
r =sin( rad( x ))*127+128
g =sin( rad( x -120))*127+128
b =sin( rad( x +120))*127+128
rainbow = rgb( r , g , b )endfunctionfunction rgb( r , g , b )
r = r and255
g = g and255
b = b and255
rgb = r + g *256+ b *256*256endfunction[quit]close#m
end