Skip to content

Commit

Permalink
Integrated mat save params - seed on/off works
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaridhg committed Oct 6, 2023
1 parent 1d21abf commit b76b4b8
Showing 1 changed file with 89 additions and 1 deletion.
90 changes: 89 additions & 1 deletion randomiser/random_all/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from bpy.app.handlers import persistent

from ..transform.operators import get_transform_inputs, randomise_selected
from ..utils import nodes2rand


# -------------------------------
Expand Down Expand Up @@ -246,6 +247,90 @@ def execute(self, context):
all_geom_dict[GNG_sck_values_str] = tmp_values

print(all_geom_dict)

### MATERIALS
bpy.data.scenes["Scene"].frame_current = 0
all_mat_dict = {}
cs = bpy.context.scene
for mat_idx in range(len(cs.socket_props_per_material.collection)):
# get this subpanel's GNG
subpanel_material = cs.socket_props_per_material.collection[
mat_idx
]
tmp_mat = subpanel_material.name
print(tmp_mat)

list_input_nodes = (
nodes2rand.get_material_nodes_to_randomise_indep(
subpanel_material.name
)
)

list_nodes2rand_in_groups = (
nodes2rand.get_material_nodes_to_randomise_group(
subpanel_material.name
)
)

list_input_nodes_all = (
nodes2rand.get_material_nodes_to_randomise_all(
subpanel_material.name
)
)

print("list_input_nodes ====== ", list_input_nodes)
print(
"list nodes2rand in groups ===== ", list_nodes2rand_in_groups
)
print("list_input_nodes_all ===== ", list_input_nodes_all)

list_input_nodes_sorted = sorted(
list_input_nodes_all, key=lambda x: x.name
)
for i_n, nd in enumerate(list_input_nodes_sorted):
# add sockets for this node in the subseq rows
for sckt in nd.outputs:
print(nd.name)
print(
getattr(
sckt,
"default_value",
)
)

test_attr = getattr(
sckt,
"default_value",
)
print(str(test_attr))

if "NodeSocketColor" not in str(test_attr):
print("NODESOCKETCOLOR", str(test_attr))
tmp_values = []
for idx in range(tot_frame_no):
bpy.app.handlers.frame_change_pre[0]("dummy")
bpy.data.scenes["Scene"].frame_current = idx
bpy.ops.node.randomise_all_material_sockets(
"INVOKE_DEFAULT"
) # issue
# w/ this being called so often -
# might need moved to diff for loop?
tmp_values.append(
getattr(
sckt,
"default_value",
)
)

print(tmp_values)
tmp_sck = nd.name
all_mat_dict[tmp_mat] = tmp_sck
MAT_sck_values_str = tmp_mat + tmp_sck
MAT_sck_values_str = "Values " + MAT_sck_values_str
print(MAT_sck_values_str)
all_mat_dict[MAT_sck_values_str] = tmp_values

print(all_mat_dict)
data = {
"location_str": loc_value_str,
"loc_x": x_pos_vals,
Expand All @@ -256,9 +341,12 @@ def execute(self, context):
"rot_y": y_rot_vals,
"rot_z": z_rot_vals,
"geometry": all_geom_dict,
"materaisl": all_mat_dict,
}

path_to_file = pathlib.Path.home() / "tmp" / "transform_geom_test.json"
path_to_file = (
pathlib.Path.home() / "tmp" / "transform_geom_mat_test.json"
)

with open(path_to_file, "w") as out_file_obj:
# convert the dictionary into text
Expand Down

0 comments on commit b76b4b8

Please sign in to comment.