Skip to content

Commit

Permalink
Merge pull request #437 from BradyAJohnston/dev-materials
Browse files Browse the repository at this point in the history
update with default materials
  • Loading branch information
BradyAJohnston authored Feb 19, 2024
2 parents f389e33 + b3ea6dc commit 36b3aa1
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test:
version := $(shell grep version pyproject.toml | grep -o -E "\b[0-9]+\.[0-9]+\.[0-9]+\b")

template:
cd 'molecularnodes/assets/template/' && zip -r 'Molecular Nodes.zip' 'Molecular Nodes'
python build.py

release:
git clean -dfX
Expand Down
24 changes: 24 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import zipfile


# zips up the template file
def zip_template():
# Define the directory and zip file paths
dir_path = 'molecularnodes/assets/template/Molecular Nodes'
zip_file_path = 'molecularnodes/assets/template/Molecular Nodes.zip'

# Create a ZipFile object in write mode
with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
# Walk the directory tree and add files to the zip file
for root, dirs, files in os.walk(dir_path):
for file in files:
# Get the path of the file
file_path = os.path.join(root, file)
# Add the file to the zip file
zipf.write(file_path, arcname=os.path.relpath(
file_path, start='molecularnodes/assets/template/'))


if __name__ == "__main__":
zip_template()
2 changes: 1 addition & 1 deletion docs/build_node_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_values(sockets):
elif dtype == "Vector":
default = [round(x, 2) for x in socket.default_value]
elif dtype == "Material":
default = '`MN_atomic_material`'
default = '`MN Default`'
elif dtype == "Color":
default = col_to_rgb_str(socket.default_value)
else:
Expand Down
Binary file modified molecularnodes/assets/MN_data_file.blend
Binary file not shown.
Binary file modified molecularnodes/assets/template/Molecular Nodes.zip
Binary file not shown.
Binary file modified molecularnodes/assets/template/Molecular Nodes/startup.blend
Binary file not shown.
12 changes: 6 additions & 6 deletions molecularnodes/blender/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,20 @@ def append(node_name, link=False):
return bpy.data.node_groups[node_name]


def MN_base_material():
def material_default():
"""
Append MN_atomic_material to the .blend file it it doesn't already exist,
Append MN Default to the .blend file it it doesn't already exist,
and return that material.
"""

mat_name = 'MN_atomic_material'
mat_name = 'MN Default'
mat = bpy.data.materials.get(mat_name)

if not mat:
print('appending material')
bpy.ops.wm.append(
directory=os.path.join(MN_DATA_FILE, 'Material'),
filename='MN_atomic_material',
filename='MN Default',
link=False
)

Expand Down Expand Up @@ -265,7 +265,7 @@ def assign_material(node, material='default'):
if not material:
pass
elif material == "default":
material_socket.default_value = MN_base_material()
material_socket.default_value = material_default()
else:
material_socket.default_value = material

Expand Down Expand Up @@ -380,7 +380,7 @@ def create_starting_nodes_starfile(object, n_images=1):
node_name = f"MN_starfile_{object.name}"

# Make sure the aotmic material is loaded
MN_base_material()
material_default()
# create a new GN node group, specific to this particular molecule
group = new_group(node_name)
node_mod.node_group = group
Expand Down
4 changes: 2 additions & 2 deletions molecularnodes/ui/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def panel_scene(layout, context):
else:
world.prop(bpy.data.scenes["Scene"].eevee, "taa_render_samples")
world.label(text="Background")
world.prop(world_shader.inputs[1], 'default_value', text="World Lighting")
world.prop(world_shader.inputs[1], 'default_value', text='HDRI Strength')
row = world.row()
row.prop(scene.render, 'film_transparent')
row.prop(world_shader.inputs[2], 'default_value', text="")
row.prop(world_shader.inputs[2], 'default_value', text="Background")

col = grid.column()
col.label(text="Camera Settings")
Expand Down

0 comments on commit 36b3aa1

Please sign in to comment.