diff options
| author | Skip Montanaro <[email protected]> | 2021-02-16 14:40:46 -0600 |
|---|---|---|
| committer | Skip Montanaro <[email protected]> | 2021-02-16 14:40:46 -0600 |
| commit | a19a216bc60160c162e616145ef091dd18ce4e61 (patch) | |
| tree | fa4bdff21f9b04a125c84a2bfab8a1c738359e15 /demo/sgi/gl_panel/flying | |
| download | python-0.9.1-patched-QoL-a19a216bc60160c162e616145ef091dd18ce4e61.tar.xz python-0.9.1-patched-QoL-a19a216bc60160c162e616145ef091dd18ce4e61.zip | |
Python 0.9.1 as posted in alt.sources
Diffstat (limited to 'demo/sgi/gl_panel/flying')
| -rw-r--r-- | demo/sgi/gl_panel/flying/data.py | 42 | ||||
| -rwxr-xr-x | demo/sgi/gl_panel/flying/flying.py | 375 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/flying.s | 140 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/freeze.s | 31 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/light.py | 46 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/light.s | 94 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/material.py | 26 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/materials.s | 161 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/objdict.py | 41 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/objectdef.py | 147 | ||||
| -rw-r--r-- | demo/sgi/gl_panel/flying/panel.s | 76 |
11 files changed, 1179 insertions, 0 deletions
diff --git a/demo/sgi/gl_panel/flying/data.py b/demo/sgi/gl_panel/flying/data.py new file mode 100644 index 0000000..bfc934a --- /dev/null +++ b/demo/sgi/gl_panel/flying/data.py @@ -0,0 +1,42 @@ + +# two string constants +ARROW = '-> ' +NULL = '' +ZERO = 0 +ONE = 1 + +# +# the color light-blue +# +lightblue = (43,169,255) + + +# +# a couple of rotation, translation, scaling vectors +# +rts1 = [[3.0,3.1,2.0],[2.2, 1.2, 2.0], [0.8,0.8,0.8]] +rts2 = [[3.2,2.6,1.8],[-1.9, 1.2, 1.6], [0.3,0.3,1.0]] +rts3 = [[2.2,3.3,1.4], [-1.0, 1.2,-1.5], [0.6,0.6, 0.6]] +rts4 = [[4.2,2.1,3.2],[1.2, 1.3, 1.0],[0.5,0.5,0.8]] +rts5 = [[1.2,3.3,2.4], [-2.0, 1.4,-2.1], [0.8, 0.8, 0.2]] +rts6 = [[3.2,3.6,2.4], [1.1, 1.6, 2.5], [0.8,0.3,0.1]] +rts7 = [[2.3,2.7,3.3], [1.1, 2.3, 1.7], [0.6,0.6,0.5]] +rts8 = [[4.2,2.1,3.2], [1.2, 1.3, 0.0], [0.5,0.5,0.5]] +# +rts90 = [[4.2,2.1,3.2], [2.0, 0.0, 0.9], [0.3,0.3,1.0]] +rts91 = [[4.2,2.1,3.2], [-2.0, 0.0, 0.9], [0.3,0.3,1.0]] +rts92 = [[4.2,2.1,3.2], [0.0, 2.0, 0.9], [0.3,0.3,1.0]] +rts93 = [[4.2,2.1,3.2], [0.0, -2.0, 0.9], [0.3,0.3,1.0]] +rts10 = [[4.2,2.1,3.2], [0.0, 0.0, 0.0], [2.2,2.2,0.2]] + +# +# (composite) object definitions +# +o1 = [['sphere',rts1, 1]] +o2 = [['cylinder', rts2, 4]] +o3 = [['cube', rts3, 3]] +o4 = [['cone', rts4, 2], ['sphere', rts8, 9]] +o5 = [['sphere', rts5, 5]] +o6 = [['cube', rts6, 6]] +o7 = [['pyramid', rts7, 8]] +o8 = [['cube', rts10, 9], ['cylinder', rts90, 2], ['cylinder', rts91, 2], ['cylinder', rts92, 2], ['cylinder', rts93, 2]] diff --git a/demo/sgi/gl_panel/flying/flying.py b/demo/sgi/gl_panel/flying/flying.py new file mode 100755 index 0000000..e6fd823 --- /dev/null +++ b/demo/sgi/gl_panel/flying/flying.py @@ -0,0 +1,375 @@ +#! /ufs/guido/bin/sgi/python + +from gl import * +from objdict import * +from GL import * +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 () + +def fixlichtact (p) : + 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) + +def cbsetmaterial (a) : + 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) + +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) + +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) + +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) + +# +# 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) + # + +# +# drawit : draws the object with the given attributes. +# +# rfac : the rotation factor. +# 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]] +# +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() + +def callbacksphere (a) : + putDict (objects, 'sphere', int (a.val)) + +def callbackcylinder (a) : + putDict (objects, 'cylinder', int (a.val)) + +def callbackcube (a) : + putDict (objects, 'cube', int (a.val)) + +def callbackicecream (a) : + putDict (objects, 'icecream', int (a.val)) + +def callbackdisk (a) : + putDict (objects, 'disk', int (a.val)) + +def callbackdiamond (a) : + putDict (objects, 'diamond', int (a.val)) + +def callbackglass (a) : + putDict (objects, 'glass', int (a.val)) + +def callbackpyramid (a) : + putDict (objects, 'pyramid', int (a.val)) + +def callbacktable (a) : + putDict (objects, 'table', int (a.val)) + +def callbackflat (a) : + shademodel(FLAT) + +def callbackgouraud (a) : + shademodel(GOURAUD) + +def callbackwire (a) : + objectdef.putFunc ([bgnclosedline, endclosedline]) + +def callbackfilled (a) : + objectdef.putFunc ([bgnpolygon, endpolygon]) + +def callbackquit (a) : + 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() + + +def callbackshowall (a) : + #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) + +# +# 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() + # + +main() diff --git a/demo/sgi/gl_panel/flying/flying.s b/demo/sgi/gl_panel/flying/flying.s new file mode 100644 index 0000000..a39fdaa --- /dev/null +++ b/demo/sgi/gl_panel/flying/flying.s @@ -0,0 +1,140 @@ +;;; This file was automatically generated by the panel editor. +;;; If you read it into gnu emacs, it will automagically format itself. + +(panel (prop help creator:user-panel-help) +(prop user-panel #t) +(label "flying objects") +(al (pnl_toggle_button (name "table") +(prop help creator:user-act-help) +(label "table") +(x 4.75) +(y 0.25) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "pyramid") +(prop help creator:user-act-help) +(label "pyramid") +(x 4.75) +(y 0.75) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "glass") +(prop help creator:user-act-help) +(label "glass") +(x 4.75) +(y 1.25) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "diamond") +(prop help creator:user-act-help) +(label "diamond") +(x 4.75) +(y 1.75) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "disk") +(prop help creator:user-act-help) +(label "disk") +(x 4.75) +(y 2.25) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "icecream") +(prop help creator:user-act-help) +(label "ice cream") +(x 4.75) +(y 2.75) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "cube") +(prop help creator:user-act-help) +(label "cube") +(x 4.75) +(y 3.25) +(val 1) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "cylinder") +(prop help creator:user-act-help) +(label "cylinder") +(x 4.75) +(y 3.75) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "sphere") +(prop help creator:user-act-help) +(label "sphere") +(x 4.75) +(y 4.25) +(downfunc move-then-resize) +) +(pnl_button (name "quit") +(prop help creator:user-act-help) +(label "quit") +(x 0.25) +(y 2.25) +(w 1.3) +(h 0.65) +(labeltype 16) +(downfunc move-then-resize) +) +(pnl_button (name "showall") +(prop help creator:user-act-help) +(label "show all") +(x 3.75) +(y 3.75) +(labeltype 8) +(downfunc move-then-resize) +) +(pnl_button (name "shownone") +(prop help creator:user-act-help) +(label "show none") +(x 3.75) +(y 3.25) +(labeltype 8) +(downfunc move-then-resize) +) +(pnl_radio_button (name "wire") +(prop end-of-group #t) +(prop help creator:user-act-help) +(label "wire frame") +(x 0.25) +(y 4.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "filled") +(prop help creator:user-act-help) +(label "filled") +(x 0.25) +(y 4) +(h 0.36) +(val 1) +(downfunc move-then-resize) +) +(pnl_radio_button (name "flat") +(prop end-of-group #t) +(prop help creator:user-act-help) +(label "flat shaded") +(x 0.25) +(y 0.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "gouraud") +(prop help creator:user-act-help) +(label "gouraud shaded") +(x 0.25) +(h 0.36) +(val 1) +(downfunc move-then-resize) +) +) +) +;;; Local Variables: +;;; mode: scheme +;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3)) +;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")")) +;;; eval: (indent-region (point-min) (point-max) nil) +;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer)) +;;; End: diff --git a/demo/sgi/gl_panel/flying/freeze.s b/demo/sgi/gl_panel/flying/freeze.s new file mode 100644 index 0000000..4bfa88c --- /dev/null +++ b/demo/sgi/gl_panel/flying/freeze.s @@ -0,0 +1,31 @@ +;;; This file was automatically generated by the panel editor. +;;; If you read it into gnu emacs, it will automagically format itself. + +(panel (prop help creator:user-panel-help) +(prop user-panel #t) +(label "frames per second") +(al (pnl_toggle_button (name "freeze") +(prop help creator:user-act-help) +(label "freeze") +(x 0.25) +(y 4.3) +(w 1.45) +(h 0.6) +(labeltype 16) +(downfunc move-then-resize) +) +(pnl_scale_chart (name "mystrip") +(prop help creator:user-act-help) +(x 0.25) +(y 0.25) +(downfunc move-then-resize) +) +) +) +;;; Local Variables: +;;; mode: scheme +;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3)) +;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")")) +;;; eval: (indent-region (point-min) (point-max) nil) +;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer)) +;;; End: diff --git a/demo/sgi/gl_panel/flying/light.py b/demo/sgi/gl_panel/flying/light.py new file mode 100644 index 0000000..f6bf379 --- /dev/null +++ b/demo/sgi/gl_panel/flying/light.py @@ -0,0 +1,46 @@ +from GL import * +from gl import * + +# identity matrix +idmat=[1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0] + +# the different materials. +m1=[SPECULAR,0.8,0.0,0.0,DIFFUSE,0.4,0.0,0.0,SHININESS,40.0,LMNULL] +m2=[SPECULAR,1.0,0.4,0.0,DIFFUSE,1.0,0.4,0.0,SHININESS,80.0,LMNULL] +m3=[SPECULAR,0.0,0.0,0.6,DIFFUSE,0.0,0.0,0.8,SHININESS,60.0,LMNULL] +m4=[SPECULAR,0.0,1.0,0.0,DIFFUSE,0.0,0.6,0.0,SHININESS,120.0,LMNULL] +m5=[SPECULAR,1.0,1.0,0.0,DIFFUSE,0.6,0.6,0.0,SHININESS,100.0,LMNULL] +m6=[SPECULAR,1.0,0.0,1.0,DIFFUSE,0.6,0.0,0.6,SHININESS,120.0,LMNULL] +m7=[SPECULAR,0.9,0.9,0.9,DIFFUSE,0.6,0.6,0.6,SHININESS,120.0,LMNULL] +m8=[SPECULAR,0.4,0.7,0.4,DIFFUSE,0.5,1.0,0.5,SHININESS,50.0,LMNULL] +m9=[SPECULAR,0.2,0.0,0.1,DIFFUSE,0.8,0.0,0.3,SHININESS,10.0,LMNULL] + +#the lightsources. +light1 = [LCOLOR,1.0,1.0,1.0,POSITION,10.0,10.0,5.0,0.0,LMNULL] +light2 = [LCOLOR,1.0,1.0,1.0,POSITION,-10.0,10.0,5.0,0.0,LMNULL] + +# the lightmodel. +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) diff --git a/demo/sgi/gl_panel/flying/light.s b/demo/sgi/gl_panel/flying/light.s new file mode 100644 index 0000000..ad56861 --- /dev/null +++ b/demo/sgi/gl_panel/flying/light.s @@ -0,0 +1,94 @@ +;;; This file was automatically generated by the panel editor. +;;; If you read it into gnu emacs, it will automagically format itself. + +(panel (prop help creator:user-panel-help) +(prop user-panel #t) +(label "Light Sources") +(al (pnl_hslider (name "X") +(prop help creator:user-act-help) +(label "x") +(y 4) +(w 3.3) +(h 0.4) +(val 0.50) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_hslider (name "Y") +(prop help creator:user-act-help) +(label "y") +(y 3.5) +(w 3.3) +(h 0.4) +(val 0.50) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_hslider (name "Z") +(prop help creator:user-act-help) +(label "z") +(y 3) +(w 3.3) +(h 0.4) +(val 0.50) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_radio_button (name "light2") +(prop help creator:user-act-help) +(label "light 2") +(x 5) +(y 4) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "light1") +(prop help creator:user-act-help) +(label "light 1") +(x 5) +(y 4.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_toggle_button (name "local") +(prop help creator:user-act-help) +(label "local") +(x 5) +(y 2.75) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "B") +(prop help creator:user-act-help) +(label "B") +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "G") +(prop help creator:user-act-help) +(label "G") +(y 0.5) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "R") +(prop help creator:user-act-help) +(label "R") +(y 1) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +) +) +;;; Local Variables: +;;; mode: scheme +;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3)) +;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")")) +;;; eval: (indent-region (point-min) (point-max) nil) +;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer)) +;;; End: diff --git a/demo/sgi/gl_panel/flying/material.py b/demo/sgi/gl_panel/flying/material.py new file mode 100644 index 0000000..f9137ea --- /dev/null +++ b/demo/sgi/gl_panel/flying/material.py @@ -0,0 +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 + +materdict = mkmatdict () + +def mklichtdict () : + 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 new file mode 100644 index 0000000..ae45ca9 --- /dev/null +++ b/demo/sgi/gl_panel/flying/materials.s @@ -0,0 +1,161 @@ +;;; This file was automatically generated by the panel editor. +;;; If you read it into gnu emacs, it will automagically format itself. + +(panel (prop help creator:user-panel-help) +(prop user-panel #t) +(label "Materials") +(al (pnl_label (prop help creator:user-act-help) +(label "specular") +(x 4) +(y 0.5) +(downfunc move-then-resize) +) +(pnl_label (prop help creator:user-act-help) +(label "diffuse") +(x 4) +(y 4) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m7") +(prop help creator:user-act-help) +(label "material 7") +(x 6.5) +(y 1.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m9") +(prop help creator:user-act-help) +(label "material 9") +(x 6.5) +(y 0.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m8") +(prop help creator:user-act-help) +(label "material 8") +(x 6.5) +(y 1) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m6") +(prop help creator:user-act-help) +(label "material 6") +(x 6.5) +(y 2) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m5") +(prop help creator:user-act-help) +(label "material 5") +(x 6.5) +(y 2.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m4") +(prop help creator:user-act-help) +(label "material 4") +(x 6.5) +(y 3) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m3") +(prop help creator:user-act-help) +(label "material 3") +(x 6.5) +(y 3.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m2") +(prop help creator:user-act-help) +(label "material 2") +(x 6.5) +(y 4) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "m1") +(prop help creator:user-act-help) +(label "material 1") +(x 6.5) +(y 4.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "diffB") +(prop help creator:user-act-help) +(label "B") +(y 3.5) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "diffG") +(prop help creator:user-act-help) +(label "G") +(y 4) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "diffR") +(prop help creator:user-act-help) +(label "R") +(y 4.5) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "specB") +(prop help creator:user-act-help) +(label "B") +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "specG") +(prop help creator:user-act-help) +(label "G") +(y 0.5) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "specR") +(prop help creator:user-act-help) +(label "R") +(y 1) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +(pnl_filled_hslider (name "shine") +(prop help creator:user-act-help) +(label "shininess") +(y 2.25) +(w 3.3) +(h 0.4) +(labeltype 0) +(downfunc move-then-resize) +) +) +) +;;; Local Variables: +;;; mode: scheme +;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3)) +;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")")) +;;; eval: (indent-region (point-min) (point-max) nil) +;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer)) +;;; End: diff --git a/demo/sgi/gl_panel/flying/objdict.py b/demo/sgi/gl_panel/flying/objdict.py new file mode 100644 index 0000000..a5d5371 --- /dev/null +++ b/demo/sgi/gl_panel/flying/objdict.py @@ -0,0 +1,41 @@ + +from data import * + +# +#the color light-blue +# +LightBlue = lightblue + +# the 'object' dictionary contains the strings of the menu items +# that denote the objects +objects = {} + +# object dictionary initialization +objects['sphere'] = [ZERO, o1] +objects['cylinder'] = [ZERO, o2] +objects['cube'] = [ONE, o3] +objects['icecream'] = [ZERO, o4] +objects['disk'] = [ZERO, o5] +objects['diamond'] = [ZERO, o6] +#objects['glass'] = [ZERO] +objects['pyramid'] = [ZERO, o7] +objects['table'] = [ZERO, o8] + +# 'putDict' sets the value of entry 'key' of dictionary 'dict' +def putDict(dict, key, val) : + dict[key][0] = val + +# +# 'getDict' get the contents of entry i of key 'key' +# of dictionary 'dict' +# +def getDict(dict, key, i) : + return dict[key][i] + +# the 'options' dictionary contains the strings of the menu items +# that denote the options +options = {} + +# option dictionary initialization +options['wire'] = [ZERO] +options['filled'] = [ONE] diff --git a/demo/sgi/gl_panel/flying/objectdef.py b/demo/sgi/gl_panel/flying/objectdef.py new file mode 100644 index 0000000..3e96113 --- /dev/null +++ b/demo/sgi/gl_panel/flying/objectdef.py @@ -0,0 +1,147 @@ +from math import * +from objdict import * +from gl import * + +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 + +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) + +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) + +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) + +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) + + +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) + +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 + + +renderfuncs = [bgnpolygon, endpolygon] + +def putFunc (funcs) : + renderfuncs [:] = funcs + +def drawobject (obj) : + # + for patch in obj : + renderfuncs[0] () + vnarray (patch) + renderfuncs[1] () + diff --git a/demo/sgi/gl_panel/flying/panel.s b/demo/sgi/gl_panel/flying/panel.s new file mode 100644 index 0000000..2365a76 --- /dev/null +++ b/demo/sgi/gl_panel/flying/panel.s @@ -0,0 +1,76 @@ +;;; This file was automatically generated by the panel editor. +;;; If you read it into gnu emacs, it will automagically format itself. + +(panel (prop help creator:user-panel-help) +(prop user-panel #t) +(label "Panel Control") +(x 394) +(y 622) +(al (pnl_radio_button (name "button4") +(prop help creator:user-act-help) +(y 2.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "button3") +(prop help creator:user-act-help) +(y 3) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "button2") +(prop help creator:user-act-help) +(y 3.5) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_radio_button (name "button1") +(prop help creator:user-act-help) +(y 4) +(h 0.36) +(downfunc move-then-resize) +) +(pnl_wide_button (name "title1") +(prop help creator:user-act-help) +(x 0.75) +(y 4.75) +(w 2.44) +(downfunc move-then-resize) +) +(pnl_wide_button (name "title2") +(prop help creator:user-act-help) +(x 3.5) +(y 4.75) +(w 2.44) +(downfunc move-then-resize) +) +(pnl_wide_button (name "title3") +(prop help creator:user-act-help) +(x 6.25) +(y 4.75) +(w 2.44) +(downfunc move-then-resize) +) +(pnl_wide_button (name "title4") +(prop help creator:user-act-help) +(x 9) +(y 4.75) +(w 2.44) +(downfunc move-then-resize) +) +(pnl_button (name "root") +(prop help creator:user-act-help) +(label "R") +(y 4.75) +(labeltype 16) +(downfunc move-then-resize) +) +) +) +;;; Local Variables: +;;; mode: scheme +;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3)) +;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")")) +;;; eval: (indent-region (point-min) (point-max) nil) +;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer)) +;;; End: |
