You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# TODO: Find a more generic place for color overrides
Returns:
bpy.types.Material: Amaterialforthegivenchemicalsymbol.
"""key=self._get_material_key(chemical_id, symbol)
material=bpy.data.materials.get(key)
ifmaterialisNone:
material=self._create_material(symbol, key)
returnmaterialdef_get_material_key(self, chemical_id: str, symbol: str) ->str:
"""Creates a unique human-readable key for a material Args: symbol (str): Chemical symbol for the material. chemical_id (str): A unique identifier for a material. Returns: str: A unique human-readable key for the material """ifself.materials_are_singleton:
key=f"{PACKAGE_PREFIX}_{symbol}"else:
key=f"{PACKAGE_PREFIX}_{symbol}_{chemical_id}"returnkeydef_create_material(self, symbol: str, key: str) ->bpy.types.Material:
"""Creates a material given a symbol and chemical id. Uses JMol colors. Args: symbol (str): Chemical symbol for the material. chemical_id (str): A unique identifier for a material. Returns: bpy.types.Material: A material for the given chemical symbol. """color= [iforiinase.data.colors.jmol_colors[ase.data.atomic_numbers[symbol]]] + [1]
# TODO: Find a more generic place for color overridesifsymbol=="C":
color= [0.0, 0.0, 0.0, 1.0]
material: bpy.types.Material=bpy.data.materials.new(key)
# Find the principled nodematerial.use_nodes=Trueshader: bpy.types.ShaderNodeBsdfPrincipled=material.node_tree.nodes.get('Principled BSDF')
# Set some general material propertiesshader.inputs[BSDF_SHADER_INPUTS["Base Color"]].default_value=colorifase.data.atomic_numbers[symbol] inMETALS:
shader.inputs[BSDF_SHADER_INPUTS["Metallic"]].default_value=1.0shader.inputs[BSDF_SHADER_INPUTS["Roughness"]].default_value=0.2shader.inputs[BSDF_SHADER_INPUTS["Clearcoat"]].default_value=0.0else:
shader.inputs[BSDF_SHADER_INPUTS["Metallic"]].default_value=0.0shader.inputs[BSDF_SHADER_INPUTS["Roughness"]].default_value=1.0shader.inputs[BSDF_SHADER_INPUTS["Clearcoat"]].default_value=1.0returnmaterial
4972fd968cfee7af756769a7e162301ee8299a40
The text was updated successfully, but these errors were encountered:
Find a more generic place for color overrides
Private
=======
hydridic_blender/utils/material_factory.py
Line 105 in fbfde06
4972fd968cfee7af756769a7e162301ee8299a40
The text was updated successfully, but these errors were encountered: