do some improvement work

- split blender material creation function.
- allow user to apply virtools material to blender nodes in operator.
- add quick group picker in add virtools group operator.
This commit is contained in:
2022-04-12 15:40:06 +08:00
parent dde95c3e4f
commit 2950857e3d
8 changed files with 117 additions and 12 deletions

View File

@ -42,13 +42,29 @@ def get_component_id(name):
# =================================
# create material
def create_material_nodes(input_mtl, ambient, diffuse, specular, emissive,
def create_blender_material(input_mtl, ambient, diffuse, specular, emissive,
specular_power, texture):
# adding material nodes
create_material_nodes(input_mtl,
ambient, diffuse, specular, emissive, specular_power, texture
)
# write custom property
UTILS_virtools_prop.set_virtools_material_data(input_mtl,
ambient, diffuse, specular, emissive, specular_power, texture
)
def create_material_nodes(input_mtl, ambient, diffuse, specular, emissive,
specular_power, texture):
# enable nodes mode
input_mtl.use_nodes=True
# delete all existed nodes
for node in input_mtl.node_tree.nodes:
input_mtl.node_tree.nodes.remove(node)
# create ballance-style blender material
bnode = input_mtl.node_tree.nodes.new(type="ShaderNodeBsdfPrincipled")
mnode = input_mtl.node_tree.nodes.new(type="ShaderNodeOutputMaterial")
input_mtl.node_tree.links.new(bnode.outputs[0],mnode.inputs[0])
@ -64,11 +80,6 @@ def create_material_nodes(input_mtl, ambient, diffuse, specular, emissive,
inode.image = texture
input_mtl.node_tree.links.new(inode.outputs[0], bnode.inputs[0])
# write custom property
UTILS_virtools_prop.set_virtools_material_data(input_mtl,
ambient, diffuse, specular, emissive, specular_power
)
# =================================
# load component