3 # Rotate a 3D surface created using NURBS.
5 # Press left mouse button to toggle surface trimming.
8 # See the GL manual for an explanation of NURBS.
18 idmat
= [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
20 surfknots
= [-1, -1, -1, -1, 1, 1, 1, 1]
26 ci
.append(-2.5, -3.7, 1.0)
27 ci
.append(-1.5, -3.7, 3.0)
28 ci
.append(1.5, -3.7, -2.5)
29 ci
.append(2.5, -3.7, -0.75)
33 ci
.append(-2.5, -2.0, 3.0)
34 ci
.append(-1.5, -2.0, 4.0)
35 ci
.append(1.5, -2.0, -3.0)
36 ci
.append(2.5, -2.0, 0.0)
40 ci
.append(-2.5, 2.0, 1.0)
41 ci
.append(-1.5, 2.0, 0.0)
42 ci
.append(1.5, 2.0, -1.0)
43 ci
.append(2.5, 2.0, 2.0)
47 ci
.append(-2.5, 2.7, 1.25)
48 ci
.append(-1.5, 2.7, 0.1)
49 ci
.append(1.5, 2.7, -0.6)
50 ci
.append(2.5, 2.7, 0.2)
55 ctlpoints
= make_ctlpoints()
57 trimknots
= [0., 0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 4.]
59 def make_trimpoints():
61 c
.append(1.0, 0.0, 1.0)
62 c
.append(1.0, 1.0, 1.0)
63 c
.append(0.0, 2.0, 2.0)
64 c
.append(-1.0, 1.0, 1.0)
65 c
.append(-1.0, 0.0, 1.0)
66 c
.append(-1.0, -1.0, 1.0)
67 c
.append(0.0, -2.0, 2.0)
68 c
.append(1.0, -1.0, 1.0)
69 c
.append(1.0, 0.0, 1.0)
72 trimpoints
= make_trimpoints()
81 setnurbsproperty( N_ERRORCHECKING
, 1.0 )
82 setnurbsproperty( N_PIXEL_TOLERANCE
, 50.0 )
84 draw_trim_surface(trim_flag
)
92 dglclose(-1) # this for DGL only
97 draw_trim_surface(trim_flag
)
98 elif dev
== LEFTMOUSE
:
100 trim_flag
= (not trim_flag
)
102 draw_trim_surface(trim_flag
)
106 #prefposition(0, 500, 0, 500)
107 wid
= winopen('nurbs')
108 wintitle('NURBS Surface')
112 lsetdepth(0x000, 0x7fffff)
120 qdevice(LEFTMOUSE
) #trimming
124 ortho( -4., 4., -4., 4., -4., 4. )
133 RGBcolor(150,150,150)
141 def draw_trim_surface(trim_flag
):
143 nurbssurface(surfknots
, surfknots
, ctlpoints
, ORDER
, ORDER
, N_XYZ
)
146 nurbscurve(trimknots
, trimpoints
, ORDER
-1, N_STW
)
152 lmdef(DEFLMODEL
,1,[])
158 a
= a
+ [EMISSION
, 0.0, 0.0, 0.0]
159 a
= a
+ [AMBIENT
, 0.1, 0.1, 0.1]
160 a
= a
+ [DIFFUSE
, 0.6, 0.3, 0.3]
161 a
= a
+ [SPECULAR
, 0.0, 0.6, 0.0]
162 a
= a
+ [SHININESS
, 2.0]
164 lmdef(DEFMATERIAL
, 1, a
)