+class MspGLMaterialProperties(bpy.types.Panel):
+ bl_idname = "MATERIAL_PT_mspgl_properties"
+ bl_label = "MspGL properties"
+ bl_space_type = "PROPERTIES"
+ bl_region_type = "WINDOW"
+ bl_context = "material"
+
+ @classmethod
+ def poll(cls, context):
+ return context.active_object.active_material is not None
+
+ def draw(self, context):
+ mat = context.active_object.active_material
+ if not mat:
+ return
+
+ self.layout.prop(mat, "render_mode")
+ if mat.render_mode=='CUSTOM':
+ self.layout.prop(mat, "shader")
+ elif mat.render_mode=='EXTERNAL':
+ self.layout.prop(mat, "technique")
+ self.layout.prop(mat, "array_atlas")
+ if mat.render_mode=='BUILTIN':
+ self.layout.prop(mat, "receive_shadows")
+ if mat.array_atlas:
+ self.layout.prop(mat, "array_layer")
+ if mat.render_mode!='EXTERNAL':
+ self.layout.prop(mat, "material_atlas")
+ if mat.render_mode=='CUSTOM':
+ self.layout.separator()
+ self.layout.label(text="Uniform values")
+ self.layout.template_list("MATERIAL_UL_mspgl_uniforms", "", mat, "uniforms", mat, "active_uniform_index")
+ row = self.layout.row()
+ row.operator("material.add_uniform")
+ row.operator("material.remove_uniform")
+
+ if mat.active_uniform_index<len(mat.uniforms):
+ uniform = mat.uniforms[mat.active_uniform_index]
+ self.layout.prop(uniform, "name")
+ self.layout.prop(uniform, "size")
+ row = self.layout.row(align=True)
+ row.label(text="Values")
+ for i in range(uniform.size):
+ row.prop(uniform, "values", text="", index=i)
+
+class MspGLTextureNodeProperties(bpy.types.Panel):
+ bl_idname = "NODE_PT_mspgl_properties"
+ bl_label = "MspGL properties"
+ bl_space_type = "NODE_EDITOR"
+ bl_region_type = "UI"
+ bl_category = "Item"
+
+ @classmethod
+ def poll(cls, context):
+ node = context.active_node
+ return node and node.type=='TEX_IMAGE'
+
+ def draw(self, context):
+ node = context.active_node
+ if not node:
+ return
+
+ self.layout.prop(node, "default_filter")
+ if not node.default_filter:
+ self.layout.prop(node, "use_mipmap")
+ self.layout.prop(node, "max_anisotropy")
+
+class MspGLLightProperties(bpy.types.Panel):
+ bl_idname = "LIGHT_PT_mspgl_properties"
+ bl_label = "MspGL properties"
+ bl_space_type = "PROPERTIES"
+ bl_region_type = "WINDOW"
+ bl_context = "data"
+
+ @classmethod
+ def poll(cls, context):
+ return context.active_object.type=="LIGHT"
+
+ def draw(self, context):
+ light = context.active_object.data
+
+ if light.use_shadow:
+ self.layout.prop(light, "shadow_map_size")
+
+class MspGLWorldProperties(bpy.types.Panel):
+ bl_idname = "WORLD_PT_mspgl_properties"
+ bl_label = "MspGL properties"
+ bl_space_type = "PROPERTIES"
+ bl_region_type = "WINDOW"
+ bl_context = "world"
+
+ def draw(self, context):
+ world = context.scene.world
+ self.layout.prop(world, "use_hdr")
+
+class MspGLUniform(bpy.types.PropertyGroup):
+ name: bpy.props.StringProperty(name="Name", description="Name of the uniform variable")
+ size: bpy.props.IntProperty(name="Size", description="Number of elements in the uniform", min=1, max=4, default=4)
+ values: bpy.props.FloatVectorProperty(name="Values", description="Values stored in the uniform", size=4)
+
+class MspGLUniformList(bpy.types.UIList):
+ bl_idname = "MATERIAL_UL_mspgl_uniforms"
+
+ def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
+ uniform = item
+ if self.layout_type=="GRID":
+ layout.label(text="", icon_value=icon)
+ else:
+ layout.prop(uniform, "name", text="", emboss=False, icon_value=icon)
+ layout.label(text="({})".format(", ".join("{:.3f}".format(v) for v in uniform.values[:uniform.size])))
+
+classes = [MspGLSceneProperties, MspGLMeshProperties, MspGLObjectProperties, MspGLMaterialProperties,
+ MspGLTextureNodeProperties, MspGLLightProperties, MspGLWorldProperties, MspGLUniform, MspGLUniformList]
+