Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Paste both, and lib_icosphere is the one you want. It only takes one arg, the amount of subdivisions you want (how many times you cut each triangle in half). You have to put a number in, at the very least 0. Has to be a whole number. Gives you a list of points centered around 0,0,0, so you need to move all the points to wherever you want them. Something like .parse_tag[<[loc_where_i_want_them].add[<[parse_value]>]>]
- Also, it's small, so you'll also probably wanna multiply each point's length so that the sphere is bigger.
- lib_icosphere:
- type: procedure
- debug: false
- definitions: subdivisions
- script:
- #Save a reference to points so we can see if we've
- #already included it or not
- - define lookup <map>
- - define phi <element[1].add[<element[5].sqrt>].div[2]>
- - define verts:->:<location[-1,<[phi]>,0].normalize>
- - define verts:->:<location[1,<[phi]>,0].normalize>
- - define verts:->:<location[-1,-<[phi]>,0].normalize>
- - define verts:->:<location[1,-<[phi]>,0].normalize>
- - define verts:->:<location[0,-1,<[phi]>].normalize>
- - define verts:->:<location[0,1,<[phi]>].normalize>
- - define verts:->:<location[0,-1,-<[phi]>].normalize>
- - define verts:->:<location[0,1,-<[phi]>].normalize>
- - define verts:->:<location[<[phi]>,0,-1].normalize>
- - define verts:->:<location[<[phi]>,0,1].normalize>
- - define verts:->:<location[-<[phi]>,0,-1].normalize>
- - define verts:->:<location[-<[phi]>,0,1].normalize>
- - define faces:->:<list[1|12|6]>
- - define faces:->:<list[1|6|2]>
- - define faces:->:<list[1|2|8]>
- - define faces:->:<list[1|8|11]>
- - define faces:->:<list[1|11|12]>
- - define faces:->:<list[2|6|10]>
- - define faces:->:<list[6|12|5]>
- - define faces:->:<list[12|11|3]>
- - define faces:->:<list[11|8|7]>
- - define faces:->:<list[8|2|9]>
- - define faces:->:<list[4|10|5]>
- - define faces:->:<list[4|5|3]>
- - define faces:->:<list[5|3|7]>
- - define faces:->:<list[4|7|9]>
- - define faces:->:<list[4|9|10]>
- - define faces:->:<list[5|10|6]>
- - define faces:->:<list[3|5|12]>
- - define faces:->:<list[7|3|11]>
- - define faces:->:<list[9|7|8]>
- - define faces:->:<list[10|9|2]>
- - repeat <[subdivisions]>:
- - define face_subdivisions <list>
- - foreach <[faces]> as:triangle:
- - definemap args:
- index1: <[triangle].get[1]>
- index2: <[triangle].get[2]>
- lookup: <[lookup]>
- vertices: <[verts]>
- - define res <[args].proc[lib_core_subdivide_triangle]>
- - if <[res].object_type.equals[Element]>:
- - debug log <[args]>
- - debug log <[res]>
- - stop
- - define verts <[res.vertices]>
- - define lookup <[res.lookup]>
- - define v1 <[res.index]>
- - definemap args:
- index1: <[triangle].get[2]>
- index2: <[triangle].get[3]>
- lookup: <[lookup]>
- vertices: <[verts]>
- - define res <[args].proc[lib_core_subdivide_triangle]>
- - define verts <[res.vertices]>
- - define lookup <[res.lookup]>
- - define v2 <[res.index]>
- - definemap args:
- index1: <[triangle].get[3]>
- index2: <[triangle].get[1]>
- lookup: <[lookup]>
- vertices: <[verts]>
- - define res <[args].proc[lib_core_subdivide_triangle]>
- - define verts <[res.vertices]>
- - define lookup <[res.lookup]>
- - define v3 <[res.index]>
- - define face_subdivisions:->:<location[<[triangle].get[1]>,<[v1]>,<[v3]>]>
- - define face_subdivisions:->:<location[<[triangle].get[2]>,<[v2]>,<[v1]>]>
- - define face_subdivisions:->:<location[<[triangle].get[3]>,<[v3]>,<[v2]>]>
- - define face_subdivisions:->:<location[<[v1]>,<[v2]>,<[v3]>]>
- - define faces:->:<[face_subdivisions]>
- - determine <[verts]>
- lib_core_subdivide_triangle:
- type: procedure
- debug: false
- definitions: args
- script:
- - define i1 <[args.index1].min[<[args.index2]>]>
- - define i2 <[args.index1].max[<[args.index2]>]>
- - define key <[i1]>_<[i2]>
- - determine <map.with[vertices].as[<[args.vertices]>].with[lookup].as[<[args.lookup]>].with[index].as[<[args.lookup.<[key]>]>]> if:<[args.lookup.<[key]>].exists>
- - define v1 <[args.vertices].get[<[i1]>]>
- - define v2 <[args.vertices].get[<[i2]>]>
- - define x <[v1].x.add[<[v2].x>].mul[0.5]>
- - define y <[v1].y.add[<[v2].y>].mul[0.5]>
- - define z <[v1].z.add[<[v2].z>].mul[0.5]>
- - define middle <[v1].with_x[<[x]>].with_y[<[y]>].with_z[<[z]>]>
- - define args.vertices:->:<[middle].normalize>
- - define args.lookup.<[key]>:<[args.vertices].size>
- - determine <map.with[vertices].as[<[args.vertices]>].with[lookup].as[<[args.lookup]>].with[index].as[<[args.lookup.<[key]>]>]>
Advertisement
Add Comment
Please, Sign In to add comment