[Bf-extensions-cvs] [91d5c210] master: Cleanup: tabs -> spaces
Campbell Barton
noreply at git.blender.org
Thu Mar 5 02:35:35 CET 2020
Commit: 91d5c210f8027877bdf8e027178f3325ee0e0a96
Author: Campbell Barton
Date: Thu Mar 5 12:33:57 2020 +1100
Branches: master
https://developer.blender.org/rBAC91d5c210f8027877bdf8e027178f3325ee0e0a96
Cleanup: tabs -> spaces
===================================================================
M automat/AdjOp.py
M automat/AutoOp.py
M automat/__init__.py
M io_scene_3ds/import_3ds.py
===================================================================
diff --git a/automat/AdjOp.py b/automat/AdjOp.py
index c5e1ee3c..3d431d4c 100644
--- a/automat/AdjOp.py
+++ b/automat/AdjOp.py
@@ -1,10 +1,10 @@
# Copyright 2015 Théo Friberg under GNU GPL 3
if "bpy" in locals():
- import importlib
- importlib.reload(JSONOps)
+ import importlib
+ importlib.reload(JSONOps)
else:
- from . import JSONOps
+ from . import JSONOps
import bpy
import os
diff --git a/automat/AutoOp.py b/automat/AutoOp.py
index 6bac76bc..f52ec58f 100644
--- a/automat/AutoOp.py
+++ b/automat/AutoOp.py
@@ -1,10 +1,10 @@
# Copyright 2015 Théo Friberg under GNU GPL 3
if "bpy" in locals():
- import importlib
- importlib.reload(JSONOps)
+ import importlib
+ importlib.reload(JSONOps)
else:
- from . import JSONOps
+ from . import JSONOps
import bpy
import os
@@ -12,184 +12,184 @@ import glob
class AutomatOperatorFromTexture(bpy.types.Operator):
- """This operator generates automatic materials from textures in Cycles."""
+ """This operator generates automatic materials from textures in Cycles."""
- # Metadata of the operator
+ # Metadata of the operator
- bl_idname = "com.new_automat"
- bl_label = "Automatic Material from Image"
- bl_options = {"UNDO"}
+ bl_idname = "com.new_automat"
+ bl_label = "Automatic Material from Image"
+ bl_options = {"UNDO"}
- # Variables used for storing the filepath given by blender's file manager
+ # Variables used for storing the filepath given by blender's file manager
- filepath: bpy.props.StringProperty(subtype="FILE_PATH")
- filename: bpy.props.StringProperty()
- directory: bpy.props.StringProperty(subtype="FILE_PATH")
+ filepath: bpy.props.StringProperty(subtype="FILE_PATH")
+ filename: bpy.props.StringProperty()
+ directory: bpy.props.StringProperty(subtype="FILE_PATH")
- make_seamless: bpy.props.BoolProperty(name="Make Seamless", description="Make tileable (removes visible borders of the image).")
+ make_seamless: bpy.props.BoolProperty(name="Make Seamless", description="Make tileable (removes visible borders of the image).")
- def execute(self, context):
+ def execute(self, context):
- """This is the main runnable method of the operator.
+ """This is the main runnable method of the operator.
This creates all the node setup."""
- # Create the material
+ # Create the material
- mat = bpy.data.materials.new(self.filename)
+ mat = bpy.data.materials.new(self.filename)
- mat.use_nodes = True
- nodes = mat.node_tree.nodes
+ mat.use_nodes = True
+ nodes = mat.node_tree.nodes
- # Empty whatever nodes we allready had.
+ # Empty whatever nodes we allready had.
- for node in nodes.keys():
- nodes.remove(nodes[node])
+ for node in nodes.keys():
+ nodes.remove(nodes[node])
- nodes_dict = {}
+ nodes_dict = {}
- # Create the main part of the material
+ # Create the main part of the material
- nodes_dict = JSONOps.inflateFile(mat, os.path.dirname(
- os.path.realpath(__file__))+os.sep+
- "automatic_material.json")
+ nodes_dict = JSONOps.inflateFile(mat, os.path.dirname(
+ os.path.realpath(__file__))+os.sep+
+ "automatic_material.json")
- # We load the images
+ # We load the images
- image_data = bpy.data.images.load(self.filepath)
- nodes_dict["Color Image"].image = image_data
+ image_data = bpy.data.images.load(self.filepath)
+ nodes_dict["Color Image"].image = image_data
- # We check if the texture must be made seamless
+ # We check if the texture must be made seamless
- if self.make_seamless:
- seamless_vector = JSONOps.inflateFile(mat, os.path.dirname(os.path.realpath(__file__))+os.sep+"seamless_vector.json", -3000, 0)
- links = mat.node_tree.links
- links.new(seamless_vector["Pick Vector"].outputs["Color"], nodes_dict["Color Image"].inputs["Vector"])
+ if self.make_seamless:
+ seamless_vector = JSONOps.inflateFile(mat, os.path.dirname(os.path.realpath(__file__))+os.sep+"seamless_vector.json", -3000, 0)
+ links = mat.node_tree.links
+ links.new(seamless_vector["Pick Vector"].outputs["Color"], nodes_dict["Color Image"].inputs["Vector"])
- # Below we check potential maps
+ # Below we check potential maps
- modified_fname = self.filename.split(".")
+ modified_fname = self.filename.split(".")
- # Check if we are dealing with maps generated with CrazyBump.
- # If so is the case, the color map is by default suffixed with _COLOR
+ # Check if we are dealing with maps generated with CrazyBump.
+ # If so is the case, the color map is by default suffixed with _COLOR
- known_scheme = False
+ known_scheme = False
- if modified_fname[0][-6:] == "_COLOR":
+ if modified_fname[0][-6:] == "_COLOR":
- # We are dealing with CrazyBump and we remove the suffix
+ # We are dealing with CrazyBump and we remove the suffix
- modified_fname[0] = modified_fname[0][:-6]
- known_scheme = True
+ modified_fname[0] = modified_fname[0][:-6]
+ known_scheme = True
- other_files = []
- folder = os.path.split(self.filepath)[0]+os.path.sep+"*"
- pattern = folder + ".".join(modified_fname[:-1])+"*."+modified_fname[-1]
- other_files = glob.glob(pattern)
+ other_files = []
+ folder = os.path.split(self.filepath)[0]+os.path.sep+"*"
+ pattern = folder + ".".join(modified_fname[:-1])+"*."+modified_fname[-1]
+ other_files = glob.glob(pattern)
- # We check if we can find a Specularity Map
+ # We check if we can find a Specularity Map
- specmap = ""
+ specmap = ""
- for file in other_files:
- if "spec" in os.path.split(file)[-1].lower():
- specmap = file
- break
+ for file in other_files:
+ if "spec" in os.path.split(file)[-1].lower():
+ specmap = file
+ break
- if len(specmap) > 0:
+ if len(specmap) > 0:
- spec_map = nodes.new("ShaderNodeTexImage")
- spec_map.location = [nodes_dict["Adjust reflectivity"].location[0],
- nodes_dict["Adjust reflectivity"].location[1]+50]
- spec_map.label = "Specularity Map"
- nodes.remove(nodes_dict["Adjust reflectivity"])
- spec_map.image = bpy.data.images.load(specmap)
- links = mat.node_tree.links
+ spec_map = nodes.new("ShaderNodeTexImage")
+ spec_map.location = [nodes_dict["Adjust reflectivity"].location[0],
+ nodes_dict["Adjust reflectivity"].location[1]+50]
+ spec_map.label = "Specularity Map"
+ nodes.remove(nodes_dict["Adjust reflectivity"])
+ spec_map.image = bpy.data.images.load(specmap)
+ links = mat.node_tree.links
- links.new(spec_map.outputs["Color"],
- nodes_dict["Mix Shaders"].inputs[0])
- if self.make_seamless:
- links.new(seamless_vector["Pick Vector"].outputs["Color"], spec_map.inputs["Vector"])
+ links.new(spec_map.outputs["Color"],
+ nodes_dict["Mix Shaders"].inputs[0])
+ if self.make_seamless:
+ links.new(seamless_vector["Pick Vector"].outputs["Color"], spec_map.inputs["Vector"])
- # We check if we can find a Normal Map
+ # We check if we can find a Normal Map
- normalmap = ""
+ normalmap = ""
- for file in other_files:
- if "normal" in os.path.split(file)[-1].lower() or ".".join(os.path.split(file)[1].split(".") [:-1])[-4:] == "_NRM":
- normalmap = file
- break
+ for file in other_files:
+ if "normal" in os.path.split(file)[-1].lower() or ".".join(os.path.split(file)[1].split(".") [:-1])[-4:] == "_NRM":
+ normalmap = file
+ break
- if len(normalmap) > 0 and ((not "normal" in self.filename.lower()) or known_scheme):
+ if len(normalmap) > 0 and ((not "normal" in self.filename.lower()) or known_scheme):
- normal_map = nodes.new("ShaderNodeTexImage")
- normal_map.location = [nodes_dict["Color Image"].location[0],
- nodes_dict["Color Image"].location[1]-240]
- normal_map.label = "Normal Map"
- normal_map.image = bpy.data.images.load(normalmap)
- links = mat.node_tree.links
+ normal_map = nodes.new("ShaderNodeTexImage")
+ normal_map.location = [nodes_dict["Color Image"].location[0],
+ nodes_dict["Color Image"].location[1]-240]
+ normal_map.label = "Normal Map"
+ normal_map.image = bpy.data.images.load(normalmap)
+ links = mat.node_tree.links
- normal = nodes.new("ShaderNodeNormalMap")
- normal.location = [nodes_dict["Convert to Bump Map"].location[0],
- nodes_dict["Convert to Bump Map"].location[1]]
- nodes.remove(nodes_dict["Convert to Bump Map"])
- links.new(normal_map.outputs["Color"],
- normal.inputs[1])
- links.new(normal.outputs["Normal"],
- nodes_dict["Diffuse Component"].inputs[2])
- links.new(normal.outputs["Normal"],
- nodes_dict["Glossy Component"].inputs[2])
- if self.make_seamless:
- links.new(seamless_vector["Pick Vector"].outputs["Color"], normal_map.inputs["Vector"])
+ normal = nodes.new("ShaderNodeNormalMap")
+ normal.location = [nodes_dict["Convert to Bump Map"].location[0],
+ nodes_dict["Convert to Bump Map"].location[1]]
+ nodes.remove(nodes_dict["Convert to Bump Map"])
+ links.new(normal_map.outputs["Color"],
+ normal.inputs[1])
+ links.new(normal.outputs["Normal"],
+ nodes_dict["Diffuse Component"].inputs[2])
+ links.new(normal.outputs["Normal"],
+ nodes_dict["Glossy Component"].inputs[2])
+ if self.make_seamless:
+ links.new(seamless_vector["Pick Vector"].outputs["Color"], normal_map.inputs["Vector"])
- # We check if we can find a Bump Map
+ # We check if we can find a Bump Map
- bumpmap = ""
+ bumpmap = ""
- for file in other_files:
- if "bump" in os.path.split(
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list