-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_template.txt
executable file
·618 lines (526 loc) · 17.2 KB
/
render_template.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#version 3.7;
#include "colors.inc"
#include "metals.inc"
#include "textures.inc"
#include "stones1.inc"
#include "shapesForUse.inc"
//#include "parse.inc"
global_settings {
assumed_gamma 1.0
}
// ----------------------------------------
#declare zoomcam=TEXTZOOMCAM;
#declare camSquareOrtho= camera {
orthographic angle
location <0, 0, -6.0>
direction 1.5*z
right x
up y
look_at <0, 0, 0>
}
#declare camSquareOrthoZoom= camera {
orthographic angle
location <0, 0, -2.0>
direction 1.5*z
right x
up y
look_at <0, 0, 0>
}
#declare cam_4_3_ratio_Perspectiv= camera {
location <0.4, 2.0, -6.0>
direction 1.5*z
right x*4/3
look_at <0.0, -0.01, 0.0>
}
#if(zoomcam=0)
camera{
camSquareOrtho //output file must be square too
}
#end
#if(zoomcam=1)
camera{
camSquareOrthoZoom //output file must be square too
}
#end
#declare userbg=TEXTUSERBG;
#if(userbg=0)
background {Black}
#end
#if(userbg=1)
background {White}
#end
#if(userbg=2)
sky_sphere {
pigment {
gradient y
color_map {
[0.0 color blue 0.6]
[1.0 color rgb 1]
}
}
}
#end
// Behind, up, and to the left of the view
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30,30, -30>
}
// soft light from the right
light_source {
<10, 0, 0> // light's position (pointed below)
color rgb <0.2, 0.2, 0.2> // light's color at .2 intensity
parallel
point_at <0, 0, 0>
}
// very soft light from the back
light_source {
<0, 0, -10> // light's position (pointed below)
color rgb <0.1, 0.1, 0.1> // light's color at .1 intensity
parallel
point_at <0, 0, 0>
}
// This is the shape of the solid
#declare shapeIndex=TEXTSHAPE;
// This is the list of cuts to apply
#declare tasks = array [8][10] {
//a task is done equally on all directions of a regular direction-vector-set
//it is specified by
// 1. symindex ( the direction-vector-set (axle-set) by index)
// 2. dividerValue based on Jaap's Sphere (scope 300 to 0) : depth
// 3. the cone-apex (a float value). there are 5 cases:
//1. under the origin (negative value)
//2. on the origin (0)
//3. between the origin and the divider (value between 0 and depth)
//4. on the divider (cone-apex == depth), planar cut
//5. above the divider (value higher than depth)
// 4. the color of the cut by index
// 5-7 Are the rotations in x,y,z
// 8-10 Are tre translations in x,y,z
//the colums are symindex, dividerValue, coneapex, colorindex, rotx, roty, rotz, tranx, trany, tranz
TEXT_CUT_0,
TEXT_CUT_1,
TEXT_CUT_2,
TEXT_CUT_3,
TEXT_CUT_4,
TEXT_CUT_5,
TEXT_CUT_6,
TEXT_CUT_7,
}
//choose the thickness of the gaps
#declare gth=TEXTCUTWIDTH;
//the orientation of the final main-object is defined here, and applied after all subtractions are done
#declare main_orientation=transform{
rotate <TEXTROTX,TEXTROTY,TEXTROTZ>
}
//colors initially set to the colors used by Jaap for the divider rows
#declare divider_row_colors=array[21] {
color Red, //0
color Green, //1
color Blue, //2
color Yellow, //3
color BlueViolet, //4
color Coral, //5
color MediumTurquoise, //6
color SpringGreen, //7
color Magenta, //8
color Maroon, //9
color YellowGreen, //10
color Orange, //11
color OrangeRed, //12
color SeaGreen, //13
color SummerSky, //14
color NeonBlue, //15
color White, //16
color Black, //17
color MediumSlateBlue, //18
color MediumSpringGreen, //19
color Scarlet, //20
};
//end of the individual configuration
// -------------------------------------------
#macro getShapeMaterial(mtype, mcolor)
#switch (mtype)
#case (0) pigment {mcolor} #break
#case (1) material{
texture{
pigment{mcolor}
finish{
conserve_energy
diffuse 0.6
ambient 0
specular 0.5
roughness 0.05
reflection{0 1 fresnel on metallic 0}
}
}
interior{ior 1.16}
} #break
#case (2) texture{ T_Gold_1C } #break
#case (3) texture{ PinkAlabaster } #break
#case (4) texture{ T_Stone17 } #break
#case (5) texture{ Cherry_Wood scale 0.1} #break
#end
#end
#macro getShapeMaterialPreset(mtype)
#switch (mtype)
#case (0) getShapeMaterial(mtype, White) #break
#case (1) getShapeMaterial(mtype, rgb <0.1, 0.1, 0.1>) #break
#case (2) getShapeMaterial(mtype, 0) #break
#case (3) getShapeMaterial(mtype, 0) #break
#case (4) getShapeMaterial(mtype, 0) #break
#case (5) getShapeMaterial(mtype, 0) #break
#end
#end
#macro getCutMaterial(mtype, mcolor)
#switch (mtype)
#case (0) pigment {mcolor} #break
#case (1) material{
texture{
pigment{mcolor}
finish{
conserve_energy
diffuse 0.6
ambient 0
specular 0.5
roughness 0.05
reflection{0 1 fresnel on metallic 1}
}
}
interior{ior 1.16}
} #break
#case (2) material{
texture{
pigment{mcolor}
finish{
conserve_energy
diffuse 0.6
ambient 0
specular 0.5
roughness 0.05
reflection{0 1 fresnel on metallic 1}
}
}
interior{ior 1.16}
} #break
#case (3) texture{pigment {mcolor} finish {ambient 0.1 diffuse 0.4 reflection{0.5 metallic}}} #break
#case (4) texture{pigment {mcolor} finish {ambient 0.1 diffuse 0.4 reflection{0.5 metallic}}} #break
#case (5) texture{pigment {mcolor} finish {ambient 0.1 diffuse 0.4 reflection{0.5 metallic}}} #break
#end
#end
#declare usermat=TEXTUSERMAT;
#macro getShape(index)
#switch (index)
#case (0) shSphere #break
#case (1) shTet #break
#case (2) shCube #break
#case (3) shOct #break
#case (4) shRhDod #break
#case (5) shDod #break
#case (6) shIco #break
#case (7) shRhTriacon #break
#case (8) shCW #break
#case (9) shDeltIcosi #break
#case (10) shDeltHex #break
#case (11) shTriaTet #break
#case (12) shTetraHex #break
#case (13) shPentIcosiD #break
#case (14) shPentIcosiL #break
#case (15) shDisdyDodeca #break
#case (16) shPentaDodeca #break
#case (17) shTriaIcosa #break
#case (18) shPentHexeD #break
#case (19) shPentHexeL #break
#case (20) shDisdyTria #break
#case (21) shTriDipyra #break
#case (22) shPentDipyra #break
#case (23) shHexDipyra #break
#case (24) shHepDipyra #break
#case (25) shOctDipyra #break
#case (26) shTetraTrapezo #break
#case (27) shPentTrapezo #break
#case (28) shHexTrapezo #break
#case (29) shHeptTrapezo #break
#case (30) shOctTrapezo #break
#case (31) shTrapRhomDod #break
#case (32) shPseuDeltIcosi #break
#case (33) shTrapRhomTria #break
#case (34) shTriPrism #break
#case (35) shPentPrism #break
#case (36) shHexPrism #break
#case (37) shHepPrism #break
#case (38) shOctPrism #break
#case (39) shTruncCube #break
#case (40) shTruncDod #break
#case (41) shCubocto #break
#case (42) shIcosidod #break
#case (43) shTrunctet #break
#case (44) shTruncoct #break
#case (45) shATrunccube #break
#case (46) shRhomCubOct #break
#case (47) shTruncCubOct #break
#case (48) shSnubcubeD #break
#case (49) shSnubcubeL #break
#case (50) shTruncIcosa #break
#case (51) shATruncDod #break
#case (52) shRhombIcosiDod #break
#case (53) shTruncIcosiDod #break
#case (54) shSnubDodD #break
#case (55) shSnubDodL #break
#case (56) shTriPrismSq #break
#case (57) shPentPrismSq #break
#case (58) shHexPrismSq #break
#case (59) shHepPrismSq #break
#case (60) shOctPrismSq #break
#case (61) shSquareAntiPrism #break
#case (62) shPentAntiPrism #break
#case (63) shHexAntiPrism #break
#case (64) shHepAntiPrism #break
#case (65) shOctAntiPrism #break
#end
#end
#declare mainSolid = getShape(shapeIndex)
#declare crosssection = TEXTCROSSSECTION;
// The crosssectional view slices the solid in half through the origin
#if(crosssection = 1)
#declare mainSolid = intersection{object{mainSolid}
plane {<0, 0, -1>, 0}};
#end
#declare mainSolid = object{mainSolid getShapeMaterialPreset(usermat)}
#macro getDirset(dirsetIndex)
#switch (dirsetIndex)
#case (1) dirsTC #break
#case (2) dirsCF #break
#case (3) dirsCC #break
#case (4) dirsCE #break
#case (5) dirsDF #break
#case (6) dirsDC #break
#case (7) dirsDE #break
#case (8) dirsCW #break
#case (9) dirsDeltIcosi #break
#case (10) dirsDeltHex #break
#case (11) dirsTriaTet #break
#case (12) dirsTetraHex #break
#case (13) dirsPentIcosiD #break
#case (14) dirsPentIcosiL #break
#case (15) dirsDisdyDodeca #break
#case (16) dirsPentaDodeca #break
#case (17) dirsTriaIcosa #break
#case (18) dirsPentHexeD #break
#case (19) dirsPentHexeL #break
#case (20) dirsDisdyTria #break
#case (21) dirsTriDipyra #break
#case (22) dirsPentDipyra #break
#case (23) dirsHexDipyra #break
#case (24) dirsHepDipyra #break
#case (25) dirsOctDipyra #break
#case (26) dirsTetraTrapezo #break
#case (27) dirsPentTrapezo #break
#case (28) dirsHexTrapezo #break
#case (29) dirsHeptTrapezo #break
#case (30) dirsOctTrapezo #break
#case (31) dirsTrapRhomDod #break
#case (32) dirsPseuDeltIcosi #break
#case (33) dirsTrapRhomTria #break
#case (34) dirsCutsDihe #break
#case (35) dirsCutsTriPrism #break
#case (36) dirsCutsSquarePrism #break
#case (37) dirsCutsPentPrism #break
#case (38) dirsCutsHexPrism #break
#case (39) dirsCutsHepPrism #break
#case (40) dirsCutsOctPrism #break
#case (41) dirsTF #break
#case (42) dirsSquareAntiPrism #break
#case (43) dirsPentAntiPrism #break
#case (44) dirsHexAntiPrism #break
#case (45) dirsHepAntiPrism #break
#case (46) dirsOctAntiPrism #break
#end
#end
//used for fitting
#declare globalScale = 1.8;
// This scale value is the ratio of the circumscribed sphere to the inscribed sphere
#declare shapeScale = array[66] {
1.0000000000, //0: sphere
0.3333333333, //1: tetrahedron
0.5773502692, //2: cube
0.5773502692, //3: octahedron
0.7071067812, //4: rhombic dodecahedron
0.7946544723, //5: dodecahedron
0.7946544723, //6: icosahedron
0.8506508084, //7: rhombic tricontahedron
0.6785983445, //8: Triakis Octahedron
0.8628562095, //9: Deltoidal Icositetrahedron
0.9245941063, //10: Deltoidal Hexecontahedron
0.5222329679, //11: Triakis Tetrahedron
0.6708203932, //12: Tetrakis Hexahedron
0.8503402074, //13: Pentagonal Icositetrahedron (dextro)
0.8503402074, //14: Pentagonal Icositetrahedron (laveo)
0.8259425910, //15: Disdyakis Dodecahedron
0.9149583817, //16: Pentakis Dodecahedron
0.8385051474, //17: Triakis Icosahedron
0.9188614921, //18: Pentagonal Hexecontahedron (dextro)
0.9188614921, //19: Pentagonal Hexecontahedron (laevo)
0.9049441875, //20: Disdyakis Triacontahedron
0.3779644730, //21: Triangular Dipyramid
0.5067318540, //22: Pentagonal Dipyramid
0.4472135955, //23: Hexagonal Dipyramid
0.3980324968, //24: Heptagonal Dipyramid
0.3574067443, //25: Octagonal Dipyramid
0.5110810845, //26: Tetragonal Trapezohedron
0.4472135955, //27: Pentagonal Trapezohedron
0.3933198932, //28: Hexagonal Trapezohedron
0.3490502193, //29: Heptagonal Trapezohedron
0.3127099914, //30: Octagonal Trapezohedron
0.7071067812, //31: Trapezo-rhombic dodecahedron
0.8628562095, //32: Pseudo-deltoidal icositetrahedron
0.8506508084, //33: Trapezo-Rhombic Triacontahedron
0.4472135955, //34: Triangular Prism
0.6289601696, //35: Pentagonal Prism
0.6546536707, //36: Hexagonal Prism
0.6693623193, //37: Heptagonal Prism
0.6785983445, //38: Octagonal Prism
0.8068982214, //39: Truncated cube
0.9226021945, //40: Truncated Dodecahedron
0.7071067812, //41: Cuboctohedron
0.8506508084, //42: Icosidodecahedron
0.5222329679, //43: Truncated Tetrahedron
0.7745966692, //44: Truncated Octahedron
0.6785983445, //45: Truncated Cube
0.8628562095, //46: Rhombicuboctahedron
0.8259425910, //47: Truncated Cuboctahedron
0.8503402074, //48: Snubecube (dextro)
0.8503402074, //49: Snubecube (laevo)
0.9149583817, //50: Truncated Icosahedron
0.8385051474, //51: Truncated Dodecahedron
0.9245941063, //52: Rhombicosidodecahedron
0.9049441875, //53: Truncated Icosidodecahedron
0.9188614921, //54: Snub Dodecahedron (dextro)
0.9188614921, //55: Snub Dodecahedron (laevo)
0.3779644730, //56: Triangular Prism Square
0.5067318540, //57: Pentagonal Prism Square
0.4472135955, //58: Hexagonal Prism Square
0.3980324968, //59: Heptagonal Prism Square
0.3574067443, //60: Octagonal Prism Square
0.5110810845, //61: Square Antiprism
0.4472135955, //62: Pentagonal Antiprism
0.3933198932, //63: Hexagonal Antiprism
0.3490502193, //64: Heptagonal Antiprism
0.3127099914, //65: Octagonal Antiprism
}
// ------------------------------------------------------
#macro ConeShell (
coneDirection, // a normalized direction from the direction-set
normDiv, // divider value in the range 1 to 0
normApx, // divider value the range 1 to 0
gth) // gap thickness
//at the divider = depth of cut
#local Base_Point = coneDirection * normDiv;
#local Base_Radius = sqrt(1 - (normDiv * normDiv));
//cone vertex
#local Cap_Point = coneDirection * normApx;
//half opening angle
#local hoa = atan(Base_Radius / vlength(Base_Point - Cap_Point));
//offset to gain the gap-thickness
#local offst = gth / sin(hoa);
//make cone big enough
#local scal = 100;
#local coneHeight = Base_Point - Cap_Point;
//Base_Point is translated, Cap_Point is kept
#local Base_Point = coneHeight * scal + Cap_Point;
#local Base_Radius = Base_Radius * scal;
#if (normApx > normDiv )
//for translating the main-cone
#local tr1 = coneDirection * (offst * 0.5);
//for translating the subtrahend-cone
#local tr2 = coneDirection * (offst * -0.5);
#else
//for translating the main-cone
#local tr1 = coneDirection * (offst * -0.5);
//for translating the subtrahend-cone
#local tr2 = coneDirection * (offst * 0.5);
#end
#local Cap_Radius = 0;
//clip cone-cap if it is outside
#if(normApx < 0)
#local Cap_Radius = tan(hoa) * vlength(Cap_Point);
#local Cap_Point = <0, 0, 0>;
#end
#if(normApx > normDiv)
#local Cap_Radius = tan(hoa) * vlength(coneHeight);
#local Cap_Point = Cap_Point + coneHeight;
#end
//cone is plane
#if(normApx = normDiv)
intersection {
plane {coneDirection, 0.999}
cylinder{
Base_Point + tr1,
Base_Point + tr2,
scal
}
}
#else
#local coneobj = cone{
Base_Point, Base_Radius,
Cap_Point, Cap_Radius
}
#if (normApx > normDiv)
// Under extreme circumstances like a depth of
// 299 and apex of 1000 the cone cap can extend
// through the surface beacuse of the translation
// so we need to clip the cone so the cap is always
// inside of the solid
intersection {
plane {coneDirection, (1.0 - (offst * 0.5))}
difference{
object{coneobj translate tr1}
object{coneobj translate tr2}
}
}
#else
difference{
object{coneobj translate tr1}
object{coneobj translate tr2}
}
#end
#end
#end
#macro subtract(dirsetIndex, dividerValue, coneApex, colIndex, rotx, roty, rotz, tranx, trany, tranz)
#local dirset = getDirset(dirsetIndex)
#local dirset_size = dimension_size(dirset,1);
// divider-value in range 1 to 0
#local normDiv = dividerValue / 300.0;
#local normApx = coneApex / 300.0;
#local i = 0;
#while (i < dirset_size) // for each dirset axis
#local dset=dirset[i];
#local subtrahendSolid = ConeShell(dirset[i], normDiv, normApx, gth)
#local subtrahendSolid = object{subtrahendSolid rotate<rotx, roty, rotz>}
#local subtrahendSolid = object{subtrahendSolid translate<tranx, trany, tranz>}
// here the cone shell is subtracted from the mainSolid
#declare mainSolid=
difference{
object{mainSolid}
object{subtrahendSolid
getCutMaterial(usermat, divider_row_colors[colIndex])}
};
#local i = i + 1;
#end
#end
// This routine iterates through the tasks and does the cutting
#declare i = 0;
#while(i < dimension_size(tasks,1))
#if (tasks[i][1] >= 0) // Skip if -1
subtract(tasks[i][0], tasks[i][1], tasks[i][2], tasks[i][3],
tasks[i][4], tasks[i][5], tasks[i][6], // rotations
tasks[i][7], tasks[i][8], tasks[i][9]) // translations
#end
#declare i = i + 1;
#end
// show mainSolid
object {
mainSolid
scale ((shapeScale [shapeIndex]) * globalScale)
transform{main_orientation} // This is where shape rotation happens
}