diff options
Diffstat (limited to 'release/scripts/ui/properties_texture.py')
-rw-r--r-- | release/scripts/ui/properties_texture.py | 549 |
1 files changed, 316 insertions, 233 deletions
diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index d6d5a806a9c..04edf8ea7e8 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -60,6 +60,12 @@ def context_tex_datablock(context): return idblock idblock = context.brush + if idblock: + return idblock + + if context.particle_system: + idblock = context.particle_system.settings + return idblock @@ -84,7 +90,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): engine = context.scene.render.engine if not hasattr(context, "texture_slot"): return False - return ((context.material or context.world or context.lamp or context.brush or context.texture) + return ((context.material or context.world or context.lamp or context.brush or context.texture or context.particle_system or isinstance(context.space_data.pin_id, bpy.types.ParticleSettings)) and (engine in cls.COMPAT_ENGINES)) def draw(self, context): @@ -94,7 +100,16 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): space = context.space_data tex = context.texture idblock = context_tex_datablock(context) - tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node + pin_id = space.pin_id + + if space.use_pin_id and not isinstance(pin_id, bpy.types.Texture): + idblock = pin_id + pin_id = None + + if not space.use_pin_id: + layout.prop(space, "texture_context", expand=True) + + tex_collection = (pin_id is None) and (node is None) and (not isinstance(idblock, bpy.types.Brush)) if tex_collection: row = layout.row() @@ -116,14 +131,11 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): elif idblock: col.template_ID(idblock, "texture", new="texture.new") - if space.pin_id: + if pin_id: col.template_ID(space, "pin_id") col = split.column() - if not space.pin_id: - col.prop(space, "show_brush_texture", text="Brush", toggle=True) - if tex: split = layout.split(percentage=0.2) @@ -199,216 +211,6 @@ class TextureSlotPanel(TextureButtonsPanel): return TextureButtonsPanel.poll(self, context) and (engine in cls.COMPAT_ENGINES) -class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel): - bl_label = "Mapping" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - - @classmethod - def poll(cls, context): - idblock = context_tex_datablock(context) - if type(idblock) == bpy.types.Brush and not context.sculpt_object: - return False - - if not getattr(context, "texture_slot", None): - return False - - engine = context.scene.render.engine - return (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - layout = self.layout - - idblock = context_tex_datablock(context) - - tex = context.texture_slot - # textype = context.texture - - if type(idblock) != bpy.types.Brush: - split = layout.split(percentage=0.3) - col = split.column() - col.label(text="Coordinates:") - col = split.column() - col.prop(tex, "texture_coords", text="") - - if tex.texture_coords == 'ORCO': - """ - ob = context.object - if ob and ob.type == 'MESH': - split = layout.split(percentage=0.3) - split.label(text="Mesh:") - split.prop(ob.data, "texco_mesh", text="") - """ - elif tex.texture_coords == 'UV': - split = layout.split(percentage=0.3) - split.label(text="Layer:") - ob = context.object - if ob and ob.type == 'MESH': - split.prop_search(tex, "uv_layer", ob.data, "uv_textures", text="") - else: - split.prop(tex, "uv_layer", text="") - - elif tex.texture_coords == 'OBJECT': - split = layout.split(percentage=0.3) - split.label(text="Object:") - split.prop(tex, "object", text="") - - if type(idblock) == bpy.types.Brush: - if context.sculpt_object: - layout.label(text="Brush Mapping:") - layout.prop(tex, "map_mode", expand=True) - - row = layout.row() - row.active = tex.map_mode in ('FIXED', 'TILED') - row.prop(tex, "angle") - else: - if type(idblock) == bpy.types.Material: - split = layout.split(percentage=0.3) - split.label(text="Projection:") - split.prop(tex, "mapping", text="") - - split = layout.split() - - col = split.column() - if tex.texture_coords in ('ORCO', 'UV'): - col.prop(tex, "use_from_dupli") - elif tex.texture_coords == 'OBJECT': - col.prop(tex, "use_from_original") - else: - col.label() - - col = split.column() - row = col.row() - row.prop(tex, "mapping_x", text="") - row.prop(tex, "mapping_y", text="") - row.prop(tex, "mapping_z", text="") - - split = layout.split() - - col = split.column() - col.prop(tex, "offset") - - col = split.column() - - col.prop(tex, "scale") - - -class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel): - bl_label = "Influence" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} - - @classmethod - def poll(cls, context): - idblock = context_tex_datablock(context) - if type(idblock) == bpy.types.Brush: - return False - - if not getattr(context, "texture_slot", None): - return False - - engine = context.scene.render.engine - return (engine in cls.COMPAT_ENGINES) - - def draw(self, context): - - layout = self.layout - - idblock = context_tex_datablock(context) - - # textype = context.texture - tex = context.texture_slot - - def factor_but(layout, active, toggle, factor, name): - row = layout.row(align=True) - row.prop(tex, toggle, text="") - sub = row.row() - sub.active = active - sub.prop(tex, factor, text=name, slider=True) - - if type(idblock) == bpy.types.Material: - if idblock.type in ('SURFACE', 'HALO', 'WIRE'): - split = layout.split() - - col = split.column() - col.label(text="Diffuse:") - factor_but(col, tex.use_map_diffuse, "use_map_diffuse", "diffuse_factor", "Intensity") - factor_but(col, tex.use_map_color_diffuse, "use_map_color_diffuse", "diffuse_color_factor", "Color") - factor_but(col, tex.use_map_alpha, "use_map_alpha", "alpha_factor", "Alpha") - factor_but(col, tex.use_map_translucency, "use_map_translucency", "translucency_factor", "Translucency") - - col.label(text="Specular:") - factor_but(col, tex.use_map_specular, "use_map_specular", "specular_factor", "Intensity") - factor_but(col, tex.use_map_color_spec, "use_map_color_spec", "specular_color_factor", "Color") - factor_but(col, tex.use_map_hardness, "use_map_hardness", "hardness_factor", "Hardness") - - col = split.column() - col.label(text="Shading:") - factor_but(col, tex.use_map_ambient, "use_map_ambient", "ambient_factor", "Ambient") - factor_but(col, tex.use_map_emit, "use_map_emit", "emit_factor", "Emit") - factor_but(col, tex.use_map_mirror, "use_map_mirror", "mirror_factor", "Mirror") - factor_but(col, tex.use_map_raymir, "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. - factor_but(col, (tex.use_map_normal or tex.use_map_displacement), "use_map_normal", "normal_factor", "Normal") - factor_but(col, tex.use_map_warp, "use_map_warp", "warp_factor", "Warp") - factor_but(col, tex.use_map_displacement, "use_map_displacement", "displacement_factor", "Displace") - - #sub = col.column() - #sub.active = tex.use_map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror - #sub.prop(tex, "default_value", text="Amount", slider=True) - elif idblock.type == 'VOLUME': - split = layout.split() - - col = split.column() - factor_but(col, tex.use_map_density, "use_map_density", "density_factor", "Density") - factor_but(col, tex.use_map_emission, "use_map_emission", "emission_factor", "Emission") - factor_but(col, tex.use_map_scatter, "use_map_scatter", "scattering_factor", "Scattering") - factor_but(col, tex.use_map_reflect, "use_map_reflect", "reflection_factor", "Reflection") - - col = split.column() - col.label(text=" ") - factor_but(col, tex.use_map_color_emission, "use_map_color_emission", "emission_color_factor", "Emission Color") - factor_but(col, tex.use_map_color_transmission, "use_map_color_transmission", "transmission_color_factor", "Transmission Color") - factor_but(col, tex.use_map_color_reflection, "use_map_color_reflection", "reflection_color_factor", "Reflection Color") - - elif type(idblock) == bpy.types.Lamp: - split = layout.split() - - col = split.column() - factor_but(col, tex.use_map_color, "map_color", "color_factor", "Color") - - col = split.column() - factor_but(col, tex.use_map_shadow, "map_shadow", "shadow_factor", "Shadow") - - elif type(idblock) == bpy.types.World: - split = layout.split() - - col = split.column() - factor_but(col, tex.use_map_blend, "use_map_blend", "blend_factor", "Blend") - factor_but(col, tex.use_map_horizon, "use_map_horizon", "horizon_factor", "Horizon") - - col = split.column() - factor_but(col, tex.use_map_zenith_up, "use_map_zenith_up", "zenith_up_factor", "Zenith Up") - factor_but(col, tex.use_map_zenith_down, "use_map_zenith_down", "zenith_down_factor", "Zenith Down") - - layout.separator() - - split = layout.split() - - col = split.column() - col.prop(tex, "blend_type", text="Blend") - col.prop(tex, "use_rgb_to_intensity") - sub = col.column() - sub.active = tex.use_rgb_to_intensity - sub.prop(tex, "color", text="") - - col = split.column() - col.prop(tex, "invert", text="Negative") - col.prop(tex, "use_stencil") - - if type(idblock) in (bpy.types.Material, bpy.types.World): - col.prop(tex, "default_value", text="DVar", slider=True) - # Texture Type Panels # @@ -599,8 +401,9 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): def draw(self, context): layout = self.layout + idblock = context_tex_datablock(context) tex = context.texture - # slot = context.texture_slot + slot = context.texture_slot split = layout.split() @@ -614,10 +417,12 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): col = split.column() - col.prop(tex, "use_normal_map") - row = col.row() - row.active = tex.use_normal_map - row.prop(tex, "normal_space", text="") + #Only for Material based textures, not for Lamp/World... + if isinstance(idblock, bpy.types.Material): + col.prop(tex, "use_normal_map") + row = col.row() + row.active = tex.use_normal_map + row.prop(slot, "normal_map_space", text="") col.prop(tex, "use_mipmap") row = col.row() @@ -651,8 +456,12 @@ class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel): col = split.column(align=True) col.label(text="Mirror:") - col.prop(tex, "use_mirror_x", text="X") - col.prop(tex, "use_mirror_y", text="Y") + row = col.row() + row.prop(tex, "use_mirror_x", text="X") + row.active = (tex.repeat_x > 1) + row = col.row() + row.prop(tex, "use_mirror_y", text="Y") + row.active = (tex.repeat_y > 1) layout.separator() elif tex.extension == 'CHECKER': @@ -691,7 +500,6 @@ class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel): tex = context.texture env = tex.environment_map - row = layout.row() row.prop(env, "source", expand=True) row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="") @@ -752,12 +560,14 @@ class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel): col.prop(tex, "lacunarity") col.prop(tex, "octaves") + musgrave_type = tex.musgrave_type col = split.column() - if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')): + if musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'): col.prop(tex, "offset") - if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')): - col.prop(tex, "gain") + if musgrave_type in ('MULTIFRACTAL', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'): col.prop(tex, "noise_intensity", text="Intensity") + if musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'): + col.prop(tex, "gain") layout.label(text="Noise:") @@ -865,10 +675,11 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel): layout.template_image(tex, "image", tex.image_user, compact=True) #layout.prop(vd, "frame_duration") - layout.prop(vd, "use_still_frame") - row = layout.row() - row.active = vd.use_still_frame - row.prop(vd, "still_frame") + if vd.file_format in ('BLENDER_VOXEL', 'RAW_8BIT'): + layout.prop(vd, "use_still_frame") + row = layout.row() + row.active = vd.use_still_frame + row.prop(vd, "still_frame") layout.prop(vd, "interpolation") layout.prop(vd, "extension") @@ -971,17 +782,289 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel): col.prop(pd, "turbulence_strength") +class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel): + bl_label = "Mapping" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + @classmethod + def poll(cls, context): + idblock = context_tex_datablock(context) + if isinstance(idblock, bpy.types.Brush) and not context.sculpt_object: + return False + + if not getattr(context, "texture_slot", None): + return False + + engine = context.scene.render.engine + return (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + + idblock = context_tex_datablock(context) + + tex = context.texture_slot + # textype = context.texture + + if not isinstance(idblock, bpy.types.Brush): + split = layout.split(percentage=0.3) + col = split.column() + col.label(text="Coordinates:") + col = split.column() + col.prop(tex, "texture_coords", text="") + + if tex.texture_coords == 'ORCO': + """ + ob = context.object + if ob and ob.type == 'MESH': + split = layout.split(percentage=0.3) + split.label(text="Mesh:") + split.prop(ob.data, "texco_mesh", text="") + """ + elif tex.texture_coords == 'UV': + split = layout.split(percentage=0.3) + split.label(text="Layer:") + ob = context.object + if ob and ob.type == 'MESH': + split.prop_search(tex, "uv_layer", ob.data, "uv_textures", text="") + else: + split.prop(tex, "uv_layer", text="") + + elif tex.texture_coords == 'OBJECT': + split = layout.split(percentage=0.3) + split.label(text="Object:") + split.prop(tex, "object", text="") + + if isinstance(idblock, bpy.types.Brush): + if context.sculpt_object: + layout.label(text="Brush Mapping:") + layout.prop(tex, "map_mode", expand=True) + + row = layout.row() + row.active = tex.map_mode in ('FIXED', 'TILED') + row.prop(tex, "angle") + else: + if isinstance(idblock, bpy.types.Material): + split = layout.split(percentage=0.3) + split.label(text="Projection:") + split.prop(tex, "mapping", text="") + + split = layout.split() + + col = split.column() + if tex.texture_coords in ('ORCO', 'UV'): + col.prop(tex, "use_from_dupli") + elif tex.texture_coords == 'OBJECT': + col.prop(tex, "use_from_original") + else: + col.label() + + col = split.column() + row = col.row() + row.prop(tex, "mapping_x", text="") + row.prop(tex, "mapping_y", text="") + row.prop(tex, "mapping_z", text="") + + split = layout.split() + + col = split.column() + col.prop(tex, "offset") + + col = split.column() + + col.prop(tex, "scale") + + +class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel): + bl_label = "Influence" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + @classmethod + def poll(cls, context): + idblock = context_tex_datablock(context) + if isinstance(idblock, bpy.types.Brush): + return False + + if not getattr(context, "texture_slot", None): + return False + + engine = context.scene.render.engine + return (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + + layout = self.layout + + idblock = context_tex_datablock(context) + + # textype = context.texture + tex = context.texture_slot + + def factor_but(layout, toggle, factor, name): + row = layout.row(align=True) + row.prop(tex, toggle, text="") + sub = row.row() + sub.active = getattr(tex, toggle) + sub.prop(tex, factor, text=name, slider=True) + return sub # XXX, temp. use_map_normal needs to override. + + if isinstance(idblock, bpy.types.Material): + if idblock.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 = (tex.use_map_normal or tex.use_map_displacement) + # END XXX + + factor_but(col, "use_map_warp", "warp_factor", "Warp") + factor_but(col, "use_map_displacement", "displacement_factor", "Displace") + + #sub = col.column() + #sub.active = tex.use_map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror + #sub.prop(tex, "default_value", text="Amount", slider=True) + elif idblock.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.type == '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") + + elif isinstance(idblock, bpy.types.Lamp): + 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, bpy.types.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, bpy.types.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") + + col = split.column() + factor_but(col, "use_map_kink", "kink_factor", "Kink") + factor_but(col, "use_map_rough", "rough_factor", "Rough") + + layout.separator() + + if not isinstance(idblock, bpy.types.ParticleSettings): + split = layout.split() + + col = split.column() + col.prop(tex, "blend_type", text="Blend") + col.prop(tex, "use_rgb_to_intensity") + # color is used on grayscale textures even when use_rgb_to_intensity is disabled. + col.prop(tex, "color", text="") + + col = split.column() + col.prop(tex, "invert", text="Negative") + col.prop(tex, "use_stencil") + + if isinstance(idblock, bpy.types.Material) or isinstance(idblock, bpy.types.World): + col.prop(tex, "default_value", text="DVar", slider=True) + + if isinstance(idblock, bpy.types.Material): + row = layout.row() + row.label(text="Bump Mapping:") + + row = layout.row() + # only show bump settings if activated but not for normalmap images + row.active = tex.use_map_normal and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) + + col = row.column() + col.prop(tex, "bump_method", text="Method") + + col = row.column() + col.prop(tex, "bump_objectspace", text="Space") + col.active = tex.bump_method in ('BUMP_DEFAULT', 'BUMP_BEST_QUALITY') + + class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "texture" + _property_type = bpy.types.Texture def register(): - pass + bpy.utils.register_module(__name__) def unregister(): - pass + bpy.utils.unregister_module(__name__) if __name__ == "__main__": register() |