3 class MspGLSceneProperties(bpy.types.Panel):
4 bl_idname = "SCENE_PT_mspgl_properties"
5 bl_label = "MspGL properties"
6 bl_space_type = "PROPERTIES"
7 bl_region_type = "WINDOW"
10 def draw(self, context):
13 self.layout.prop(scene, "scene_type")
15 class MspGLMeshProperties(bpy.types.Panel):
16 bl_idname = "MESH_PT_mspgl_properties"
17 bl_label = "MspGL properties"
18 bl_space_type = "PROPERTIES"
19 bl_region_type = "WINDOW"
23 def poll(cls, context):
24 return context.active_object.type=="MESH"
26 def draw(self, context):
27 mesh = context.active_object.data
29 self.layout.prop(mesh, "winding_test")
30 self.layout.prop(mesh, "smoothing")
31 self.layout.prop(mesh, "use_strips")
33 self.layout.separator()
35 col = self.layout.column()
36 col.label(text="Data selection")
37 col.prop(mesh, "use_lines")
38 col.prop(mesh, "vertex_groups")
39 col.prop(mesh, "max_groups_per_vertex")
41 self.layout.separator()
43 col = self.layout.column()
44 col.label(text="Texturing")
45 col.prop(mesh, "use_uv")
46 col.prop(mesh, "tangent_vecs")
47 col.prop(mesh, "tangent_uvtex")
49 class MspGLObjectProperties(bpy.types.Panel):
50 bl_idname = "OBJECT_PT_mspgl_properties"
51 bl_label = "MspGL properties"
52 bl_space_type = "PROPERTIES"
53 bl_region_type = "WINDOW"
56 def draw(self, context):
57 obj = context.active_object
59 self.layout.prop(obj, "compound")
60 self.layout.prop(obj, "lod_for_parent")
61 if obj.lod_for_parent:
62 self.layout.prop(obj, "lod_index")
64 class MspGLMaterialProperties(bpy.types.Panel):
65 bl_idname = "MATERIAL_PT_mspgl_properties"
66 bl_label = "MspGL properties"
67 bl_space_type = "PROPERTIES"
68 bl_region_type = "WINDOW"
69 bl_context = "material"
72 def poll(cls, context):
73 return context.active_object.active_material is not None
75 def draw(self, context):
76 mat = context.active_object.active_material
80 self.layout.prop(mat, "render_mode")
81 if mat.render_mode=='CUSTOM':
82 self.layout.prop(mat, "shader")
83 elif mat.render_mode=='EXTERNAL':
84 self.layout.prop(mat, "technique")
85 self.layout.prop(mat, "array_atlas")
87 self.layout.prop(mat, "array_layer")
88 if mat.render_mode!='EXTERNAL':
89 self.layout.prop(mat, "material_atlas")
90 if mat.render_mode=='CUSTOM':
91 self.layout.separator()
92 self.layout.label(text="Uniform values")
93 self.layout.template_list("MATERIAL_UL_mspgl_uniforms", "", mat, "uniforms", mat, "active_uniform_index")
94 row = self.layout.row()
95 row.operator("material.add_uniform")
96 row.operator("material.remove_uniform")
98 if mat.active_uniform_index<len(mat.uniforms):
99 uniform = mat.uniforms[mat.active_uniform_index]
100 self.layout.prop(uniform, "name")
101 self.layout.prop(uniform, "size")
102 row = self.layout.row(align=True)
103 row.label(text="Values")
104 for i in range(uniform.size):
105 row.prop(uniform, "values", text="", index=i)
107 class MspGLTextureNodeProperties(bpy.types.Panel):
108 bl_idname = "NODE_PT_mspgl_properties"
109 bl_label = "MspGL properties"
110 bl_space_type = "NODE_EDITOR"
111 bl_region_type = "UI"
115 def poll(cls, context):
116 node = context.active_node
117 return node and node.type=='TEX_IMAGE'
119 def draw(self, context):
120 node = context.active_node
124 self.layout.prop(node, "default_filter")
125 if not node.default_filter:
126 self.layout.prop(node, "use_mipmap")
127 self.layout.prop(node, "max_anisotropy")
129 class MspGLUniform(bpy.types.PropertyGroup):
130 name: bpy.props.StringProperty(name="Name", description="Name of the uniform variable")
131 size: bpy.props.IntProperty(name="Size", description="Number of elements in the uniform", min=1, max=4, default=4)
132 values: bpy.props.FloatVectorProperty(name="Values", description="Values stored in the uniform", size=4)
134 class MspGLUniformList(bpy.types.UIList):
135 bl_idname = "MATERIAL_UL_mspgl_uniforms"
137 def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
139 if self.layout_type=="GRID":
140 layout.label(text="", icon_value=icon)
142 layout.prop(uniform, "name", text="", emboss=False, icon_value=icon)
143 layout.label(text="({})".format(", ".join("{:.3f}".format(v) for v in uniform.values[:uniform.size])))
145 classes = [MspGLSceneProperties, MspGLMeshProperties, MspGLObjectProperties, MspGLMaterialProperties, MspGLTextureNodeProperties, MspGLUniform, MspGLUniformList]
147 def register_properties():
149 bpy.utils.register_class(c)
151 bpy.types.Scene.scene_type = bpy.props.EnumProperty(name="Scene type", description="Type of scene to use for exporting", default="SIMPLE",
152 items=(("SIMPLE", "Simple", "Objects are rendered in no specific order"),
153 ("ORDERED", "Ordered", "Objects are rendered in order by their name"),
154 ("ZSORTED", "Z-sorted", "Objects are rendered in order by their distance from the camera")))
156 bpy.types.Mesh.winding_test = bpy.props.BoolProperty(name="Winding test", description="Perform winding test to skip back faces")
157 bpy.types.Mesh.smoothing = bpy.props.EnumProperty(name="Smoothing", description="Smoothing method to use", default="MSPGL",
158 items=(("NONE", "None", "No smoothing"),
159 ("BLENDER", "Blender", "Use Blender's vertex normals"),
160 ("MSPGL", "MspGL", "Compute vertex normals internally")))
161 bpy.types.Mesh.use_lines = bpy.props.BoolProperty(name="Include lines", description="Include edges without faces as lines", default=False)
162 bpy.types.Mesh.use_strips = bpy.props.BoolProperty(name="Use strips", description="Combine the mesh's triangles into triangle strips", default=True)
163 bpy.types.Mesh.vertex_groups = bpy.props.BoolProperty(name="Vertex groups", description="Include vertex groups and weights", default=False)
164 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)
165 bpy.types.Mesh.use_uv = bpy.props.EnumProperty(name="Use UV", description="Use UV coordinates", default="UNIT0",
166 items=(("NONE", "None", "Ignore all UV coordinates"),
167 ("UNIT0", "Unit 0", "Use UV coordinates for unit 0"),
168 ("ALL", "All", "Use all UV coordinates")))
169 bpy.types.Mesh.tangent_vecs = bpy.props.EnumProperty(name="Tangent vectors", description="Compute tangent vectors for vertices", default="AUTO",
170 items=(("NO", "No", "Do not export tangent vectors"),
171 ("AUTO", "Auto", "Automatically determine the need for tangent vectors"),
172 ("YES", "Yes", "Always export tangent vectors")))
173 bpy.types.Mesh.tangent_uvtex = bpy.props.StringProperty(name="Tangent UV layer", description="UV layer to use as basis for tangent vectors", default="")
175 bpy.types.Object.compound = bpy.props.BoolProperty(name="Compound with parent", description="Join this object to its parent when exporting")
176 bpy.types.Object.lod_for_parent = bpy.props.BoolProperty(name="LoD for parent", description="This object is a level of detail for its parent")
177 bpy.types.Object.lod_index = bpy.props.IntProperty(name="LoD index", description="Index of the level of detail", min=1, max=16, default=1)
179 bpy.types.Material.render_mode = bpy.props.EnumProperty(name="Render mode", description="How this material should be rendered", default="BUILTIN",
180 items=(("BUILTIN", "Built-in", "Use built-in shaders"),
181 ("CUSTOM", "Custom shader", "Use a custom shader"),
182 ("EXTERNAL", "External technique", "Use an externally defined technique")))
183 bpy.types.Material.technique = bpy.props.StringProperty(name="Custom technique", description="Name of an external technique to use for rendering")
184 bpy.types.Material.shader = bpy.props.StringProperty(name="Custom shader", description="Name of an external technique to use for rendering")
185 bpy.types.Material.array_atlas = bpy.props.BoolProperty(name="Texture array atlas", description="The material is stored in a texture array")
186 bpy.types.Material.array_layer = bpy.props.IntProperty("Texture array layer", description="Layer of the texture array atlas to use")
187 bpy.types.Material.material_atlas = bpy.props.BoolProperty(name="Material atlas", description="Make this material part of a material atlas")
188 bpy.types.Material.uniforms = bpy.props.CollectionProperty(type=MspGLUniform, name="Uniform", description="Uniform variables to add to the technique")
189 bpy.types.Material.active_uniform_index = bpy.props.IntProperty("Active uniform index")
191 bpy.types.ShaderNodeTexImage.default_filter = bpy.props.BoolProperty(name="Default filter", description="Let the loading program determine filtering options")
192 bpy.types.ShaderNodeTexImage.use_mipmap = bpy.props.BoolProperty(name="Use mipmaps", description="Use mipmaps (automatically generated) for the texture", default=True)
193 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)
195 def unregister_properties():
197 bpy.utils.unregister_class(c)