Skip to content
Snippets Groups Projects
texturing_gui.py 48 KiB
Newer Older
  • Learn to ignore specific revisions
  • Maurice Raybaud's avatar
    Maurice Raybaud committed
            idblock = pov_context_tex_datablock(context)
            # tex = context.pov_texture_slot
            # mat = bpy.context.active_object.active_material
            texslot = idblock.pov_texture_slots[
                idblock.pov.active_texture_index
            ]  # bpy.data.textures[mat.active_texture_index]
    
            # below tex unused yet ...maybe for particles?
            try:
                tex = bpy.data.textures[idblock.pov_texture_slots[idblock.pov.active_texture_index].texture]  # NOT USED
            except KeyError:
                tex = None  # NOT USED
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
    
            def factor_but(layout, toggle, factor, name):
                row = layout.row(align=True)
                row.prop(texslot, toggle, text="")
                sub = row.row(align=True)
                sub.active = getattr(texslot, toggle)
                sub.prop(texslot, factor, text=name, slider=True)
                return sub  # XXX, temp. use_map_normal needs to override.
    
            if isinstance(idblock, Material):
                split = layout.split()
    
                col = split.column()
                if idblock.pov.type in {'SURFACE', 'WIRE'}:
    
                    split = layout.split()
    
                    col = split.column()
                    col.label(text="Diffuse:")
                    factor_but(col, "use_map_diffuse", "diffuse_factor", "Intensity")
                    factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
                    factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
                    factor_but(col, "use_map_translucency", "translucency_factor", "Translucency")
    
                    col.label(text="Specular:")
                    factor_but(col, "use_map_specular", "specular_factor", "Intensity")
                    factor_but(col, "use_map_color_spec", "specular_color_factor", "Color")
                    factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
    
                    col = split.column()
                    col.label(text="Shading:")
                    factor_but(col, "use_map_ambient", "ambient_factor", "Ambient")
                    factor_but(col, "use_map_emit", "emit_factor", "Emit")
                    factor_but(col, "use_map_mirror", "mirror_factor", "Mirror")
                    factor_but(col, "use_map_raymir", "raymir_factor", "Ray Mirror")
    
                    col.label(text="Geometry:")
                    # XXX replace 'or' when displacement is fixed to not rely on normal influence value.
                    sub_tmp = factor_but(col, "use_map_normal", "normal_factor", "Normal")
                    sub_tmp.active = texslot.use_map_normal or texslot.use_map_displacement
                    # END XXX
    
                    factor_but(col, "use_map_warp", "warp_factor", "Warp")
                    factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
    
                elif idblock.pov.type == 'HALO':
                    layout.label(text="Halo:")
    
                    split = layout.split()
    
                    col = split.column()
                    factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
                    factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
    
                    col = split.column()
                    factor_but(col, "use_map_raymir", "raymir_factor", "Size")
                    factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
                    factor_but(col, "use_map_translucency", "translucency_factor", "Add")
                elif idblock.pov.type == 'VOLUME':
                    layout.label(text="Volume:")
    
                    split = layout.split()
    
                    col = split.column()
                    factor_but(col, "use_map_density", "density_factor", "Density")
                    factor_but(col, "use_map_emission", "emission_factor", "Emission")
                    factor_but(col, "use_map_scatter", "scattering_factor", "Scattering")
                    factor_but(col, "use_map_reflect", "reflection_factor", "Reflection")
    
                    col = split.column()
                    col.label(text=" ")
                    factor_but(col, "use_map_color_emission", "emission_color_factor", "Emission Color")
                    factor_but(
                        col,
                        "use_map_color_transmission",
                        "transmission_color_factor",
                        "Transmission Color",
                    )
                    factor_but(
                        col, "use_map_color_reflection", "reflection_color_factor", "Reflection Color"
                    )
    
                    layout.label(text="Geometry:")
    
                    split = layout.split()
    
                    col = split.column()
                    factor_but(col, "use_map_warp", "warp_factor", "Warp")
    
                    col = split.column()
                    factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
    
            elif isinstance(idblock, Light):
                split = layout.split()
    
                col = split.column()
                factor_but(col, "use_map_color", "color_factor", "Color")
    
                col = split.column()
                factor_but(col, "use_map_shadow", "shadow_factor", "Shadow")
    
            elif isinstance(idblock, World):
                split = layout.split()
    
                col = split.column()
                factor_but(col, "use_map_blend", "blend_factor", "Blend")
                factor_but(col, "use_map_horizon", "horizon_factor", "Horizon")
    
                col = split.column()
                factor_but(col, "use_map_zenith_up", "zenith_up_factor", "Zenith Up")
                factor_but(col, "use_map_zenith_down", "zenith_down_factor", "Zenith Down")
            elif isinstance(idblock, ParticleSettings):
                split = layout.split()
    
                col = split.column()
                col.label(text="General:")
                factor_but(col, "use_map_time", "time_factor", "Time")
                factor_but(col, "use_map_life", "life_factor", "Lifetime")
                factor_but(col, "use_map_density", "density_factor", "Density")
                factor_but(col, "use_map_size", "size_factor", "Size")
    
                col = split.column()
                col.label(text="Physics:")
                factor_but(col, "use_map_velocity", "velocity_factor", "Velocity")
                factor_but(col, "use_map_damp", "damp_factor", "Damp")
                factor_but(col, "use_map_gravity", "gravity_factor", "Gravity")
                factor_but(col, "use_map_field", "field_factor", "Force Fields")
    
                layout.label(text="Hair:")
    
                split = layout.split()
    
                col = split.column()
                factor_but(col, "use_map_length", "length_factor", "Length")
                factor_but(col, "use_map_clump", "clump_factor", "Clump")
                factor_but(col, "use_map_twist", "twist_factor", "Twist")
    
                col = split.column()
                factor_but(col, "use_map_kink_amp", "kink_amp_factor", "Kink Amplitude")
                factor_but(col, "use_map_kink_freq", "kink_freq_factor", "Kink Frequency")
                factor_but(col, "use_map_rough", "rough_factor", "Rough")
    
            elif isinstance(idblock, FreestyleLineStyle):
                split = layout.split()
    
                col = split.column()
                factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
                col = split.column()
                factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
    
            layout.separator()
    
            if not isinstance(idblock, ParticleSettings):
                split = layout.split()
    
                col = split.column()
                # col.prop(tex, "blend_type", text="Blend") #deprecated since 2.8
                # col.prop(tex, "use_rgb_to_intensity") #deprecated since 2.8
                # color is used on gray-scale textures even when use_rgb_to_intensity is disabled.
                # col.prop(tex, "color", text="") #deprecated since 2.8
    
                col = split.column()
                # col.prop(tex, "invert", text="Negative") #deprecated since 2.8
                # col.prop(tex, "use_stencil") #deprecated since 2.8
    
            # if isinstance(idblock, (Material, World)):
            # col.prop(tex, "default_value", text="DVar", slider=True)
    
    
    class TEXTURE_PT_POV_tex_gamma(TextureButtonsPanel, Panel):
        """Use this class to define pov texture gamma buttons."""
    
        bl_label = "Image Gamma"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
    
        def draw_header(self, context):
            tex = context.texture
    
            self.layout.prop(tex.pov, "tex_gamma_enable", text="", icon='SEQ_LUMA_WAVEFORM')
    
        def draw(self, context):
            layout = self.layout
    
            tex = context.texture
    
            layout.active = tex.pov.tex_gamma_enable
            layout.prop(tex.pov, "tex_gamma_value", text="Gamma Value")
    
    
    # commented out below UI for texture only custom code inside exported material:
    # class TEXTURE_PT_povray_replacement_text(TextureButtonsPanel, Panel):
    # bl_label = "Custom POV Code"
    # COMPAT_ENGINES = {'POVRAY_RENDER'}
    
    # def draw(self, context):
    # layout = self.layout
    
    # tex = context.texture
    
    # col = layout.column()
    # col.label(text="Replace properties with:")
    # col.prop(tex.pov, "replacement_text", text="")
    
    
    classes = (
        WORLD_TEXTURE_SLOTS_UL_POV_layerlist,
        TEXTURE_MT_POV_specials,
    
        # TEXTURE_PT_context # todo: solve UI design for painting
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
        TEXTURE_PT_POV_context_texture,
        TEXTURE_PT_colors,
        TEXTURE_PT_POV_type,
        TEXTURE_PT_POV_preview,
        TEXTURE_PT_POV_parameters,
        TEXTURE_PT_POV_tex_gamma,
        MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist,
        TEXTURE_OT_POV_texture_slot_add,
        TEXTURE_OT_POV_texture_slot_remove,
        TEXTURE_PT_POV_influence,
        TEXTURE_PT_POV_mapping,
    )
    
    
    def register():
        for cls in classes:
            register_class(cls)
    
    
    def unregister():
        for cls in reversed(classes):
    
            # if cls != TEXTURE_PT_context:
            unregister_class(cls)