Date: 2023/02/22 22:07:06 UTC-08:00
Type: Denizen Script
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
icosphere:
type: procedure
debug: false
definitions: subdivisions
script:
- define lookup <map>
- define verts:->:<static[<location[-1,1.618033988749895,0].normalize>]>
- define verts:->:<static[<location[1,1.618033988749895,0].normalize>]>
- define verts:->:<static[<location[-1,-1.618033988749895,0].normalize>]>
- define verts:->:<static[<location[1,-1.618033988749895,0].normalize>]>
- define verts:->:<static[<location[0,-1,1.618033988749895].normalize>]>
- define verts:->:<static[<location[0,1,1.618033988749895].normalize>]>
- define verts:->:<static[<location[0,-1,-1.618033988749895].normalize>]>
- define verts:->:<static[<location[0,1,-1.618033988749895].normalize>]>
- define verts:->:<static[<location[1.618033988749895,0,-1].normalize>]>
- define verts:->:<static[<location[1.618033988749895,0,1].normalize>]>
- define verts:->:<static[<location[-1.618033988749895,0,-1].normalize>]>
- define verts:->:<static[<location[-1.618033988749895,0,1].normalize>]>
- define faces:->:<static[<list[1|12|6]>]>
- define faces:->:<static[<list[1|6|2]>]>
- define faces:->:<static[<list[1|2|8]>]>
- define faces:->:<static[<list[1|8|11]>]>
- define faces:->:<static[<list[1|11|12]>]>
- define faces:->:<static[<list[2|6|10]>]>
- define faces:->:<static[<list[6|12|5]>]>
- define faces:->:<static[<list[12|11|3]>]>
- define faces:->:<static[<list[11|8|7]>]>
- define faces:->:<static[<list[8|2|9]>]>
- define faces:->:<static[<list[4|10|5]>]>
- define faces:->:<static[<list[4|5|3]>]>
- define faces:->:<static[<list[5|3|7]>]>
- define faces:->:<static[<list[4|7|9]>]>
- define faces:->:<static[<list[4|9|10]>]>
- define faces:->:<static[<list[5|10|6]>]>
- define faces:->:<static[<list[3|5|12]>]>
- define faces:->:<static[<list[7|3|11]>]>
- define faces:->:<static[<list[9|7|8]>]>
- define faces:->:<static[<list[10|9|2]>]>
- repeat <[subdivisions]>:
- define face_subdivisions <list>
- foreach <[faces]> as:triangle:
- define new_verts <list>
- foreach 1,2|2,3|3,1 as:tuple:
- define indices <[tuple].split[,]>
- define i1 <[triangle].get[<[indices].first>]>
- define i2 <[triangle].get[<[indices].last>]>
- define min <[i1].min[<[i2]>]>
- define max <[i1].max[<[i2]>]>
- define key <[min]>_<[max]>
- if not <[lookup.<[key]>].exists>:
- define verts:->:<proc[midpoint].context[a=<[verts].get[<[min]>]>;b=<[verts].get[<[max]>]>].normalize>
- define lookup.<[key]>:<[verts].size>
- define new_verts:->:<[lookup.<[key]>]>
- define face_subdivisions:->:<list[<[triangle].get[1]>|<[new_verts].get[1]>|<[new_verts].get[3]>]>
- define face_subdivisions:->:<list[<[triangle].get[2]>|<[new_verts].get[2]>|<[new_verts].get[1]>]>
- define face_subdivisions:->:<list[<[triangle].get[3]>|<[new_verts].get[3]>|<[new_verts].get[2]>]>
- define face_subdivisions:->:<list[<[new_verts].get[1]>|<[new_verts].get[2]>|<[new_verts].get[3]>]>
- define faces <[face_subdivisions]>
- determine <[verts]>