]> git.tdb.fi Git - libs/gl.git/blob - blender/io_mspgl/properties.py
Rename material map to material atlas in the exporter
[libs/gl.git] / blender / io_mspgl / properties.py
1 import bpy
2
3 class MspGLMeshProperties(bpy.types.Panel):
4         bl_idname = "MESH_PT_mspgl_properties"
5         bl_label = "MspGL properties"
6         bl_space_type = "PROPERTIES"
7         bl_region_type = "WINDOW"
8         bl_context = "data"
9
10         @classmethod
11         def poll(cls, context):
12                 return context.active_object.type=="MESH"
13
14         def draw(self, context):
15                 mesh = context.active_object.data
16
17                 self.layout.prop(mesh, "winding_test")
18                 self.layout.prop(mesh, "smoothing")
19
20                 self.layout.separator()
21
22                 col = self.layout.column()
23                 col.label(text="Data selection")
24                 col.prop(mesh, "use_lines")
25                 col.prop(mesh, "vertex_groups")
26                 col.prop(mesh, "max_groups_per_vertex")
27
28                 self.layout.separator()
29
30                 col = self.layout.column()
31                 col.label(text="Texturing")
32                 col.prop(mesh, "use_uv")
33                 col.prop(mesh, "tbn_vecs")
34                 col.prop(mesh, "tbn_uvtex")
35
36 class MspGLObjectProperties(bpy.types.Panel):
37         bl_idname = "OBJECT_PT_mspgl_properties"
38         bl_label = "MspGL properties"
39         bl_space_type = "PROPERTIES"
40         bl_region_type = "WINDOW"
41         bl_context = "object"
42
43         def draw(self, context):
44                 obj = context.active_object
45
46                 self.layout.prop(obj, "compound")
47                 self.layout.prop(obj, "lod_for_parent")
48                 if obj.lod_for_parent:
49                         self.layout.prop(obj, "lod_index")
50
51 class MspGLMaterialProperties(bpy.types.Panel):
52         bl_idname = "MATERIAL_PT_mspgl_properties"
53         bl_label = "MspGL properties"
54         bl_space_type = "PROPERTIES"
55         bl_region_type = "WINDOW"
56         bl_context = "material"
57
58         @classmethod
59         def poll(cls, context):
60                 return context.active_object.active_material is not None
61
62         def draw(self, context):
63                 mat = context.active_object.active_material
64                 if not mat:
65                         return
66
67                 self.layout.prop(mat, "render_mode")
68                 if mat.render_mode=='CUSTOM':
69                         self.layout.prop(mat, "shader")
70                 elif mat.render_mode=='EXTERNAL':
71                         self.layout.prop(mat, "technique")
72                 self.layout.prop(mat, "array_atlas")
73                 if mat.array_atlas:
74                         self.layout.prop(mat, "array_layer")
75                 if mat.render_mode!='EXTERNAL':
76                         self.layout.prop(mat, "material_atlas")
77
78 class MspGLTextureNodeProperties(bpy.types.Panel):
79         bl_idname = "NODE_PT_mspgl_properties"
80         bl_label = "MspGL properties"
81         bl_space_type = "NODE_EDITOR"
82         bl_region_type = "UI"
83         bl_category = "Item"
84
85         @classmethod
86         def poll(cls, context):
87                 node = context.active_node
88                 return node and node.type=='TEX_IMAGE'
89
90         def draw(self, context):
91                 node = context.active_node
92                 if not node:
93                         return
94
95                 self.layout.prop(node, "default_filter")
96                 if not node.default_filter:
97                         self.layout.prop(node, "use_mipmap")
98                         self.layout.prop(node, "max_anisotropy")
99
100 classes = [MspGLMeshProperties, MspGLObjectProperties, MspGLMaterialProperties, MspGLTextureNodeProperties]
101
102 def register_properties():
103         bpy.types.Mesh.winding_test = bpy.props.BoolProperty(name="Winding test", description="Perform winding test to skip back faces")
104         bpy.types.Mesh.smoothing = bpy.props.EnumProperty(name="Smoothing", description="Smoothing method to use", default="MSPGL",
105                 items=(("NONE", "None", "No smoothing"),
106                         ("BLENDER", "Blender", "Use Blender's vertex normals"),
107                         ("MSPGL", "MspGL", "Compute vertex normals internally")))
108         bpy.types.Mesh.use_lines = bpy.props.BoolProperty(name="Include lines", description="Include edges without faces as lines", default=False)
109         bpy.types.Mesh.vertex_groups = bpy.props.BoolProperty(name="Vertex groups", description="Include vertex groups and weights", default=False)
110         bpy.types.Mesh.max_groups_per_vertex = bpy.props.IntProperty(name="Max groups", description="Maximum amount of groups per vertex", min=1, max=4, default=2)
111         bpy.types.Mesh.use_uv = bpy.props.EnumProperty(name="Use UV", description="Use UV coordinates", default="UNIT0",
112                 items=(("NONE", "None", "Ignore all UV coordinates"),
113                         ("UNIT0", "Unit 0", "Use UV coordinates for unit 0"),
114                         ("ALL", "All", "Use all UV coordinates")))
115         bpy.types.Mesh.tbn_vecs = bpy.props.BoolProperty(name="TBN vectors", description="Compute tangent and binormal vectors for vertices", default=False)
116         bpy.types.Mesh.tbn_uvtex = bpy.props.StringProperty(name="TBN UV layer", description="UV layer to use as basis for TBN vectors", default="")
117
118         bpy.types.Object.compound = bpy.props.BoolProperty(name="Compound with parent", description="Join this object to its parent when exporting")
119         bpy.types.Object.lod_for_parent = bpy.props.BoolProperty(name="LoD for parent", description="This object is a level of detail for its parent")
120         bpy.types.Object.lod_index = bpy.props.IntProperty(name="LoD index", description="Index of the level of detail", min=1, max=16, default=1)
121
122         bpy.types.Material.render_mode = bpy.props.EnumProperty(name="Render mode", description="How this material should be rendered", default="BUILTIN",
123                 items=(("BUILTIN", "Built-in", "Use built-in shaders"),
124                         ("CUSTOM", "Custom shader", "Use a custom shader"),
125                         ("EXTERNAL", "External technique", "Use an externally defined technique")))
126         bpy.types.Material.technique = bpy.props.StringProperty(name="Custom technique", description="Name of an external technique to use for rendering")
127         bpy.types.Material.shader = bpy.props.StringProperty(name="Custom shader", description="Name of an external technique to use for rendering")
128         bpy.types.Material.array_atlas = bpy.props.BoolProperty(name="Texture array atlas", description="The material is stored in a texture array")
129         bpy.types.Material.array_layer = bpy.props.IntProperty("Texture array layer", description="Layer of the texture array atlas to use")
130         bpy.types.Material.material_atlas = bpy.props.BoolProperty(name="Material atlas", description="Make this material part of a material atlas")
131
132         bpy.types.ShaderNodeTexImage.default_filter = bpy.props.BoolProperty(name="Default filter", description="Let the loading program determine filtering options")
133         bpy.types.ShaderNodeTexImage.use_mipmap = bpy.props.BoolProperty(name="Use mipmaps", description="Use mipmaps (automatically generated) for the texture", default=True)
134         bpy.types.ShaderNodeTexImage.max_anisotropy = bpy.props.FloatProperty(name="Maximum anisotropy", description="Maximum anisotropy to use in texture filtering", min=1, max=16, default=1)
135
136         for c in classes:
137                 bpy.utils.register_class(c)
138
139 def unregister_properties():
140         for c in classes:
141                 bpy.utils.unregister_class(c)