-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaterial_operators.py
More file actions
77 lines (61 loc) · 2.52 KB
/
material_operators.py
File metadata and controls
77 lines (61 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import bpy
from .goldsrc.importmat import FixImportMaterials, FixImportAllMaterials
from .common.mat import *
class ZODEUTILS_GoldSrcMaterialImport(bpy.types.Operator):
bl_idname="zodeutils.goldsrc_material_import"
bl_label="Selected object"
bl_description = "Automatically sets up nodes & loads .bmp files from the .blend's folder\nAutomatically tries to detect chrome setups"
@classmethod
def poll(cls, context):
return len(bpy.context.object.material_slots) > 0
def execute(self, context):
if FixImportMaterials():
self.report({"INFO"}, "Imported materials")
else:
self.report({"INFO"}, "Didn't import materials")
return {"FINISHED"}
class ZODEUTILS_GoldSrcMaterialImportAll(bpy.types.Operator):
bl_idname="zodeutils.goldsrc_material_import_all"
bl_label="All objects"
bl_description = "Automatically sets up nodes & loads .bmp files from the .blend's folder\nAutomatically tries to detect chrome setups for all objects in scene"
@classmethod
def poll(cls, context):
return len(bpy.data.objects) > 0
def execute(self, context):
if FixImportAllMaterials():
self.report({"INFO"}, "Imported materials")
else:
self.report({"INFO"}, "Didn't import materials")
return {"FINISHED"}
class ZODEUTILS_MaterialToDiffuse(bpy.types.Operator):
bl_idname="zodeutils.material_to_diffuse"
bl_label="Diffuse"
bl_description = "Swap node setup to standard diffuse setup"
@classmethod
def poll(cls, context):
return bpy.context.object.active_material is not None
def execute(self, context):
MakeMaterialDiffuse()
self.report({"INFO"}, "Material turned to diffuse")
return {"FINISHED"}
class ZODEUTILS_MaterialToMatcap(bpy.types.Operator):
bl_idname="zodeutils.material_to_matcap"
bl_label="Matcap"
bl_description = "Swap node setup to matcap setup, also known as \"chrome\" in goldsrc"
@classmethod
def poll(cls, context):
return bpy.context.object.active_material is not None
def execute(self, context):
MakeMaterialMatcap()
self.report({"INFO"}, "Material turned to matcap")
return {"FINISHED"}
def register():
bpy.utils.register_class(ZODEUTILS_GoldSrcMaterialImport)
bpy.utils.register_class(ZODEUTILS_GoldSrcMaterialImportAll)
bpy.utils.register_class(ZODEUTILS_MaterialToMatcap)
bpy.utils.register_class(ZODEUTILS_MaterialToDiffuse)
def unregister():
bpy.utils.unregister_class(ZODEUTILS_GoldSrcMaterialImport)
bpy.utils.unregister_class(ZODEUTILS_GoldSrcMaterialImportAll)
bpy.utils.unregister_class(ZODEUTILS_MaterialToMatcap)
bpy.utils.unregister_class(ZODEUTILS_MaterialToDiffuse)