|
Post by bluatigro on Apr 14, 2018 5:17:21 GMT -5
update :
i chaged some -a to 0-a i removed al light and material code added a v3d constructor
i renamed my v3d OOP sfuf so you can see what belongs togeter
''bluatigro 10 apr 2018 ''openGL + bluaGL ''shapes try : whitout fog ''whit some OOP
[consts] global GL.COLOR.BUFFER.BIT : GL.COLOR.BUFFER.BIT = 16384 global GL.DEPTH.BUFFER.BIT : GL.DEPTH.BUFFER.BIT = 256 global GL.DEPTH.TEST : GL.DEPTH.TEST = 2929 global GL.PROJECTION : GL.PROJECTION = 5889 global GL.MODELVIEW : GL.MODELVIEW = 5888 global GL.SMOOTH : GL.SMOOTH = 7425 global GL.CULL.FACE : GL.CULL.FACE = 2884 ' primatifs global GL.POINTS : GL.POINTS = 0 global GL.LINES : GL.LINES = 1 global GL.LINE.STRIP : GL.LINE.STRIP = 3 global GL.LINE.LOOP : GL.LINE.LOOP = 2 global GL.LINE.STIPPLE : GL.LINE.STIPPLE = 2852 global GL.TRIANGLES : GL.TRIANGLES = 4 global GL.TRIANGLE.FAN : GL.TRIANGLE.FAN = 6 global GL.TRIANGLE.STRIP : GL.TRANGLE.STRIP = 5 global GL.QUADS : GL.QUADS = 7 global GL.QUAD.STRIP : GL.QUAD.STRIP = 8 ' light + material global GL.COLOR.MATERIAL : GL.COLOR.MATERIAL = 2903 Global GL.LIGHTING : GL.LIGHTING = 2896 Global GL.LIGHT0 : GL.LIGHT0 = 16384 Global GL.AMBIENT : GL.AMBIENT = 4608 Global GL.DIFFUSE : GL.DIFFUSE = 4609 Global GL.SPECULAR : GL.SPECULAR = 4610 Global GL.SHININESS : GL.SHININESS = 5633 Global GL.EMISSION : GL.EMISSION = 5632 Global GL.POSITION : GL.POSITION = 4611 global GL.SPOT.DIRCTION : GL.SPOT.DIRECTION = 4612 global GL.SPOT.EXPONENT : GL.SPOT.EXPONENT = 4613 global GL.SPOT.CUTOFF : GL.SPOT.CUTOFF = 4614 global GL.CONSTANT.ATTENUATION GL.CONSTANT.ATTENUATION = 4615 global GL.LINEAR.ATTENUATION GL.LINEAR.ATTENUATION = 4616 global GL.QUADRATIC.ATTENUATION GL.QUADRATIC.ATTENUATION = 4617 global GL.FRONT : GL.FRONT = 1028 Global GL.FRONT.AND.BACK : GL.FRONT.AND.BACK = 103 '' Fog Global GL.FOG : GL.FOG = 2912 Global GL.FOG.MODE : GL.FOG.MODE = 2917 Global GL.FOG.DENSITY : GL.FOG.DENSITY = 2914 Global GL.FOG.COLOR : GL.FOG.COLOR = 2918 Global GL.FOG.INDEX : GL.FOG.INDEX = 2913 Global GL.FOG.START : GL.FOG.START = 2915 Global GL.FOG.END : GL.FOG.END = 2916 Global GL.LINEAR : GL.LINEAR = 9729 Global GL.EXP : GL.EXP = 2048 Global GL.EXP2 : GL.EXP2 = 2049 ''bluaGL const's ''colorObject's global black , red , green , yellow global blue , magenta , cyan , white global gray , pink , purple , orange black = rgba( 000 , 000 , 000 , 255 ) red = rgba( 255 , 000 , 000 , 255 ) green = rgba( 000 , 255 , 000 , 255 ) yellow = rgba( 255 , 255 , 000 , 255 ) blue = rgba( 000 , 000 , 255 , 255 ) magenta = rgba( 255 , 000 , 255 , 255 ) cyan = rgba( 000 , 255 , 255 , 255 ) white = rgba( 255 , 255 , 255 , 255 ) gray = rgba( 127 , 127 , 127 , 255 ) pink = rgba( 255 , 127 , 127 , 255 ) purple = rgba( 127 , 000 , 127 , 255 ) orange = rgba( 255 , 127 , 000 , 255 ) ''for joint angle control global xyz , xzy , yxz , yzx , zxy , zyx xyz = 0 xzy = 1 yxz = 2 yzx = 3 zxy = 4 zyx = 5 global pi pi = atn( 1 ) * 4 dim hil( 16 , 16 ) nomainwin ''some joint number's for humanoid and 4 legged animal global arm,elbow,wrist,leg,knee,enkle,eye global leftno,rightno arm = 0 elbow = 1 wrist = 2 leg = 3 knee = 4 enkle = 5 eye = 6 global thumb,index,middle,ring,tail,neck thumb = 7 index = 10 middle = 13 ring = 16 tail = 20 neck = 21 leftno = 0 rightno = 32 ''some joint number's for bug's global iarm,ielbow,iwrist,ifinger,ithumb global ileg,iknee,itail,isensor,ieye iarm = 1 ielbow = 2 iwrist = 3 ileg = 4 iknee = 9 iwing = 14 itail = 16 isensor = 17 ithumb = 18 ifinger = 19 ieye = 20
WindowWidth = DisplayWidth WindowHeight = DisplayHeight global winx , winy , winyx winx = WindowWidth winy = WindowHeight winyx = winy / winx
global false , true false = 0 true = not( false )
global mouse.x , mouse.y , key$
global MainH , MainDC ''wil be filled by code
global angle ''for animation's global state open "opengl32.dll" for dll as #gl menu #m , "info" , "instruction's" , [info] if instr( Platform$ , "LBB" ) then open "openGL" for window as #m else open "openGL" for graphics as #m end if #m "trapclose [quit]" #m "when characterInput [key]" #m "when mouseMove [mouse.move]" #m "setfocus" MainH = hwnd( #m ) gosub [openGL] gosub [bluaGL] call openglInit call camera.set 0 , 0 , 0 , 0 state = -1 timer 40 , [timer] wait
[info] notice chr$( 13 ) _ + "Welkome by a openGL demo" + chr$( 13 ) _ + "made by bluatigro" + chr$( 13 ) _ + "use mouse :" + chr$( 13 ) _ + "left turn + right turn + forwart + back" + chr$( 13 ) _ + "use cursor key's :" + chr$( 13 ) _ + "left + right + up + down" + chr$( 13 ) _ + "use [q] : reset camera" + chr$( 13 ) _ + "use [esc] : quit program" wait [mouse.move] mouse.x = MouseX mouse.y = MouseY wait [timer] scan clra = rainbow( angle ) clrb = rainbow( angle + 180 ) call glClear GL.COLOR.BUFFER.BIT or GL.DEPTH.BUFFER.BIT call camera.use call glScale winyx , 1 , 1
''only change code below this [ exept you are sure what you do ]
call glPushMatrix select case state case -1 ''draws not right jet call glRotate 30 , 0,1,0 call glScale .5,.5,.5 call home.anim ''reset al joint angle's to 0 call bug.home ''set bug in start mode ''turn animation[s] of and on by REM ''to see what happens ''you can control bug animation[s] independently '' call bug.fly angle , 10 call bug.sting angle , 7 '' call bug.left.legs angle , 5 '' call bug.left.box angle , 5 '' call bug.right.legs angle , 5 '' call bug.right.box angle , 5 call bug.draw clra case 0 ''draws what i expect call glRotate 30 , 0,1,0 call glScale .4,.4,.4 call home.anim ''reset al joint angle's to 0 ''turn animation[s] on and of by REM ''to see what happens ''you can contol humanoid animation[s] independetly call man.legs angle , 30 call man.arms angle , 30 call man.fingers angle , 20 call robot.draw 1 , clra case 1 ''draws what i expect call glRotate angle , 0,0,1 call glBegin GL.TRIANGLES call glColor 1 , 0 , 0 , 1 call glVertex .5 , 0 , 0 call glColor 0 , 1 , 0 , 1 call glVertex -.5 , .5 , 0 call glColor 0 , 0 , 1 , 1 call glVertex -.5 , -.5 , 0 call glEnd '' case -2 ''is almost right '' call glRotate angle , 0,1,0 '' call setbox 0,0,0 , .7,.7,.7 '' call sphere 24 , 24 , 3 , 3 , clra , clrb case 2 ''is almost right call glRotate angle , 0,1,0 call glRotate angle , 1,0,0 call setbox 0,0,0 , .7,.1,.1 call torus 12 , 12 , clra , clrb case 3 ''is a litle shaggy call glRotate angle , 0,1,0 call glRotate angle , 1,0,0 call setbox 0,0,0 , .7,.1,.1 call banana 12 , 12 , clra , clrb case 4 ''draws what i expect call glRotate angle , 0,1,0 call glRotate angle , 1,0,0 call setbox 0,0,0 , .7,.7,.7 ''make first parameter not to big !! [ < 4 ] call isoca 2 , clra , clrb case 5 ''draws what i expect call glTranslate 0,-0.5,0 call glScale 0.2,0.2,0.2 call glRotate angle , 0,1,0 ''make first parameter not to big !! call tree 3 , "f[xybLh]zXybLh" _ , .7 , 45 , 90 , 20 , rainbow( angle ) case 6 ''draws what i expect call glRotate 30 , 0,1,0 call glScale .4,.4,.4 call home.anim ''reset al joint angle's to 0 ''4 legged animal has only 1 animation call dog.walk angle , 30 call dog.draw clra case else end select call glPopMatrix angle = angle + 5 if angle >= 360 * 5 then angle = 0 state = state + 1 if state >= 7 then state = -1 end if ''read input and akt on it if false then ''for turning camera move's on and of if mouse.x < winx / 3 then call camera.move 0 , 0 , 0 , 1 end if if mouse.x > winx * 2 / 3 then call camera.move 0 , 0 , 0 , -1 end if if mouse.y < winy / 3 then call camera.move 0 , 0 , .1 , 0 end if if mouse.y > winy * 2 / 3 then call camera.move 0 , 0 , -.1 , 0 end if select case key$ case chr$( _VK_UP ) call camera.move 0 , .1 , 0 , 0 case chr$( _VK_DOWN ) call camera.move 0 , -.1 , 0 , 0 case chr$( _VK_LEFT ) call camera.move -.1 , 0 , 0 , 0 case chr$( _VK_RIGHT ) call camera.move .1 , 0 , 0 , 0 case "q" call camera.set 0 , 0 , 0 , 0 case chr$( _VK_ESCAPE ) goto [quit] end select key$ = "" end if
''only change code above this [ exept you are sure what you do ]
calldll #gdi32,"SwapBuffers" _ , MainDC as ulong _ , ret as long wait
[key] key$ = right$( Inkey$ , 1 ) if key$ <> chr$( 27 ) then wait [quit] calldll #gl,"wglMakeCurrent" _ , 0 as ulong, 0 as ulong, ret as long calldll #gl,"wglDeleteContext" _ , GLContext as ulong, ret as long calldll #user32, "ReleaseDC" _ , MainH as ulong, MainDC as ulong,ret as long close #m close #gl end
[animations]
sub home.anim for i = 0 to 64 call skelet i , 0 , 0 , 0 next i end sub
sub dog.walk f , a ''example of a 4 legged animal avatar animation call skelet arm + leftno _ , pend( f + 180 , 0 - a ) , 0 , 0 call skelet elbow + leftno _ , pend( f + 90 , 0 - a ) + a , 0 , 0 call skelet arm + rightno _ , pend( f , 0 - a ) , 0 , 0 call skelet elbow + rightno _ , pend( f - 90 , 0-a ) + a , 0 , 0 call skelet leg + leftno _ , pend( f + 180 , 0 - a ) , 0 , 0 call skelet knee + leftno _ , pend( f + 90 , 0 - a ) + a , 0 , 0 call skelet leg + rightno _ , pend( f , 0 - a ) , 0 , 0 call skelet knee + rightno _ , pend( f - 90 , 0 - a ) + a , 0 , 0 call skelet tail , -45 , 0 , pend( f * 2 , 30 ) end sub
sub man.arms f , a ''example of a humanoid avatar animation call skelet arm + leftno , pend( f , a ) , 0 , 0 call skelet elbow + leftno , abs( a ) , 0 , 0 call skelet arm + rightno _ , pend( f + 180, a ) , 0 , 0 call skelet elbow + rightno , abs( a ) , 0 , 0 end sub
sub man.legs f , a ''example of a humanoid avatar animation call skelet leg + leftno _ , pend( f + 180 , a ) , 0 , 0 call skelet knee + leftno _ , pend( f + 90 , a ) - a , 0 , 0 call skelet leg + rightno _ , pend( f , a ) , 0 , 0 call skelet knee + rightno _ , pend( f - 90 , a ) - a , 0 , 0 end sub
sub man.fingers f , a ''example of a humanoid avatar animation call skelet thumb + leftno _ , pend( f , a ) + a , 0 , 0 call skelet thumb + rightno _ , pend( f , a ) + a , 0 , 0 for i = 0 to 2 call skelet index + i + leftno _ , 0 , 0 , pend( f , a ) - a call skelet middle + i + leftno _ , 0 , 0 , pend( f - 120 , a ) - a call skelet ring + i + leftno _ , 0 , 0 , pend( f + 120 , a ) - a call skelet index + i + rightno _ , 0 , 0 , pend( f , a ) + a call skelet middle + i + rightno _ , 0 , 0 , pend( f - 120 , a ) + a call skelet ring + i + rightno _ , 0 , 0 , pend( f + 120 , a ) + a next i end sub
''example bug avatar animation's
sub bug.fly f , a call skelet iwing + leftno _ , 0 , 0 , pend( f , 0 - a ) call skelet iwing + leftno + 1 _ , 0 , 0 , pend( f , a ) call skelet iwing + rightno _ , 0 , 0 , pend( f , a ) call skelet iwing + rightno + 1 _ , 0 , 0 , pend( f , 0 - a ) end sub
sub bug.left.box f , a call skelet iarm + leftno _ , 0 , pend( f , 0 - a ) + 45 , 0 call skelet ielbow + leftno _ , 0 , pend( f , a * 2 ) - 60 , 0 end sub
sub bug.left.legs f , a For i = 0 To 4 call skelet ileg + leftno + i _ , 0 , 0 , pend( f + i * 180 , a ) call skelet iknee + leftno + i _ , pend( f + i * 180 + 90 , a ) , 0 , 0 Next end sub
sub bug.right.box f , a call skelet iarm + rightno _ , 0 , pend( f , a ) - 45 , 0 call skelet ielbow + rightno _ , 0 , pend( f , 0 - a * 2 ) + 60 , 0 end sub
sub bug.right.legs f , a For i = 0 To 4 call skelet ileg + rightno + i _ , 0 , 0 , pend( f + i * 180 , a ) call skelet iknee + rightno + i _ , pend( f + i * 180 + 90 , a ) , 0 , 0 Next end sub
sub bug.home call skelet iarm + leftno , 0 , 45 , 0 call skelet ielbow + leftno , 0 , -60 , 0 call skelet ifinger + leftno , 0 , 0 , 0 call skelet ithumb + leftno , 0 , 0 , 0 call skelet iarm + rightno , 0 , -45, 0 call skelet ielbow + rightno , 0 , 60 , 0 call skelet ifinger + rightno , 0 , 0, 0 call skelet ithumb + rightno , 0 , 0, 0 call skelet itail + leftno , 10 , 0 , 0 call skelet itail + rightno , 10 , 0 , 0 end sub
sub bug.sting f , a call skelet itail + rightno , 10 + pend( f , a ) , 0 , 0 call skelet itail + leftno , 10 - pend( f , a ) , 0 , 0 end sub
[landscape]
sub tree l , prog$ , f,x,y,z,kl ''draw a tree ''l = depth : do not make to big ''prog$ = description ''f = how mutch smaller : must be < 1 ''x,y,z = angles in degrees ''kl = color of flower [ if any ] if l > 0 then for i = 1 to len( prog$ ) select case mid$( prog$ , i , 1 ) case "f" ''draw trunk or twig and move pen call setbox 0,1,0 , .3,1,.3 call oneColorCube orange call glTranslate 0,2,0 case "l" ''draw a leave call glPushMatrix call glScale .5 , .5 , .5 call point 0 , 0,0,0 call point 1 , 1,0,1 call point 2 , 3,0,3 call point 3 , 1,0,-1 call quad 0 , 1 , 2 , 3 , green call glPopMatrix case "L" ''draw a set of leaves for t = 0 to 4 call glPushMatrix call glRotate 72 * t , 0,1,0 call glScale .5 , .5 , .5 call point 0 , 0,0,0 call point 1 , 1,0,1 call point 2 , 3,0,3 call point 3 , 1,0,-1 call quad 0 , 1 , 2 , 3 , green call glPopMatrix next t case "h" ''draw a flower for t = 0 to 4 call glPushMatrix call glRotate 72 * t , 0,1,0 call glScale .5 , .5 , .5 call point 0 , 0,0,0 call point 1 , 1,1,1 call point 2 , 3,3,3 call point 3 , 1,1,-1 call quad 0 , 1 , 2 , 3 , kl call glPopMatrix next t case "g" ''move pen call glTranslate 0,2,0 case "[" ''store pen call glPushMatrix case "]" ''read pen call glPopMatrix case "X" call glRotate 0-x , 1,0,0 case "x" call glRotate x , 1,0,0 case "Y" call glRotate 0-y , 0,1,0 case "y" call glRotate y , 0,1,0 case "Z" call glRotate 0-z , 0,0,1 case "z" call glRotate z , 0,0,1 case "b" ''draw hole tree f smaler call glScale f,f,f call tree l - 1 , prog$ , f,x,y,z,kl case else end select next i end if end sub
[avatars]
sub robot.finger.draw i , clr ''part of hand of humanoid avatar ''i = finger number call glPushMatrix call child 0,-.2,0 , i , xyz call setbox 0,-.1,0 , .1,.1,.1 call oneColorCube clr call glPushMatrix call child 0,-.2,0 , i+1 , xyz call oneColorCube clr call glPushMatrix call child 0,-.2,0 , i+2 , xyz call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix end sub
sub robot.hand.draw i , clr ''part of humanoid avatar ''i = leftno or right no call setbox 0,-.3,0 , .1,.3,.3 call oneColorCube clr call glPushMatrix call child 0,-.2,-.5 , thumb + i , xyz call robot.finger.draw thumb + i , clr call glPopMatrix call glPushMatrix call child 0,-.6,-.3 , index + i , xyz call robot.finger.draw index + i , clr call glPopMatrix call glPushMatrix call child 0,-.6,0 , middle + i , xyz call robot.finger.draw middle + i , clr call glPopMatrix call glPushMatrix call child 0,-.6,.3 , ring + i , xyz call robot.finger.draw ring + i , clr call glPopMatrix end sub
sub robot.draw h , clr ''example humanoid avatar ''if h then robot has finger's call setbox 0 , 0 , 0 , .3 , .1 , .1 call oneColorCube clr call setbox 0 , .75 , 0 , .1 , .5 , .1 call oneColorCube clr call setbox 0 , 1.8 , 0 , .2 , .2 , .2 call oneColorCube clr call setbox 0 , 1.4 , 0 , .7 , .1 , .1 call oneColorCube clr call glPushMatrix call child .25 , 0 , 0 , leg + leftno , zyx call setbox 0 , -.6 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , knee + leftno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1.2 , 0 , enkle + leftno , xyz call setbox 0 , 0 , -.2 , .1 , .1 , .3 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child -.25 , 0 , 0 , leg + rightno , zyx call setbox 0 , -.6 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , knee + rightno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1.2 , 0 , enkle + rightno , xyz call setbox 0 , 0 , -.2 , .1 , .1 , .3 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child .65 , 1.3 , 0 , arm + leftno , xyz call setbox 0 , -.5 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , elbow + leftno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , wrist + leftno , zyx if h then call robot.hand.draw leftno , white else call setbox 0 , -.3 , 0 , .05 , .2 , .15 call oneColorCube clr end if call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child -.65 , 1.3 , 0 , arm + rightno , xyz call setbox 0 , -.5 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , elbow + rightno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , wrist + rightno , zyx if h then call robot.hand.draw rightno , white else call setbox 0 , -.3 , 0 , .05 , .2 , .15 call oneColorCube clr end if call glPopMatrix call glPopMatrix call glPopMatrix end sub
sub dog.draw clr ''example 4 legged avatar call glPushMatrix call glRotate 180 , 0,1,0 call setbox 0,.2,.5 , .3,.3,.7 call oneColorCube clr call glPushMatrix call child 0 , .6 , 1.5 , neck + leftno , xyz call glPushMatrix call child 0 , 0 , 0 , neck + rightno , zyx call setbox 0,0,0 , .3 , .3 , .3 call oneColorCube clr call setbox 0,-.2,.3 , .2,.2,.2 call oneColorCube clr call setbox 0,0,.5 , .1,.1,.1 call oneColorCube clr call setbox .3,-.15,0 , .05,.3,.2 call oneColorCube clr call setbox -.3,-.15,0 , .05,.3,.2 call oneColorCube clr call glPopMatrix call glPopMatrix call glPushMatrix call child 0 , .4 , -.5 , tail , yzx call setbox 0,.3,0 , .1 , .3 , .1 call oneColorCube clr call glPopMatrix call glPushMatrix call child .3 , 0 , 1 , leg + leftno, zyx call setbox 0 , -.6 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , knee + leftno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1.2 , 0 , enkle + leftno, xyz call setbox 0 , 0 , .2 , .1 , .1 , .3 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child -.3 , 0 , 1 , leg + rightno, zyx call setbox 0 , -.6 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , knee + rightno, xyz call oneColorCube clr call glPushMatrix call child 0 , -1.2 , 0 , enkle + rightno, xyz call setbox 0 , 0 , .2 , .1 , .1 , .3 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child .3 , 0 , 0 , arm + leftno , zyx call setbox 0 , -.6 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , elbow + leftno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1.2 , 0 , wrist + leftno , xyz call setbox 0 , 0 , .2 , .1 , .1 , .3 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child -.3 , 0 , 0 , arm + rightno , zyx call setbox 0 , -.6 , 0 , .1 , .4 , .1 call oneColorCube clr call glPushMatrix call child 0 , -1 , 0 , elbow + rightno , xyz call oneColorCube clr call glPushMatrix call child 0 , -1.2 , 0 , wrist + rightno , xyz call setbox 0 , 0 , .2 , .1 , .1 , .3 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPopMatrix end sub
sub bug.draw clr ''example bug avatar call glPushMatrix call glScale .005 , .005 , .005 call glRotate 180 , 0,1,0 call setbox 0, 0, 0, 30, 10.0, 60.0 call oneColorCube clr For i = 0 To 4 call glPushMatrix call child 35.0, 0.0, i * 25 - 50 , ileg + leftno + i, xyz call setbox 30.0, 0.0, 0.0, 30.0, 5.0, 5.0 call oneColorCube clr call glPushMatrix call child 65.0, -5.0, 0.0 , iknee + leftno + i, xyz call setbox 0.0, -30.0, 0.0, 5.0, 30.0, 5.0 call oneColorCube clr call glPopMatrix call glPopMatrix call glPushMatrix call child -35.0, 0.0, i * 25 - 50, ileg + rightno + i, xyz call setbox -30.0, 0.0, 0.0, 30.0, 5.0, 5.0 call oneColorCube clr call glPushMatrix call child -65.0, -5.0, 0.0 , iknee + rightno + 1, xyz call setbox 0.0, -30.0, 0.0, 5.0, 30.0, 5.0 call oneColorCube clr call glPopMatrix call glPopMatrix Next call glPushMatrix call child 0 , 0 , -50 , itail + leftno , xyz For i = 0 To 9 call glPushMatrix call child 0.0, 0.0, -30.0 , itail + leftno , xyz call setbox 0.0, 0.0, -15.0, 10.0, 10.0, 10.0 call oneColorCube clr Next for i = 0 to 8 call glPushMatrix call child 0 , 0 , -30 , itail + rightno , xyz call oneColorCube clr next i for i = 0 to 8 call glPopMatrix call glPopMatrix next i call glPopMatrix call glPushMatrix call child 30.0, 0.0, 65.0, iarm + leftno , xyz call setbox 0.0, 0.0, 65.0 , 5 , 35 , 5 call oneColorCube clr call glPushMatrix call child 0.0, 0.0, 65.0, ielbow + leftno , xyz call oneColorCube clr call glPushMatrix call child 0.0, 0.0, 65.0 , iwrist + leftno, xyz call glPushMatrix call child -10.0, 0.0, 5.0 , ithumb + leftno , xyz call oneColorCube clr call glPopMatrix call glPushMatrix call child 5.0, 0.0, 5.0, ifinger + leftno , xyz call setbox 0.0, 0.0, 30.0, 5.0, 10.0, 30.0 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPopMatrix call glPushMatrix call child -30.0, 0.0, 65.0, iarm + rightno , xyz call setbox 0.0, 0.0, 30.0, 5.0, 5.0, 30.0 call oneColorCube clr call glPushMatrix call child 0.0, 0.0, 65.0, ielbow + rightno , xyz call oneColorCube clr call glPushMatrix call child 0.0, 0.0, 65.0, iwrist + rightno , xyz
call glPushMatrix call child 10.0, 0.0, 5.0, ithumb + rightno , xyz call oneColorCube clr call glPopMatrix call glPushMatrix call child -5.0, 0.0, 5.0, ifinger + rightno , xyz call setbox 0.0, 0.0, 30.0, 5.0, 10.0, 30.0 call oneColorCube clr call glPopMatrix call glPopMatrix call glPopMatrix call glPopMatrix For i = 0 To 1 call glPushMatrix call child 20.0, 20.0, 40.0 - 50.0 * i _ , iwing + leftno + i , xyz call setbox 60.0, 0.0, 8.0, 60.0, 2.0, 16.0 call oneColorCube clr call glPopMatrix call glPushMatrix call child -20.0, 20.0, 40.0 - 50.0 * i _ , iwing + rightno + i, xyz call setbox -60.0, 0.0, 8.0, 60.0, 2.0, 16.0 call oneColorCube clr call glPopMatrix Next i call glPopMatrix end sub
[bluaGL] ''wrapper around openGL ''for creating mesh's dim pntx( 256 ) , pnty( 256 ) , pntz( 256 ) ''for bounding box for mesh's dim box( 5 ) ''for joint's dim sk( 64 , 2 ) ''for vertor3d output global v3d.x,v3d.y,v3d.z ''for camera global camera.x , camera.y , camera.z , camera.pan ''for light and material struct d4d _ , a as double _ , b as double _ , c as double _ , d as double
return
sub camera.set x , y , z , pan ''set camera position and angle camera.x = x camera.y = y camera.z = z camera.pan = pan end sub
sub camera.move dx , dy , dz , dpan ''change camera positon and angle call rotate dx , dz , camera.pan camera.x = camera.x + dx camera.y = camera.y + dy camera.z = camera.z + dz camera.pan = ( camera.pan + pan ) mod 360 end sub
sub camera.use ''use camera position and angle call glLoadIdentity call glRotate 0-camera.pan , 0,1,0 call glTranslate 0-camera.x , 0-camera.y , 0-camera.z end sub
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
function rainbow( x ) ''create a colorObject from a rainbow r = sin( rad( x ) ) * 127 + 128 g = sin( rad( x - 120 ) ) * 127 + 128 b = sin( rad( x + 120 ) ) * 127 + 128 rainbow = rgba( r , g , b , 255 ) end function
function rgba( r , g , b , a ) ''create colorObject r = r and 255 g = g and 255 b = b and 255 a = a and 255 rgba = r + g * 256 + b * 256 ^ 2 + a * 256 ^ 3 end function
function mix( kl1 , f , kl2 ) ''mix 2 colorObject's r1 = int( kl1 ) and 255 g1 = int( kl1 / 256 ) and 255 b1 = int( kl1 / 256 ^ 2 ) and 255 a1 = int( kl1 / 256 ^ 3 ) and 255 r2 = int( kl2 ) and 255 g2 = int( kl2 / 256 ) and 255 b2 = int( kl2 / 256 ^ 2 ) and 255 a2 = int( kl2 / 256 ^ 3 ) and 255 r = r1 + ( r2 - r1 ) * f g = g1 + ( g2 - g1 ) * f b = b1 + ( b2 - b1 ) * f a = a1 + ( a2 - a1 ) * f mix = rgba( r , g , b , a ) end function
sub setColor clr r = ( int( clr ) and 255 ) / 256 g = ( int( clr / 256 ) and 255 ) / 256 b = ( int( clr / 256 ^ 2 ) and 255 ) / 256 a = ( int( clr / 256 ^ 3 ) and 255 ) / 256 call glColor r , g , b , a end sub
'' vector math
function v3d.lenght( x , y , z ) v3d.lenght = sqr( x ^ 2 + y ^ 2 + z ^ 2 ) end function
sub v3d.cross x1 , y1 , z1 , x2 , y2 , z2 ''cross product v3d.x = y1 * z2 - y2 * z1 v3d.y = z1 * x2 - z2 * x1 v3d.z = x1 * y2 - x2 * y1 end sub
sub v3d.add x1,y1,z1 , x2,y2,z2 v3d.x = x1 + x2 v3d.y = y1 + y2 v3d.z = z1 + z2 end sub
sub v3d.sub x1,y1,z1 , x2,y2,z2 v3d.x = x1 - x2 v3d.y = y1 - y2 v3d.z = z1 - z2 end sub
sub v3d.div x1,y1,z1 , d v3d.x = x1 / d v3d.y = y1 / d v3d.z = z1 / d end sub
sub v3d.mul x1,y1,z1 , d v3d.x = x1 * d v3d.y = y1 * d v3d.z = z1 * d end sub
sub v3d.normalize x , y , z q = v3d.lenght( x , y , z ) + 1e-9 call v3d.div x , y , z , q end sub
''3d engine
sub child x , y , z , lim , ax ''create a joint of a avatar if lim < 0 or lim > 64 then exit sub select case ax case xyz call glTranslate x , y , z call glRotate sk(lim,0) , 1,0,0 call glRotate sk(lim,1) , 0,1,0 call glRotate sk(lim,2) , 0,0,1 case xzy call glTranslate x , y , z call glRotate sk(lim,0) , 1,0,0 call glRotate sk(lim,2) , 0,0,1 call glRotate sk(lim,1) , 0,1,0 case yxz call glTranslate x , y , z call glRotate sk(lim,1) , 0,1,0 call glRotate sk(lim,0) , 1,0,0 call glRotate sk(lim,2) , 0,0,1 case yzx call glTranslate x , y , z call glRotate sk(lim,1) , 0,1,0 call glRotate sk(lim,2) , 0,0,1 call glRotate sk(lim,0) , 1,0,0 case zxy call glTranslate x , y , z call glRotate sk(lim,2) , 0,0,1 call glRotate sk(lim,0) , 1,0,0 call glRotate sk(lim,1) , 0,1,0 case zyx call glTranslate x , y , z call glRotate sk(lim,2) , 0,0,1 call glRotate sk(lim,1) , 0,1,0 call glRotate sk(lim,0) , 1,0,0 case else end select end sub
sub skelet no , x , y , z ''set joint angle's of a avatar if no < 0 or no > 64 then exit sub sk( no , 0 ) = x sk( no , 1 ) = y sk( no , 2 ) = z end sub
function pend( f , a ) ''for smooth animation's pend = sin( rad( f ) ) * a end function
function rad( x ) ''from degrees to radians rad = x * pi / 180 end function
function rad2( x , sides ) rad2 = x * pi * 2 / sides end function
function sgn( x ) uit = 0 if x < 0 then uit = -1 if x > 0 then uit = 1 sgn = uit end function
''shapes
sub setbox mx , my , mz , dx , dy , dz ''set bodinging box coordinates ''alway set this before drawing mesh's box( 0 ) = mx box( 1 ) = my box( 2 ) = mz box( 3 ) = dx box( 4 ) = dy box( 5 ) = dz end sub
sub isoca no , kl1 , kl2 call point 0 , 1,0,0 call point 1 , 0,1,0 call point 2 , 0,0,1 call point 3 , -1,0,0 call point 4 , 0,-1,0 call point 5 , 0,0,-1 call glPushMatrix call glTranslate box(0) , box(1) , box(2) call glScale box(3) , box(4) , box(5) call geo no , 0 , 1 , 2 , kl1 , kl2 call geo no , 0 , 1 , 5 , kl2 , kl1 call geo no , 0 , 4 , 2 , kl2 , kl1 call geo no , 0 , 4 , 5 , kl1 , kl2 call geo no , 3 , 1 , 2 , kl2 , kl1 call geo no , 3 , 1 , 5 , kl1 , kl2 call geo no , 3 , 4 , 2 , kl1 , kl2 call geo no , 3 , 4 , 5 , kl2 , kl1 call glPopMatrix end sub
sub geo no , p1 , p2 , p3 , kl1 , kl2 if no < 1 then call tri p1 , p2 , p3 , kl1 else p12 = 255 - no * 3 p13 = 255 - no * 3 - 1 p23 = 255 - no * 3 - 2 x1 = pntx( p1 ) y1 = pnty( p1 ) z1 = pntz( p1 ) x2 = pntx( p2 ) y2 = pnty( p2 ) z2 = pntz( p2 ) x3 = pntx( p3 ) y3 = pnty( p3 ) z3 = pntz( p3 ) call v3d.add x1,y1,z1 , x2,y2,z2 call v3d.normalize v3d.x,v3d.y,v3d.z call point p12 , v3d.x , v3d.y , v3d.z call v3d.add x1,y1,z1 , x3,y3,z3 call v3d.normalize v3d.x,v3d.y,v3d.z call point p13 , v3d.x , v3d.y , v3d.z call v3d.add x2,y2,z2 , x3,y3,z3 call v3d.normalize v3d.x,v3d.y,v3d.z call point p23 , v3d.x , v3d.y , v3d.z call geo no - 1 , p1 , p12 , p13 , kl1 , kl2 call geo no - 1 , p2 , p23 , p12 , kl1 , kl2 call geo no - 1 , p3 , p13 , p23 , kl1 , kl2 call geo no - 1 , p12 , p23 , p13 , kl2 , kl1 end if end sub
sub oneColorCube cleftno ''draw a cube mesh whit i color shaded a = mix( cleftno , .6 , black ) b = mix( cleftno , .3 , black ) call cube b,b,cleftno,cleftno,a,a end sub
sub colorCube ''draw a cube mesh whit fixed color's on screen call cube red,cyan , green,magenta , blue,yellow end sub
sub cube left , right , front , back , down , up ''draw a cube mesh on screen
''first fil swarm whit points call point 0 , -1 , -1 , -1 call point 1 , -1 , -1 , 1 call point 2 , -1 , 1 , -1 call point 3 , -1 , 1 , 1 call point 4 , 1 , -1 , -1 call point 5 , 1 , -1 , 1 call point 6 , 1 , 1 , -1 call point 7 , 1 , 1 , 1
''then use points in swarm to draw quads call glPushMatrix call glTranslate box(0) , box(1) , box(2) call glScale box(3) , box(4) , box(5) call quad 0 , 1 , 3 , 2 , left call quad 7 , 6 , 4 , 5 , right call quad 0 , 2 , 6 , 4 , down call quad 7 , 5 , 1 , 3 , up call quad 0 , 1 , 5 , 4 , front call quad 7 , 6 , 2 , 3 , back call glPopMatrix end sub
sub sphere a , b , da , db , kl1 , kl2 ''draw a sphere mesh on screen ''a = horizontal sides ''b = vertical sides ''da , db = superellipsoid [ 1 , 1 = sphere ] call sphere.half a , b , b , da , db , kl1 , kl2 end sub
sub sphere.half a , b , t , da , db , kl1 , kl2 ''draw a part of a sphere mesh on screen ''a = horizontal sides ''b = vertical sides ''da , db = superellipsoid [ 1 , 1 = sphere ] ''t = height sides if a < 4 then a = 4 if a > 64 then a = 64 if b < 4 then b = 4 if b > 64 then b = 64 call glPushMatrix call glTranslate box(0) , box(1) , box(2) call glScale box(3) , box(4) , box(5) for i = 0-pi to pi step pi*2/a i2 = i + pi*2/a for j = 0-pi / 2 to t/b*pi step pi*2/b j2 = j + pi*2/b
x = sin( i ) * cos( j ) y = sin( j ) z = cos( i ) * cos( j ) call point 0 _ , abs( x ) ^ da * sgn( x ) _ , abs( y ) ^ db * sgn( y ) _ , abs( z ) ^ da * sgn( z )
x = sin( i2 ) * cos( j ) y = sin( j ) z = cos( i2 ) * cos( j ) call point 1 _ , abs( x ) ^ da * sgn( x ) _ , abs( y ) ^ db * sgn( y ) _ , abs( z ) ^ da * sgn( z )
x = sin( i2 ) * cos( j2 ) y = sin( j2 ) z = cos( i2 ) * cos( j2 ) call point 2 _ , abs( x ) ^ da * sgn( x ) _ , abs( y ) ^ db * sgn( y ) _ , abs( z ) ^ da * sgn( z )
x = sin( i ) * cos( j2 ) y = sin( j2 ) z = cos( i ) * cos( j2 ) call point 3 _ , abs( x ) ^ da * sgn( x ) _ , abs( y ) ^ db * sgn( y ) _ , abs( z ) ^ da * sgn( z )
if ( int(i*a/pi/2) + int(j*b/pi/2) ) and 1 then call quad 0 , 1 , 2 , 3 , kl1 else call quad 0 , 1 , 2 , 3 , kl2 end if
next j next i call glPopMatrix end sub
sub torus a , b , kl1 , kl2 ''draw a donut mesh on screen ''a , b = sides if a < 4 then a = 4 if a > 64 then a = 643 if b < 4 then b = 4 if b > 64 then b = 64 mx = box(0) my = box(1) mz = box(2) dx = box(3) dy = box(4) dz = box(5) for i = 0-pi to pi step pi*2/a i2 = i + pi*2/a for j = 0-pi to pi step pi*2/b j2 = j + pi*2/a call point 0 _ , mx + ( dx + dy * cos( i ) ) * cos( j ) _ , my + ( dx + dy * cos( i ) ) * sin( j ) _ , mz + sin( i ) * dz call point 1 _ , mx + ( dx + dy * cos( i ) ) * cos( j2 ) _ , my + ( dx + dy * cos( i ) ) * sin( j2 ) _ , mz + sin( i ) * dz call point 2 _ , mx + ( dx + dy * cos( i2 ) ) * cos( j2 ) _ , my + ( dx + dy * cos( i2 ) ) * sin( j2 ) _ , mz + sin( i2 ) * dz call point 3 _ , mx + ( dx + dy * cos( i2 ) ) * cos( j ) _ , my + ( dx + dy * cos( i2 ) ) * sin( j ) _ , mz + sin( i2 ) * dz
if ( int(i*a/pi/2) + int(j*b/pi/2) ) and 1 then call quad 0 , 1 , 2 , 3 , kl1 else call quad 0 , 1 , 2 , 3 , kl2 end if
next j next i end sub
sub banana a , b , kl1 , kl2 ''draw a 'banana' mesh on screen ''a , b = sides if a < 4 then a = 4 if a > 64 then a = 643 if b < 4 then b = 4 if b > 64 then b = 64 mx = box(0) my = box(1) mz = box(2) dx = box(3) dy = box(4) dz = box(5) for i = 0-pi to pi-pi*2/a step pi*2/a i2 = i + pi*2/a for j = 0-pi/2 to pi/2-pi/a step pi/b j2 = j + pi/b call point 0 _ , mx + ( dx + dy * cos( i ) * cos( j ) ) _ * cos( j ) _ , my + ( dx + dy * cos( i ) * cos( j ) ) _ * sin( j ) _ , mz + sin( i ) * dz * cos( j ) call point 1 _ , mx + ( dx + dy * cos( i ) * cos( j2 ) ) _ * cos( j2 ) _ , my + ( dx + dy * cos( i ) * cos( j2 ) ) _ * sin( j2 ) _ , mz + sin( i ) * dz * cos( j2 ) call point 2 _ , mx + ( dx + dy * cos( i2 ) * cos( j2 ) ) _ * cos( j2 ) _ , my + ( dx + dy * cos( i2 ) * cos( j2 ) ) _ * sin( j2 ) _ , mz + sin( i2 ) * dz * cos( j2 ) call point 3 _ , mx + ( dx + dy * cos( i2 ) * cos( j ) ) _ * cos( j ) _ , my + ( dx + dy * cos( i2 ) * cos( j ) ) _ * sin( j ) _ , mz + sin( i2 ) * dz * cos( j )
if ( int(i*a/pi/2) + int(j*b/pi/2) ) and 1 then call quad 0 , 1 , 2 , 3 , kl1 else call quad 0 , 1 , 2 , 3 , kl2 end if
next j next i end sub
sub cilinder sides , dx , dz , top , bottom , kl1 , kl2 ''draw a cilinder mesh on screen ''dx , dz = diam at top : so you can make cone's ''top , bottom = iscapped if sides < 4 then sides = 4 if sides > 64 then sides = 64 for f = 0 to sides + 2 call point f _ , box(0) + sin( f * pi * 2 / sides ) * box(3) _ , box(1) - box(4) _ , box(2) + cos( f * pi * 2 / sides ) * box(5) call point f + sides + 1 _ , box(0) + sin( f * pi * 2 / sides ) * dx _ , box(1) + box(4) _ , box(2) + cos( f * pi * 2 / sides ) * dz next f for f = 0 to sides + 1 if f and 1 then call quad f , f + 1 , f + 2 + sides _ , f + 1 + sides , kl1 else call quad f , f + 1 , f + 2 + sides _ , f + 1 + sides , kl2 end if next f if top then for f = 0 to sides call point f _ , box(0) + sin( f * pi * 2 / sides ) * dx _ , box(1) + box(4) _ , box(2) + cos( f * pi * 2 / sides ) * dy next f call polygon sides , kl1 end if if bottom then for f = 0 to sides call point f _ , box(0) - sin( f * pi * 2 / sides ) * box(3) _ , box(1) - box(4) _ , box(2) + cos( f * pi * 2 / sides ) * box(5) next f call polygon sides , kl2 end if end sub
sub cube.half kl1 , kl2 ''draw a half cube mesh on screen call point 0 , box(0) + box(3) , box(1) + box(4) , box(2) + box(5) call point 1 , box(0) + box(3) , box(1) + box(4) , box(2) - box(5) call point 2 , box(0) + box(3) , box(1) - box(4) , box(2) + box(5) call point 3 , box(0) + box(3) , box(1) - box(4) , box(2) - box(5) call point 4 , box(0) - box(3) , box(1) + box(4) , box(2) + box(5) call point 5 , box(0) - box(3) , box(1) + box(4) , box(2) - box(5) call point 6 , box(0) - box(3) , box(1) - box(4) , box(2) + box(5) call point 7 , box(0) - box(3) , box(1) - box(4) , box(2) - box(5)
call point 0 , box(0) + box(3) , box(1) - box(4) , 0 call point 8 , box(0) + box(3) , 0 , box(2) - box(5) call point 9 , 0 , box(1) + box(4) , box(2) - box(5) call point 10 , box(0) - box(3) , box(0) + box(4) , 0 call point 11 , box(0) - box(3) , 0 , box(2) + box(5) call point 12, 0 , box(1) - box(4) , box(2) + box(5)
call tri 7 , 6 , 3 , kl1 call tri 7 , 5 , 6 , kl1 call tri 7 , 3 , 5 , kl1
call quad 6 , 5 , 10 , 11 , kl2 call quad 5 , 3 , 8 , 9 , kl2 call quad 3 , 6 , 12 , 0 , kl2
call tri 6 , 12 , 11 , kl1 call tri 3 , 8 , 0 , kl1 call tri 5 , 9 , 10 , kl1 end sub
''primativ's wrapper
sub point no , x , y , z ''set a point in the swarm ''for creating mesh's if no < 0 or no > 256 then exit sub pntx( no ) = x pnty( no ) = y pntz( no ) = z end sub
sub points x , y , z , size , kl ''draw a point on screen call glPointSize size call glBegin GL.POINTS call setColor kl call glVertex x , y , z call glEnd end sub
sub lines x1,y1,z1 , x2,y2,z2 , w , style , kl ''draw a line on screen ''w = width ''style = 16 bits : 2 ^ 16 - 1 = solid call glLineWidth w call glEnable GL.LINE.STIPPLE call glLineStipple style call glBegin GL.LINES call setColor kl call glVertex x1 , y1 , z1 call glVertex x2 , y2 , z2 call glEnd end sub
sub line.strip n , w , style , kl ''draw a set of lines connected to eats other ''n = max number of point filled ''w = width ''style = 16 bits : 2 ^ 16 - 1 = solid call glLineWidth w call glEnable GL.LINE.STIPPLE call glLineStipple style call glBegin GL.LINE.STRIP call setColor kl for i = 0 to n call glVertex pntx(i) , pnty(i) , pntz(i) next i call glEnd end sub
sub line.loop n , w , style , kl ''draw a set of lines last linked whit first ''n = max number of point filled ''w = width ''style = 16 bits : 2 ^ 16 - 1 = solid call glLineWidth w call glEnable GL.LINE.STIPPLE call glLineStipple style call glBegin GL.LINE.LOOP call setColor kl for i = 0 to n call glVertex pntx(i) , pnty(i) , pntz(i) next i call glEnd end sub
sub tri p1 , p2 , p3 , kl ''draw a triangle from point's in swarm if p1 < 0 or p1 > 256 then exit sub if p2 < 0 or p2 > 256 then exit sub if p3 < 0 or p3 > 256 then exit sub x1 = pntx( p1 ) y1 = pnty( p1 ) z1 = pntz( p1 ) x2 = pntx( p2 ) y2 = pnty( p2 ) z2 = pntz( p2 ) x3 = pntx( p3 ) y3 = pnty( p3 ) z3 = pntz( p3 ) call v3d.cross x2-x1 , y2-y1 , z2-z1 , x3-x1 , y3-y1 , z3-z1 call glBegin GL.TRIANGLES call setColor kl call glNormal v3d.x , v3d.y , v3d.z call glVertex x1 , y1 , z1 call glVertex x2 , y2 , z2 call glVertex x3 , y3 , z3 call glEnd end sub
sub quad p1 , p2 , p3 , p4 , kl ''draw a quadangle from points in the swarm if p1 < 0 or p1 > 256 then exit sub if p2 < 0 or p2 > 256 then exit sub if p3 < 0 or p3 > 256 then exit sub if p4 < 0 or p4 > 256 then exit sub x1 = pntx( p1 ) y1 = pnty( p1 ) z1 = pntz( p1 ) x2 = pntx( p2 ) y2 = pnty( p2 ) z2 = pntz( p2 ) x3 = pntx( p3 ) y3 = pnty( p3 ) z3 = pntz( p3 ) x4 = pntx( p4 ) y4 = pnty( p4 ) z4 = pntz( p4 ) call v3d.cross x2-x1 , y2-y1 , z2-z1 , x3-x1 , y3-y1 , z3-z1 call glBegin GL.QUADS call setColor kl call glNormal v3d.x , v3d.y , v3d.z call glVertex x1 , y1 , z1 call glVertex x2 , y2 , z2 call glVertex x3 , y3 , z3 call glVertex x4 , y4 , z4 call glEnd end sub
sub triangle.fan n , kl ''draw a triangle fan from point's in swarm ''n = max number of point filled ''i m not sure about this if n < 2 or n > 256 then exit sub x1 = pntx( 0 ) y1 = pnty( 0 ) z1 = pntz( 0 ) x2 = pntx( 1 ) y2 = pnty( 1 ) z2 = pntz( 1 ) x3 = pntx( 2 ) y3 = pnty( 2 ) z3 = pntz( 2 ) call v3d.cross x2-x1 , y2-y1 , z2-z1 , x3-x1 , y3-y1 , z3-z1 call glBegin GL.TRANGLE.FAN call setColor kl call glNormal v3d.x , v3d.y , v3d.z for i = 0 to n call glVertex pntx( i ) , pnty( i ) , pntz( i ) next i call glEnd end sub
sub triangle.strip n , kl ''draw a triangle strip from point's in swarm ''n = max number of point filled ''i m not sure about this if n < 2 or n > 256 then exit sub x1 = pntx( 0 ) y1 = pnty( 0 ) z1 = pntz( 0 ) x2 = pntx( 1 ) y2 = pnty( 1 ) z2 = pntz( 1 ) x3 = pntx( 2 ) y3 = pnty( 2 ) z3 = pntz( 2 ) call v3d.cross x2-x1 , y2-y1 , z2-z1 , x3-x1 , y3-y1 , z3-z1 call glBegin GL.TRANGLE.STRIP call setColor kl call glNormal v3d.x , v3d.y , v3d.z for i = 0 to n call glVertex pntx( i ) , pnty( i ) , pntz( i ) next i call glEnd end sub
sub quad.strip n , kl ''draw a quad strip from point's in swarm ''max number of point filled ''i m not sure about this if n < 3 or n > 256 then exit sub x1 = pntx( 0 ) y1 = pnty( 0 ) z1 = pntz( 0 ) x2 = pntx( 1 ) y2 = pnty( 1 ) z2 = pntz( 1 ) x3 = pntx( 2 ) y3 = pnty( 2 ) z3 = pntz( 2 ) call v3d.cross x2-x1 , y2-y1 , z2-z1 , x3-x1 , y3-y1 , z3-z1 call glBegin GL.QUAD.STRIP call setColor kl call glNormal v3d.x , v3d.y , v3d.z for i = 0 to n call glVertex pntx( i ) , pnty( i ) , pntz( i ) next i call glEnd end sub
sub polygon n , kl ''draw a polygon whit n sides from point's in swarm ''n max number of point filled ''this is expecting al point's in 1 plane if n < 2 or n > 256 then exit sub x1 = pntx( 0 ) y1 = pnty( 0 ) z1 = pntz( 0 ) x2 = pntx( 1 ) y2 = pnty( 1 ) z2 = pntz( 1 ) x3 = pntx( 2 ) y3 = pnty( 2 ) z3 = pntz( 2 ) call v3d.cross x2-x1 , y2-y1 , z2-z1 , x3-x1 , y3-y1 , z3-z1 call glBegin GL.POLYGON call setColor kl call glNormal v3d.x , v3d.y , v3d.z for i = 0 to n call glVertex pntx( i ) , pnty( i ) , pntz( i ) next i call glEnd end sub
[openGL] ''openGL stuf : wil be extended ''i wanted to put the openGL const's here ''but that didn't work return
sub glColor r , g , b , a calldll #gl , "glColor4d" _ , r as double _ , g as double _ , b as double _ , a as double _ , ret as long end sub
sub glClearColor r , g , b , a calldll #gl , "glClearColor" _ , r as double _ , g as double _ , b as double _ , a as double _ , ret as long end sub
sub glShadeModel i calldll #gl , "glShadeModel" _ , i as long _ , ret as long end sub
sub glMatrixMode i calldll #gl , "glMatrixMode" _ , i as long _ , ret as long end sub
sub glClear code ''clear the openGL screen calldll #gl , "glClear" _ , code as long _ , ret as long end sub
sub glPointSize i ''set size of point's calldll #gl , "glPointSize" _ , i as double _ , ret as long end sub
sub glLineWidth i ''set width of line calldll #gl , "glLineWidth" _ , i as double _ , ret as long end sub
sub glLineStipple style ''set style of line calldll #gl , "glLineStipple" _ , style as short _ , ret as long end sub
sub glLoadIdentity ''set drawingmatrix to standert calldll #gl , "glLoadIdentity" _ , ret as long end sub
sub glPushMatrix ''to new drawingmatrix calldll #gl , "glPushMatrix" _ , ret as long end sub
sub glPopMatrix ''to old drawingmatrix calldll #gl , "glPopMatrix" _ , ret as long end sub
sub glEnd ''end of polygon[s] calldll #gl , "glEnd" _ , ret as void end sub
sub glEnable i ''set a item calldll #gl , "glEnable" _ , i as long _ , ret as long end sub
sub glBegin i ''set polygon mode calldll #gl , "glBegin" _ , i as long _ , ret as long end sub
sub glScale x , y , z ''scale drawingmatrix calldll #gl , "glScaled" _ , x as double _ , y as double _ , z as double _ , ret as long end sub
sub glTranslate x , y , z ''move drawingmatrix calldll #gl , "glTranslated" _ , x as double _ , y as double _ , z as double _ , ret as long end sub
sub glRotate a , x , y , z ''rotate drawinmatrix calldll #gl , "glRotated" _ , a as double _ , x as double _ , y as double _ , z as double _ , ret as long end sub
sub glVertex x , y , z ''add a point to a polygon calldll #gl , "glVertex3d" _ , x as double _ , y as double _ , z as double _ , ret as long end sub
sub glNormal x , y , z ''set normal of point[s] calldll #gl , "glNormal3f" _ , x as double _ , y as double _ , z as double _ , ret as long end sub
sub openglInit struct PFD _ , Size as word _ , Version as word _ , Flags as long _ , pixelType as char[1] _ , ColorBits as char[1] _ , RedBits as char[1] _ , RedShift as char[1] _ , GreenBits as char[1] _ , GreenShift as char[1] _ , BlueBits as char[1] _ , BlueShift as char[1] _ , AlphaBits as char[1] _ , AlphaShift as char[1] _ , AccumBits as char[1] _ , AccumRedBits as char[1] _ , AccumGreenBits as char[1] _ , AccumBlueBits as char[1] _ , AccumAlphaBits as char[1] _ , DepthBits as char[1] _ , StencilBits as char[1] _ , AuxBuffers as char[1] _ , LayerType as char[1] _ , Reserved as char[1] _ , LayerMask as long _ , VisibleMask as long _ , DamageMask as long
PFD.Version.struct=1 PFD.ColorBits.struct=24 PFD.DepthBits.struct=16 PFD.Size.struct=len(PFD.struct) PFD.Flags.struct=37
calldll #user32 , "GetDC" _ , MainH as ulong , MainDC as ulong calldll #gdi32 , "ChoosePixelFormat" _ , MainDC as ulong , PFD as struct , ret as long calldll #gdi32 , "SetPixelFormat" _ , MainDC as ulong , ret as long , PFD as struct , t as long calldll #gl , "wglCreateContext" _ , MainDC as ulong , GLContext as ulong calldll #gl , "wglMakeCurrent" _ , MainDC as ulong , GLContext as ulong , ret as long call glEnable GL.DEPTH.TEST end sub
|
|