Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
24263314
Kaydet (Commit)
24263314
authored
Ara 14, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Unknown changes by Jack.
üst
05e46dde
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
61 deletions
+41
-61
kunst.py
Demo/sgi/gl/kunst.py
+41
-61
No files found.
Demo/sgi/gl/kunst.py
Dosyayı görüntüle @
24263314
#!
/ufs/guido/bin/sgi
/python
#!
/usr/local/bin
/python
# Simulate the artwork in the hall.
# Simulate the artwork in the hall.
# Jack Jansen, Feb 91.
# Jack Jansen, Feb 91.
#
# Please please please don't try to read this code.
# It is the first GL program I ever wrote, and used to do
# very different things before it's current function:-)
from
gl
import
*
from
gl
import
*
from
GL
import
*
from
GL
import
*
from
math
import
*
from
math
import
*
...
@@ -197,6 +194,7 @@ def axis():
...
@@ -197,6 +194,7 @@ def axis():
v3f
(
0.1
,
0.1
,
1.0
)
v3f
(
0.1
,
0.1
,
1.0
)
endline
()
endline
()
#
#
green_velvet
=
[
DIFFUSE
,
0.05
,
0.4
,
0.05
,
LMNULL
]
silver
=
[
DIFFUSE
,
0.3
,
0.3
,
0.3
,
SPECULAR
,
0.9
,
0.9
,
0.95
,
\
silver
=
[
DIFFUSE
,
0.3
,
0.3
,
0.3
,
SPECULAR
,
0.9
,
0.9
,
0.95
,
\
SHININESS
,
40.0
,
LMNULL
]
SHININESS
,
40.0
,
LMNULL
]
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
]
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,26 +210,23 @@ floor1light = [ LCOLOR, 1.0, 1.0, 1.0, POSITION, 3.9, -3.9, 0.0, 1.0, \
...
@@ -212,26 +210,23 @@ floor1light = [ LCOLOR, 1.0, 1.0, 1.0, POSITION, 3.9, -3.9, 0.0, 1.0, \
lmodel
=
[
AMBIENT
,
0.92
,
0.8
,
0.5
,
LOCALVIEWER
,
1.0
,
LMNULL
]
lmodel
=
[
AMBIENT
,
0.92
,
0.8
,
0.5
,
LOCALVIEWER
,
1.0
,
LMNULL
]
#
#
def
lighting
():
def
lighting
():
INDIGO
=
1
# XXXX Seems indigo only has one light.
lmdef
(
DEFMATERIAL
,
1
,
green_velvet
)
lmdef
(
DEFMATERIAL
,
2
,
silver
)
lmdef
(
DEFMATERIAL
,
2
,
silver
)
lmdef
(
DEFMATERIAL
,
3
,
floormat
)
lmdef
(
DEFMATERIAL
,
3
,
floormat
)
lmdef
(
DEFMATERIAL
,
4
,
wallmat
)
lmdef
(
DEFMATERIAL
,
4
,
wallmat
)
lmdef
(
DEFMATERIAL
,
5
,
offwhite
)
lmdef
(
DEFMATERIAL
,
5
,
offwhite
)
lmdef
(
DEFMATERIAL
,
6
,
doormat
)
lmdef
(
DEFMATERIAL
,
6
,
doormat
)
lmdef
(
DEFLIGHT
,
1
,
toplight
)
lmdef
(
DEFLIGHT
,
1
,
toplight
)
if
not
INDIGO
:
lmdef
(
DEFLIGHT
,
2
,
floor1light
)
lmdef
(
DEFLIGHT
,
2
,
floor1light
)
lmdef
(
DEFLMODEL
,
1
,
lmodel
)
lmdef
(
DEFLMODEL
,
1
,
lmodel
)
lmbind
(
MATERIAL
,
1
)
lmbind
(
LIGHT0
,
1
)
lmbind
(
LIGHT0
,
1
)
if
not
INDIGO
:
lmbind
(
LIGHT1
,
2
)
lmbind
(
LIGHT1
,
2
)
lmbind
(
LMODEL
,
1
)
lmbind
(
LMODEL
,
1
)
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
]
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
]
#
#
wrongrange
=
'Wrong Range'
def
defun
(
axis
):
def
defun
(
axis
):
done
=
0
done
=
0
res
=
0.0
# Hack around exec(...)
while
not
done
:
while
not
done
:
print
'F'
+
axis
+
'(t) = '
,
print
'F'
+
axis
+
'(t) = '
,
s
=
sys
.
stdin
.
readline
(
100
)
s
=
sys
.
stdin
.
readline
(
100
)
...
@@ -239,24 +234,12 @@ def defun(axis):
...
@@ -239,24 +234,12 @@ def defun(axis):
try
:
try
:
s
=
'def f'
+
axis
+
'(t): return '
+
s
s
=
'def f'
+
axis
+
'(t): return '
+
s
exec
(
s
,
main_dict
)
exec
(
s
,
main_dict
)
exec
(
'res = f'
+
axis
+
'(0.0)
\n
'
)
if
res
<
-
10.0
or
res
>
10.0
:
raise
wrongrange
exec
(
'res = f'
+
axis
+
'(100.0)
\n
'
)
if
res
<
-
10.0
or
res
>
10.0
:
raise
wrongrange
done
=
1
done
=
1
except
RuntimeError
:
except
RuntimeError
:
print
'Sorry, there is a syntax error in your expression'
print
'Sorry, there is a syntax error in your expression'
except
TypeError
:
print
'Please remember to use floating point numbers'
except
wrongrange
:
print
'Sorry, function values out of range (non-periodic function?)'
def
getfunctions
():
def
getfunctions
():
print
'Welcome to the CWI art simulator. You can now enter X, Y and Z'
print
'Welcome to the CWI art simulator. You can now enter X, Y and Z'
print
'coordinates as a function of t.'
print
'coordinates as a function of t.'
print
'Alternatively, you can specify the name of a python module'
print
'defining functions fx(t), fy(t) and fz(t) on the command line'
print
'Normal trig functions are available. Please use floating point'
print
'Normal trig functions are available. Please use floating point'
print
'values only (so 0.0 for 0). Comments to jack@cwi.nl'
print
'values only (so 0.0 for 0). Comments to jack@cwi.nl'
defun
(
'x'
)
defun
(
'x'
)
...
@@ -265,10 +248,7 @@ def getfunctions():
...
@@ -265,10 +248,7 @@ def getfunctions():
print
'Ok, here you go. Use mouse+right button to move up/down,'
print
'Ok, here you go. Use mouse+right button to move up/down,'
print
'mouse+middle to speed up/slow down time. type ESC to quit simulation'
print
'mouse+middle to speed up/slow down time. type ESC to quit simulation'
def
main
():
def
main
():
if
len
(
sys
.
argv
)
>
1
:
getfunctions
()
exec
(
'from '
+
sys
.
argv
[
1
]
+
' import *
\n
'
)
else
:
getfunctions
()
foreground
()
foreground
()
prefposition
(
100
,
600
,
100
,
600
)
prefposition
(
100
,
600
,
100
,
600
)
void
=
winopen
(
'cyl'
)
void
=
winopen
(
'cyl'
)
...
@@ -281,15 +261,15 @@ def main():
...
@@ -281,15 +261,15 @@ def main():
gconfig
()
gconfig
()
zbuffer
(
1
)
zbuffer
(
1
)
mmode
(
MVIEWING
)
mmode
(
MVIEWING
)
perspective
(
600
,
1.0
,
0.01
,
20.0
)
perspective
(
400
,
1.0
,
1.0
,
20.0
)
loadmatrix
(
IdMat
)
loadmatrix
(
IdMat
)
vx
=
0.0
vx
=
0.0
vy
=
-
3.9
vy
=
-
6.0
vz
=
0.0
vz
=
0.0
lookat
(
0.0
,
-
3.9
,
0.0
,
0.0
,
0.0
,
0.0
,
0
)
lookat
(
0.0
,
-
6.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0
)
lighting
()
lighting
()
t
=
-
1.0
t
=
-
1.0
step
=
0.2
step
=
1.0
bol
=
mkcyl
(
12
,
24
,
1
)
bol
=
mkcyl
(
12
,
24
,
1
)
cable
=
mkcyl
(
1
,
6
,
0
)
cable
=
mkcyl
(
1
,
6
,
0
)
floors
=
drawfloors
()
floors
=
drawfloors
()
...
@@ -313,7 +293,7 @@ def main():
...
@@ -313,7 +293,7 @@ def main():
elif
(
dev
==
MOUSE1
or
dev
==
MOUSE2
)
and
value
==
1
:
elif
(
dev
==
MOUSE1
or
dev
==
MOUSE2
)
and
value
==
1
:
if
mousing
>
0
:
if
mousing
>
0
:
vx
=
0.0
vx
=
0.0
vy
=
-
3.9
vy
=
-
6.0
vz
=
0.0
vz
=
0.0
mousing
=
dev
mousing
=
dev
oldx
=
getvaluator
(
MOUSEX
)
oldx
=
getvaluator
(
MOUSEX
)
...
@@ -325,10 +305,8 @@ def main():
...
@@ -325,10 +305,8 @@ def main():
newy
=
getvaluator
(
MOUSEY
)
newy
=
getvaluator
(
MOUSEY
)
if
newy
<>
oldy
and
mousing
==
MOUSE1
:
if
newy
<>
oldy
and
mousing
==
MOUSE1
:
vz
=
vz
+
float
(
newy
-
oldy
)
/
100.0
vz
=
vz
+
float
(
newy
-
oldy
)
/
100.0
if
vz
<
-
5.99
:
vz
=
-
5.99
dist
=
sqrt
(
vx
*
vx
+
vy
*
vy
+
vz
*
vz
)
dist
=
sqrt
(
vx
*
vx
+
vy
*
vy
+
vz
*
vz
)
perspective
(
600
,
1.0
,
0.01
,
dist
+
16.0
)
perspective
(
400
,
1.0
,
1.0
,
dist
+
16.0
)
loadmatrix
(
IdMat
)
loadmatrix
(
IdMat
)
if
vz
<
0.0
:
if
vz
<
0.0
:
lookat
(
vx
,
vy
,
vz
,
0.0
,
0.0
,
0.0
,
1800
)
lookat
(
vx
,
vy
,
vz
,
0.0
,
0.0
,
0.0
,
1800
)
...
@@ -346,28 +324,11 @@ def main():
...
@@ -346,28 +324,11 @@ def main():
shademodel
(
FLAT
)
shademodel
(
FLAT
)
#
#
# Draw background and axis
# Draw background and axis
czclear
(
0x802020
,
getgdesc
(
GD_ZMAX
))
cpack
(
0x105090
)
#axis()
clear
()
#
zclear
()
# draw the floors
cpack
(
0x905010
)
#
axis
()
lmbind
(
MATERIAL
,
3
)
callobj
(
floors
)
lmbind
(
MATERIAL
,
4
)
callobj
(
walls
)
lmbind
(
MATERIAL
,
5
)
pushmatrix
()
translate
(
-
4.5
,
4.5
,
3.0
)
scale
(
0.2
,
0.2
,
9.0
)
rotate
(
450
,
'z'
)
callobj
(
pillar
)
popmatrix
()
callobj
(
railing
)
lmbind
(
MATERIAL
,
6
)
pushmatrix
()
translate
(
0.0
,
-
0.01
,
0.0
)
callobj
(
doors
)
popmatrix
()
#
#
# Draw object
# Draw object
#
#
...
@@ -386,16 +347,14 @@ def main():
...
@@ -386,16 +347,14 @@ def main():
translate
(
bolx
,
boly
,
bolz
)
translate
(
bolx
,
boly
,
bolz
)
scale
(
0.3
,
0.3
,
0.3
)
scale
(
0.3
,
0.3
,
0.3
)
lmbind
(
MATERIAL
,
2
)
lmbind
(
MATERIAL
,
2
)
blendfunction
(
BF_ONE
,
BF_ONE
)
callobj
(
bol
)
callobj
(
bol
)
blendfunction
(
BF_ONE
,
BF_ZERO
)
popmatrix
()
popmatrix
()
#
#
# Draw the cables
# Draw the cables
#
#
bolz
=
bolz
+
0.3
bolz
=
bolz
+
0.3
pushmatrix
()
pushmatrix
()
#
linesmooth(SML_ON)
linesmooth
(
SML_ON
)
bgnline
()
bgnline
()
v3i
(
-
4
,
-
4
,
9
)
v3i
(
-
4
,
-
4
,
9
)
v3f
(
bolx
,
boly
,
bolz
)
v3f
(
bolx
,
boly
,
bolz
)
...
@@ -413,6 +372,26 @@ def main():
...
@@ -413,6 +372,26 @@ def main():
v3f
(
bolx
,
boly
,
bolz
)
v3f
(
bolx
,
boly
,
bolz
)
endline
()
endline
()
popmatrix
()
popmatrix
()
#
# draw the floors
#
lmbind
(
MATERIAL
,
3
)
callobj
(
floors
)
lmbind
(
MATERIAL
,
4
)
callobj
(
walls
)
lmbind
(
MATERIAL
,
5
)
pushmatrix
()
translate
(
-
4.5
,
4.5
,
3.0
)
scale
(
0.2
,
0.2
,
9.0
)
rotate
(
450
,
'z'
)
callobj
(
pillar
)
popmatrix
()
callobj
(
railing
)
lmbind
(
MATERIAL
,
6
)
pushmatrix
()
translate
(
0.0
,
-
0.01
,
0.0
)
callobj
(
doors
)
popmatrix
()
if
mousing
==
MOUSE2
or
err
:
if
mousing
==
MOUSE2
or
err
:
cpack
(
0xff0000
)
cpack
(
0xff0000
)
cmov
(
0.0
,
0.0
,
0.4
)
cmov
(
0.0
,
0.0
,
0.4
)
...
@@ -424,6 +403,7 @@ def main():
...
@@ -424,6 +403,7 @@ def main():
if
err
:
if
err
:
cpack
(
0xff00
)
cpack
(
0xff00
)
cmov
(
0.0
,
0.0
,
0.2
)
cmov
(
0.0
,
0.0
,
0.2
)
print
err
charstr
(
err
)
charstr
(
err
)
pausing
=
1
pausing
=
1
if
pausing
:
if
pausing
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment