21
from bpy.types import Menu, Panel
21
from bpy.types import Menu, Panel, UIList
23
23
from bpy.types import (Brush,
30
31
from rna_prop_ui import PropertyPanel
33
from bl_ui.properties_paint_common import brush_texture_settings
33
36
class TEXTURE_MT_specials(Menu):
34
37
bl_label = "Texture Specials"
52
55
layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
53
56
layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
59
class TEXTURE_UL_texslots(UIList):
60
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
61
# assert(isinstance(item, bpy.types.MaterialTextureSlot)
64
tex = slot.texture if slot else None
65
if self.layout_type in {'DEFAULT', 'COMPACT'}:
66
layout.label(text=tex.name if tex else "", translate=False, icon_value=icon)
67
if tex and isinstance(item, bpy.types.MaterialTextureSlot):
68
layout.prop(ma, "use_textures", text="", index=index)
69
elif self.layout_type in {'GRID'}:
70
layout.alignment = 'CENTER'
71
layout.label(text="", icon_value=icon)
55
74
from bl_ui.properties_material import active_node_mat
100
def id_tex_datablock(bid):
101
if isinstance(bid, Object):
102
if bid.type == 'LAMP':
104
return bid.active_material
81
109
class TextureButtonsPanel():
82
110
bl_space_type = 'PROPERTIES'
83
111
bl_region_type = 'WINDOW'
99
127
engine = context.scene.render.engine
100
128
if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
102
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, ParticleSettings))
103
and (engine in cls.COMPAT_ENGINES))
130
return ((context.material or
135
context.particle_system or
136
isinstance(context.space_data.pin_id, ParticleSettings)) and
137
(engine in cls.COMPAT_ENGINES))
105
139
def draw(self, context):
106
140
layout = self.layout
107
142
slot = getattr(context, "texture_slot", None)
108
143
node = getattr(context, "texture_node", None)
109
144
space = context.space_data
123
158
if tex_collection:
124
159
row = layout.row()
126
row.template_list(idblock, "texture_slots", idblock, "active_texture_index", rows=2)
161
row.template_list("TEXTURE_UL_texslots", "", idblock, "texture_slots", idblock, "active_texture_index", rows=2)
128
163
col = row.column(align=True)
129
164
col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
130
165
col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
131
166
col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
133
split = layout.split(percentage=0.65)
136
168
if tex_collection:
137
col.template_ID(idblock, "active_texture", new="texture.new")
169
layout.template_ID(idblock, "active_texture", new="texture.new")
139
col.template_ID(node, "texture", new="texture.new")
171
layout.template_ID(node, "texture", new="texture.new")
141
col.template_ID(idblock, "texture", new="texture.new")
173
layout.template_ID(idblock, "texture", new="texture.new")
144
col.template_ID(space, "pin_id")
176
layout.template_ID(space, "pin_id")
149
179
split = layout.split(percentage=0.2)
402
432
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
404
434
def draw(self, context):
435
if context.scene.render.engine == 'BLENDER_GAME':
436
self.draw_bge(context)
438
self.draw_bi(context)
440
def draw_bi(self, context):
405
441
layout = self.layout
407
443
idblock = context_tex_datablock(context)
413
449
col = split.column()
414
450
col.label(text="Alpha:")
415
col.prop(tex, "use_alpha", text="Use")
452
row.active = tex.image and tex.image.use_alpha
453
row.prop(tex, "use_alpha", text="Use")
416
454
col.prop(tex, "use_calculate_alpha", text="Calculate")
417
455
col.prop(tex, "invert_alpha", text="Invert")
440
478
texture_filter_common(tex, col)
480
def draw_bge(self, context):
483
idblock = context_tex_datablock(context)
484
tex = context.texture
485
slot = getattr(context, "texture_slot", None)
487
split = layout.split()
490
col.label(text="Alpha:")
491
col.prop(tex, "use_calculate_alpha", text="Calculate")
492
col.prop(tex, "invert_alpha", text="Invert")
496
#Only for Material based textures, not for Lamp/World...
497
if slot and isinstance(idblock, Material):
498
col.prop(tex, "use_normal_map")
500
row.active = tex.use_normal_map
501
row.prop(slot, "normal_map_space", text="")
504
row.active = not tex.use_normal_map
505
row.prop(tex, "use_derivative_map")
443
508
class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
444
509
bl_label = "Image Mapping"
855
920
split.prop(tex, "object", text="")
857
922
if isinstance(idblock, Brush):
858
if context.sculpt_object:
859
layout.label(text="Brush Mapping:")
860
layout.prop(tex, "map_mode", expand=True)
863
row.active = tex.map_mode in {'FIXED', 'TILED'}
864
row.prop(tex, "angle")
923
if context.sculpt_object or context.image_paint_object:
924
brush_texture_settings(layout, idblock, context.sculpt_object)
866
926
if isinstance(idblock, Material):
867
927
split = layout.split(percentage=0.3)
873
933
col = split.column()
874
934
if tex.texture_coords in {'ORCO', 'UV'}:
875
935
col.prop(tex, "use_from_dupli")
936
if (idblock.type == 'VOLUME' and tex.texture_coords == 'ORCO'):
937
col.prop(tex, "use_map_to_bounds")
876
938
elif tex.texture_coords == 'OBJECT':
877
939
col.prop(tex, "use_from_original")
940
if (idblock.type == 'VOLUME'):
941
col.prop(tex, "use_map_to_bounds")
884
948
row.prop(tex, "mapping_y", text="")
885
949
row.prop(tex, "mapping_z", text="")
888
row.column().prop(tex, "offset")
889
row.column().prop(tex, "scale")
952
row.column().prop(tex, "offset")
953
row.column().prop(tex, "scale")
892
956
class TEXTURE_PT_influence(TextureSlotPanel, Panel):