Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2426331

Browse files
committed
Unknown changes by Jack.
1 parent 05e46dd commit 2426331

1 file changed

Lines changed: 41 additions & 61 deletions

File tree

Demo/sgi/gl/kunst.py

Lines changed: 41 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#!/ufs/guido/bin/sgi/python
1+
#! /usr/local/bin/python
22
# Simulate the artwork in the hall.
33
# Jack Jansen, Feb 91.
4-
#
5-
# Please please please don't try to read this code.
6-
# It is the first GL program I ever wrote, and used to do
7-
# very different things before it's current function:-)
4+
85
from gl import *
96
from GL import *
107
from math import *
@@ -197,6 +194,7 @@ def axis():
197194
v3f(0.1,0.1,1.0)
198195
endline()
199196
#
197+
green_velvet = [ DIFFUSE, 0.05, 0.4, 0.05, LMNULL]
200198
silver = [ DIFFUSE, 0.3, 0.3, 0.3, SPECULAR, 0.9, 0.9, 0.95, \
201199
SHININESS, 40.0, LMNULL]
202200
floormat = [ AMBIENT, 0.5, 0.25, 0.15, DIFFUSE, 0.5, 0.25, 0.15, SPECULAR, 0.6, 0.3, 0.2, SHININESS, 20.0, LMNULL]
@@ -212,51 +210,36 @@ def axis():
212210
lmodel = [ AMBIENT, 0.92, 0.8, 0.5, LOCALVIEWER, 1.0, LMNULL]
213211
#
214212
def lighting():
215-
INDIGO=1 # XXXX Seems indigo only has one light.
213+
lmdef(DEFMATERIAL, 1, green_velvet)
216214
lmdef(DEFMATERIAL, 2, silver)
217215
lmdef(DEFMATERIAL, 3, floormat)
218216
lmdef(DEFMATERIAL, 4, wallmat)
219217
lmdef(DEFMATERIAL, 5, offwhite)
220218
lmdef(DEFMATERIAL, 6, doormat)
221219
lmdef(DEFLIGHT, 1, toplight)
222-
if not INDIGO:
223-
lmdef(DEFLIGHT, 2, floor1light)
220+
lmdef(DEFLIGHT, 2, floor1light)
224221
lmdef(DEFLMODEL, 1, lmodel)
222+
lmbind(MATERIAL, 1)
225223
lmbind(LIGHT0, 1)
226-
if not INDIGO:
227-
lmbind(LIGHT1, 2)
224+
lmbind(LIGHT1, 2)
228225
lmbind(LMODEL, 1)
229226
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]
230227
#
231-
wrongrange='Wrong Range'
232228
def defun(axis):
233229
done = 0
234-
res = 0.0 # Hack around exec(...)
235230
while not done:
236231
print 'F'+axis+'(t) = ',
237232
s = sys.stdin.readline(100)
238233
print
239234
try:
240235
s = 'def f'+axis+'(t): return '+s
241236
exec(s, main_dict)
242-
exec('res = f'+axis+'(0.0)\n')
243-
if res < -10.0 or res > 10.0:
244-
raise wrongrange
245-
exec('res = f'+axis+'(100.0)\n')
246-
if res < -10.0 or res > 10.0:
247-
raise wrongrange
248237
done = 1
249238
except RuntimeError:
250239
print 'Sorry, there is a syntax error in your expression'
251-
except TypeError:
252-
print 'Please remember to use floating point numbers'
253-
except wrongrange:
254-
print 'Sorry, function values out of range (non-periodic function?)'
255240
def getfunctions():
256241
print 'Welcome to the CWI art simulator. You can now enter X, Y and Z'
257242
print 'coordinates as a function of t.'
258-
print 'Alternatively, you can specify the name of a python module'
259-
print 'defining functions fx(t), fy(t) and fz(t) on the command line'
260243
print 'Normal trig functions are available. Please use floating point'
261244
print 'values only (so 0.0 for 0). Comments to [email protected]'
262245
defun('x')
@@ -265,10 +248,7 @@ def getfunctions():
265248
print 'Ok, here you go. Use mouse+right button to move up/down,'
266249
print 'mouse+middle to speed up/slow down time. type ESC to quit simulation'
267250
def main():
268-
if len(sys.argv) > 1:
269-
exec('from '+sys.argv[1]+' import *\n')
270-
else:
271-
getfunctions()
251+
getfunctions()
272252
foreground()
273253
prefposition(100,600,100,600)
274254
void = winopen('cyl')
@@ -281,15 +261,15 @@ def main():
281261
gconfig()
282262
zbuffer(1)
283263
mmode(MVIEWING)
284-
perspective(600, 1.0, 0.01, 20.0)
264+
perspective(400, 1.0, 1.0, 20.0)
285265
loadmatrix(IdMat)
286266
vx = 0.0
287-
vy = -3.9
267+
vy = -6.0
288268
vz = 0.0
289-
lookat(0.0, -3.9, 0.0, 0.0, 0.0, 0.0, 0)
269+
lookat(0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0)
290270
lighting()
291271
t = -1.0
292-
step = 0.2
272+
step = 1.0
293273
bol = mkcyl(12,24, 1)
294274
cable = mkcyl(1, 6, 0)
295275
floors = drawfloors()
@@ -313,7 +293,7 @@ def main():
313293
elif (dev==MOUSE1 or dev==MOUSE2) and value == 1:
314294
if mousing > 0:
315295
vx = 0.0
316-
vy = -3.9
296+
vy = -6.0
317297
vz = 0.0
318298
mousing = dev
319299
oldx = getvaluator(MOUSEX)
@@ -325,10 +305,8 @@ def main():
325305
newy = getvaluator(MOUSEY)
326306
if newy <> oldy and mousing==MOUSE1:
327307
vz = vz + float(newy - oldy)/100.0
328-
if vz < -5.99:
329-
vz = -5.99
330308
dist = sqrt(vx*vx + vy*vy + vz*vz)
331-
perspective(600, 1.0, 0.01, dist+16.0)
309+
perspective(400, 1.0, 1.0, dist+16.0)
332310
loadmatrix(IdMat)
333311
if vz < 0.0:
334312
lookat(vx, vy, vz, 0.0, 0.0, 0.0, 1800)
@@ -346,28 +324,11 @@ def main():
346324
shademodel(FLAT)
347325
#
348326
# Draw background and axis
349-
czclear(0x802020,getgdesc(GD_ZMAX))
350-
#axis()
351-
#
352-
# draw the floors
353-
#
354-
lmbind(MATERIAL, 3)
355-
callobj(floors)
356-
lmbind(MATERIAL, 4)
357-
callobj(walls)
358-
lmbind(MATERIAL, 5)
359-
pushmatrix()
360-
translate(-4.5,4.5,3.0)
361-
scale(0.2,0.2,9.0)
362-
rotate(450,'z')
363-
callobj(pillar)
364-
popmatrix()
365-
callobj(railing)
366-
lmbind(MATERIAL, 6)
367-
pushmatrix()
368-
translate(0.0, -0.01, 0.0)
369-
callobj(doors)
370-
popmatrix()
327+
cpack(0x105090)
328+
clear()
329+
zclear()
330+
cpack(0x905010)
331+
axis()
371332
#
372333
# Draw object
373334
#
@@ -386,16 +347,14 @@ def main():
386347
translate(bolx, boly, bolz)
387348
scale(0.3, 0.3, 0.3)
388349
lmbind(MATERIAL, 2)
389-
blendfunction(BF_ONE, BF_ONE)
390350
callobj(bol)
391-
blendfunction(BF_ONE, BF_ZERO)
392351
popmatrix()
393352
#
394353
# Draw the cables
395354
#
396355
bolz = bolz + 0.3
397356
pushmatrix()
398-
#linesmooth(SML_ON)
357+
linesmooth(SML_ON)
399358
bgnline()
400359
v3i(-4,-4,9)
401360
v3f(bolx, boly, bolz)
@@ -413,6 +372,26 @@ def main():
413372
v3f(bolx, boly, bolz)
414373
endline()
415374
popmatrix()
375+
#
376+
# draw the floors
377+
#
378+
lmbind(MATERIAL, 3)
379+
callobj(floors)
380+
lmbind(MATERIAL, 4)
381+
callobj(walls)
382+
lmbind(MATERIAL, 5)
383+
pushmatrix()
384+
translate(-4.5,4.5,3.0)
385+
scale(0.2,0.2,9.0)
386+
rotate(450,'z')
387+
callobj(pillar)
388+
popmatrix()
389+
callobj(railing)
390+
lmbind(MATERIAL, 6)
391+
pushmatrix()
392+
translate(0.0, -0.01, 0.0)
393+
callobj(doors)
394+
popmatrix()
416395
if mousing == MOUSE2 or err:
417396
cpack(0xff0000)
418397
cmov(0.0, 0.0, 0.4)
@@ -424,6 +403,7 @@ def main():
424403
if err:
425404
cpack(0xff00)
426405
cmov(0.0, 0.0, 0.2)
406+
print err
427407
charstr(err)
428408
pausing = 1
429409
if pausing:

0 commit comments

Comments
 (0)