Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt .nif import to Blender 4+ API #639

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def map_normals(b_mesh, normals):
# the normals need to be pre-normalized or blender will do it inconsistely, leading to marked sharp edges
no_array = Vertex.normalize(no_array)
# use normals_split_custom_set_from_vertices to set the loop custom normals from the per-vertex normals
b_mesh.use_auto_smooth = True
if bpy.app.version < (4,0,0):
b_mesh.use_auto_smooth = True

b_mesh.normals_split_custom_set_from_vertices(no_array)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,16 @@ def link_normal_node(self, b_texture_node):
node_group = bpy.data.node_groups.new(group_name, "ShaderNodeTree")
group_nodes = node_group.nodes
# add the in/output nodes
input_node = group_nodes.new('NodeGroupInput')
node_group.inputs.new('NodeSocketColor', "Input")
output_node = group_nodes.new('NodeGroupOutput')
node_group.outputs.new('NodeSocketColor', "Output")
if bpy.app.version < (4,0,0):
input_node = group_nodes.new('NodeGroupInput')
node_group.inputs.new('NodeSocketColor', "Input")
output_node = group_nodes.new('NodeGroupOutput')
node_group.outputs.new('NodeSocketColor', "Output")
else:
input_node = group_nodes.new('NodeGroupInput')
node_group.interface.new_socket(name='NodeSocketColor', in_out="INPUT")
output_node = group_nodes.new('NodeGroupOutput')
node_group.interface.new_socket(name='NodeSocketColor', in_out="OUTPUT")
# create the converting nodes
separate_node = group_nodes.new("ShaderNodeSeparateRGB")
invert_node = group_nodes.new("ShaderNodeInvert")
Expand Down