Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from portnov/NodeTree
Last active May 15, 2020 10:05
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 zeffii/ab213faae5cc1ac75abb5cfcf3d288c5 to your computer and use it in GitHub Desktop.
Save zeffii/ab213faae5cc1ac75abb5cfcf3d288c5 to your computer and use it in GitHub Desktop.
to do later? 2018
{
"export_version": "0.079",
"framed_nodes": {},
"groups": {},
"nodes": {
"A Number": {
"bl_idname": "SvNumberNode",
"height": 100.0,
"hide": false,
"label": "",
"location": [
-334.58795166015625,
-367.5118103027344
],
"params": {
"float_": 0.0,
"int_": 9,
"selected_mode": "int"
},
"width": 140.0
},
"A Number.001": {
"bl_idname": "SvNumberNode",
"height": 100.0,
"hide": false,
"label": "",
"location": [
-300.5088806152344,
-220.95509338378906
],
"params": {
"float_": 0.0,
"int_": 40,
"selected_mode": "int"
},
"width": 140.0
},
"Assign Materials List": {
"bl_idname": "SvAssignMaterialListNode",
"height": 100.0,
"hide": false,
"label": "",
"location": [
610.7916870117188,
96.184814453125
],
"materials": [
"M0",
"M1",
"M2",
"M3"
],
"params": {},
"width": 200.0
},
"Inset faces": {
"bl_idname": "SvInsetFaces",
"height": 100.0,
"hide": false,
"label": "",
"location": [
136.02902221679688,
115.28933715820312
],
"params": {
"depth": 0.08999999612569809,
"inset_type": "region",
"thickness": 0.03999999910593033
},
"width": 140.0
},
"List Input": {
"bl_idname": "SvListInputNode",
"height": 100.0,
"hide": false,
"label": "",
"location": [
-503.9411926269531,
-174.15679931640625
],
"params": {
"int_": 10,
"int_list": [
1,
1,
1,
2,
3,
3,
3,
1,
1,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
},
"width": 140.0
},
"Plane MK2": {
"bl_idname": "SvPlaneNodeMK2",
"color": [
0.0,
0.5,
0.5
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
-445.6921691894531,
146.77545166015625
],
"params": {
"center": 1,
"normalize": 1,
"numx": 40,
"numy": 40
},
"use_custom_color": true,
"width": 140.0
},
"Scripted Node Lite": {
"bl_idname": "SvScriptNodeLite",
"color": [
0.0,
0.800000011920929,
0.949999988079071
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
-68.32210540771484,
-150.6959686279297
],
"params": {
"inject_params": 0,
"injected_state": 0,
"int_list": [
0,
0,
0,
40,
0,
0,
2,
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": "turtle_random_walk.py",
"script_str": "\"\"\"\nin in_verts v d=[] n=0\nin in_faces s d=[] n=0\nin in_start_face_idx s d=0 n=2\nin in_steps s d=40 n=2\nin in_select_mask s d=[1,1,1] n=1\nin in_paint_mask s d=[1,1,2] n=1\nin in_seed s d=9 n=2\nout out_face_mask s\nout out_face_data s\n\"\"\"\n\nimport random\n\nfrom sverchok.data_structure import zip_long_repeat\nfrom sverchok.utils.sv_bmesh_utils import bmesh_from_pydata\nfrom sverchok.utils.logging import debug, info\nfrom sverchok.utils.turtle import Turtle\n\nif in_select_mask is None:\n in_select_mask = [[]]\nif in_paint_mask is None:\n in_paint_mask = [[]]\n\nout_face_mask = []\nout_face_data = []\nobjects = zip_long_repeat(in_verts, in_faces, in_start_face_idx, in_steps,\n in_select_mask, in_paint_mask, in_seed)\nfor verts, faces, start_face, steps, select_mask, paint_mask, seed in objects:\n info(seed)\n if isinstance(seed, (list, tuple)):\n seed = seed[0]\n random.seed(seed)\n if isinstance(start_face, (list, tuple)):\n if not start_face:\n start_face = random.choice(range(len(faces)))\n else:\n start_face = start_face[0]\n if isinstance(steps, (list, tuple)):\n steps = steps[0]\n \n bm = bmesh_from_pydata(verts, [], faces, normal_update=True)\n bm.verts.ensure_lookup_table()\n bm.faces.ensure_lookup_table()\n turtle = Turtle(bm)\n \n # When manually assigning the current_face, remember\n # to assign current_loop correspondingly!\n turtle.current_face = bm.faces[start_face]\n turtle.current_loop = turtle.current_face.loops[0]\n \n if select_mask:\n turtle.start_selecting(Turtle.MASK, select_mask)\n else:\n turtle.start_selecting()\n if paint_mask:\n turtle.start_painting(paint_mask)\n \n for i in range(steps):\n steps = int( random.uniform(4, 12) )\n for j in range(steps):\n for k in range(len(turtle.current_face.edges)):\n bound = turtle.is_looking_at_boundary\n next_face = turtle.get_next_face(count=2)\n if bound or next_face.select:\n r = random.uniform(0, 1)\n if r > 0.5:\n turtle.turn_next()\n else:\n turtle.turn_prev()\n else:\n break\n turtle.step()\n rot = int( random.uniform(-3, 3) )\n if rot > 0:\n turtle.turn_next(rot)\n else:\n turtle.turn_next(- rot)\n \n new_face_mask = turtle.get_selection_mask()\n new_face_data = turtle.get_painting_data()\n bm.free()\n out_face_mask.append(new_face_mask)\n out_face_data.append(new_face_data)\n"
},
"snlite_ui": [],
"use_custom_color": true,
"width": 140.0
},
"Viewer BMesh": {
"bl_idname": "SvBmeshViewerNodeV28",
"color": [
1.0,
0.30000001192092896,
0.0
],
"height": 100.0,
"hide": false,
"label": "",
"location": [
395.14337158203125,
102.3606185913086
],
"params": {},
"use_custom_color": true,
"width": 140.0
}
},
"update_lists": [
[
"Plane MK2",
0,
"Scripted Node Lite",
0
],
[
"Plane MK2",
2,
"Scripted Node Lite",
1
],
[
"A Number.001",
0,
"Scripted Node Lite",
3
],
[
"List Input",
0,
"Scripted Node Lite",
5
],
[
"A Number",
0,
"Scripted Node Lite",
6
],
[
"Plane MK2",
0,
"Inset faces",
0
],
[
"Plane MK2",
2,
"Inset faces",
2
],
[
"Scripted Node Lite",
1,
"Inset faces",
3
],
[
"Scripted Node Lite",
0,
"Inset faces",
4
],
[
"Inset faces",
0,
"Viewer BMesh",
0
],
[
"Inset faces",
2,
"Viewer BMesh",
2
],
[
"Inset faces",
3,
"Viewer BMesh",
3
],
[
"Viewer BMesh",
0,
"Assign Materials List",
0
]
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment