Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2017 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5c05331342ce8a85d9e5c2c2a9eaa444 to your computer and use it in GitHub Desktop.
Save anonymous/5c05331342ce8a85d9e5c2c2a9eaa444 to your computer and use it in GitHub Desktop.
to do later?
{
"export_version": "0.065",
"framed_nodes": {},
"groups": {},
"nodes": {
"Bisect": {
"bl_idname": "SvBisectNode",
"color": [
0.6079999804496765,
0.6079999804496765,
0.6079999804496765
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
28.764007568359375,
179.14825439453125
],
"params": {
"inner": 1
},
"width": 140.0
},
"Extrude Region": {
"bl_idname": "SvExtrudeRegionNode",
"color": [
0.6079999804496765,
0.6079999804496765,
0.6079999804496765
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
358.0616760253906,
-9.819915771484375
],
"params": {
"height_": 0.17999999225139618,
"multiple": 1,
"scale_": 1.059999942779541,
"transform_mode": "Normal"
},
"width": 140.0
},
"IcoSphere": {
"bl_idname": "SvIcosphereNode",
"color": [
0.9200000166893005,
0.9200000166893005,
0.9200000166893005
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
-166.52955627441406,
142.32244873046875
],
"params": {
"subdivisions": 3
},
"width": 140.0
},
"Matrix in": {
"bl_idname": "SvMatrixGenNodeMK2",
"color": [
0.6079999804496765,
0.6079999804496765,
0.6079999804496765
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
-168.986083984375,
-6.2080535888671875
],
"params": {},
"width": 140.0
},
"Randomize input vertices": {
"bl_idname": "SvRandomizeVerticesNode",
"color": [
0.6079999804496765,
0.6079999804496765,
0.6079999804496765
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
199.55657958984375,
193.8784942626953
],
"params": {
"random_x_": 0.029999999329447746,
"random_y_": 0.029999999329447746,
"random_z_": 0.029999999329447746
},
"width": 140.0
},
"Remove Doubles": {
"bl_idname": "SvRemoveDoublesNode",
"color": [
0.6079999804496765,
0.6079999804496765,
0.6079999804496765
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
367.604736328125,
311.7209167480469
],
"params": {
"distance": 0.05800001323223114
},
"width": 140.0
},
"Scripted Node Lite": {
"bl_idname": "SvScriptNodeLite",
"color": [
0.0,
0.800000011920929,
0.949999988079071
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
603.858642578125,
132.24313354492188
],
"params": {
"float_list": [
0.0,
0.0,
0.0,
0.8999999761581421,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
],
"inject_params": 0,
"injected_state": 0,
"int_list": [
0,
0,
0,
0,
20,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"script_name": "voronoi_3d.py",
"script_str": "\"\"\"\nin verts_in v d=[] n=1\nin obj_verts_in v d=[] n=1\nin obj_faces_in s d=[] n=1\nin shrink s d=0.9 n=2\nin bounding_n s d=14 n=2\nout new_verts v\nout new_faces s\n\"\"\"\nfrom itertools import combinations\nimport bmesh\nimport mathutils\nfrom mathutils import Vector\nfrom collections import defaultdict\n\n# from sverchok.utils.sv_bmesh_utils import bmesh_join\nfrom sverchok.utils.sv_mesh_utils import mesh_join\n\nlocators = defaultdict(list)\n\nsize = len(verts_in)\nkd = mathutils.kdtree.KDTree(size)\nfor i, xyz in enumerate(verts_in):\n kd.insert(xyz, i)\nkd.balance()\n\nfor idx, vtx in enumerate(verts_in):\n n_list = kd.find_n(vtx, bounding_n)\n for co, index, dist in n_list:\n if index == idx:\n continue\n pt = (((Vector(co)-Vector(vtx))/2)*shrink) + Vector(vtx) #((.... ) * distor) + Vector(vtx)\n normal = Vector(co)-Vector(vtx)\n locators[idx].append((pt, normal))\n\n__new_verts = []\n__new_faces = []\nfor k, v in locators.items():\n\n working_geom = bmesh_from_pydata(obj_verts_in, None, obj_faces_in, normal_update=True)\n for pt, normal in v:\n geom_in = working_geom.verts[:] + working_geom.edges[:] + working_geom.faces[:]\n\n res = bmesh.ops.bisect_plane(\n working_geom, geom=geom_in, dist=0.00001,\n plane_co=pt, plane_no=normal, use_snap_center=False,\n clear_outer=True, clear_inner=False\n )\n\n surround = [e for e in res['geom_cut'] if isinstance(e, bmesh.types.BMEdge)]\n fres = bmesh.ops.edgenet_prepare(working_geom, edges=surround)\n bmesh.ops.edgeloop_fill(working_geom, edges=fres['edges']) \n\n ___v, _, ___f = pydata_from_bmesh(working_geom)\n __new_verts.append(___v)\n __new_faces.append(___f)\n\n_v, _e, _f = mesh_join(__new_verts, [], __new_faces)\n\nnew_verts.append(_v)\nnew_faces.append(_f)\n"
},
"snlite_ui": [],
"width": 140.0
},
"Vector Math": {
"bl_idname": "SvVectorMathNodeMK2",
"color": [
0.6079999804496765,
0.6079999804496765,
0.6079999804496765
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
601.107177734375,
297.3572998046875
],
"params": {
"amount": 1.0180000066757202,
"current_op": "SCALAR"
},
"width": 140.0
},
"Viewer Draw": {
"bl_idname": "ViewerNode2",
"color": [
0.6284880042076111,
0.931007981300354,
1.0
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
807.604736328125,
250.34466552734375
],
"params": {
"activate": 1,
"edge_colors": [
0.8989999890327454,
0.85777747631073,
0.5
],
"edge_width": 1,
"face_colors": [
0.8989999890327454,
0.8092300295829773,
0.03009999915957451
],
"shading": 1,
"vertex_colors": [
0.9480000138282776,
0.9430409073829651,
0.8999999761581421
],
"vertex_size": 2.0
},
"width": 140.0
},
"Viewer Draw.001": {
"bl_idname": "ViewerNode2",
"color": [
0.6284880042076111,
0.931007981300354,
1.0
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
603.5607299804688,
-119.06964111328125
],
"params": {
"activate": 0,
"edge_colors": [
0.5,
0.6725208759307861,
0.8989999890327454
],
"edge_width": 1,
"face_colors": [
0.03009999915957451,
0.40579769015312195,
0.8989999890327454
],
"shading": 0,
"vertex_colors": [
0.8999999761581421,
0.9207543730735779,
0.9480000138282776
],
"vertex_size": 2.0
},
"width": 140.0
}
},
"update_lists": [
[
"IcoSphere",
0,
"Bisect",
0
],
[
"IcoSphere",
2,
"Bisect",
1
],
[
"Matrix in",
0,
"Bisect",
2
],
[
"Bisect",
0,
"Randomize input vertices",
0
],
[
"Randomize input vertices",
0,
"Remove Doubles",
1
],
[
"Bisect",
0,
"Extrude Region",
0
],
[
"Bisect",
2,
"Extrude Region",
2
],
[
"Remove Doubles",
0,
"Vector Math",
0
],
[
"Vector Math",
0,
"Scripted Node Lite",
0
],
[
"Extrude Region",
0,
"Scripted Node Lite",
1
],
[
"Extrude Region",
2,
"Scripted Node Lite",
2
],
[
"Scripted Node Lite",
0,
"Viewer Draw",
0
],
[
"Scripted Node Lite",
1,
"Viewer Draw",
1
],
[
"Extrude Region",
0,
"Viewer Draw.001",
0
],
[
"Extrude Region",
2,
"Viewer Draw.001",
1
]
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment