|
Post by bluatigro on Oct 5, 2019 14:10:37 GMT
this wil be a set of ever increasing diffecult anaglyph games of corse i wil have to do graphics first
scene : a set of points shaping a sphere
error : i got only a black screen
WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , pi winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny in$ = "350" prompt "screen x in mm." ; in$ screenx = val( in$ ) in$ = "200" prompt "screen y in mm." ; in$ screeny = val( in$ ) in$ = "500" prompt "distance you - screen in mm." ; in$ screeneye = val( in$ )
nomainwin open "annaglyp" for graphics as #m #m "trapclose [quit]" #m "fill black" #m "rule " ; _R2_MERGEPEN for i = 0 to pi * 2 step pi / 12 for j = 0 - pi / 2 to pi / 2 step pi / 12 x = sin( i ) * cos( j ) * 200 y = sin( j ) * 200 z = cos( i ) * cos( j ) * 200 - 300 call punt x , y , z , 5 , 255 next j next i #m "flush" wait [quit] close #m end sub punt x , y , z , size , kl ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "size " ; d call penred kl #m "goto " ; ar ; " " ; b #m "down" #m "set " ; ar ; " " ; b #m "up" call penblue kl #m "goto " ; al ; " " ; b #m "down" #m "set " ; al ; " " ; b #m "up" end sub sub lijn x1,y1,z1 , x2,y2,z2 , size , kl ar1 = x( x1 , y1 , z1 , 0 ) al1 = x( x1 , y1 , z1 , 1 ) b1 = y( x1 , y1 , z1 ) ar2 = x( x2 , y2 , z1 , 0 ) al2 = x( x2 , y2 , z1 , 1 ) b2 = y( x2 , y2 , z2 ) #m "size " ; size call penred kl #m "down" #m "line " ; ar1 ; " " ; b1 ; " " ; ar2 ; " " ; b2 #m "up" call penblue kl #m "down" #m "line " ; al1 ; " " ; b1 ; " " ; al2 ; " " ; b2 #m "up" end sub sub penred g #m "color " ; g ; " 0 0" end sub sub penblue g #m "color 0 0 " ; g end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx end if x = uit end function function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny end function
|
|
|
Post by tsh73 on Oct 5, 2019 15:40:02 GMT
sub punt x , y , z , size , kl should be probably
sub punt x , y , z , d , kl
With this I see some big red and blue dots (there was dots as it but tiny 1-pixel ones)
|
|
|
Post by bluatigro on Oct 6, 2019 11:50:55 GMT
update : point , line and cube
i have no stereoscopic vision so i can not test if it is good now
'' bluatigro 6 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , pi winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny in$ = "350" prompt "screen x in mm." ; in$ screenx = val( in$ ) in$ = "200" prompt "screen y in mm." ; in$ screeny = val( in$ ) in$ = "500" prompt "distance you - screen in mm." ; in$ screeneye = val( in$ )
nomainwin open "annaglyph" for graphics as #m #m "trapclose [quit]" #m "fill black" #m "rule " ; _R2_MERGEPEN for i = 0 to pi * 2 step pi / 12 for j = 0 - pi / 2 to pi / 2 step pi / 12 x = sin( i ) * cos( j ) * 100 y = sin( j ) * 100 z = cos( i ) * cos( j ) * 100 + screeneye call punt x , y , z , 2 , 255 next j next i call kubus 0,0,screeneye , 100,100,100 , 2 , 255 #m "flush" wait [quit] close #m end sub punt x , y , z , size , kl '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "size " ; size call penred kl #m "goto " ; ar ; " " ; b #m "down" #m "set " ; ar ; " " ; b #m "up" call penblue kl #m "goto " ; al ; " " ; b #m "down" #m "set " ; al ; " " ; b #m "up" end sub sub lijn x1,y1,z1 , x2,y2,z2 , size , kl '' draw a line from x1,y1,z1 to x2,y2,z2 '' whit thicknes size '' and grayscale kl [ 0 ... 255 ] ar1 = x( x1 , y1 , z1 , 0 ) al1 = x( x1 , y1 , z1 , 1 ) b1 = y( x1 , y1 , z1 ) ar2 = x( x2 , y2 , z2 , 0 ) al2 = x( x2 , y2 , z2 , 1 ) b2 = y( x2 , y2 , z2 ) #m "size " ; size call penred kl #m "down" #m "line " ; ar1 ; " " ; b1 ; " " ; ar2 ; " " ; b2 #m "up" call penblue kl #m "down" #m "line " ; al1 ; " " ; b1 ; " " ; al2 ; " " ; b2 #m "up" end sub sub penred g #m "color " ; g ; " 0 0" end sub sub kubus mx,my,mz , dx,dy,dz , size , kl '' draw a cuboid midle mx,my,mz border dx,dy,dz '' whit thicknes size '' and grayscale kl [ 0 ... 255 ] call lijn mx+dx,my+dy,mz+dz , mx-dx,my+dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx+dx,my-dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl
call lijn mx+dx,my+dy,mz+dz , mx+dx,my-dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx-dx,my+dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl
call lijn mx+dx,my+dy,mz+dz , mx+dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx-dx,my-dy,mz+dz , mx-dx,my-dy,mz-dz , size , kl
end sub sub penblue g #m "color 0 0 " ; g end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx / 2 end if x = uit end function function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny / 2 end function
@ carl : for lb5 : i want to be able to REM and deREM several lines at 1 time this for testing my code
|
|
|
Post by Rod on Oct 6, 2019 12:13:43 GMT
Ok that works, with the correct color film, red on left eye, blue on right I see a well defined square box containing a 3d sphere.
You can rem out blocks right now with If / Endif
It would be a good addition to let the user fine tune the color used so that it matches their glasses, some are cyan/green not truly blue.
|
|
|
Post by tsh73 on Oct 6, 2019 20:06:48 GMT
Just found my 3d glasses. Yes it works. Cool effect indeed.
|
|
|
Post by bluatigro on Oct 7, 2019 11:20:28 GMT
update : i think i got now al color combinations react if you mis one
'' bluatigro 6 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , pi winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny , colormode '' consts are in mm. '' these are myne pc screen sizes : you have to change this to yours screenx = 350 ''size of display in mm. screeny = 200 screeneye = 500 ''distance you - screen in mm. global blue.red , cyan.red , green.red blue.red = 1 cyan.red = 2 green.red = 3 colormode = blue.red
nomainwin menu #m , "color" _ , "blue - red" , [blue.red] _ , "cyan - red" , [cyan.red] _ , "green - red" , [green.red] open "annaglyph" for graphics as #m #m "trapclose [quit]" wait sub scene #m "fill black" #m "rule " ; _R2_MERGEPEN for i = 0 to pi * 2 step pi / 12 for j = 0 - pi / 2 to pi / 2 step pi / 12 x = sin( i ) * cos( j ) * 100 y = sin( j ) * 100 z = cos( i ) * cos( j ) * 100 + screeneye call punt x , y , z , 2 , 255 next j next i call kubus 0,0,screeneye , 100,100,100 , 2 , 255 #m "flush" end sub [blue.red] colormode = blue.red call scene wait [cyan.red] colormode = cyan.red call scene wait [green.red] colormode = green.red call scene wait [quit] close #m end sub punt x , y , z , size , kl '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "size " ; size call penred kl #m "goto " ; ar ; " " ; b #m "down" #m "set " ; ar ; " " ; b #m "up" call penblue kl #m "goto " ; al ; " " ; b #m "down" #m "set " ; al ; " " ; b #m "up" end sub sub lijn x1,y1,z1 , x2,y2,z2 , size , kl '' draw a line from x1,y1,z1 to x2,y2,z2 '' whit thicknes size '' and grayscale kl [ 0 ... 255 ] ar1 = x( x1 , y1 , z1 , 0 ) al1 = x( x1 , y1 , z1 , 1 ) b1 = y( x1 , y1 , z1 ) ar2 = x( x2 , y2 , z2 , 0 ) al2 = x( x2 , y2 , z2 , 1 ) b2 = y( x2 , y2 , z2 ) #m "size " ; size call penred kl #m "down" #m "line " ; ar1 ; " " ; b1 ; " " ; ar2 ; " " ; b2 #m "up" call penblue kl #m "down" #m "line " ; al1 ; " " ; b1 ; " " ; al2 ; " " ; b2 #m "up" end sub sub penred g #m "color " ; g ; " 0 0" end sub sub kubus mx,my,mz , dx,dy,dz , size , kl '' draw a cuboid midle mx,my,mz border dx,dy,dz '' whit thicknes size '' and grayscale kl [ 0 ... 255 ] call lijn mx+dx,my+dy,mz+dz , mx-dx,my+dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx+dx,my-dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl
call lijn mx+dx,my+dy,mz+dz , mx+dx,my-dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx-dx,my+dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl
call lijn mx+dx,my+dy,mz+dz , mx+dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx-dx,my-dy,mz+dz , mx-dx,my-dy,mz-dz , size , kl
end sub sub penblue g select case colormode case blue.red #m "color 0 0 " ; g case cyan.red #m "color 0 " ; g ; " " ; g case green.red #m "color 0 " ; g ; " 0" case else end select end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx / 2 end if x = uit end function function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny / 2 end function
|
|
|
Post by bluatigro on Oct 7, 2019 12:24:48 GMT
update : ANIMATION !!
'' bluatigro 7 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , pi winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny , colormode , frame '' consts are in mm. '' these are myne pc screen sizes : you may want to change this screenx = 350 '' screen size in mm. screeny = 200 screeneye = 500 '' distance you - screen in mm. global blue.red , cyan.red , green.red blue.red = 1 cyan.red = 2 green.red = 3 colormode = blue.red
nomainwin open "annaglyph sprites" for graphics as #m #m "trapclose [quit]" #m "goto 0 1" #m "color red" #m "down" #m "set 0 1" #m "up" #m "getbmp reddot 0 0 1 2" #m "color blue" #m "down" #m "set 0 1" #m "up" #m "getbmp bluedot 0 0 1 2" for i = 0 to 1000 #m "addsprite red" ; i ; " reddot" #m "spritescale red" ; i ; " 300" #m "addsprite blue" ; i ; " bluedot" #m "spritescale blue" ; i ; " 300" next i #m "fill black" #m "getbmp back 0 0 1 1" #m "background back" timer 40 , [tick] wait [tick] call scene wait sub scene scan a = 100 b = 0 call rotate a , b , frame for i = 0 to 11 for j = -6 to 6 x = a + sin( i * pi / 6 ) * cos( j * pi / 6 ) * 100 y = sin( j * pi / 6 ) * 100 z = b + cos( i * pi / 6 ) * cos( j * pi / 6 ) * 100 + screeneye #m "spritexy blue" ; 6 + i * 12 + j _ ; " " ; x( x , y , z , 1 ) _ ; " " ; y( x , y , z ) #m "spritexy red" ; 6 + i * 12 + j _ ; " " ; x( x , y , z , 0 ) _ ; " " ; y( x , y , z ) next j next i #m "drawsprites" frame = frame + 5 end sub [quit] close #m end function rad( deg ) rad = deg * pi / 180 end function sub rotate byref k , byref l , deg s = sin( rad( deg ) ) c = cos( rad( deg ) ) hk = k * c - l * s hl = k * s + l * c k = hk l = hl end sub sub punt x , y , z , size , kl '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "size " ; size call penred kl #m "goto " ; ar ; " " ; b #m "down" #m "set " ; ar ; " " ; b #m "up" call penblue kl #m "goto " ; al ; " " ; b #m "down" #m "set " ; al ; " " ; b #m "up" end sub sub lijn x1,y1,z1 , x2,y2,z2 , size , kl '' draw a line from x1,y1,z1 to x2,y2,z2 '' whit thicknes size '' and grayscale kl [ 0 ... 255 ] ar1 = x( x1 , y1 , z1 , 0 ) al1 = x( x1 , y1 , z1 , 1 ) b1 = y( x1 , y1 , z1 ) ar2 = x( x2 , y2 , z2 , 0 ) al2 = x( x2 , y2 , z2 , 1 ) b2 = y( x2 , y2 , z2 ) #m "size " ; size call penred kl #m "down" #m "line " ; ar1 ; " " ; b1 ; " " ; ar2 ; " " ; b2 #m "up" call penblue kl #m "down" #m "line " ; al1 ; " " ; b1 ; " " ; al2 ; " " ; b2 #m "up" end sub sub penred g #m "color " ; g ; " 0 0" end sub sub kubus mx,my,mz , dx,dy,dz , size , kl '' draw a cuboid midle mx,my,mz border dx,dy,dz '' whit thicknes size '' and grayscale kl [ 0 ... 255 ] call lijn mx+dx,my+dy,mz+dz , mx-dx,my+dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx+dx,my-dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl
call lijn mx+dx,my+dy,mz+dz , mx+dx,my-dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx-dx,my+dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl
call lijn mx+dx,my+dy,mz+dz , mx+dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx-dx,my-dy,mz+dz , mx-dx,my-dy,mz-dz , size , kl
end sub sub penblue g select case colormode case blue.red #m "color 0 0 " ; g case cyan.red #m "color 0 " ; g ; " " ; g case green.red #m "color 0 " ; g ; " 0" case else end select end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx / 2 end if x = uit end function function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny / 2 end function
|
|
|
Post by bluatigro on Oct 7, 2019 13:08:37 GMT
'' bluatigro 7 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , pi , pointtel winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny , colormode , frame '' consts are in mm. '' these are myne pc screen sizes : you may want to change this screenx = 350 '' screen size in mm. screeny = 200 screeneye = 500 '' distance you - screen in mm.
nomainwin open "annaglyph sprites" for graphics as #m #m "trapclose [quit]" #m "goto 0 1" #m "color red" #m "down" #m "set 0 1" #m "up" #m "getbmp reddot 0 0 1 2" #m "color blue" #m "down" #m "set 0 1" #m "up" #m "getbmp bluedot 0 0 1 2" for i = 0 to 1000 #m "addsprite red" ; i ; " reddot" #m "spritescale red" ; i ; " 300" #m "addsprite blue" ; i ; " bluedot" #m "spritescale blue" ; i ; " 300" next i #m "fill black" #m "getbmp back 0 0 1 1" #m "background back" timer 40 , [tick] wait [tick] call scene wait sub scene scan pointtel = 0 a = 100 b = 0 call rotate a , b , frame for i = 0 to 11 for j = -6 to 6 x = sin( i * pi / 6 ) * cos( j * pi / 6 ) * 100 y = sin( j * pi / 6 ) * 100 z = cos( i * pi / 6 ) * cos( j * pi / 6 ) * 100 + screeneye call punt x + a , y , z + b next j next i #m "drawsprites" frame = frame + 5 end sub [quit] close #m end function rad( deg ) rad = deg * pi / 180 end function sub rotate byref k , byref l , deg s = sin( rad( deg ) ) c = cos( rad( deg ) ) hk = k * c - l * s hl = k * s + l * c k = hk l = hl end sub sub punt x , y , z '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "spritexy blue" ; pointtel _ ; " " ; al _ ; " " ; b #m "spritexy red" ; pointtel _ ; " " ; ar _ ; " " ; b pointtel = pointtel + 1 end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx / 2 end if x = uit end function function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny / 2 end function
|
|
|
Post by B+ on Oct 7, 2019 14:56:25 GMT
Very nice 3D effect with so little code! fixed so can close screen without JB bugging out and having to reload code over and over
'' bluatigro 7 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth -100 WindowHeight = DisplayHeight global winx , winy , pi , pointtel winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny , colormode , frame '' consts are in mm. '' these are myne pc screen sizes : you may want to change this screenx = 350 '' screen size in mm. screeny = 200 screeneye = 500 '' distance you - screen in mm.
nomainwin open "annaglyph sprites" for graphics_nsb_nf as #m #m "trapclose [quit]" #m "goto 0 1" #m "color red" #m "down" #m "set 0 1" #m "up" #m "getbmp reddot 0 0 1 2" #m "color blue" #m "down" #m "set 0 1" #m "up" #m "getbmp bluedot 0 0 1 2" for i = 0 to 1000 #m "addsprite red" ; i ; " reddot" #m "spritescale red" ; i ; " 300" #m "addsprite blue" ; i ; " bluedot" #m "spritescale blue" ; i ; " 300" next i #m "fill black" #m "getbmp back 0 0 1 1" #m "background back" timer 40 , [tick] wait
[tick] scan pointtel = 0 a = 100 b = 0 call rotate a , b , frame for i = 0 to 11 for j = -6 to 6 x = sin( i * pi / 6 ) * cos( j * pi / 6 ) * 100 y = sin( j * pi / 6 ) * 100 z = cos( i * pi / 6 ) * cos( j * pi / 6 ) * 100 + screeneye call punt x + a , y , z + b next j next i #m "drawsprites" frame = frame + 5 wait
[quit] close #m end
function rad( deg ) rad = deg * pi / 180 end function
sub rotate byref k , byref l , deg s = sin( rad( deg ) ) c = cos( rad( deg ) ) hk = k * c - l * s hl = k * s + l * c k = hk l = hl end sub
sub punt x , y , z '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "spritexy blue" ; pointtel; " " ; al; " " ; b #m "spritexy red" ; pointtel; " " ; ar; " " ; b pointtel = pointtel + 1 end sub
function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx / 2 end if x = uit end function
function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny / 2 end function
|
|
|
Post by tsh73 on Oct 8, 2019 6:29:56 GMT
Interesting use of _R2_MERGEPEN I was thinking how horizontal cube line is drawn, where red and blue overlaps? So I print screened it and magnified. It looks like with _R2_MERGEPEN it produces magenta
Now I have couple of ideas - may be I'll check them later
1. Will variations of color work, not only red (255 0 0 ) but others (any 0 0 ) - so we can draw shaded 3d figure?
2. I know sprites could be semi-transparent with LB (making mask grey instead of black or something like that). I wonder if overprinting red and blue sprites will give as magenta, as with _R2_MERGEPEN?
3. One could draw fine mesh over a sprite so dots actually drawn are in checkered pattern (just diagonal lines every other pixel) We could take red picture - make it checkered - take blue one, make it checkered 1 pixel off. Now we can put these sprites in the same position and they both will be visible. (and so with overlap, say if we make sure our coordinates are odd)
- I wonder if with (2) or (3) we could make some things like 3d cubes and make of them something like Soma puzzle.
|
|
|
Post by bluatigro on Oct 8, 2019 8:18:24 GMT
if the mask is white sprites react to sprites the _r2_mergepen way
thinking about grayscale sprite points
spritepoints can be shaping other shapes wil do that to
even thinking about 3d engine build in
|
|
|
Post by bluatigro on Oct 8, 2019 9:42:23 GMT
update : sub sphere added grayscale added
296 point's and it is getting slow
'' bluatigro 8 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth - 100 WindowHeight = DisplayHeight global winx , winy , pi , pointtel winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global screeneye , screenx , screeny , colormode , frame '' consts are in mm. '' these are myne pc screen sizes : you may want to change this screenx = 350 '' screen size in mm. screeny = 200 screeneye = 500 '' distance you - screen in mm.
nomainwin open "annaglyph sprites" for graphics as #m #m "trapclose [quit]" for i = 0 to 255 #m "goto 0 1" #m "color " ; i ; " 0 0" #m "down" #m "set 0 1" #m "up" #m "getbmp r" ; i ; " 0 0 1 2" animred$ = animred$ + "r" ; i ; " " #m "color 0 0 " ; i #m "down" #m "set 0 1" #m "up" #m "getbmp b" ; i ; " 0 0 1 2" animblue$ = animblue$ + "b" ; i ; " " next i for i = 0 to 1000 #m "addsprite red" ; i ; " " ; animred$ #m "spritescale red" ; i ; " 300" #m "addsprite blue" ; i ; " " ; animblue$ #m "spritescale blue" ; i ; " 300" next i #m "fill black" #m "getbmp back 0 0 1 1" #m "background back" timer 40 , [tick] wait [tick] call scene wait sub scene scan pointtel = 0 randomize 1 x = 100 z = 0 call rotate x , z , frame call sphere x,0,y,20,255,14 call sphere 0-x,0,0-z,10,100,10 #m "drawsprites" frame = frame + 5 end sub [quit] close #m end sub sphere mx,my,mz,d,kl,sides for i = 0 to sides - 1 for j = 0-sides/2 to sides/2 x = mx + sin( i * pi / sides * 2 ) _ * cos( j * pi / sides * 2 ) * 100 y = my + sin( j * pi / sides * 2 ) * 100 z = mz + cos( i * pi / sides * 2 ) _ * cos( j * pi / sides * 2 ) * 100 call punt x , y , z + screeneye , kl next j next i end sub function irnd( l , h ) irnd = int( rnd(0) * ( h - l + 1 ) ) + l end function function rad( deg ) rad = deg * pi / 180 end function sub rotate byref k , byref l , deg s = sin( rad( deg ) ) c = cos( rad( deg ) ) hk = k * c - l * s hl = k * s + l * c k = hk l = hl end sub sub punt x , y , z , kl '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "spriteimage blue" ; pointtel ; " b" ; int( kl ) #m "spritexy blue" ; pointtel _ ; " " ; al ; " " ; b #m "spriteimage red" ; pointtel ; " r" ; int( kl ) #m "spritexy red" ; pointtel _ ; " " ; ar ; " " ; b pointtel = pointtel + 1 end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / z * screeneye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / z * screeneye * winx / screenx / 2 end if x = uit end function function y( x , y , z ) y = winy / 2 - y / z * screeneye * winy / screeny / 2 end function
what was the trick to not kicked uot of JB2 ?
|
|
|
Post by bluatigro on Oct 8, 2019 11:23:26 GMT
update : lijn [ line ] + kubus [ cube ] subs added
'' bluatigro 8 okt 2019 '' anaglyph '' coordinates are in mm WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , pi , pointtel winx = WindowWidth winy = WindowHeight pi = atn( 1 ) * 4 global eye , screenx , screeny , colormode , frame '' consts are in mm. '' these are myne pc screen sizes : you may want to change this screenx = 350 '' screen size in mm. screeny = 200 eye = 500 '' distance you - screen in mm.
nomainwin open "annaglyph sprites" for graphics as #m #m "trapclose [quit]" for i = 0 to 255 #m "goto 0 1" #m "color " ; i ; " 0 0" #m "down" #m "set 0 1" #m "up" #m "getbmp r" ; i ; " 0 0 1 2" animred$ = animred$ + "r" ; i ; " " #m "color 0 0 " ; i #m "down" #m "set 0 1" #m "up" #m "getbmp b" ; i ; " 0 0 1 2" animblue$ = animblue$ + "b" ; i ; " " next i for i = 0 to 1000 #m "addsprite red" ; i ; " " ; animred$ #m "spritescale red" ; i ; " 300" #m "addsprite blue" ; i ; " " ; animblue$ #m "spritescale blue" ; i ; " 300" next i #m "fill black" #m "getbmp back 0 0 1 1" #m "background back" timer 40 , [tick] wait [tick] call scene wait sub scene scan pointtel = 0 randomize 1 x = 100 z = 0 call rotate x , z , frame '' call sphere x,0,y,20,255,14 '' call lijn x,0,z,0-x,0,0-z , 10 , 255 call kubus x,0,z , 20,20,20 , 10 , 255 #m "drawsprites" frame = frame + 5 end sub [quit] close #m end sub sphere mx,my,mz,d,kl,sides for i = 0 to sides - 1 for j = 0-sides/2 to sides/2 x = mx + sin( i * pi / sides * 2 ) _ * cos( j * pi / sides * 2 ) * 100 y = my + sin( j * pi / sides * 2 ) * 100 z = mz + cos( i * pi / sides * 2 ) _ * cos( j * pi / sides * 2 ) * 100 call punt x , y , z , kl next j next i end sub sub lijn x1,y1,z1 , x2,y2,z2 , p , kl af = sqr( ( x1 - x2 ) ^ 2 + ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 ) if p = 0 then p = af for i = 0 to p x = x1 + ( x2 - x1 ) * i / p y = y1 + ( y2 - y1 ) * i / p z = z1 + ( z2 - z1 ) * i / p call punt x , y , z , kl next i end sub sub kubus mx,my,mz, dx,dy,dz , size , kl call lijn mx+dx,my+dy,mz+dz , mx-dx,my+dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx+dx,my-dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl call lijn mx+dx,my+dy,mz+dz , mx+dx,my-dy,mz+dz , size , kl call lijn mx+dx,my+dy,mz-dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my-dy,mz+dz , size , kl call lijn mx-dx,my+dy,mz-dz , mx-dx,my-dy,mz-dz , size , kl call lijn mx+dx,my+dy,mz+dz , mx+dx,my+dy,mz-dz , size , kl call lijn mx+dx,my-dy,mz+dz , mx+dx,my-dy,mz-dz , size , kl call lijn mx-dx,my+dy,mz+dz , mx-dx,my+dy,mz-dz , size , kl call lijn mx-dx,my-dy,mz+dz , mx-dx,my-dy,mz-dz , size , kl end sub function irnd( l , h ) irnd = int( rnd(0) * ( h - l + 1 ) ) + l end function function rad( deg ) rad = deg * pi / 180 end function sub rotate byref k , byref l , deg s = sin( rad( deg ) ) c = cos( rad( deg ) ) hk = k * c - l * s hl = k * s + l * c k = hk l = hl end sub sub punt x , y , z , kl '' draw a point on x,y,z '' whit diameter size '' and grayscale kl [ 0 ... 255 ] ar = x( x , y , z , 0 ) al = x( x , y , z , 1 ) b = y( x , y , z ) #m "spriteimage blue" ; pointtel ; " b" ; int( kl ) #m "spritexy blue" ; pointtel _ ; " " ; al ; " " ; b #m "spriteimage red" ; pointtel ; " r" ; int( kl ) #m "spritexy red" ; pointtel _ ; " " ; ar ; " " ; b pointtel = pointtel + 1 end sub function x( x , y , z , linx ) uit = winx / 2 + ( 35 + x ) / ( z + eye ) * eye * winx / screenx / 2 if linx then uit = winx / 2 + ( -35 + x ) / ( z + eye ) * eye * winx / screenx / 2 end if x = uit end function function y( x , y , z ) y = winy / 2 - y / ( z + eye ) * eye * winy / screeny / 2 end function
|
|
|
Post by tsh73 on Oct 8, 2019 12:01:59 GMT
If you mean you close it and falls - Program falls out of JB because you press "Close window", and it happens inside "scene" sub. It looks for [quit] handler, but it just not there. You can put another [quit] inside, or switch to sub event handler - it will be available everywhere.
#m "trapclose quit" '... sub quit handle$ timer 0 close #handle$ end end sub
If you mean "it works but then dies saying
invalid branch label: [tick] " then probably computer don't fast enough to finish sub scene before next tick. I just added [tick] just before end sub of sub scene. Or increase timer value from 40 to bigger one (100 works for me)
|
|
|
Post by Rod on Oct 8, 2019 15:56:28 GMT
Neither of the last two sets of code work for me. The squares are not properly aligned. I simply see two squares rotating.
|
|