diff options
| author | Skip Montanaro <[email protected]> | 2021-02-16 20:14:16 -0600 |
|---|---|---|
| committer | Skip Montanaro <[email protected]> | 2021-02-16 20:14:16 -0600 |
| commit | c2587c76f1b416cdbecb979e54941933246bf856 (patch) | |
| tree | bb61ee9128075ce22af4eafa232f13c2e5a07896 /demo/sgi/gl_panel | |
| parent | d90761a005b24018ae237bf551515772a1de656f (diff) | |
| download | python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.tar.xz python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.zip | |
starting over
Diffstat (limited to 'demo/sgi/gl_panel')
| -rw-r--r-- | demo/sgi/gl_panel/README | 34 | ||||
| -rwxr-xr-x | demo/sgi/gl_panel/apanel/apanel.py | 90 | ||||
| -rwxr-xr-x | demo/sgi/gl_panel/flying/flying.py | 590 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/light.py | 42 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/material.py | 34 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/materials.s | 4 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/objdict.py | 6 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/objectdef.py | 234 | ||||
| -rwxr-xr-x | demo/sgi/gl_panel/nurbs/nurbs.py | 318 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/nurbs/nurbsdata.py | 90 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/twoview/block.py | 124 | ||||
| -rwxr-xr-x | demo/sgi/gl_panel/twoview/twoview.py | 634 |
12 files changed, 1100 insertions, 1100 deletions
diff --git a/demo/sgi/gl_panel/README b/demo/sgi/gl_panel/README index 889a2cf..ccf255d 100644 --- a/demo/sgi/gl_panel/README +++ b/demo/sgi/gl_panel/README @@ -1,23 +1,23 @@ This directory contains demos that use the Panel Library by NASA Ames. They only run on SGI machines and require the 'pnl' and 'gl' built-in -modules. Each subdirectory contains one demo. +modules. Each subdirectory contains one demo. -apanel A trivial user interface to the audio capabilities of - the 4D/25 (Personal IRIS). Lets you record a sample and - play it back at different volumes. Requires the 'audio' - built-in module. +apanel A trivial user interface to the audio capabilities of + the 4D/25 (Personal IRIS). Lets you record a sample and + play it back at different volumes. Requires the 'audio' + built-in module. -flying A large demonstration that can display several - differently shaped objects through space. Control - panels let you manipulate light sources, material - properties and drawing modes. +flying A large demonstration that can display several + differently shaped objects through space. Control + panels let you manipulate light sources, material + properties and drawing modes. -nurbs A demo of the capabilities of the GL 'nurbs' functions - that can display the control points. (It was intended - to let you move these as well, but there was a problem - with the mapping of mouse movements in a 3-D world.) +nurbs A demo of the capabilities of the GL 'nurbs' functions + that can display the control points. (It was intended + to let you move these as well, but there was a problem + with the mapping of mouse movements in a 3-D world.) -twoview A demo of GL's transformation primitives. Two views on - a scene are given, and the position and orientation of a - viewer in one of the views can be changed through - various buttons and dials in a control panel. +twoview A demo of GL's transformation primitives. Two views on + a scene are given, and the position and orientation of a + viewer in one of the views can be changed through + various buttons and dials in a control panel. diff --git a/demo/sgi/gl_panel/apanel/apanel.py b/demo/sgi/gl_panel/apanel/apanel.py index de9a710..a5adfdb 100755 --- a/demo/sgi/gl_panel/apanel/apanel.py +++ b/demo/sgi/gl_panel/apanel/apanel.py @@ -14,50 +14,50 @@ panel.block(1) import audio def main(): - gl.foreground() - gl.noport() - #gl.prefposition(700, 850, 950, 970) - wid = gl.winopen('audio demo') - # - panels = panel.defpanellist('apanel.s') # XXX - p = panels[0] - p.playbackbutton.back = p - p.recordbutton.back = p - p.sample = '' - # - def quit(a): - sys.exit(0) - # - p.quitbutton.downfunc = quit - # - def playback(a): - p = a.back - gain = int(255.0*p.outputgain.val) - a.val = 1.0 - a.fixact() - panel.drawpanel() - audio.setoutgain(gain) - audio.write(p.sample) - audio.setoutgain(0) - a.val = 0.0 - a.fixact() - # - p.playbackbutton.downfunc = playback - # - def record(a): - p = a.back - size = int(10.0 * 8192.0 * p.recordsize.val) - a.val = 1.0 - a.fixact() - panel.drawpanel() - audio.setoutgain(0) - p.sample = audio.read(size) - a.val = 0.0 - a.fixact() - # - p.recordbutton.downfunc = record - # - while 1: - act = panel.dopanel() + gl.foreground() + gl.noport() + #gl.prefposition(700, 850, 950, 970) + wid = gl.winopen('audio demo') + # + panels = panel.defpanellist('apanel.s') # XXX + p = panels[0] + p.playbackbutton.back = p + p.recordbutton.back = p + p.sample = '' + # + def quit(a): + sys.exit(0) + # + p.quitbutton.downfunc = quit + # + def playback(a): + p = a.back + gain = int(255.0*p.outputgain.val) + a.val = 1.0 + a.fixact() + panel.drawpanel() + audio.setoutgain(gain) + audio.write(p.sample) + audio.setoutgain(0) + a.val = 0.0 + a.fixact() + # + p.playbackbutton.downfunc = playback + # + def record(a): + p = a.back + size = int(10.0 * 8192.0 * p.recordsize.val) + a.val = 1.0 + a.fixact() + panel.drawpanel() + audio.setoutgain(0) + p.sample = audio.read(size) + a.val = 0.0 + a.fixact() + # + p.recordbutton.downfunc = record + # + while 1: + act = panel.dopanel() main() diff --git a/demo/sgi/gl_panel/flying/flying.py b/demo/sgi/gl_panel/flying/flying.py index e6fd823..b51f466 100755 --- a/demo/sgi/gl_panel/flying/flying.py +++ b/demo/sgi/gl_panel/flying/flying.py @@ -7,369 +7,369 @@ import DEVICE, time import objectdef, light, panel, material def fixmatact (p) : - p.diffR.fixact () - p.diffG.fixact () - p.diffB.fixact () - p.specR.fixact () - p.specG.fixact () - p.specB.fixact () - p.shine.fixact () + p.diffR.fixact () + p.diffG.fixact () + p.diffB.fixact () + p.specR.fixact () + p.specG.fixact () + p.specB.fixact () + p.shine.fixact () def fixlichtact (p) : - p.R.fixact () - p.G.fixact () - p.B.fixact () - p.X.fixact () - p.Y.fixact () - p.Z.fixact () - p.local.fixact () + p.R.fixact () + p.G.fixact () + p.B.fixact () + p.X.fixact () + p.Y.fixact () + p.Z.fixact () + p.local.fixact () def cbsetlight (a) : - p = a.back - setlight (p, a.label) + p = a.back + setlight (p, a.label) def cbsetmaterial (a) : - p = a.back - setmaterial (p, a.label) + p = a.back + setmaterial (p, a.label) mater = [0] licht = [0] def setmaterial (p, mname) : - # - mater [0:1] = [material.materdict [mname]] - # - p.diffR.val = mater [0][1] - p.diffG.val = mater [0][2] - p.diffB.val = mater [0][3] - # - p.specR.val = mater [0][5] - p.specG.val = mater [0][6] - p.specB.val = mater [0][7] - # - p.shine.val = mater [0][9] / 128.0 - fixmatact (p) + # + mater [0:1] = [material.materdict [mname]] + # + p.diffR.val = mater [0][1] + p.diffG.val = mater [0][2] + p.diffB.val = mater [0][3] + # + p.specR.val = mater [0][5] + p.specG.val = mater [0][6] + p.specB.val = mater [0][7] + # + p.shine.val = mater [0][9] / 128.0 + fixmatact (p) def setlight (p, mname) : - # - licht [0:1] = [material.lichtdict [mname]] - # - p.R.val = licht [0][1] - p.G.val = licht [0][2] - p.B.val = licht [0][3] - # - p.X.val = (licht [0][5] + 10.0) / 20.0 - p.Y.val = (licht [0][6] + 10.0) / 20.0 - p.Z.val = (licht [0][7] + 10.0) / 20.0 - # - p.local.val = licht [0][8] - # - fixlichtact (p) + # + licht [0:1] = [material.lichtdict [mname]] + # + p.R.val = licht [0][1] + p.G.val = licht [0][2] + p.B.val = licht [0][3] + # + p.X.val = (licht [0][5] + 10.0) / 20.0 + p.Y.val = (licht [0][6] + 10.0) / 20.0 + p.Z.val = (licht [0][7] + 10.0) / 20.0 + # + p.local.val = licht [0][8] + # + fixlichtact (p) def cbmaterial (a) : - # - if mater[0] = 0 : return - # - p = a.back - mater [0][5:8] = [p.diffR.val, p.diffG.val, p.diffB.val] - mater [0][1:4] = [p.specR.val, p.specG.val, p.specB.val] - mater [0][9:10] = [128.0 * p.shine.val] - light.bindlight (0) + # + if mater[0] = 0 : return + # + p = a.back + mater [0][5:8] = [p.diffR.val, p.diffG.val, p.diffB.val] + mater [0][1:4] = [p.specR.val, p.specG.val, p.specB.val] + mater [0][9:10] = [128.0 * p.shine.val] + light.bindlight (0) def cblight (a) : - # - if licht[0] = 0 : return - # - p = a.back - licht [0][1:4] = [p.R.val, p.G.val, p.B.val] - licht [0][5:8] = [20.0 * p.X.val - 10.0, 20.0 * p.Y.val - 10.0, 20.0 * p.Z.val - 10.0] - if p.local.val = 0.0 : - licht [0][8:9] = [0.0] - else: - licht [0][8:9] = [1.0] - # - light.bindlight (0) + # + if licht[0] = 0 : return + # + p = a.back + licht [0][1:4] = [p.R.val, p.G.val, p.B.val] + licht [0][5:8] = [20.0 * p.X.val - 10.0, 20.0 * p.Y.val - 10.0, 20.0 * p.Z.val - 10.0] + if p.local.val = 0.0 : + licht [0][8:9] = [0.0] + else: + licht [0][8:9] = [1.0] + # + light.bindlight (0) # # initgl : initialize window, pipeline, light, viewing # def initgl () : - # - # init window - # - foreground () - keepaspect (1, 1) - prefposition (100, 500, 100, 500) - w = winopen ('flying objects') - keepaspect (1, 1) - winconstraints () - # - # configure pipline - # - doublebuffer () - shademodel (GOURAUD) - zbuffer (1) - RGBmode () - gconfig () - # - # init lighting - # - light.bindlight (1) - # - # set viewing - # - lookat (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0) - # + # + # init window + # + foreground () + keepaspect (1, 1) + prefposition (100, 500, 100, 500) + w = winopen ('flying objects') + keepaspect (1, 1) + winconstraints () + # + # configure pipline + # + doublebuffer () + shademodel (GOURAUD) + zbuffer (1) + RGBmode () + gconfig () + # + # init lighting + # + light.bindlight (1) + # + # set viewing + # + lookat (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0) + # # # drawit : draws the object with the given attributes. # # rfac : the rotation factor. -# mat : the material identification -# attr : a list of attributes : +# mat : the material identification +# attr : a list of attributes : # -# [[rotate vector ], [tranlate vector], [scale vector]] -# i.e : -# [[rX, rY, rZ], [tX, tY, tZ], [sX, sY, sZ]] +# [[rotate vector ], [tranlate vector], [scale vector]] +# i.e : +# [[rX, rY, rZ], [tX, tY, tZ], [sX, sY, sZ]] # def drawit(object, rfac, attr, mat) : - pushmatrix() - rot (attr[0][0] * float (rfac), 'X') - rot (attr[0][1] * float (rfac), 'Y') - rot (attr[0][2] * float (rfac), 'Z') - translate(attr[1][0], attr[1][1], attr[1][2]) - scale(attr[2][0], attr[2][1], attr[2][2]) - lmbind(MATERIAL, mat) - objectdef.drawobject(object) - popmatrix() + pushmatrix() + rot (attr[0][0] * float (rfac), 'X') + rot (attr[0][1] * float (rfac), 'Y') + rot (attr[0][2] * float (rfac), 'Z') + translate(attr[1][0], attr[1][1], attr[1][2]) + scale(attr[2][0], attr[2][1], attr[2][2]) + lmbind(MATERIAL, mat) + objectdef.drawobject(object) + popmatrix() def callbacksphere (a) : - putDict (objects, 'sphere', int (a.val)) + putDict (objects, 'sphere', int (a.val)) def callbackcylinder (a) : - putDict (objects, 'cylinder', int (a.val)) + putDict (objects, 'cylinder', int (a.val)) def callbackcube (a) : - putDict (objects, 'cube', int (a.val)) + putDict (objects, 'cube', int (a.val)) def callbackicecream (a) : - putDict (objects, 'icecream', int (a.val)) + putDict (objects, 'icecream', int (a.val)) def callbackdisk (a) : - putDict (objects, 'disk', int (a.val)) + putDict (objects, 'disk', int (a.val)) def callbackdiamond (a) : - putDict (objects, 'diamond', int (a.val)) + putDict (objects, 'diamond', int (a.val)) def callbackglass (a) : - putDict (objects, 'glass', int (a.val)) + putDict (objects, 'glass', int (a.val)) def callbackpyramid (a) : - putDict (objects, 'pyramid', int (a.val)) + putDict (objects, 'pyramid', int (a.val)) def callbacktable (a) : - putDict (objects, 'table', int (a.val)) + putDict (objects, 'table', int (a.val)) def callbackflat (a) : - shademodel(FLAT) + shademodel(FLAT) def callbackgouraud (a) : - shademodel(GOURAUD) + shademodel(GOURAUD) def callbackwire (a) : - objectdef.putFunc ([bgnclosedline, endclosedline]) + objectdef.putFunc ([bgnclosedline, endclosedline]) def callbackfilled (a) : - objectdef.putFunc ([bgnpolygon, endpolygon]) + objectdef.putFunc ([bgnpolygon, endpolygon]) def callbackquit (a) : - import sys - sys.exit (-1) + import sys + sys.exit (-1) def allObjects(p, val) : - p.sphere.val = val - p.sphere.fixact () - p.cube.val = val - p.cube.fixact () - p.cylinder.val = val - p.cylinder.fixact () - p.pyramid.val = val - p.pyramid.fixact () - p.disk.val = val - p.disk.fixact () - p.diamond.val = val - p.diamond.fixact () - p.icecream.val = val - p.icecream.fixact () - p.table.val = val - p.table.fixact () - p.fixpanel() - + p.sphere.val = val + p.sphere.fixact () + p.cube.val = val + p.cube.fixact () + p.cylinder.val = val + p.cylinder.fixact () + p.pyramid.val = val + p.pyramid.fixact () + p.disk.val = val + p.disk.fixact () + p.diamond.val = val + p.diamond.fixact () + p.icecream.val = val + p.icecream.fixact () + p.table.val = val + p.table.fixact () + p.fixpanel() + def callbackshowall (a) : - #print objects - for key in objects.keys () : - #print key - putDict (objects, key, 1) - allObjects (a.back, 1.0) + #print objects + for key in objects.keys () : + #print key + putDict (objects, key, 1) + allObjects (a.back, 1.0) def callbackshownone (a) : - for key in objects.keys () : - putDict (objects, key, 0) - allObjects (a.back, 0.0) + for key in objects.keys () : + putDict (objects, key, 0) + allObjects (a.back, 0.0) # # main : makeobjects, initialze graphics, and loop continuously. # def main () : - # - # iter keeps track of the iterations. It is used as the - # (x, y, z) rotation increments to which the objects rotate. - iter = 0 - # - # make the objects. the objects are put in the odict dictionary - # - od = objectdef.makeobjects () - # - # initialize gl - # - initgl () - # - # initialize time and iterations per second - # - time0 = time.time () # epoch-time of previous second - fps = 0 # frames per second - # - # initialize panels - # - panel.needredraw() - panels = panel.defpanellist('flying.s') #XXX - p = panels[0] - p.sphere.upfunc = callbacksphere - p.cylinder.upfunc = callbackcylinder - p.cube.upfunc = callbackcube - p.icecream.upfunc = callbackicecream - p.disk.upfunc = callbackdisk - p.diamond.upfunc = callbackdiamond - # NOT YET IMPLEMENTED p.glass.upfunc = callbackglass - p.pyramid.upfunc = callbackpyramid - p.table.upfunc = callbacktable - p.wire.upfunc = callbackwire - p.filled.upfunc = callbackfilled - p.flat.upfunc = callbackflat - p.gouraud.upfunc = callbackgouraud - p.quit.upfunc = callbackquit - p.showall.upfunc = callbackshowall - p.shownone.upfunc = callbackshownone - p.showall.back = p - p.shownone.back = p - # - qanels = panel.defpanellist('freeze.s') #XXX - q = qanels[0] - # - ranels = panel.defpanellist('materials.s') #XXX - r = ranels[0] - r.m9.upfunc = cbsetmaterial - r.m8.upfunc = cbsetmaterial - r.m7.upfunc = cbsetmaterial - r.m6.upfunc = cbsetmaterial - r.m5.upfunc = cbsetmaterial - r.m4.upfunc = cbsetmaterial - r.m3.upfunc = cbsetmaterial - r.m2.upfunc = cbsetmaterial - r.m1.upfunc = cbsetmaterial - r.specR.activefunc = cbmaterial - r.specG.activefunc = cbmaterial - r.specB.activefunc = cbmaterial - r.diffR.activefunc = cbmaterial - r.diffG.activefunc = cbmaterial - r.diffB.activefunc = cbmaterial - r.shine.activefunc = cbmaterial - r.m9.back = r - r.m8.back = r - r.m7.back = r - r.m6.back = r - r.m5.back = r - r.m4.back = r - r.m3.back = r - r.m2.back = r - r.m1.back = r - r.diffR.back = r - r.diffG.back = r - r.diffB.back = r - r.specR.back = r - r.specG.back = r - r.specB.back = r - r.shine.back = r - # - sanels = panel.defpanellist('light.s') #XXX - s = sanels[0] - s.X.back = s - s.Y.back = s - s.Z.back = s - s.R.back = s - s.G.back = s - s.B.back = s - s.light1.back = s - s.light2.back = s - s.local.back = s - s.light1.upfunc = cbsetlight - s.light2.upfunc = cbsetlight - s.R.activefunc = cblight - s.G.activefunc = cblight - s.B.activefunc = cblight - s.X.activefunc = cblight - s.Y.activefunc = cblight - s.Z.activefunc = cblight - # - while 1 : - # - act = panel.dopanel() - # - wid = panel.userredraw () - if wid : - winset (wid) - reshapeviewport() - # - # increment iter - # - if int (q.freeze.val) = 0 : - iter = iter + 1 - fps = fps + 1 - if time.time() - time0 >= 1 : - f = float(fps)/float(time.time()-time0) - q.mystrip.val = f - q.mystrip.fixact () - q.fixpanel() - time0 = time.time() - fps = 0 - # - # clear the zbuffer and make the background light blue - # - zclear() - c3i (LightBlue) - clear() - # - # for each object in the objects dictionary - # - for key in objects.keys() : - # - # if the object should be displayed - # - if getDict (objects, key, 0) = ONE : - loo = getDict (objects, key, 1) - for o in loo : - # - # get attributes and materail - # - attr = o [1] - mat = o [2] - # - # display the object - # - drawit(od[o[0]],iter,attr,mat) - # - swapbuffers() - # + # + # iter keeps track of the iterations. It is used as the + # (x, y, z) rotation increments to which the objects rotate. + iter = 0 + # + # make the objects. the objects are put in the odict dictionary + # + od = objectdef.makeobjects () + # + # initialize gl + # + initgl () + # + # initialize time and iterations per second + # + time0 = time.time () # epoch-time of previous second + fps = 0 # frames per second + # + # initialize panels + # + panel.needredraw() + panels = panel.defpanellist('flying.s') #XXX + p = panels[0] + p.sphere.upfunc = callbacksphere + p.cylinder.upfunc = callbackcylinder + p.cube.upfunc = callbackcube + p.icecream.upfunc = callbackicecream + p.disk.upfunc = callbackdisk + p.diamond.upfunc = callbackdiamond + # NOT YET IMPLEMENTED p.glass.upfunc = callbackglass + p.pyramid.upfunc = callbackpyramid + p.table.upfunc = callbacktable + p.wire.upfunc = callbackwire + p.filled.upfunc = callbackfilled + p.flat.upfunc = callbackflat + p.gouraud.upfunc = callbackgouraud + p.quit.upfunc = callbackquit + p.showall.upfunc = callbackshowall + p.shownone.upfunc = callbackshownone + p.showall.back = p + p.shownone.back = p + # + qanels = panel.defpanellist('freeze.s') #XXX + q = qanels[0] + # + ranels = panel.defpanellist('materials.s') #XXX + r = ranels[0] + r.m9.upfunc = cbsetmaterial + r.m8.upfunc = cbsetmaterial + r.m7.upfunc = cbsetmaterial + r.m6.upfunc = cbsetmaterial + r.m5.upfunc = cbsetmaterial + r.m4.upfunc = cbsetmaterial + r.m3.upfunc = cbsetmaterial + r.m2.upfunc = cbsetmaterial + r.m1.upfunc = cbsetmaterial + r.specR.activefunc = cbmaterial + r.specG.activefunc = cbmaterial + r.specB.activefunc = cbmaterial + r.diffR.activefunc = cbmaterial + r.diffG.activefunc = cbmaterial + r.diffB.activefunc = cbmaterial + r.shine.activefunc = cbmaterial + r.m9.back = r + r.m8.back = r + r.m7.back = r + r.m6.back = r + r.m5.back = r + r.m4.back = r + r.m3.back = r + r.m2.back = r + r.m1.back = r + r.diffR.back = r + r.diffG.back = r + r.diffB.back = r + r.specR.back = r + r.specG.back = r + r.specB.back = r + r.shine.back = r + # + sanels = panel.defpanellist('light.s') #XXX + s = sanels[0] + s.X.back = s + s.Y.back = s + s.Z.back = s + s.R.back = s + s.G.back = s + s.B.back = s + s.light1.back = s + s.light2.back = s + s.local.back = s + s.light1.upfunc = cbsetlight + s.light2.upfunc = cbsetlight + s.R.activefunc = cblight + s.G.activefunc = cblight + s.B.activefunc = cblight + s.X.activefunc = cblight + s.Y.activefunc = cblight + s.Z.activefunc = cblight + # + while 1 : + # + act = panel.dopanel() + # + wid = panel.userredraw () + if wid : + winset (wid) + reshapeviewport() + # + # increment iter + # + if int (q.freeze.val) = 0 : + iter = iter + 1 + fps = fps + 1 + if time.time() - time0 >= 1 : + f = float(fps)/float(time.time()-time0) + q.mystrip.val = f + q.mystrip.fixact () + q.fixpanel() + time0 = time.time() + fps = 0 + # + # clear the zbuffer and make the background light blue + # + zclear() + c3i (LightBlue) + clear() + # + # for each object in the objects dictionary + # + for key in objects.keys() : + # + # if the object should be displayed + # + if getDict (objects, key, 0) = ONE : + loo = getDict (objects, key, 1) + for o in loo : + # + # get attributes and materail + # + attr = o [1] + mat = o [2] + # + # display the object + # + drawit(od[o[0]],iter,attr,mat) + # + swapbuffers() + # main() diff --git a/demo/sgi/gl_panel/flying/light.py b/demo/sgi/gl_panel/flying/light.py index f6bf379..51803fc 100644 --- a/demo/sgi/gl_panel/flying/light.py +++ b/demo/sgi/gl_panel/flying/light.py @@ -23,24 +23,24 @@ light2 = [LCOLOR,1.0,1.0,1.0,POSITION,-10.0,10.0,5.0,0.0,LMNULL] model = [AMBIENT,0.4,0.4,0.4,LMNULL] def bindlight (bool) : - # Initializes all settings for a window. - if bool <> 0 : - mmode(MVIEWING) - perspective (900, 1.0, 1.0, 35.0) - loadmatrix(idmat) - # define materials and lights - lmdef(DEFMATERIAL, 1, m1) - lmdef(DEFMATERIAL, 2, m2) - lmdef(DEFMATERIAL, 3, m3) - lmdef(DEFMATERIAL, 4, m4) - lmdef(DEFMATERIAL, 5, m5) - lmdef(DEFMATERIAL, 6, m6) - lmdef(DEFMATERIAL, 7, m7) - lmdef(DEFMATERIAL, 8, m8) - lmdef(DEFMATERIAL, 9, m9) - lmdef(DEFLIGHT, 1, light1) - lmdef(DEFLIGHT, 2, light2) - lmdef(DEFLMODEL, 1, model) - lmbind(LIGHT0,1) - lmbind(LIGHT1,2) - lmbind(LMODEL,1) + # Initializes all settings for a window. + if bool <> 0 : + mmode(MVIEWING) + perspective (900, 1.0, 1.0, 35.0) + loadmatrix(idmat) + # define materials and lights + lmdef(DEFMATERIAL, 1, m1) + lmdef(DEFMATERIAL, 2, m2) + lmdef(DEFMATERIAL, 3, m3) + lmdef(DEFMATERIAL, 4, m4) + lmdef(DEFMATERIAL, 5, m5) + lmdef(DEFMATERIAL, 6, m6) + lmdef(DEFMATERIAL, 7, m7) + lmdef(DEFMATERIAL, 8, m8) + lmdef(DEFMATERIAL, 9, m9) + lmdef(DEFLIGHT, 1, light1) + lmdef(DEFLIGHT, 2, light2) + lmdef(DEFLMODEL, 1, model) + lmbind(LIGHT0,1) + lmbind(LIGHT1,2) + lmbind(LMODEL,1) diff --git a/demo/sgi/gl_panel/flying/material.py b/demo/sgi/gl_panel/flying/material.py index f9137ea..f091fbb 100644 --- a/demo/sgi/gl_panel/flying/material.py +++ b/demo/sgi/gl_panel/flying/material.py @@ -1,26 +1,26 @@ import light def mkmatdict () : - m = {} - m['material 1'] = light.m1 - m['material 2'] = light.m2 - m['material 3'] = light.m3 - m['material 4'] = light.m4 - m['material 5'] = light.m5 - m['material 6'] = light.m6 - m['material 7'] = light.m7 - m['material 8'] = light.m8 - m['material 9'] = light.m9 - # - return m + m = {} + m['material 1'] = light.m1 + m['material 2'] = light.m2 + m['material 3'] = light.m3 + m['material 4'] = light.m4 + m['material 5'] = light.m5 + m['material 6'] = light.m6 + m['material 7'] = light.m7 + m['material 8'] = light.m8 + m['material 9'] = light.m9 + # + return m materdict = mkmatdict () def mklichtdict () : - m = {} - m['light 1'] = light.light1 - m['light 2'] = light.light2 - # - return m + m = {} + m['light 1'] = light.light1 + m['light 2'] = light.light2 + # + return m lichtdict = mklichtdict () diff --git a/demo/sgi/gl_panel/flying/materials.s b/demo/sgi/gl_panel/flying/materials.s index ae45ca9..b505f0b 100644 --- a/demo/sgi/gl_panel/flying/materials.s +++ b/demo/sgi/gl_panel/flying/materials.s @@ -56,7 +56,7 @@ (h 0.36) (downfunc move-then-resize) ) -(pnl_radio_button (name "m4") +(pnl_radio_button (name "m4") (prop help creator:user-act-help) (label "material 4") (x 6.5) @@ -80,7 +80,7 @@ (h 0.36) (downfunc move-then-resize) ) -(pnl_radio_button (name "m1") +(pnl_radio_button (name "m1") (prop help creator:user-act-help) (label "material 1") (x 6.5) diff --git a/demo/sgi/gl_panel/flying/objdict.py b/demo/sgi/gl_panel/flying/objdict.py index a5d5371..9195093 100644 --- a/demo/sgi/gl_panel/flying/objdict.py +++ b/demo/sgi/gl_panel/flying/objdict.py @@ -23,14 +23,14 @@ objects['table'] = [ZERO, o8] # 'putDict' sets the value of entry 'key' of dictionary 'dict' def putDict(dict, key, val) : - dict[key][0] = val + dict[key][0] = val # -# 'getDict' get the contents of entry i of key 'key' +# 'getDict' get the contents of entry i of key 'key' # of dictionary 'dict' # def getDict(dict, key, i) : - return dict[key][i] + return dict[key][i] # the 'options' dictionary contains the strings of the menu items # that denote the options diff --git a/demo/sgi/gl_panel/flying/objectdef.py b/demo/sgi/gl_panel/flying/objectdef.py index 3e96113..02a9513 100644 --- a/demo/sgi/gl_panel/flying/objectdef.py +++ b/demo/sgi/gl_panel/flying/objectdef.py @@ -7,141 +7,141 @@ FUZZY = 0.00001 # first try - brute force method (ala M.Overmars...) def makespinobject (smooth,rot,n,x1,z1,nx1,nz1,x2,z2,nx2,nz2) : - object = [] - dth = 2.0 * pi / float (rot) - for i in range (0, n) : - for j in range (0, rot) : - th = dth * float (j) - # - if smooth = 1: - a1 = th - a2 =th+dth - else : - a1 = th + dth / 2.0 - a2 = th + dth / 2.0 - # - v0 = (x1[i]*sin(th),x1[i]*cos(th),z1[i]) - n0 = (nx1[i]*sin(a1),nx1[i]*cos(a1),nz1[i]) - # - v1 = (x1[i]*sin(th+dth),x1[i]*cos(th+dth),z1[i]) - n1 = (nx1[i]*sin(a2), nx1[i]*cos(a2), nz1[i]) - # - v2 = (x2[i]*sin(th+dth),x2[i]*cos(th+dth),z2[i]) - n2 = (nx2[i]*sin(a2), nx2[i]*cos(a2), nz2[i]) - # - v3 = (x2[i]*sin(th), x2[i]*cos(th), z2[i]) - n3 = (nx2[i]*sin(a1), nx2[i]*cos(a1), nz2[i]) - # - patch = ((v0,n0), (v1,n1), (v2,n2), (v3,n3)) - #patch = ((n0,v0), (n1,v1), (n2,v2), (n3,v3)) - # - if x1[i] < FUZZY : - patch = patch[1:] - # - object.append (patch) - # - return object + object = [] + dth = 2.0 * pi / float (rot) + for i in range (0, n) : + for j in range (0, rot) : + th = dth * float (j) + # + if smooth = 1: + a1 = th + a2 =th+dth + else : + a1 = th + dth / 2.0 + a2 = th + dth / 2.0 + # + v0 = (x1[i]*sin(th),x1[i]*cos(th),z1[i]) + n0 = (nx1[i]*sin(a1),nx1[i]*cos(a1),nz1[i]) + # + v1 = (x1[i]*sin(th+dth),x1[i]*cos(th+dth),z1[i]) + n1 = (nx1[i]*sin(a2), nx1[i]*cos(a2), nz1[i]) + # + v2 = (x2[i]*sin(th+dth),x2[i]*cos(th+dth),z2[i]) + n2 = (nx2[i]*sin(a2), nx2[i]*cos(a2), nz2[i]) + # + v3 = (x2[i]*sin(th), x2[i]*cos(th), z2[i]) + n3 = (nx2[i]*sin(a1), nx2[i]*cos(a1), nz2[i]) + # + patch = ((v0,n0), (v1,n1), (v2,n2), (v3,n3)) + #patch = ((n0,v0), (n1,v1), (n2,v2), (n3,v3)) + # + if x1[i] < FUZZY : + patch = patch[1:] + # + object.append (patch) + # + return object def makesphere (n): - asin = [] - acos = [] - for i in range (0, n-1): - asin.append (sin((pi/float (n))*(1.0+float (i)))) - acos.append(cos((pi/float (n))*(1.0+float (i)))) - # - x1 = [0.0] + asin - z1 = [1.0] + acos - nx1 = [0.0] + asin - nz1 = [1.0] + acos - # - x2 = asin + [0.0] - z2 = acos + [-1.0] - nx2 = asin + [0.0] - nz2 = acos + [-1.0] - # - return makespinobject (1,2*n,n,x1,z1,nx1,nz1,x2,z2,nx2,nz2) + asin = [] + acos = [] + for i in range (0, n-1): + asin.append (sin((pi/float (n))*(1.0+float (i)))) + acos.append(cos((pi/float (n))*(1.0+float (i)))) + # + x1 = [0.0] + asin + z1 = [1.0] + acos + nx1 = [0.0] + asin + nz1 = [1.0] + acos + # + x2 = asin + [0.0] + z2 = acos + [-1.0] + nx2 = asin + [0.0] + nz2 = acos + [-1.0] + # + return makespinobject (1,2*n,n,x1,z1,nx1,nz1,x2,z2,nx2,nz2) def makecylinder(n) : - x1 = [0.0, 1.0, 1.0] - nx1 = [0.0, 1.0, 0.0] - z1 = [1.0, 1.0, -1.0] - nz1 = [1.0, 0.0, -1.0] - # - z2 = [1.0, -1.0, -1.0] - nz2 = [1.0, 0.0, -1.0] - x2 = [1.0, 1.0, 0.0] - nx2 = [0.0, 1.0, 0.0] - # - return makespinobject(1,2*n,3,x1,z1,nx1,nz1,x2,z2,nx2,nz2) + x1 = [0.0, 1.0, 1.0] + nx1 = [0.0, 1.0, 0.0] + z1 = [1.0, 1.0, -1.0] + nz1 = [1.0, 0.0, -1.0] + # + z2 = [1.0, -1.0, -1.0] + nz2 = [1.0, 0.0, -1.0] + x2 = [1.0, 1.0, 0.0] + nx2 = [0.0, 1.0, 0.0] + # + return makespinobject(1,2*n,3,x1,z1,nx1,nz1,x2,z2,nx2,nz2) def makecone(n) : - x1 = [0.0, 1.0, 1.0] - nx1 = [2.0/sqrt(5.0), 0.0, 0.0] - z1 = [1.0, -1.0, -1.0] - nz1 = [1.0/sqrt(5.0), -1.0, -1.0] - # - x2 = [1.0, 0.0, 0.0] - nx2 = [2.0/sqrt(5.0), 0.0, 0.0] - nz2 = [1.0/sqrt(5.0), -1.0, -1.0] - z2 = [-1.0, -1.0, -1.0] - # - return makespinobject(1,2*n,2,x1,z1,nx1,nz1,x2,z2,nx2,nz2) + x1 = [0.0, 1.0, 1.0] + nx1 = [2.0/sqrt(5.0), 0.0, 0.0] + z1 = [1.0, -1.0, -1.0] + nz1 = [1.0/sqrt(5.0), -1.0, -1.0] + # + x2 = [1.0, 0.0, 0.0] + nx2 = [2.0/sqrt(5.0), 0.0, 0.0] + nz2 = [1.0/sqrt(5.0), -1.0, -1.0] + z2 = [-1.0, -1.0, -1.0] + # + return makespinobject(1,2*n,2,x1,z1,nx1,nz1,x2,z2,nx2,nz2) def makecube() : - x1 = [0.0, sqrt(2.0), sqrt (2.0)] - nx1 = [0.0, 1.0, 0.0] - z1 = [1.0, 1.0, -1.0] - nz1 = [1.0, 0.0, -1.0] - # - x2 = [sqrt(2.0), sqrt(2.0), 0.0] - nx2 = [0.0, 1.0, 0.0] - z2 = [1.0, -1.0, -1.0] - nz2 = [1.0, 0.0, -1.0] - # - return makespinobject(0,4,3,x1,z1,nx1,nz1,x2,z2,nx2,nz2) + x1 = [0.0, sqrt(2.0), sqrt (2.0)] + nx1 = [0.0, 1.0, 0.0] + z1 = [1.0, 1.0, -1.0] + nz1 = [1.0, 0.0, -1.0] + # + x2 = [sqrt(2.0), sqrt(2.0), 0.0] + nx2 = [0.0, 1.0, 0.0] + z2 = [1.0, -1.0, -1.0] + nz2 = [1.0, 0.0, -1.0] + # + return makespinobject(0,4,3,x1,z1,nx1,nz1,x2,z2,nx2,nz2) def makepyramid() : - x1 = [0.0, sqrt(2.0), 0.0] - nx1 = [2.0 / sqrt(5.0), 0.0, 0.0] - z1 = [1.0, -1.0, 0.0] - nz1 = [1.0 / sqrt(5.0), -1.0, 0.0] - # - x2 = [sqrt(2.0), 0.0, 0.0] - nx2 = [2.0 / sqrt(5.0), 0.0, 0.0] - z2 = [-1.0, -1.0, -1.0] - nz2 = [1.0/sqrt(5.0), -1.0, 0.0] - # - return makespinobject(0,4,3,x1,z1,nx1,nz1,x2,z2,nx2,nz2) + x1 = [0.0, sqrt(2.0), 0.0] + nx1 = [2.0 / sqrt(5.0), 0.0, 0.0] + z1 = [1.0, -1.0, 0.0] + nz1 = [1.0 / sqrt(5.0), -1.0, 0.0] + # + x2 = [sqrt(2.0), 0.0, 0.0] + nx2 = [2.0 / sqrt(5.0), 0.0, 0.0] + z2 = [-1.0, -1.0, -1.0] + nz2 = [1.0/sqrt(5.0), -1.0, 0.0] + # + return makespinobject(0,4,3,x1,z1,nx1,nz1,x2,z2,nx2,nz2) def makeobjects () : - cube = makecube() - sphere = makesphere (6) - cylinder = makecylinder (6) - cone = makecone (6) - pyramid = makepyramid () - # - odict = {} - odict ['cube'] = cube - odict ['pyramid'] = pyramid - odict ['sphere'] = sphere - odict ['cylinder'] = cylinder - odict ['cone'] = cone - odict ['diamond'] = cube - odict ['disk'] = sphere - # - return odict + cube = makecube() + sphere = makesphere (6) + cylinder = makecylinder (6) + cone = makecone (6) + pyramid = makepyramid () + # + odict = {} + odict ['cube'] = cube + odict ['pyramid'] = pyramid + odict ['sphere'] = sphere + odict ['cylinder'] = cylinder + odict ['cone'] = cone + odict ['diamond'] = cube + odict ['disk'] = sphere + # + return odict renderfuncs = [bgnpolygon, endpolygon] def putFunc (funcs) : - renderfuncs [:] = funcs + renderfuncs [:] = funcs def drawobject (obj) : - # - for patch in obj : - renderfuncs[0] () - vnarray (patch) - renderfuncs[1] () + # + for patch in obj : + renderfuncs[0] () + vnarray (patch) + renderfuncs[1] () diff --git a/demo/sgi/gl_panel/nurbs/nurbs.py b/demo/sgi/gl_panel/nurbs/nurbs.py index 686c3bd..c92cb46 100755 --- a/demo/sgi/gl_panel/nurbs/nurbs.py +++ b/demo/sgi/gl_panel/nurbs/nurbs.py @@ -1,6 +1,6 @@ #! /ufs/guido/bin/sgi/python -# Fancy NURBS demo. Require Z buffer and Panel Library. +# Fancy NURBS demo. Require Z buffer and Panel Library. from gl import * from GL import * @@ -11,186 +11,186 @@ import panel # # flags = trim_f, invis_f, cpvis_f, tpvis_f, axvis_f, freeze_f # -TRIM = 0 -VIS = 1 -CPVIS = 2 -TPVIS = 3 -AXVIS = 4 -FREEZE = 5 +TRIM = 0 +VIS = 1 +CPVIS = 2 +TPVIS = 3 +AXVIS = 4 +FREEZE = 5 flags = [0, 1, 0, 0, 0, 0] def draw_axis () : - cpack (0x0) - zero = (0.0, 0.0, 0.0) - # - one = (1.0, 0.0, 0.0) - smallline (zero, one) - cmov (1.0, 0.0, 0.0) - charstr ('x') - # - one = (0.0, 1.0, 0.0) - smallline (zero, one) - cmov (0.0, 1.0, 0.0) - charstr ('y') - # - one = (0.0, 0.0, 1.0) - smallline (zero, one) - cmov (0.0, 0.0, 1.0) - charstr ('z') + cpack (0x0) + zero = (0.0, 0.0, 0.0) + # + one = (1.0, 0.0, 0.0) + smallline (zero, one) + cmov (1.0, 0.0, 0.0) + charstr ('x') + # + one = (0.0, 1.0, 0.0) + smallline (zero, one) + cmov (0.0, 1.0, 0.0) + charstr ('y') + # + one = (0.0, 0.0, 1.0) + smallline (zero, one) + cmov (0.0, 0.0, 1.0) + charstr ('z') DELTA = 0.1 def cross (p) : - p0 = [p[0], p[1], p[2]] - p1 = [p[0], p[1], p[2]] - for i in range (0, 3) : - p0[i] = p0[i] + DELTA - p1[i] = p1[i] - DELTA - smallline (p0, p1) - p0[i] = p0[i] - DELTA - p1[i] = p1[i] + DELTA + p0 = [p[0], p[1], p[2]] + p1 = [p[0], p[1], p[2]] + for i in range (0, 3) : + p0[i] = p0[i] + DELTA + p1[i] = p1[i] - DELTA + smallline (p0, p1) + p0[i] = p0[i] - DELTA + p1[i] = p1[i] + DELTA def smallline (p0, p1) : - bgnline () - v3f (p0) - v3f (p1) - endline () + bgnline () + v3f (p0) + v3f (p1) + endline () def draw_pts (pnts, color) : - linewidth (2) - cpack (color) - for i in pnts : - cross (i) + linewidth (2) + cpack (color) + for i in pnts : + cross (i) def init_windows(): - foreground() - wid = winopen('nurbs') - wintitle('NURBS Surface') - doublebuffer() - RGBmode() - gconfig() - lsetdepth(0x000, 0x7fffff) - zbuffer( TRUE ) + foreground() + wid = winopen('nurbs') + wintitle('NURBS Surface') + doublebuffer() + RGBmode() + gconfig() + lsetdepth(0x000, 0x7fffff) + zbuffer( TRUE ) def init_view(): - mmode(MPROJECTION) - ortho( -5., 5., -5., 5., -5., 5. ) - # - mmode(MVIEWING) - loadmatrix(idmat) - # - lmbind(MATERIAL, 1) + mmode(MPROJECTION) + ortho( -5., 5., -5., 5., -5., 5. ) + # + mmode(MVIEWING) + loadmatrix(idmat) + # + lmbind(MATERIAL, 1) def set_scene(flags): - # - lmbind(MATERIAL, 0) - RGBcolor(150,150,150) - lmbind(MATERIAL, 1) - clear() - zclear() - # - if not flags[FREEZE] : - rotate( 100, 'y' ) - rotate( 100, 'z' ) + # + lmbind(MATERIAL, 0) + RGBcolor(150,150,150) + lmbind(MATERIAL, 1) + clear() + zclear() + # + if not flags[FREEZE] : + rotate( 100, 'y' ) + rotate( 100, 'z' ) def draw_trim_surface(flags): - pnts = ctlpoints - if flags[VIS] : - bgnsurface() - nurbssurface(surfknots,surfknots,pnts,ORDER,ORDER,N_XYZ) - if flags[TRIM]: - bgntrim() - nurbscurve(trimknots,trimpoints,ORDER-1,N_STW) - endtrim() - endsurface() - # - if flags[CPVIS] : - for i in pnts : - draw_pts (i, RED) - # - if flags[TPVIS] : - tpts = trimpoints - draw_pts (tpts, YELLOW) - # - if flags[AXVIS] : - draw_axis () - # - swapbuffers() + pnts = ctlpoints + if flags[VIS] : + bgnsurface() + nurbssurface(surfknots,surfknots,pnts,ORDER,ORDER,N_XYZ) + if flags[TRIM]: + bgntrim() + nurbscurve(trimknots,trimpoints,ORDER-1,N_STW) + endtrim() + endsurface() + # + if flags[CPVIS] : + for i in pnts : + draw_pts (i, RED) + # + if flags[TPVIS] : + tpts = trimpoints + draw_pts (tpts, YELLOW) + # + if flags[AXVIS] : + draw_axis () + # + swapbuffers() def make_lights(): - lmdef(DEFLMODEL,1,[]) - lmdef(DEFLIGHT,1,[]) - # - # define material #1 - # - a = [] - a = a + [EMISSION, 0.0, 0.0, 0.0] - a = a + [AMBIENT, 0.1, 0.1, 0.1] - a = a + [DIFFUSE, 0.6, 0.3, 0.3] - a = a + [SPECULAR, 0.0, 0.6, 0.0] - a = a + [SHININESS, 2.0] - a = a + [LMNULL] - lmdef(DEFMATERIAL, 1, a) - # - # turn on lighting - # - lmbind(LIGHT0, 1) - lmbind(LMODEL, 1) + lmdef(DEFLMODEL,1,[]) + lmdef(DEFLIGHT,1,[]) + # + # define material #1 + # + a = [] + a = a + [EMISSION, 0.0, 0.0, 0.0] + a = a + [AMBIENT, 0.1, 0.1, 0.1] + a = a + [DIFFUSE, 0.6, 0.3, 0.3] + a = a + [SPECULAR, 0.0, 0.6, 0.0] + a = a + [SHININESS, 2.0] + a = a + [LMNULL] + lmdef(DEFMATERIAL, 1, a) + # + # turn on lighting + # + lmbind(LIGHT0, 1) + lmbind(LMODEL, 1) def main(): - init_windows() - make_lights() - init_view() - # - panel.needredraw() - panels = panel.defpanellist('nurbs.s') - p = panels[0] - # - def cbtrim (a) : - flags[TRIM:TRIM+1] = [int (a.val)] - p.trim.upfunc = cbtrim - # - def cbquit (a) : - import sys - sys.exit (1) - p.quit.upfunc = cbquit - # - def cbmotion (a) : - flags[FREEZE:FREEZE+1] = [int (a.val)] - p.motion.upfunc = cbmotion - # - def cbxyzaxis (a) : - flags[AXVIS:AXVIS+1] = [int (a.val)] - p.xyzaxis.upfunc = cbxyzaxis - # - def cbtrimpnts (a) : - flags[TPVIS:TPVIS+1] = [int (a.val)] - p.trimpnts.upfunc = cbtrimpnts - # - def cbcntlpnts (a) : - flags[CPVIS:CPVIS+1] = [int (a.val)] - p.cntlpnts.upfunc = cbcntlpnts - # - def cbnurb (a) : - flags[VIS:VIS+1] = [int (a.val)] - p.nurb.upfunc = cbnurb - # - set_scene(flags) - setnurbsproperty( N_ERRORCHECKING, 1.0 ) - setnurbsproperty( N_PIXEL_TOLERANCE, 50.0 ) - draw_trim_surface(flags) - # - while 1: - act = panel.dopanel() - # - wid = panel.userredraw () - if wid : - winset (wid) - reshapeviewport() - set_scene(flags) - draw_trim_surface(flags) - # - set_scene(flags) - draw_trim_surface(flags) + init_windows() + make_lights() + init_view() + # + panel.needredraw() + panels = panel.defpanellist('nurbs.s') + p = panels[0] + # + def cbtrim (a) : + flags[TRIM:TRIM+1] = [int (a.val)] + p.trim.upfunc = cbtrim + # + def cbquit (a) : + import sys + sys.exit (1) + p.quit.upfunc = cbquit + # + def cbmotion (a) : + flags[FREEZE:FREEZE+1] = [int (a.val)] + p.motion.upfunc = cbmotion + # + def cbxyzaxis (a) : + flags[AXVIS:AXVIS+1] = [int (a.val)] + p.xyzaxis.upfunc = cbxyzaxis + # + def cbtrimpnts (a) : + flags[TPVIS:TPVIS+1] = [int (a.val)] + p.trimpnts.upfunc = cbtrimpnts + # + def cbcntlpnts (a) : + flags[CPVIS:CPVIS+1] = [int (a.val)] + p.cntlpnts.upfunc = cbcntlpnts + # + def cbnurb (a) : + flags[VIS:VIS+1] = [int (a.val)] + p.nurb.upfunc = cbnurb + # + set_scene(flags) + setnurbsproperty( N_ERRORCHECKING, 1.0 ) + setnurbsproperty( N_PIXEL_TOLERANCE, 50.0 ) + draw_trim_surface(flags) + # + while 1: + act = panel.dopanel() + # + wid = panel.userredraw () + if wid : + winset (wid) + reshapeviewport() + set_scene(flags) + draw_trim_surface(flags) + # + set_scene(flags) + draw_trim_surface(flags) main() diff --git a/demo/sgi/gl_panel/nurbs/nurbsdata.py b/demo/sgi/gl_panel/nurbs/nurbsdata.py index ed7e705..9a3f09e 100644 --- a/demo/sgi/gl_panel/nurbs/nurbsdata.py +++ b/demo/sgi/gl_panel/nurbs/nurbsdata.py @@ -25,58 +25,58 @@ surfknots = [-1, -1, -1, -1, 1, 1, 1, 1] # list of list of control points # def make_ctlpoints(): - c = [] - # - ci = [] - ci.append(-2.5, -3.7, 1.0) - ci.append(-1.5, -3.7, 3.0) - ci.append(1.5, -3.7, -2.5) - ci.append(2.5, -3.7, -0.75) - c.append(ci) - # - ci = [] - ci.append(-2.5, -2.0, 3.0) - ci.append(-1.5, -2.0, 4.0) - ci.append(1.5, -2.0, -3.0) - ci.append(2.5, -2.0, 0.0) - c.append(ci) - # - ci = [] - ci.append(-2.5, 2.0, 1.0) - ci.append(-1.5, 2.0, 0.0) - ci.append(1.5, 2.0, -1.0) - ci.append(2.5, 2.0, 2.0) - c.append(ci) - # - ci = [] - ci.append(-2.5, 2.7, 1.25) - ci.append(-1.5, 2.7, 0.1) - ci.append(1.5, 2.7, -0.6) - ci.append(2.5, 2.7, 0.2) - c.append(ci) - # - return c + c = [] + # + ci = [] + ci.append(-2.5, -3.7, 1.0) + ci.append(-1.5, -3.7, 3.0) + ci.append(1.5, -3.7, -2.5) + ci.append(2.5, -3.7, -0.75) + c.append(ci) + # + ci = [] + ci.append(-2.5, -2.0, 3.0) + ci.append(-1.5, -2.0, 4.0) + ci.append(1.5, -2.0, -3.0) + ci.append(2.5, -2.0, 0.0) + c.append(ci) + # + ci = [] + ci.append(-2.5, 2.0, 1.0) + ci.append(-1.5, 2.0, 0.0) + ci.append(1.5, 2.0, -1.0) + ci.append(2.5, 2.0, 2.0) + c.append(ci) + # + ci = [] + ci.append(-2.5, 2.7, 1.25) + ci.append(-1.5, 2.7, 0.1) + ci.append(1.5, 2.7, -0.6) + ci.append(2.5, 2.7, 0.2) + c.append(ci) + # + return c ctlpoints = make_ctlpoints () # # trim knots # -trimknots = [0., 0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 4.] +trimknots = [0., 0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 4.] def make_trimpoints(): - c = [] - # - c.append(1.0, 0.0, 1.0) - c.append(1.0, 1.0, 1.0) - c.append(0.0, 2.0, 2.0) - c.append(-1.0, 1.0, 1.0) - c.append(-1.0, 0.0, 1.0) - c.append(-1.0, -1.0, 1.0) - c.append(0.0, -2.0, 2.0) - c.append(1.0, -1.0, 1.0) - c.append(1.0, 0.0, 1.0) - # - return c + c = [] + # + c.append(1.0, 0.0, 1.0) + c.append(1.0, 1.0, 1.0) + c.append(0.0, 2.0, 2.0) + c.append(-1.0, 1.0, 1.0) + c.append(-1.0, 0.0, 1.0) + c.append(-1.0, -1.0, 1.0) + c.append(0.0, -2.0, 2.0) + c.append(1.0, -1.0, 1.0) + c.append(1.0, 0.0, 1.0) + # + return c trimpoints = make_trimpoints() diff --git a/demo/sgi/gl_panel/twoview/block.py b/demo/sgi/gl_panel/twoview/block.py index 9ac518d..a40c8e9 100644 --- a/demo/sgi/gl_panel/twoview/block.py +++ b/demo/sgi/gl_panel/twoview/block.py @@ -7,67 +7,67 @@ from GL import MATERIAL # Arguments are the material indices (0 = don't call lmbind) # def block(m_front, m_back, m_left, m_right, m_top, m_bottom): - # - # Distances defining the sides - # - x_left = -1.0 - x_right = 1.0 - y_top = 1.0 - y_bottom = -1.0 - z_front = 1.0 - z_back = -1.0 - # - # Top surface points: A, B, C, D - # - A = x_right, y_top, z_front - B = x_right, y_top, z_back - C = x_left, y_top, z_back - D = x_left, y_top, z_front - # - # Bottom surface points: E, F, G, H - # - E = x_right, y_bottom, z_front - F = x_right, y_bottom, z_back - G = x_left, y_bottom, z_back - H = x_left, y_bottom, z_front - # - # Draw front face - # - if m_front: lmbind(MATERIAL, m_front) - n3f(0.0, 0.0, 1.0) - face(H, E, A, D) - # - # Draw back face - # - if m_back: lmbind(MATERIAL, m_back) - n3f(0.0, 0.0, -1.0) - face(G, F, B, C) - # - # Draw left face - # - if m_left: lmbind(MATERIAL, m_left) - n3f(-1.0, 0.0, 0.0) - face(G, H, D, C) - # - # Draw right face - # - if m_right: lmbind(MATERIAL, m_right) - n3f(1.0, 0.0, 0.0) - face(F, E, A, B) - # - # Draw top face - # - if m_top: lmbind(MATERIAL, m_top) - n3f(0.0, 1.0, 0.0) - face(A, B, C, D) - # - # Draw bottom face - # - if m_bottom: lmbind(MATERIAL, m_bottom) - n3f(0.0, -1.0, 0.0) - face(E, F, G, H) + # + # Distances defining the sides + # + x_left = -1.0 + x_right = 1.0 + y_top = 1.0 + y_bottom = -1.0 + z_front = 1.0 + z_back = -1.0 + # + # Top surface points: A, B, C, D + # + A = x_right, y_top, z_front + B = x_right, y_top, z_back + C = x_left, y_top, z_back + D = x_left, y_top, z_front + # + # Bottom surface points: E, F, G, H + # + E = x_right, y_bottom, z_front + F = x_right, y_bottom, z_back + G = x_left, y_bottom, z_back + H = x_left, y_bottom, z_front + # + # Draw front face + # + if m_front: lmbind(MATERIAL, m_front) + n3f(0.0, 0.0, 1.0) + face(H, E, A, D) + # + # Draw back face + # + if m_back: lmbind(MATERIAL, m_back) + n3f(0.0, 0.0, -1.0) + face(G, F, B, C) + # + # Draw left face + # + if m_left: lmbind(MATERIAL, m_left) + n3f(-1.0, 0.0, 0.0) + face(G, H, D, C) + # + # Draw right face + # + if m_right: lmbind(MATERIAL, m_right) + n3f(1.0, 0.0, 0.0) + face(F, E, A, B) + # + # Draw top face + # + if m_top: lmbind(MATERIAL, m_top) + n3f(0.0, 1.0, 0.0) + face(A, B, C, D) + # + # Draw bottom face + # + if m_bottom: lmbind(MATERIAL, m_bottom) + n3f(0.0, -1.0, 0.0) + face(E, F, G, H) def face(points): - bgnpolygon() - varray(points) - endpolygon() + bgnpolygon() + varray(points) + endpolygon() diff --git a/demo/sgi/gl_panel/twoview/twoview.py b/demo/sgi/gl_panel/twoview/twoview.py index eea7c75..79c664f 100755 --- a/demo/sgi/gl_panel/twoview/twoview.py +++ b/demo/sgi/gl_panel/twoview/twoview.py @@ -1,7 +1,7 @@ #! /ufs/guido/bin/sgi/python # A demo of GL's viewing transformations, showing two views on one scene. -# Requires the NASA AMES Panel Library. Requires Z buffer. +# Requires the NASA AMES Panel Library. Requires Z buffer. from gl import * from GL import * @@ -13,383 +13,383 @@ far = 1000.0 near = 100.0 def main(): - foreground() - # - keepaspect(1, 1) - prefposition(10, 610, 10, 610) - obswid = winopen('Observer View') - doublebuffer() - RGBmode() - gconfig() - # - keepaspect(1, 1) - prefposition(10, 310, 650, 950) - topwid = winopen('Top View') - doublebuffer() - RGBmode() - gconfig() - # - panels = panel.defpanellist('observer.s') - panels = panels + panel.defpanellist('camera.s') - panels = panels + panel.defpanellist('topview.s') - # - p = panels[0] - q = panels[1] - r = panels[2] - # - p.farclip = q.farclip - p.nearclip = q.nearclip - p.zoom = q.zoom - p.quitbutton = q.quitbutton - # - p.xpos = r.xpos - p.zpos = r.zpos - p.direction = r.direction - # - p.direction.winds = 1.0 # allow full rotation - # - def quit(act): - import sys - sys.exit(0) - p.quitbutton.downfunc = quit - # - p.left.back = p - p.fast_left.back = p - p.right.back = p - p.fast_right.back = p - p.forward.back = p - p.fast_forward.back = p - p.reverse.back = p - p.fast_reverse.back = p - p.up.back = p - p.down.back = p - # - p.left.activefunc = left - p.fast_left.activefunc = fast_left - p.right.activefunc = right - p.fast_right.activefunc = fast_right - p.forward.activefunc = forward - p.fast_forward.activefunc = fast_forward - p.reverse.activefunc = reverse - p.fast_reverse.activefunc = fast_reverse - p.up.activefunc = up - p.down.activefunc = down - # - makeobjects() - # - drawall(p, obswid, topwid) - panel.needredraw() - while 1: - act = panel.dopanel() - if panel.userredraw() or act: - drawall(p, obswid, topwid) + foreground() + # + keepaspect(1, 1) + prefposition(10, 610, 10, 610) + obswid = winopen('Observer View') + doublebuffer() + RGBmode() + gconfig() + # + keepaspect(1, 1) + prefposition(10, 310, 650, 950) + topwid = winopen('Top View') + doublebuffer() + RGBmode() + gconfig() + # + panels = panel.defpanellist('observer.s') + panels = panels + panel.defpanellist('camera.s') + panels = panels + panel.defpanellist('topview.s') + # + p = panels[0] + q = panels[1] + r = panels[2] + # + p.farclip = q.farclip + p.nearclip = q.nearclip + p.zoom = q.zoom + p.quitbutton = q.quitbutton + # + p.xpos = r.xpos + p.zpos = r.zpos + p.direction = r.direction + # + p.direction.winds = 1.0 # allow full rotation + # + def quit(act): + import sys + sys.exit(0) + p.quitbutton.downfunc = quit + # + p.left.back = p + p.fast_left.back = p + p.right.back = p + p.fast_right.back = p + p.forward.back = p + p.fast_forward.back = p + p.reverse.back = p + p.fast_reverse.back = p + p.up.back = p + p.down.back = p + # + p.left.activefunc = left + p.fast_left.activefunc = fast_left + p.right.activefunc = right + p.fast_right.activefunc = fast_right + p.forward.activefunc = forward + p.fast_forward.activefunc = fast_forward + p.reverse.activefunc = reverse + p.fast_reverse.activefunc = fast_reverse + p.up.activefunc = up + p.down.activefunc = down + # + makeobjects() + # + drawall(p, obswid, topwid) + panel.needredraw() + while 1: + act = panel.dopanel() + if panel.userredraw() or act: + drawall(p, obswid, topwid) def left(a): - doturn(a.back, 0.01) + doturn(a.back, 0.01) def fast_left(a): - doturn(a.back, 0.1) + doturn(a.back, 0.1) def right(a): - doturn(a.back, -0.01) + doturn(a.back, -0.01) def fast_right(a): - doturn(a.back, -0.1) + doturn(a.back, -0.1) def doturn(p, angle): - alpha = lookangle(p) + angle - # Reverse the following assignment: - # alpha = pi*1.5 - p.direction.val*2.0*pi - val = (pi*1.5 - alpha) / 2.0 / pi - while val < 0.0: val = val + 1.0 - while val > 1.0: val = val - 1.0 - p.direction.val = val - p.direction.fixact() + alpha = lookangle(p) + angle + # Reverse the following assignment: + # alpha = pi*1.5 - p.direction.val*2.0*pi + val = (pi*1.5 - alpha) / 2.0 / pi + while val < 0.0: val = val + 1.0 + while val > 1.0: val = val - 1.0 + p.direction.val = val + p.direction.fixact() def forward(a): - dostep(a.back, 1.0) + dostep(a.back, 1.0) def fast_forward(a): - dostep(a.back, 10.0) + dostep(a.back, 10.0) def reverse(a): - dostep(a.back, -1.0) + dostep(a.back, -1.0) def fast_reverse(a): - dostep(a.back, -10.0) + dostep(a.back, -10.0) def dostep(p, step): - x, y, z = observerpos(p) - alpha = lookangle(p) - x = x + step*cos(alpha) - z = z - step*sin(alpha) - # Reverse the following assignments: - # x = 2.0 * p.xpos.val * near - near - # z = near - 2.0 * p.zpos.val * near - p.xpos.val = (x + near) / 2.0 / near - p.zpos.val = - (z - near) / 2.0 / near - p.xpos.fixact() - p.zpos.fixact() + x, y, z = observerpos(p) + alpha = lookangle(p) + x = x + step*cos(alpha) + z = z - step*sin(alpha) + # Reverse the following assignments: + # x = 2.0 * p.xpos.val * near - near + # z = near - 2.0 * p.zpos.val * near + p.xpos.val = (x + near) / 2.0 / near + p.zpos.val = - (z - near) / 2.0 / near + p.xpos.fixact() + p.zpos.fixact() def up(a): - doup(a.back, 0.2) + doup(a.back, 0.2) def down(a): - doup(a.back, -0.2) + doup(a.back, -0.2) def doup(p, step): - x, y, z = observerpos(p) - y = y + step - # Reverse: - # y = p.ypos.val * near - p.ypos.val = y/near - p.ypos.fixact() + x, y, z = observerpos(p) + y = y + step + # Reverse: + # y = p.ypos.val * near + p.ypos.val = y/near + p.ypos.fixact() def drawall(p, obswid, topwid): - # - winset(obswid) - obsview(p) - drawscene() - swapbuffers() - # - winset(topwid) - topview(p) - drawscene() - drawobserver(p) - swapbuffers() + # + winset(obswid) + obsview(p) + drawscene() + swapbuffers() + # + winset(topwid) + topview(p) + drawscene() + drawobserver(p) + swapbuffers() def drawobserver(p): - x, y, z = observerpos(p) - alpha = lookangle(p) - fov = 2.0 + 1798.0 * p.zoom.val - beta = fov*pi/3600.0 # Half fov, expressed in radians - # - c3i(0, 255, 0) - # - move(x, y, z) - x1 = x + inf*cos(alpha+beta) - y1 = y - z1 = z - inf*sin(alpha+beta) - draw(x1, y1, z1) - # - move(x, y, z) - x1 = x + inf*cos(alpha-beta) - y1 = y - z1 = z - inf*sin(alpha-beta) - draw(x1, y1, z1) + x, y, z = observerpos(p) + alpha = lookangle(p) + fov = 2.0 + 1798.0 * p.zoom.val + beta = fov*pi/3600.0 # Half fov, expressed in radians + # + c3i(0, 255, 0) + # + move(x, y, z) + x1 = x + inf*cos(alpha+beta) + y1 = y + z1 = z - inf*sin(alpha+beta) + draw(x1, y1, z1) + # + move(x, y, z) + x1 = x + inf*cos(alpha-beta) + y1 = y + z1 = z - inf*sin(alpha-beta) + draw(x1, y1, z1) def observerlookat(p): - x, y, z = observerpos(p) - alpha = lookangle(p) - return x, y, z, x+near*cos(alpha), y, z-near*sin(alpha), 0 + x, y, z = observerpos(p) + alpha = lookangle(p) + return x, y, z, x+near*cos(alpha), y, z-near*sin(alpha), 0 def observerpos(p): - x = 2.0 * p.xpos.val * near - near - y = p.ypos.val * near - z = near - 2.0 * p.zpos.val * near - return x, y, z + x = 2.0 * p.xpos.val * near - near + y = p.ypos.val * near + z = near - 2.0 * p.zpos.val * near + return x, y, z def lookangle(p): - return pi*1.5 - p.direction.val*2.0*pi + return pi*1.5 - p.direction.val*2.0*pi idmat = 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 def topview(p): - mmode(MVIEWING) - ortho(-far, far, -far, far, far, -far) - loadmatrix(idmat) - rotate(900, 'x') + mmode(MVIEWING) + ortho(-far, far, -far, far, far, -far) + loadmatrix(idmat) + rotate(900, 'x') def obsview(p): - fov = 2.0 + 1798.0 * p.zoom.val - nearclip = p.nearclip.val * 10.0 - farclip = p.farclip.val * 10.0*far - aspectratio = 1.0 - mmode(MVIEWING) - perspective(int(fov), aspectratio, nearclip, farclip) - loadmatrix(idmat) - lookat(observerlookat(p)) + fov = 2.0 + 1798.0 * p.zoom.val + nearclip = p.nearclip.val * 10.0 + farclip = p.farclip.val * 10.0*far + aspectratio = 1.0 + mmode(MVIEWING) + perspective(int(fov), aspectratio, nearclip, farclip) + loadmatrix(idmat) + lookat(observerlookat(p)) def drawscene(): - # - # clear window - # - c3i(0, 0, 0) - clear() - # - # turn on z buffering and clear it - # - zbuffer(TRUE) - zclear() - # - # dark blue sky (depending on your gamma value!) - # - c3i(0, 0, 150) - callobj(41) - # - # bright red near and far units circle - # (use rotate since circ() always draws in x-y plane) - # - c3i(255, 0, 0) - pushmatrix() - rotate(900, 'x') - circ(0.0, 0.0, near) - circ(0.0, 0.0, far) - popmatrix() - # - # bright white striping - # - c3i(255, 255, 200) - callobj(42) - # - # building (does its own colors) - # - building() - # - # some other objects - # - dice() + # + # clear window + # + c3i(0, 0, 0) + clear() + # + # turn on z buffering and clear it + # + zbuffer(TRUE) + zclear() + # + # dark blue sky (depending on your gamma value!) + # + c3i(0, 0, 150) + callobj(41) + # + # bright red near and far units circle + # (use rotate since circ() always draws in x-y plane) + # + c3i(255, 0, 0) + pushmatrix() + rotate(900, 'x') + circ(0.0, 0.0, near) + circ(0.0, 0.0, far) + popmatrix() + # + # bright white striping + # + c3i(255, 255, 200) + callobj(42) + # + # building (does its own colors) + # + building() + # + # some other objects + # + dice() def makeobjects(): - # - # sky object - # - makeobj(41) - pmv(-inf, 0.0, -far) - pdr(inf, 0.0, -far) - pdr(inf, inf, -far) - pdr(-inf, inf, -far) - pclos() - closeobj() - # - # road stripes object - # - makeobj(42) - stripes() - closeobj() - # - # lighting model definitions - # - deflight() + # + # sky object + # + makeobj(41) + pmv(-inf, 0.0, -far) + pdr(inf, 0.0, -far) + pdr(inf, inf, -far) + pdr(-inf, inf, -far) + pclos() + closeobj() + # + # road stripes object + # + makeobj(42) + stripes() + closeobj() + # + # lighting model definitions + # + deflight() def stripes(): - # - # left line - # - botrect(-11, -10, far, -far) - # - # right line - # - botrect(10, 11, far, -far) - # - # center lines - # - z = far - while z > -far: - botrect(-0.5, 0.5, z, z - 4.0) - z = z - 10.0 + # + # left line + # + botrect(-11, -10, far, -far) + # + # right line + # + botrect(10, 11, far, -far) + # + # center lines + # + z = far + while z > -far: + botrect(-0.5, 0.5, z, z - 4.0) + z = z - 10.0 def dice(): - from block import block - uselight() - pushmatrix() - translate(0.0, 1.0, -20.0) - rotate(200, 'y') - block(1, 0, 0, 0, 0, 0) - translate(1.0, 0.0, 3.0) - rotate(500, 'y') - block(2, 0, 0, 0, 0, 0) - popmatrix() + from block import block + uselight() + pushmatrix() + translate(0.0, 1.0, -20.0) + rotate(200, 'y') + block(1, 0, 0, 0, 0, 0) + translate(1.0, 0.0, 3.0) + rotate(500, 'y') + block(2, 0, 0, 0, 0, 0) + popmatrix() def deflight(): - # Material for first die (red) - lmdef(DEFMATERIAL, 1, (DIFFUSE, 1.0, 0.0, 0.0)) - # Material for second die (green) - lmdef(DEFMATERIAL, 2, (DIFFUSE, 0.0, 1.0, 0.0)) - # First light source (default: white, from front) - lmdef(DEFLIGHT, 1, ()) - # Second light source (red, from back) - lmdef(DEFLIGHT, 2, (POSITION, 0.0, 1.0, -1.0, 0.0)) - lmdef(DEFLIGHT, 2, (LCOLOR, 1.0, 0.0, 0.0)) - # Lighting model - lmdef(DEFLMODEL, 1, (AMBIENT, 0.0, 0.0, 1.0)) + # Material for first die (red) + lmdef(DEFMATERIAL, 1, (DIFFUSE, 1.0, 0.0, 0.0)) + # Material for second die (green) + lmdef(DEFMATERIAL, 2, (DIFFUSE, 0.0, 1.0, 0.0)) + # First light source (default: white, from front) + lmdef(DEFLIGHT, 1, ()) + # Second light source (red, from back) + lmdef(DEFLIGHT, 2, (POSITION, 0.0, 1.0, -1.0, 0.0)) + lmdef(DEFLIGHT, 2, (LCOLOR, 1.0, 0.0, 0.0)) + # Lighting model + lmdef(DEFLMODEL, 1, (AMBIENT, 0.0, 0.0, 1.0)) def uselight(): - lmbind(LIGHT0, 1) - lmbind(LIGHT1, 2) - lmbind(LMODEL, 1) - # (materials are bound later) + lmbind(LIGHT0, 1) + lmbind(LIGHT1, 2) + lmbind(LMODEL, 1) + # (materials are bound later) def building(): - # - c3i(0, 255, 255) - # - # house bounding coordinates - # - x1 = 20.0 - x1a = 25.0 - x2 = 30.0 - y1 = 0.0 - y2 = 15.0 - y2a = 20.0 - z1 = -40.0 - z2 = -55.0 - # - # door y and z coordinates - # - dy1 = 0.0 - dy2 = 4.0 - dz1 = -45.0 - dz2 = -47.0 - # - # front side (seen from origin) - # - A1 = (x1, y1, z1) - B1 = (x2, y1, z1) - C1 = (x2, y2, z1) - D1 = (x1a, y2a, z1) - E1 = (x1, y2, z1) - # - # back size - # - A2 = (x1, y1, z2) - B2 = (x2, y1, z2) - C2 = (x2, y2, z2) - D2 = (x1a, y2a, z2) - E2 = (x1, y2, z2) - # - # door in the left side - # - P = x1, dy1, dz2 - Q = x1, dy2, dz2 - R = x1, dy2, dz1 - S = x1, dy1, dz1 - # - # draw it - # - concave(TRUE) - c3i(255, 0, 0) - face(A1, B1, C1, D1, E1) - c3i(127, 127, 0) - face(A1, E1, E2, A2, P, Q, R, S) - c3i(0, 255, 0) - face(E1, D1, D2, E2) - c3i(0, 127, 127) - face(D1, C1, C2, D2) - c3i(0, 0, 255) - face(C1, B1, B2, C2) - c3i(127, 0, 127) - face(E2, D2, C2, B2, A2) - concave(FALSE) + # + c3i(0, 255, 255) + # + # house bounding coordinates + # + x1 = 20.0 + x1a = 25.0 + x2 = 30.0 + y1 = 0.0 + y2 = 15.0 + y2a = 20.0 + z1 = -40.0 + z2 = -55.0 + # + # door y and z coordinates + # + dy1 = 0.0 + dy2 = 4.0 + dz1 = -45.0 + dz2 = -47.0 + # + # front side (seen from origin) + # + A1 = (x1, y1, z1) + B1 = (x2, y1, z1) + C1 = (x2, y2, z1) + D1 = (x1a, y2a, z1) + E1 = (x1, y2, z1) + # + # back size + # + A2 = (x1, y1, z2) + B2 = (x2, y1, z2) + C2 = (x2, y2, z2) + D2 = (x1a, y2a, z2) + E2 = (x1, y2, z2) + # + # door in the left side + # + P = x1, dy1, dz2 + Q = x1, dy2, dz2 + R = x1, dy2, dz1 + S = x1, dy1, dz1 + # + # draw it + # + concave(TRUE) + c3i(255, 0, 0) + face(A1, B1, C1, D1, E1) + c3i(127, 127, 0) + face(A1, E1, E2, A2, P, Q, R, S) + c3i(0, 255, 0) + face(E1, D1, D2, E2) + c3i(0, 127, 127) + face(D1, C1, C2, D2) + c3i(0, 0, 255) + face(C1, B1, B2, C2) + c3i(127, 0, 127) + face(E2, D2, C2, B2, A2) + concave(FALSE) def face(points): - bgnpolygon() - varray(points) - endpolygon() + bgnpolygon() + varray(points) + endpolygon() # draw a rectangle at y=0.0 # def botrect(x1, x2, z1, z2): - polf(x1, 0.0, z1, x2, 0.0, z1, x2, 0.0, z2, x1, 0.0, z2) + polf(x1, 0.0, z1, x2, 0.0, z1, x2, 0.0, z2, x1, 0.0, z2) main() |
