Post by bluatigro on Feb 27, 2019 5:22:28 GMT -5
update :
i have build a avatar whitout global lim's
now if i want to code a animation
i need to use the same numbers
my memory is not perfect
so that wil be difecult
@ carl :
PEASE change it so that i can use globals as parameters
if not i have to stop whit LB5
becuase coding is not fun anymore
i have build a avatar whitout global lim's
now if i want to code a animation
i need to use the same numbers
my memory is not perfect
so that wil be difecult
@ carl :
PEASE change it so that i can use globals as parameters
if not i have to stop whit LB5
becuase coding is not fun anymore
'' bluatigro 25 feb 2019
'' lino world
WindowWidth = DisplayWidth
WindowHeight = DispayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global mmax , rotx , roty , rotz , trans , temp , number , angle , pi
mmax = 20
rotx = mmax + 1
roty = maxx + 2
rotz = maxx + 3
trans = mmax + 4
temp = mmax + 5
pi = atn( 1 ) * 4
dim matrix( temp , 3 , 3 ) , sk( 64 , 2 )
global xyz , xzy , yxz , yzx , zxy , zyx
xyz = 0
xzy = 1
yxz = 2
yzx = 3
zxy = 4
zyx = 5
call matrix.init 0
open "lino3d 1.0" for graphics as #m
#m "trapclose [quit]"
timer 40 , [tick]
wait
[tick]
scan
#m "fill black"
a = angle
call human "yellow" , 5
angle = angle + 5
wait
[quit]
close #m
end
sub sixcubes
call link 1 , -200,100,0 , a,a,a , 0 , 0
call cube 0,0,0 , 50,50,50 , "red" , 5
call link 1 , 0,100,0 , a,a,a , 1 , 0
call cube 0,0,0 , 50,50,50 , "green" , 5
call link 1 , 200,100,0 , a,a,a , 2 , 0
call cube 0,0,0 , 50,50,50 , "blue" , 5
call link 1 , -200,-100,0 , a,a,a , 3 , 0
call cube 0,0,0 , 50,50,50 , "cyan" , 5
call link 1 , 0,-100,0 , a,a,a , 4 , 0
call cube 0,0,0 , 50,50,50 , "pink" , 5
call link 1 , 200,-100,0 , a,a,a , 5 , 0
call cube 0,0,0 , 50,50,50 , "yellow" , 5
end sub
sub human kl$ , size
''example avatar
no = number
''body
call lino 0,0,0 , 0,100,0 , kl$ , size
call lino -30,0,0 , 30,0,0 , kl$ , size
call lino -50,100,0 , 50,100,0 , kl$ , size
''head
call child 10 , 0,100,0 , 12 , no
call cube 0,20,0 , 20,20,20 , kl$ , size
''left arm
call child 10 , 50,100,0 , 0 , no
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 11 , 0,-70,0 , 1 , 10
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 12 , 0,-70,0 , 2 , 11
call cube 0,-20,0 , 5,20,5 , kl$ , size
''now i have to remember :
''left : arm = 0 : elbow = 1 : wrist = 2
''sorry : if this is the case i do not like LB5
''right arm
call child 10 , -50,100,0 , 32 , no
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 11 , 0,-70,0 , 33 , 10
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 12 , 0,-70,0 , 34 , 11
call cube 0,-20,0 , 5,20,5 , kl$ , size
''left leg
call child 10 , 30,0,0 , 4 , no
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 11 , 0,-70,0 , 5 , 10
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 12 , 0,-70,0 , 6 , 11
call lino 0,0,0 , 0,0,-30 , kl$ , size
''right leg
call child 10 , 30,0,0 , 36 , no
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 11 , 0,-70,0 , 37 , 10
call lino 0,0,0 , 0,-70,0 , kl$ , size
call child 12 , 0,-70,0 , 38 , 11
call lino 0,0,0 , 0,0,-30 , kl$ , size
end sub
sub lino x1,y1,z1 , x2,y2,z2 , kl$ , size
call spot x1,y1,z1
call spot x2,y2,z2
a1 = winx / 2 + x1 / ( z1 + 1000 ) * 1000
b1 = winx / 2 - y1 / ( z1 + 1000 ) * 1000
a2 = winx / 2 + x2 / ( z2 + 1000 ) * 1000
b2 = winx / 2 - y2 / ( z2 + 1000 ) * 1000
#m "color " ; kl$
#m "size " ; size
#m "down"
#m "line " ; a1 ; " " ; b1 ; " " ; a2 ; " " ; b2
#m "up"
end sub
sub cube x,y,z , dx,dy,dz , kl$ , size
call lino x+dx,y+dy,z+dz,x-dx,y+dy,z+dz,kl$,size
call lino x+dx,y+dy,z-dz,x-dx,y+dy,z-dz,kl$,size
call lino x+dx,y-dy,z+dz,x-dx,y-dy,z+dz,kl$,size
call lino x+dx,y-dy,z-dz,x-dx,y-dy,z-dz,kl$,size
call lino x+dx,y+dy,z+dz,x+dx,y-dy,z+dz,kl$,size
call lino x+dx,y+dy,z-dz,x+dx,y-dy,z-dz,kl$,size
call lino x-dx,y+dy,z+dz,x-dx,y-dy,z+dz,kl$,size
call lino x-dx,y+dy,z-dz,x-dx,y-dy,z-dz,kl$,size
call lino x+dx,y+dy,z+dz,x+dx,y+dy,z-dz,kl$,size
call lino x+dx,y-dy,z+dz,x+dx,y-dy,z-dz,kl$,size
call lino x-dx,y+dy,z+dz,x-dx,y+dy,z-dz,kl$,size
call lino x-dx,y-dy,z+dz,x-dx,y-dy,z-dz,kl$,size
end sub
sub skelet lim , x , y , z
sk( lim , 0 ) = x
sk( lim , 1 ) = y
sk( lim , 2 ) = z
end sub
sub child no , x , y , z , lim , ax , p
call link no , x , y , z _
, sk( lim , 1 ) , sk( lim , 0 ) , sk( lim , 2 ) _
, ax , p
end sub
sub link no , x , y , z , xz , yz , xy , ax , p
if no < 1 or no > 20 then exit sub
if p < 0 or p > 20 then exit sub
if no = p then exit sub
number = no
call matrix.init rotx
call matrix.init roty
call matrix.init rotz
call matrix.init trans
matrix( rotx , 1 , 1 ) = cos( rad( yz ) )
matrix( rotx , 1 , 2 ) = sin( rad( yz ) )
matrix( rotx , 2 , 1 ) = 0-sin( rad( yz ) )
matrix( rotx , 2 , 2 ) = cos( rad( yz ) )
matrix( roty , 0 , 0 ) = cos( rad( xz ) )
matrix( roty , 0 , 2 ) = sin( rad( xz ) )
matrix( roty , 2 , 0 ) = 0-sin( rad( xz ) )
matrix( roty , 2 , 2 ) = cos( rad( xz ) )
matrix( rotz , 1 , 1 ) = cos( rad( xy ) )
matrix( rotz , 1 , 0 ) = sin( rad( xy ) )
matrix( rotz , 0 , 1 ) = 0-sin( rad( xy ) )
matrix( rotz , 0 , 0 ) = cos( rad( xy ) )
matrix( trans , 3 , 0 ) = x
matrix( trans , 3 , 1 ) = y
matrix( trans , 3 , 2 ) = z
select case ax
case xyz
call matrix.reeks rotx , roty , rotz , trans , p , no
case xzy
call matrix.reeks rotx , rotz , roty , trans , p , no
case yxz
call matrix.reeks roty , rotx , rotz , trans , p , no
case yzx
call matrix.reeks roty , rotz , rotx , trans , p , no
case zxy
call matrix.reeks rotz , rotx , roty , trans , p , no
case zyx
call matrix.reeks rotz , roty , rotx , trans , p , no
case else
end select
end sub
function rad( deg )
rad = deg * pi / 180
end function
sub spot byref x , byref y , byref z
hx = matrix( number , 0 , 0 ) * x _
+ matrix( number , 1 , 0 ) * y _
+ matrix( number , 2 , 0 ) * z _
+ matrix( number , 3 , 0 )
hy = matrix( number , 0 , 1 ) * x _
+ matrix( number , 1 , 1 ) * y _
+ matrix( number , 2 , 1 ) * z _
+ matrix( number , 3 , 1 )
hz = matrix( number , 0 , 2 ) * x _
+ matrix( number , 1 , 2 ) * y _
+ matrix( number , 2 , 2 ) * z _
+ matrix( number , 3 , 2 )
x = hx
y = hy
z = hz
end sub
sub matrix.reeks a , b , c , t , p , uit
call matrix.multiply a , b , temp
call matrix.multiply temp , c , a
call matrix.multiply a , t , temp
call matrix.multiply temp , p , uit
end sub
sub matrix.multiply a , b , uit
for i = 0 to 3
for j = 0 to 3
matrix( uit , i , j ) = 0
for k = 0 to 3
matrix( uit , i , j ) = matrix( uit , i , j ) _
+ matrix( a , i , k ) * matrix( b , k , j )
next k
next j
next i
end sub
sub matrix.init no
for i = 0 to 3
for j = 0 to 3
matrix( no , i , j ) = 0
next j
matrix( no , i , i ) = 1
next i
end sub