Skip to content

Commit

Permalink
make sure nodes don't appear on top of each other by adding a functio…
Browse files Browse the repository at this point in the history
…n to change position based on the number of nodes in the tree
  • Loading branch information
AnimNyan committed Apr 5, 2022
1 parent af5107e commit 9984618
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions io_import_scene_lwo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,11 +1339,13 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object
vertex_color_node = curr_material.node_tree.nodes.new('ShaderNodeVertexColor')

#position x, y
vertex_color_node.location = (-800, 0)
vertex_color_node.location = get_new_node_location(curr_material)

#create a mixRGB node
mix_rgb_tint_node = curr_material.node_tree.nodes.new('ShaderNodeMixRGB')

mix_rgb_tint_node.location = get_new_node_location(curr_material)

mix_rgb_tint_node.blend_type = 'MULTIPLY'
mix_rgb_tint_node.inputs["Fac"].default_value = 1

Expand Down Expand Up @@ -1455,7 +1457,7 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object
vertex_color_node_2 = curr_material.node_tree.nodes.new('ShaderNodeVertexColor')

#position x, y
vertex_color_node_2.location = (-900, -200)
vertex_color_node_2.location = get_new_node_location(curr_material)

#-------------------------------------------------------NEED TO CHANGE IS HARDCODED
#-------------------------------------------------------
Expand Down Expand Up @@ -1571,7 +1573,7 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object
uv_map_node = curr_material.node_tree.nodes.new('ShaderNodeUVMap')

#position x, y
uv_map_node.location = (-600, 150)
uv_map_node.location = get_new_node_location(curr_material)

material_link(uv_map_node.outputs["UV"], image_texture_node.inputs["Vector"])
#image_texture_node.uv_layer = texture.uvname
Expand Down Expand Up @@ -2005,6 +2007,18 @@ def build_objects(object_layers, object_surfs, object_clips, object_tags, object

print("Done Importing LWO File")

#return a different (x,y) position
#this depends upon how many nodes currently exist
#so every node will return a different x and y position
def get_new_node_location(curr_material):
count = len(curr_material.node_tree.nodes)

x_location = count * -150
y_location = count * -20

return (x_location,y_location)



from bpy.props import StringProperty, BoolProperty, CollectionProperty

Expand Down

0 comments on commit 9984618

Please sign in to comment.