Import Upstream version 20180207
[hcoop/debian/mlton.git] / benchmark / tests / DATA / chess.gml
1 % chess.gml
2 %
3 % OUTPUTS: chess.ppm
4 %
5 %%%
6 %%% Author:
7 %%% Leif Kornstaedt <kornstae@ps.uni-sb.de>
8 %%%
9 %%% Copyright:
10 %%% Leif Kornstaedt, 2000
11 %%%
12 %%% Last change:
13 %%% $Date: 2000/09/04 22:34:00 $ by $Author: kornstae $
14 %%% $Revision: 1.6 $
15 %%%
16
17 { /y /x x x mulf y y mulf addf sqrt } /dist
18
19 0.2 0.2 0.3 point /black1
20 0.4 0.4 0.5 point /black2
21 0.7 0.7 0.5 point /white1
22 1.0 1.0 0.8 point /white2
23
24 %%
25 %% Surface functions
26 %%
27
28 { /col2 /col1
29 { /v /u /face
30 face 0 eqi
31 { % rotational: stripes according to angle u
32 u 12.0 mulf floor 2 modi 1 eqi { col1 } { col2 } if
33 }
34 { % flat: rays according to angle from origin to (u, v)
35 u 0.5 subf /u v 0.5 subf /v
36 u u v dist apply divf /b
37 0.0 v lessf { b asin } { 360.0 b asin subf } if 180.0 addf 30.0 divf
38 floor 2 modi 1 eqi { col1 } { col2 } if
39 }
40 if
41 0.7 0.3 1.0
42 }
43 } /figureSurface
44
45 %%
46 %% Board
47 %%
48
49 { /v /u /face
50 3 face lessi
51 { % top, bottom: checkered
52 0 u 8.0 mulf floor v 8.0 mulf floor addi
53 }
54 { face 2 modi 0 eqi
55 { 0 } % front, left: striped black/white
56 { 1 } % back, right: striped white/black
57 if u 8.0 mulf floor
58 } if 2 modi eqi { black1 } { white2 } if
59 0.4 0.6 0.5
60 } cube -0.5 -1.0 -0.5 translate 8.0 0.3 8.0 scale /board
61
62 %%
63 %% Pawns
64 %%
65
66 { /col2 /col1
67 col1 col2 figureSurface apply /surface
68 surface sphere 0.0 1.0 0.0 translate
69 surface cylinder union
70 surface sphere 0.0 2.3 0.0 translate difference
71 surface sphere 0.8 uscale 0.0 2.5 0.0 translate union
72 0.3 uscale
73 } /pawn
74
75 white1 white2 pawn apply /whitePawn
76 black1 black2 pawn apply /blackPawn
77
78 %%
79 %% Towers
80 %%
81
82 { /col2 /col1
83 col1 col2 figureSurface apply /surface
84 col1 col1 figureSurface apply /surface1
85 col2 col2 figureSurface apply /surface2
86 % Base
87 surface cylinder 1.0 0.75 1.0 scale
88 % Wall
89 surface cone 0.0 -1.0 0.0 translate 180.0 rotatez 90.0 rotatey
90 1.0 7.5 1.0 scale union
91 surface cylinder 1.0 2.8 1.0 scale intersect
92 % Platform
93 surface cylinder 0.0 3.0 0.0 translate union
94 % Viewholes
95 surface cylinder 0.7 4.0 0.7 scale
96 { /rot
97 surface1 plane 90.0 rotatex
98 surface2 plane -90.0 rotatex 30.0 rotatey intersect rot rotatey
99 } /apex
100 15.0 apex apply 75.0 apex apply union 135.0 apex apply union
101 195.0 apex apply union 255.0 apex apply union 315.0 apex apply union
102 surface cylinder intersect union
103 0.0 3.5 0.0 translate difference
104 0.4 uscale
105 } /tower
106
107 white1 white2 tower apply /whiteTower
108 black1 black2 tower apply /blackTower
109
110 %%
111 %% Knights
112 %%
113
114 { /col2 /col1
115 col1 col2 figureSurface apply /surface
116 % Base
117 surface cylinder 1.0 0.75 1.0 scale
118 % Body
119 surface cone 180.0 rotatez 30.0 rotatey 0.0 1.0 0.0 translate
120 1.0 5.0 1.0 scale
121 surface plane 0.0 3.0 0.0 translate intersect union
122 % Head
123 surface cone 1.0 3.0 1.0 scale 0.0 -1.0 0.0 translate
124 surface cylinder 1.0 2.0 1.0 scale intersect 0.0 -1.5 0.0 translate /head
125 head 1.25 1.0 1.25 scale 0.0 0.5 0.0 translate -90.0 rotatex
126 0.0 3.2 0.0 translate difference
127 head 0.8 1.0 0.8 scale -90.0 rotatex 0.0 3.2 0.0 translate union
128 0.4 uscale
129 } /knight
130
131 white1 white2 knight apply /whiteKnight
132 black1 black2 knight apply 180.0 rotatey /blackKnight
133
134 %%
135 %% Bishops
136 %%
137
138 { /col2 /col1
139 col1 col2 figureSurface apply /surface
140 % Base
141 surface cylinder 1.0 0.75 1.0 scale
142 % Body
143 surface cone 180.0 rotatez 30.0 rotatey 0.0 1.0 0.0 translate
144 1.0 5.0 1.0 scale
145 surface plane 0.0 3.0 0.0 translate intersect union
146 % Head
147 surface sphere 0.9 uscale 0.0 3.15 0.0 translate difference
148 surface sphere 0.8 uscale 0.0 3.25 0.0 translate union
149 0.4 uscale
150 } /bishop
151
152 white1 white2 bishop apply /whiteBishop
153 black1 black2 bishop apply /blackBishop
154
155 %%
156 %% Queens
157 %%
158
159 { /col2 /col1
160 col1 col2 figureSurface apply /surface
161 col1 col1 figureSurface apply /surface1
162 col2 col2 figureSurface apply /surface2
163 % Base
164 surface cylinder 1.0 0.75 1.0 scale
165 % Body
166 surface cone 180.0 rotatez 30.0 rotatey 0.0 1.0 0.0 translate
167 1.0 7.5 1.0 scale
168 surface plane 0.0 4.0 0.0 translate intersect union
169 % Crown
170 38.146 /phi
171 surface cylinder 1.0 2.0 1.0 scale
172 surface1 plane -90.0 phi subf rotatex
173 surface2 plane 90.0 phi addf rotatex intersect
174 -45.0 rotatez 1.0 0.0 0.0 translate /wedge
175 wedge wedge 60.0 rotatey union wedge 120.0 rotatey union
176 wedge 180.0 rotatey union wedge 240.0 rotatey union wedge 300.0 rotatey union
177 0.0 1.0 0.0 translate difference
178 0.6 0.25 0.6 scale 0.0 4.7 0.0 translate union
179 % Head
180 surface sphere 0.9 uscale 0.0 3.9 0.0 translate difference
181 surface sphere 0.8 uscale 0.0 4.0 0.0 translate union
182 0.4 uscale
183 } /queen
184
185 white1 white2 queen apply /whiteQueen
186 black1 black2 queen apply /blackQueen
187
188 %%
189 %% Kings
190 %%
191
192 { /col2 /col1
193 col1 col2 figureSurface apply /surface
194 col1 col1 figureSurface apply /surface1
195 col2 col2 figureSurface apply /surface2
196 % Base
197 surface cylinder 1.0 0.75 1.0 scale
198 % Body
199 surface cone 180.0 rotatez 30.0 rotatey 0.0 1.0 0.0 translate
200 1.0 7.5 1.0 scale
201 surface plane 0.0 4.0 0.0 translate intersect union
202 % Crown
203 38.146 /phi
204 surface cylinder 1.0 2.0 1.0 scale
205 surface1 plane -90.0 phi subf rotatex
206 surface2 plane 90.0 phi addf rotatex intersect
207 -45.0 rotatez 1.0 0.0 0.0 translate /wedge
208 wedge wedge 60.0 rotatey union wedge 120.0 rotatey union
209 wedge 180.0 rotatey union wedge 240.0 rotatey union wedge 300.0 rotatey union
210 0.0 1.0 0.0 translate difference 0.6 0.25 0.6 scale
211 % Scepter
212 surface2 cube 0.1 0.7 0.1 scale
213 surface2 cube 0.6 0.1 0.1 scale -0.25 0.35 0.0 translate union
214 -0.05 0.4 -0.05 translate union
215 0.0 4.7 0.0 translate union
216 % Head
217 surface sphere 0.9 uscale 0.0 3.9 0.0 translate difference
218 surface sphere 0.8 uscale 0.0 4.0 0.0 translate union
219 0.4 uscale
220 } /king
221
222 white1 white2 king apply /whiteKing
223 black1 black2 king apply /blackKing
224
225 %%
226 %% The scene
227 %%
228
229 board
230 whitePawn -3.5 0.0 -2.5 translate union
231 whitePawn -2.5 0.0 -2.5 translate union
232 whitePawn -1.5 0.0 -2.5 translate union
233 whitePawn -0.5 0.0 -2.5 translate union
234 whitePawn 0.5 0.0 -2.5 translate union
235 whitePawn 1.5 0.0 -2.5 translate union
236 whitePawn 2.5 0.0 -2.5 translate union
237 whitePawn 3.5 0.0 -2.5 translate union
238 whiteTower -3.5 0.0 -3.5 translate union
239 whiteTower 3.5 0.0 -3.5 translate union
240 whiteKnight -2.5 0.0 -3.5 translate union
241 whiteKnight 2.5 0.0 -3.5 translate union
242 whiteBishop -1.5 0.0 -3.5 translate union
243 whiteBishop 1.5 0.0 -3.5 translate union
244 whiteQueen -0.5 0.0 -3.5 translate union
245 whiteKing 0.5 0.0 -3.5 translate union
246 blackPawn -3.5 0.0 2.5 translate union
247 blackPawn -2.5 0.0 2.5 translate union
248 blackPawn -1.5 0.0 2.5 translate union
249 blackPawn -0.5 0.0 2.5 translate union
250 blackPawn 0.5 0.0 2.5 translate union
251 blackPawn 1.5 0.0 2.5 translate union
252 blackPawn 2.5 0.0 2.5 translate union
253 blackPawn 3.5 0.0 2.5 translate union
254 blackTower -3.5 0.0 3.5 translate union
255 blackTower 3.5 0.0 3.5 translate union
256 blackKnight -2.5 0.0 3.5 translate union
257 blackKnight 2.5 0.0 3.5 translate union
258 blackBishop -1.5 0.0 3.5 translate union
259 blackBishop 1.5 0.0 3.5 translate union
260 blackQueen -0.5 0.0 3.5 translate union
261 blackKing 0.5 0.0 3.5 translate union
262 30.0 rotatey -20.0 rotatex 0.4 uscale 0.3 0.0 3.0 translate
263
264 %whiteTower -70.0 rotatex 0.0 0.0 4.0 translate
265
266 /scene
267
268 0.0 0.0 -1.0 point
269 1.0 1.0 1.0 point pointlight /l
270
271 0.33 0.33 0.33 point [ l ] scene 3 60.0 400 300 "chess.ppm" render