1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
# gpl author: Ryan Inch (Imaginer)
import bpy
from bpy.types import Menu
from . import utils_core
class TextureMenu(Menu):
bl_label = "Texture Options"
bl_idname = "VIEW3D_MT_sv3_texture_menu"
@classmethod
def poll(self, context):
return utils_core.get_mode() in (
'SCULPT',
'VERTEX_PAINT',
'TEXTURE_PAINT'
)
def draw(self, context):
layout = self.layout
if utils_core.get_mode() == 'SCULPT':
self.sculpt(layout, context)
elif utils_core.get_mode() == 'VERTEX_PAINT':
self.vertpaint(layout, context)
else:
self.texpaint(layout, context)
def sculpt(self, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush")
tex_slot = has_brush.texture_slot if has_brush else None
# Menus
layout.row().menu(Textures.bl_idname)
layout.row().menu(TextureMapMode.bl_idname)
layout.row().separator()
# Checkboxes
if tex_slot:
if tex_slot.map_mode != '3D':
if tex_slot.map_mode in ('RANDOM', 'VIEW_PLANE', 'AREA_PLANE'):
layout.row().prop(tex_slot, "use_rake", toggle=True)
layout.row().prop(tex_slot, "use_random", toggle=True)
# Sliders
layout.row().prop(tex_slot, "angle",
text=utils_core.PIW + "Angle", slider=True)
if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE') and tex_slot.use_random:
layout.row().prop(tex_slot, "random_angle",
text=utils_core.PIW + "Random Angle", slider=True)
# Operator
if tex_slot.tex_paint_map_mode == 'STENCIL':
if has_brush.texture and has_brush.texture.type == 'IMAGE':
layout.row().operator("brush.stencil_fit_image_aspect")
layout.row().operator("brush.stencil_reset_transform")
else:
layout.row().label(text="No Texture Slot available", icon="INFO")
def vertpaint(self, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush")
tex_slot = has_brush.texture_slot if has_brush else None
# Menus
layout.row().menu(Textures.bl_idname)
layout.row().menu(TextureMapMode.bl_idname)
# Checkboxes
if tex_slot:
if tex_slot.tex_paint_map_mode != '3D':
if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE'):
layout.row().prop(tex_slot, "use_rake", toggle=True)
layout.row().prop(tex_slot, "use_random", toggle=True)
# Sliders
layout.row().prop(tex_slot, "angle",
text=utils_core.PIW + "Angle", slider=True)
if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE') and tex_slot.use_random:
layout.row().prop(tex_slot, "random_angle",
text=utils_core.PIW + "Random Angle", slider=True)
# Operator
if tex_slot.tex_paint_map_mode == 'STENCIL':
if has_brush.texture and has_brush.texture.type == 'IMAGE':
layout.row().operator("brush.stencil_fit_image_aspect")
layout.row().operator("brush.stencil_reset_transform")
else:
layout.row().label(text="No Texture Slot available", icon="INFO")
def texpaint(self, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush")
tex_slot = has_brush.texture_slot if has_brush else None
mask_tex_slot = has_brush.mask_texture_slot if has_brush else None
# Texture Section
layout.row().label(text="Texture", icon='TEXTURE')
# Menus
layout.row().menu(Textures.bl_idname)
layout.row().menu(TextureMapMode.bl_idname)
# Checkboxes
if tex_slot:
if tex_slot.tex_paint_map_mode != '3D':
if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE'):
layout.row().prop(tex_slot, "use_rake", toggle=True)
layout.row().prop(tex_slot, "use_random", toggle=True)
# Sliders
layout.row().prop(tex_slot, "angle",
text=utils_core.PIW + "Angle", slider=True)
if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE') and tex_slot.use_random:
layout.row().prop(tex_slot, "random_angle",
text=utils_core.PIW + "Random Angle", slider=True)
# Operator
if tex_slot.tex_paint_map_mode == 'STENCIL':
if has_brush.texture and has_brush.texture.type == 'IMAGE':
layout.row().operator("brush.stencil_fit_image_aspect")
layout.row().operator("brush.stencil_reset_transform")
else:
layout.row().label(text="No Texture Slot available", icon="INFO")
layout.row().separator()
# Texture Mask Section
layout.row().label(text="Texture Mask", icon='MOD_MASK')
# Menus
layout.row().menu(MaskTextures.bl_idname)
layout.row().menu(MaskMapMode.bl_idname)
layout.row().menu(MaskPressureModeMenu.bl_idname)
# Checkboxes
if mask_tex_slot:
if mask_tex_slot.mask_map_mode in ('RANDOM', 'VIEW_PLANE'):
layout.row().prop(mask_tex_slot, "use_rake", toggle=True)
layout.row().prop(mask_tex_slot, "use_random", toggle=True)
# Sliders
layout.row().prop(mask_tex_slot, "angle",
text=utils_core.PIW + "Angle", icon_value=5, slider=True)
if mask_tex_slot.mask_map_mode in ('RANDOM', 'VIEW_PLANE') and mask_tex_slot.use_random:
layout.row().prop(mask_tex_slot, "random_angle",
text=utils_core.PIW + "Random Angle", slider=True)
# Operator
if mask_tex_slot.mask_map_mode == 'STENCIL':
if has_brush.mask_texture and has_brush.mask_texture.type == 'IMAGE':
layout.row().operator("brush.stencil_fit_image_aspect")
prop = layout.row().operator("brush.stencil_reset_transform")
prop.mask = True
else:
layout.row().label(text="Mask Texture not available", icon="INFO")
class Textures(Menu):
bl_label = "Brush Texture"
bl_idname = "VIEW3D_MT_sv3_texture_list"
def init(self):
if utils_core.get_mode() == 'SCULPT':
datapath = "tool_settings.sculpt.brush.texture"
elif utils_core.get_mode() == 'VERTEX_PAINT':
datapath = "tool_settings.vertex_paint.brush.texture"
elif utils_core.get_mode() == 'TEXTURE_PAINT':
datapath = "tool_settings.image_paint.brush.texture"
else:
datapath = ""
return datapath
def draw(self, context):
datapath = self.init()
has_brush = utils_core.get_brush_link(context, types="brush")
current_texture = eval("bpy.context.{}".format(datapath)) if \
has_brush else None
layout = self.layout
# get the current texture's name
if current_texture:
current_texture = current_texture.name
layout.row().label(text="Brush Texture")
layout.row().separator()
# add an item to set the texture to None
utils_core.menuprop(layout.row(), "None", "None",
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=(None, current_texture),
path=True)
# add the menu items
for item in bpy.data.textures:
utils_core.menuprop(layout.row(), item.name,
'bpy.data.textures["%s"]' % item.name,
datapath, icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=(item.name, current_texture),
path=True)
class TextureMapMode(Menu):
bl_label = "Brush Mapping"
bl_idname = "VIEW3D_MT_sv3_texture_map_mode"
def draw(self, context):
layout = self.layout
has_brush = utils_core.get_brush_link(context, types="brush")
layout.row().label(text="Brush Mapping")
layout.row().separator()
if has_brush:
if utils_core.get_mode() == 'SCULPT':
path = "tool_settings.sculpt.brush.texture_slot.map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['map_mode'].enum_items:
utils_core.menuprop(
layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
elif utils_core.get_mode() == 'VERTEX_PAINT':
path = "tool_settings.vertex_paint.brush.texture_slot.tex_paint_map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['tex_paint_map_mode'].enum_items:
utils_core.menuprop(
layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
path = "tool_settings.image_paint.brush.texture_slot.tex_paint_map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['tex_paint_map_mode'].enum_items:
utils_core.menuprop(
layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
layout.row().label(text="No brushes available", icon="INFO")
class MaskTextures(Menu):
bl_label = "Mask Texture"
bl_idname = "VIEW3D_MT_sv3_mask_texture_list"
def draw(self, context):
layout = self.layout
datapath = "tool_settings.image_paint.brush.mask_texture"
has_brush = utils_core.get_brush_link(context, types="brush")
current_texture = eval("bpy.context.{}".format(datapath)) if \
has_brush else None
layout.row().label(text="Mask Texture")
layout.row().separator()
if has_brush:
# get the current texture's name
if current_texture:
current_texture = current_texture.name
# add an item to set the texture to None
utils_core.menuprop(
layout.row(), "None", "None",
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=(None, current_texture),
path=True
)
# add the menu items
for item in bpy.data.textures:
utils_core.menuprop(
layout.row(), item.name, 'bpy.data.textures["%s"]' % item.name,
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=(item.name, current_texture),
path=True
)
else:
layout.row().label(text="No brushes available", icon="INFO")
class MaskMapMode(Menu):
bl_label = "Mask Mapping"
bl_idname = "VIEW3D_MT_sv3_mask_map_mode"
def draw(self, context):
layout = self.layout
path = "tool_settings.image_paint.brush.mask_texture_slot.mask_map_mode"
has_brush = utils_core.get_brush_link(context, types="brush")
layout.row().label(text="Mask Mapping")
layout.row().separator()
if has_brush:
items = has_brush. \
mask_texture_slot.bl_rna.properties['mask_map_mode'].enum_items
# add the menu items
for item in items:
utils_core.menuprop(
layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
layout.row().label(text="No brushes available", icon="INFO")
class TextureAngleSource(Menu):
bl_label = "Texture Angle Source"
bl_idname = "VIEW3D_MT_sv3_texture_angle_source"
def draw(self, context):
layout = self.layout
has_brush = utils_core.get_brush_link(context, types="brush")
if has_brush:
if utils_core.get_mode() == 'SCULPT':
items = has_brush. \
bl_rna.properties['texture_angle_source_random'].enum_items
path = "tool_settings.sculpt.brush.texture_angle_source_random"
elif utils_core.get_mode() == 'VERTEX_PAINT':
items = has_brush. \
bl_rna.properties['texture_angle_source_random'].enum_items
path = "tool_settings.vertex_paint.brush.texture_angle_source_random"
else:
items = has_brush. \
bl_rna.properties['texture_angle_source_random'].enum_items
path = "tool_settings.image_paint.brush.texture_angle_source_random"
# add the menu items
for item in items:
utils_core.menuprop(
layout.row(), item[0], item[1], path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
layout.row().label(text="No brushes available", icon="INFO")
class MaskPressureModeMenu(Menu):
bl_label = "Mask Pressure Mode"
bl_idname = "VIEW3D_MT_sv3_mask_pressure_mode_menu"
def draw(self, context):
layout = self.layout
path = "tool_settings.image_paint.brush.use_pressure_masking"
layout.row().label(text="Mask Pressure Mode")
layout.row().separator()
# add the menu items
for item in context.tool_settings.image_paint.brush. \
bl_rna.properties['use_pressure_masking'].enum_items:
utils_core.menuprop(
layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
|