LEFT | RIGHT |
1 # ##### BEGIN GPL LICENSE BLOCK ##### | 1 # ##### BEGIN GPL LICENSE BLOCK ##### |
2 # | 2 # |
3 # This program is free software; you can redistribute it and/or | 3 # This program is free software; you can redistribute it and/or |
4 # modify it under the terms of the GNU General Public License | 4 # modify it under the terms of the GNU General Public License |
5 # as published by the Free Software Foundation; either version 2 | 5 # as published by the Free Software Foundation; either version 2 |
6 # of the License, or (at your option) any later version. | 6 # of the License, or (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with this program; if not, write to the Free Software Foundation, | 14 # along with this program; if not, write to the Free Software Foundation, |
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 # | 16 # |
17 # ##### END GPL LICENSE BLOCK ##### | 17 # ##### END GPL LICENSE BLOCK ##### |
18 | 18 |
19 # <pep8 compliant> | 19 # <pep8 compliant> |
20 import bpy | 20 import bpy |
21 from bpy.types import Menu, Panel | 21 from bpy.types import Menu, Panel, UIList |
22 from rna_prop_ui import PropertyPanel | 22 from rna_prop_ui import PropertyPanel |
23 | 23 |
24 | 24 |
25 class MESH_MT_vertex_group_specials(Menu): | 25 class MESH_MT_vertex_group_specials(Menu): |
26 bl_label = "Vertex Group Specials" | 26 bl_label = "Vertex Group Specials" |
27 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} | 27 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} |
28 | 28 |
29 def draw(self, context): | 29 def draw(self, context): |
30 layout = self.layout | 30 layout = self.layout |
31 | 31 |
32 layout.operator("object.vertex_group_sort", icon='SORTALPHA') | 32 layout.operator("object.vertex_group_sort", icon='SORTALPHA') |
33 layout.operator("object.vertex_group_copy", icon='COPY_ID') | 33 layout.operator("object.vertex_group_copy", icon='COPY_ID') |
34 layout.operator("object.vertex_group_copy_to_linked", icon='LINK_AREA') | 34 layout.operator("object.vertex_group_copy_to_linked", icon='LINK_AREA') |
35 layout.operator("object.vertex_group_copy_to_selected", icon='LINK_AREA'
) | 35 layout.operator("object.vertex_group_copy_to_selected", icon='LINK_AREA'
) |
36 layout.operator("object.vertex_group_mirror", icon='ARROW_LEFTRIGHT') | 36 layout.operator("object.vertex_group_mirror", icon='ARROW_LEFTRIGHT').us
e_topology = False |
37 layout.operator("object.vertex_group_remove", icon='X', text="Delete All
").all = True | 37 layout.operator("object.vertex_group_mirror", text="Mirror Vertex Group
(Topology)", icon='ARROW_LEFTRIGHT').use_topology = True |
| 38 layout.operator("object.vertex_group_remove_from", icon='X', text="Remov
e from All Groups").use_all_groups = True |
| 39 layout.operator("object.vertex_group_remove_from", icon='X', text="Clear
Active Group").use_all_verts = True |
| 40 layout.operator("object.vertex_group_remove", icon='X', text="Delete All
Groups").all = True |
| 41 layout.separator() |
| 42 layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Al
l").action = 'LOCK' |
| 43 layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="UnLoc
k All").action = 'UNLOCK' |
| 44 layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock In
vert All").action = 'INVERT' |
38 | 45 |
39 | 46 |
40 class MESH_MT_shape_key_specials(Menu): | 47 class MESH_MT_shape_key_specials(Menu): |
41 bl_label = "Shape Key Specials" | 48 bl_label = "Shape Key Specials" |
42 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} | 49 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} |
43 | 50 |
44 def draw(self, context): | 51 def draw(self, context): |
45 layout = self.layout | 52 layout = self.layout |
46 | 53 |
47 layout.operator("object.shape_key_transfer", icon='COPY_ID') # icon is
not ideal | 54 layout.operator("object.shape_key_transfer", icon='COPY_ID') # icon is
not ideal |
48 layout.operator("object.join_shapes", icon='COPY_ID') # icon is not ide
al | 55 layout.operator("object.join_shapes", icon='COPY_ID') # icon is not ide
al |
49 layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT') | 56 layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT').use_t
opology = False |
50 op = layout.operator("object.shape_key_add", icon='ZOOMIN', text="New Sh
ape From Mix") | 57 layout.operator("object.shape_key_mirror", text="Mirror Shape Key (Topol
ogy)", icon='ARROW_LEFTRIGHT').use_topology = True |
51 op.from_mix = True | 58 layout.operator("object.shape_key_add", icon='ZOOMIN', text="New Shape F
rom Mix").from_mix = True |
| 59 layout.operator("object.shape_key_remove", icon='X', text="Delete All Sh
apes").all = True |
| 60 |
| 61 |
| 62 class MESH_UL_vgroups(UIList): |
| 63 def draw_item(self, context, layout, data, item, icon, active_data, active_p
ropname, index): |
| 64 # assert(isinstance(item, bpy.types.VertexGroup) |
| 65 vgroup = item |
| 66 if self.layout_type in {'DEFAULT', 'COMPACT'}: |
| 67 layout.label(text=vgroup.name, translate=False, icon_value=icon) |
| 68 icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED' |
| 69 layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False) |
| 70 elif self.layout_type in {'GRID'}: |
| 71 layout.alignment = 'CENTER' |
| 72 layout.label(text="", icon_value=icon) |
| 73 |
| 74 |
| 75 class MESH_UL_shape_keys(UIList): |
| 76 def draw_item(self, context, layout, data, item, icon, active_data, active_p
ropname, index): |
| 77 # assert(isinstance(item, bpy.types.ShapeKey) |
| 78 obj = active_data |
| 79 key = data |
| 80 key_block = item |
| 81 if self.layout_type in {'DEFAULT', 'COMPACT'}: |
| 82 split = layout.split(0.66, False) |
| 83 split.label(text=item.name, translate=False, icon_value=icon) |
| 84 row = split.row(align=True) |
| 85 if key_block.mute or (obj.mode == 'EDIT' and not (obj.use_shape_key_
edit_mode and obj.type == 'MESH')): |
| 86 row.active = False |
| 87 if not item.relative_key or index > 0: |
| 88 row.prop(key_block, "value", text="", emboss=False) |
| 89 else: |
| 90 row.label(text="") |
| 91 row.prop(key_block, "mute", text="", emboss=False) |
| 92 elif self.layout_type in {'GRID'}: |
| 93 layout.alignment = 'CENTER' |
| 94 layout.label(text="", icon_value=icon) |
| 95 |
| 96 |
| 97 class MESH_UL_uvmaps_vcols(UIList): |
| 98 def draw_item(self, context, layout, data, item, icon, active_data, active_p
ropname, index): |
| 99 # assert(isinstance(item, (bpy.types.MeshTexturePolyLayer, bpy.types.Mes
hLoopColorLayer)) |
| 100 if self.layout_type in {'DEFAULT', 'COMPACT'}: |
| 101 layout.label(text=item.name, translate=False, icon_value=icon) |
| 102 icon = 'RESTRICT_RENDER_OFF' if item.active_render else 'RESTRICT_RE
NDER_ON' |
| 103 layout.prop(item, "active_render", text="", icon=icon, emboss=False) |
| 104 elif self.layout_type in {'GRID'}: |
| 105 layout.alignment = 'CENTER' |
| 106 layout.label(text="", icon_value=icon) |
52 | 107 |
53 | 108 |
54 class MeshButtonsPanel(): | 109 class MeshButtonsPanel(): |
55 bl_space_type = 'PROPERTIES' | 110 bl_space_type = 'PROPERTIES' |
56 bl_region_type = 'WINDOW' | 111 bl_region_type = 'WINDOW' |
57 bl_context = "data" | 112 bl_context = "data" |
58 | 113 |
59 @classmethod | 114 @classmethod |
60 def poll(cls, context): | 115 def poll(cls, context): |
61 engine = context.scene.render.engine | 116 engine = context.scene.render.engine |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 engine = context.scene.render.engine | 184 engine = context.scene.render.engine |
130 obj = context.object | 185 obj = context.object |
131 return (obj and obj.type in {'MESH', 'LATTICE'} and (engine in cls.COMPA
T_ENGINES)) | 186 return (obj and obj.type in {'MESH', 'LATTICE'} and (engine in cls.COMPA
T_ENGINES)) |
132 | 187 |
133 def draw(self, context): | 188 def draw(self, context): |
134 layout = self.layout | 189 layout = self.layout |
135 | 190 |
136 ob = context.object | 191 ob = context.object |
137 group = ob.vertex_groups.active | 192 group = ob.vertex_groups.active |
138 | 193 |
139 rows = 2 | 194 rows = 1 |
140 if group: | 195 if group: |
141 rows = 5 | 196 rows = 4 |
142 | 197 |
143 row = layout.row() | 198 row = layout.row() |
144 row.template_list(ob, "vertex_groups", ob.vertex_groups, "active_index",
rows=rows) | 199 row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_
groups, "active_index", rows=rows) |
145 | 200 |
146 col = row.column(align=True) | 201 col = row.column(align=True) |
147 col.operator("object.vertex_group_add", icon='ZOOMIN', text="") | 202 col.operator("object.vertex_group_add", icon='ZOOMIN', text="") |
148 col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="") | 203 col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="").all
= False |
149 col.menu("MESH_MT_vertex_group_specials", icon='DOWNARROW_HLT', text="") | 204 col.menu("MESH_MT_vertex_group_specials", icon='DOWNARROW_HLT', text="") |
150 if group: | 205 if group: |
| 206 col.separator() |
151 col.operator("object.vertex_group_move", icon='TRIA_UP', text="").di
rection = 'UP' | 207 col.operator("object.vertex_group_move", icon='TRIA_UP', text="").di
rection = 'UP' |
152 col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").
direction = 'DOWN' | 208 col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").
direction = 'DOWN' |
153 | 209 |
154 if group: | |
155 row = layout.row() | 210 row = layout.row() |
156 row.prop(group, "name") | 211 row.prop(group, "name") |
157 | 212 |
158 if ob.mode == 'EDIT' and len(ob.vertex_groups) > 0: | 213 if ob.vertex_groups and (ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT'
and ob.type == 'MESH' and ob.data.use_paint_mask_vertex)): |
159 row = layout.row() | 214 row = layout.row() |
160 | 215 |
161 sub = row.row(align=True) | 216 sub = row.row(align=True) |
162 sub.operator("object.vertex_group_assign", text="Assign") | 217 sub.operator("object.vertex_group_assign", text="Assign") |
163 sub.operator("object.vertex_group_remove_from", text="Remove") | 218 sub.operator("object.vertex_group_remove_from", text="Remove") |
164 | 219 |
165 sub = row.row(align=True) | 220 sub = row.row(align=True) |
166 sub.operator("object.vertex_group_select", text="Select") | 221 sub.operator("object.vertex_group_select", text="Select") |
167 sub.operator("object.vertex_group_deselect", text="Deselect") | 222 sub.operator("object.vertex_group_deselect", text="Deselect") |
168 | 223 |
(...skipping 19 matching lines...) Expand all Loading... |
188 | 243 |
189 enable_edit = ob.mode != 'EDIT' | 244 enable_edit = ob.mode != 'EDIT' |
190 enable_edit_value = False | 245 enable_edit_value = False |
191 | 246 |
192 if ob.show_only_shape_key is False: | 247 if ob.show_only_shape_key is False: |
193 if enable_edit or (ob.type == 'MESH' and ob.use_shape_key_edit_mode)
: | 248 if enable_edit or (ob.type == 'MESH' and ob.use_shape_key_edit_mode)
: |
194 enable_edit_value = True | 249 enable_edit_value = True |
195 | 250 |
196 row = layout.row() | 251 row = layout.row() |
197 | 252 |
198 rows = 2 | 253 rows = 1 |
199 if kb: | 254 if kb: |
200 rows = 5 | 255 rows = 4 |
201 row.template_list(key, "key_blocks", ob, "active_shape_key_index", rows=
rows) | 256 row.template_list("MESH_UL_shape_keys", "", key, "key_blocks", ob, "acti
ve_shape_key_index", rows=rows) |
202 | 257 |
203 col = row.column() | 258 col = row.column() |
204 | 259 |
205 sub = col.column(align=True) | 260 sub = col.column(align=True) |
206 op = sub.operator("object.shape_key_add", icon='ZOOMIN', text="") | 261 sub.operator("object.shape_key_add", icon='ZOOMIN', text="").from_mix =
False |
207 op.from_mix = False | 262 sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="").all = F
alse |
208 sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="") | |
209 sub.menu("MESH_MT_shape_key_specials", icon='DOWNARROW_HLT', text="") | 263 sub.menu("MESH_MT_shape_key_specials", icon='DOWNARROW_HLT', text="") |
210 | 264 |
211 if kb: | 265 if kb: |
212 col.separator() | 266 col.separator() |
213 | 267 |
214 sub = col.column(align=True) | 268 sub = col.column(align=True) |
215 sub.operator("object.shape_key_move", icon='TRIA_UP', text="").type
= 'UP' | 269 sub.operator("object.shape_key_move", icon='TRIA_UP', text="").type
= 'UP' |
216 sub.operator("object.shape_key_move", icon='TRIA_DOWN', text="").typ
e = 'DOWN' | 270 sub.operator("object.shape_key_move", icon='TRIA_DOWN', text="").typ
e = 'DOWN' |
217 | 271 |
218 split = layout.split(percentage=0.4) | 272 split = layout.split(percentage=0.4) |
219 row = split.row() | 273 row = split.row() |
220 row.enabled = enable_edit | 274 row.enabled = enable_edit |
221 row.prop(key, "use_relative") | 275 row.prop(key, "use_relative") |
222 | 276 |
223 row = split.row() | 277 row = split.row() |
224 row.alignment = 'RIGHT' | 278 row.alignment = 'RIGHT' |
225 | 279 |
226 sub = row.row(align=True) | 280 sub = row.row(align=True) |
| 281 sub.label() # XXX, for alignment only |
227 subsub = sub.row(align=True) | 282 subsub = sub.row(align=True) |
228 subsub.active = enable_edit_value | 283 subsub.active = enable_edit_value |
229 subsub.prop(ob, "show_only_shape_key", text="") | 284 subsub.prop(ob, "show_only_shape_key", text="") |
230 subsub.prop(kb, "mute", text="") | 285 layout.prop(lay, "name") |
231 sub.prop(ob, "use_shape_key_edit_mode", text="") | 286 |
232 | 287 |
233 sub = row.row() | 288 class DATA_PT_texface(MeshButtonsPanel, Panel): |
234 sub.operator("object.shape_key_clear", icon='X', text="") | 289 bl_label = "Texture Face" |
235 | 290 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} |
236 row = layout.row() | 291 |
237 row.prop(kb, "name") | 292 @classmethod |
238 | 293 def poll(cls, context): |
239 if key.use_relative: | 294 obj = context.object |
240 if ob.active_shape_key_index != 0: | 295 return (context.mode == 'EDIT_MESH') and obj and obj.type == 'MESH' |
241 row = layout.row() | 296 |
242 row.active = enable_edit_value | 297 def draw(self, context): |
243 row.prop(kb, "value") | 298 layout = self.layout |
244 | 299 col = layout.column() |
245 split = layout.split() | |
246 | |
247 col = split.column(align=True) | |
248 col.active = enable_edit_value | |
249 col.label(text="Range:") | |
250 col.prop(kb, "slider_min", text="Min") | |
251 col.prop(kb, "slider_max", text="Max") | |
252 | |
253 col = split.column(align=True) | |
254 col.active = enable_edit_value | |
255 col.label(text="Blend:") | |
256 col.prop_search(kb, "vertex_group", ob, "vertex_groups", tex
t="") | |
257 col.prop_search(kb, "relative_key", key, "key_blocks", text=
"") | |
258 | |
259 else: | |
260 row = layout.row() | |
261 row.active = enable_edit_value | |
262 row.prop(key, "slurph") | |
263 | |
264 | |
265 class DATA_PT_uv_texture(MeshButtonsPanel, Panel): | |
266 bl_label = "UV Texture" | |
267 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} | |
268 | |
269 def draw(self, context): | |
270 layout = self.layout | |
271 | 300 |
272 me = context.mesh | 301 me = context.mesh |
273 | 302 |
274 row = layout.row() | 303 tf = me.faces.active_tface |
275 col = row.column() | 304 |
276 | 305 if tf: |
277 col.template_list(me, "uv_textures", me.uv_textures, "active_index", row
s=2) | 306 if context.scene.render.engine != 'BLENDER_GAME': |
278 | 307 col.label(text="Options only supported in Game Engine") |
279 col = row.column(align=True) | 308 |
280 col.operator("mesh.uv_texture_add", icon='ZOOMIN', text="") | 309 split = layout.split() |
281 col.operator("mesh.uv_texture_remove", icon='ZOOMOUT', text="") | 310 col = split.column() |
282 | 311 |
283 lay = me.uv_textures.active | 312 col.prop(tf, "use_image") |
284 if lay: | 313 col.prop(tf, "use_light") |
285 layout.prop(lay, "name") | 314 col.prop(tf, "hide") |
| 315 col.prop(tf, "use_collision") |
| 316 |
| 317 col.prop(tf, "use_blend_shared") |
| 318 col.prop(tf, "use_twoside") |
| 319 col.prop(tf, "use_object_color") |
| 320 |
| 321 col = split.column() |
| 322 |
| 323 col.prop(tf, "use_halo") |
| 324 col.prop(tf, "use_billboard") |
| 325 col.prop(tf, "use_shadow_cast") |
| 326 col.prop(tf, "use_bitmap_text") |
| 327 col.prop(tf, "use_alpha_sort") |
| 328 |
| 329 col = layout.column() |
| 330 col.prop(tf, "blend_type") |
| 331 else: |
| 332 col.label(text="No UV Texture") |
286 | 333 |
287 | 334 |
288 class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): | 335 class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): |
289 bl_label = "Vertex Colors" | 336 bl_label = "Vertex Colors" |
290 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} | 337 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} |
291 | |
292 def draw(self, context): | |
293 layout = self.layout | |
294 | |
295 me = context.mesh | |
296 | |
297 row = layout.row() | |
298 col = row.column() | |
299 | |
300 col.template_list(me, "vertex_colors", me.vertex_colors, "active_index",
rows=2) | |
301 | |
302 col = row.column(align=True) | |
303 col.operator("mesh.vertex_color_add", icon='ZOOMIN', text="") | |
304 col.operator("mesh.vertex_color_remove", icon='ZOOMOUT', text="") | |
305 | |
306 lay = me.vertex_colors.active | |
307 if lay: | |
308 layout.prop(lay, "name") | |
309 | |
310 | |
311 class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel): | |
312 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} | |
313 _context_path = "object.data" | |
314 _property_type = bpy.types.Mesh | |
315 | |
316 if __name__ == "__main__": # only for live edit. | |
317 bpy.utils.register_module(__name__) | |
LEFT | RIGHT |