2.5: Buttons Window
[blender.git] / release / ui / buttons_material.py
1         
2 import bpy
3
4 class MaterialButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "material"
8
9         def poll(self, context):
10                 return (context.material != None)
11
12 class MATERIAL_PT_preview(MaterialButtonsPanel):
13         __idname__= "MATERIAL_PT_preview"
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18                 mat = context.material
19                 
20                 layout.template_preview(mat)
21                 
22 class MATERIAL_PT_context_material(MaterialButtonsPanel):
23         __idname__= "MATERIAL_PT_context_material"
24         __no_header__ = True
25
26         def poll(self, context):
27                 return (context.object)
28
29         def draw(self, context):
30                 layout = self.layout
31                 
32                 mat = context.material
33                 ob = context.object
34                 slot = context.material_slot
35                 space = context.space_data
36
37                 if ob:
38                         row = layout.row()
39
40                         row.template_list(ob, "materials", ob, "active_material_index")
41
42                         col = row.column(align=True)
43                         col.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
44                         col.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
45
46                 split = layout.split(percentage=0.65)
47
48                 if ob and slot:
49                         split.template_ID(slot, "material", new="MATERIAL_OT_new")
50                         #split.itemR(ob, "active_material_index", text="Active")
51                 elif mat:
52                         split.template_ID(space, "pin_id")
53                         split.itemS()
54
55         
56 class MATERIAL_PT_material(MaterialButtonsPanel):
57         __idname__= "MATERIAL_PT_material"
58         __label__ = "Material"
59
60         def draw(self, context):
61                 layout = self.layout
62                 
63                 mat = context.material
64                 ob = context.object
65                 slot = context.material_slot
66                 space = context.space_data
67
68                 if mat:
69                         layout.itemR(mat, "type", expand=True)
70                         
71                         layout.itemR(mat, "alpha", slider=True)
72
73                         row = layout.row()
74                         row.active = mat.type in ('SURFACE', 'VOLUME')
75                         row.itemR(mat, "shadeless")     
76                         row.itemR(mat, "wireframe")
77                         rowsub = row.row()
78                         rowsub.active = mat.shadeless== False
79                         rowsub.itemR(mat, "tangent_shading")
80                         
81 class MATERIAL_PT_strand(MaterialButtonsPanel):
82         __idname__= "MATERIAL_PT_strand"
83         __label__ = "Strand"
84         __default_closed__ = True
85         
86         def draw(self, context):
87                 layout = self.layout
88                 tan = context.material.strand
89                 mat = context.material
90                 
91                 split = layout.split()
92                 
93                 sub = split.column()
94                 sub.itemL(text="Size:")
95                 sub.itemR(tan, "start_size", text="Root")
96                 sub.itemR(tan, "end_size", text="Tip")
97                 sub.itemR(tan, "min_size", text="Minimum")
98                 sub.itemR(tan, "blender_units")
99                 colsub = sub.column()
100                 colsub.active = mat.shadeless== False
101                 colsub.itemR(tan, "tangent_shading")
102                 
103                 sub = split.column()
104                 sub.itemR(tan, "shape")
105                 sub.itemR(tan, "width_fade")
106                 sub.itemR(tan, "uv_layer")
107                 colsub = sub.column()
108                 colsub.active = mat.shadeless== False
109                 colsub.itemR(tan, "surface_diffuse")
110                 colsubsub = colsub.column()
111                 colsubsub.active = tan.surface_diffuse
112                 colsubsub.itemR(tan, "blend_distance", text="Distance")
113                 
114 class MATERIAL_PT_options(MaterialButtonsPanel):
115         __idname__= "MATERIAL_PT_options"
116         __label__ = "Options"
117
118         def draw(self, context):
119                 layout = self.layout
120                 mat = context.material
121                 
122                 split = layout.split()
123                 
124                 sub = split.column()
125                 sub.itemR(mat, "traceable")
126                 sub.itemR(mat, "full_oversampling")
127                 sub.itemR(mat, "sky")
128                 sub.itemR(mat, "exclude_mist")
129                 sub.itemR(mat, "face_texture")
130                 colsub = sub.column()
131                 colsub.active = mat.face_texture
132                 colsub.itemR(mat, "face_texture_alpha")
133                 sub.itemR(mat, "invert_z")
134                 sub.itemR(mat, "light_group")
135                 sub.itemR(mat, "light_group_exclusive")
136                 
137                 sub = split.column()
138                 sub.itemL(text="Shadows:")
139                 sub.itemR(mat, "shadows", text="Recieve")
140                 sub.itemR(mat, "transparent_shadows", text="Recieve Transparent")
141                 sub.itemR(mat, "only_shadow", text="Shadows Only")
142                 sub.itemR(mat, "cast_shadows_only", text="Cast Only")
143                 sub.itemR(mat, "shadow_casting_alpha", text="Casting Alpha", slider=True)
144                 
145                 sub.itemR(mat, "ray_shadow_bias")
146                 colsub = sub.column()
147                 colsub.active = mat.ray_shadow_bias
148                 colsub.itemR(mat, "shadow_ray_bias", text="Raytracing Bias")
149                 sub.itemR(mat, "cast_buffer_shadows")
150                 colsub = sub.column()
151                 colsub.active = mat.cast_buffer_shadows
152                 colsub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias")
153
154 class MATERIAL_PT_diffuse(MaterialButtonsPanel):
155         __idname__= "MATERIAL_PT_diffuse"
156         __label__ = "Diffuse"
157
158         def poll(self, context):
159                 mat = context.material
160                 return (mat and mat.type != "HALO")
161
162         def draw(self, context):
163                 layout = self.layout
164                 mat = context.material  
165                 
166                 split = layout.split()
167                 
168                 sub = split.column()
169                 sub.itemR(mat, "diffuse_color", text="")
170                 sub.itemR(mat, "object_color")
171                 colsub = sub.column()
172                 colsub.active = mat.shadeless== False
173                 colsub.itemR(mat, "ambient", slider=True)
174                 colsub.itemR(mat, "emit")
175                 sub.itemR(mat, "translucency", slider=True)
176                 
177                 sub = split.column()
178                 sub.active = mat.shadeless== False
179                 sub.itemR(mat, "diffuse_reflection", text="Intensity", slider=True)
180                 sub.itemR(mat, "vertex_color_light")
181                 sub.itemR(mat, "vertex_color_paint")
182                 sub.itemR(mat, "cubic")
183                 
184                 row = layout.row()
185                 row.active = mat.shadeless== False
186                 row.itemR(mat, "diffuse_shader", text="Shader")
187                 
188                 split = layout.split()
189                 split.active = mat.shadeless== False
190                 sub = split.column()
191                 if mat.diffuse_shader == 'OREN_NAYAR':
192                         sub.itemR(mat, "roughness")
193                 if mat.diffuse_shader == 'MINNAERT':
194                         sub.itemR(mat, "darkness")
195                 if mat.diffuse_shader == 'TOON':
196                         sub.itemR(mat, "diffuse_toon_size", text="Size")
197                         sub = split.column()
198                         sub.itemR(mat, "diffuse_toon_smooth", text="Smooth")
199                 if mat.diffuse_shader == 'FRESNEL':
200                         sub.itemR(mat, "diffuse_fresnel", text="Fresnel")
201                         sub = split.column()
202                         sub.itemR(mat, "diffuse_fresnel_factor", text="Factor")
203                 
204                 layout.itemR(mat, "diffuse_ramp", text="Ramp")
205
206 class MATERIAL_PT_specular(MaterialButtonsPanel):
207         __idname__= "MATERIAL_PT_specular"
208         __label__ = "Specular"
209
210         def poll(self, context):
211                 mat = context.material
212                 return (mat and mat.type != "HALO")
213
214         def draw(self, context):
215                 layout = self.layout
216                 mat = context.material
217                 
218                 layout.active = mat.shadeless== False
219                 
220                 split = layout.split()
221                 
222                 sub = split.column()
223                 sub.itemR(mat, "specular_color", text="")
224                 sub = split.column()
225                 sub.itemR(mat, "specular_reflection", text="Intensity", slider=True)
226                 
227                 layout.itemR(mat, "spec_shader", text="Shader")
228                 
229                 split = layout.split()
230                 
231                 sub = split.column()
232                 if mat.spec_shader in ('COOKTORR', 'PHONG'):
233                         sub.itemR(mat, "specular_hardness", text="Hardness")
234                 if mat.spec_shader == 'BLINN':
235                         sub.itemR(mat, "specular_hardness", text="Hardness")
236                         sub = split.column()
237                         sub.itemR(mat, "specular_ior", text="IOR")
238                 if mat.spec_shader == 'WARDISO':
239                         sub.itemR(mat, "specular_slope", text="Slope")
240                         sub = split.column()
241                         sub.itemR(mat, "specular_hardness", text="Hardness")
242                 if mat.spec_shader == 'TOON':
243                         sub.itemR(mat, "specular_toon_size", text="Size")
244                         sub = split.column()
245                         sub.itemR(mat, "specular_toon_smooth", text="Smooth")
246                 
247                 layout.itemR(mat, "specular_ramp", text="Ramp")
248
249 class MATERIAL_PT_sss(MaterialButtonsPanel):
250         __idname__= "MATERIAL_PT_sss"
251         __label__ = "Subsurface Scattering"
252         __default_closed__ = True
253         
254         def poll(self, context):
255                 mat = context.material
256                 return (mat and mat.type == "SURFACE")
257
258         def draw_header(self, context):
259                 layout = self.layout
260                 sss = context.material.subsurface_scattering
261
262                 layout.itemR(sss, "enabled", text="")
263         
264         def draw(self, context):
265                 layout = self.layout
266                 sss = context.material.subsurface_scattering
267                 mat = context.material
268                 layout.active = sss.enabled     
269                 
270                 split = layout.split()
271                 split.active = mat.shadeless== False
272                 
273                 sub = split.column()
274                 sub.itemR(sss, "color", text="")
275                 sub.itemL(text="Blend:")
276                 sub.itemR(sss, "color_factor", slider=True)
277                 sub.itemR(sss, "texture_factor", slider=True)
278                 sub.itemL(text="Scattering Weight:")
279                 sub.itemR(sss, "front")
280                 sub.itemR(sss, "back")
281                 
282                 sub = split.column()
283                 sub.itemR(sss, "ior")
284                 sub.itemR(sss, "scale")
285                 sub.itemR(sss, "radius", text="RGB Radius")
286                 sub.itemR(sss, "error_tolerance")
287
288 class MATERIAL_PT_raymir(MaterialButtonsPanel):
289         __idname__= "MATERIAL_PT_raymir"
290         __label__ = "Ray Mirror"
291         __default_closed__ = True
292         
293         def poll(self, context):
294                 mat = context.material
295                 return (mat and mat.type == "SURFACE")
296         
297         def draw_header(self, context):
298                 layout = self.layout
299                 raym = context.material.raytrace_mirror
300
301                 layout.itemR(raym, "enabled", text="")
302         
303         def draw(self, context):
304                 layout = self.layout
305                 raym = context.material.raytrace_mirror
306                 mat = context.material
307                 
308                 layout.active = raym.enabled
309                 
310                 split = layout.split()
311                 
312                 sub = split.column()
313                 sub.itemR(raym, "reflect", text="Reflectivity", slider=True)
314                 sub.itemR(mat, "mirror_color", text="")
315                 sub.itemR(raym, "fresnel")
316                 sub.itemR(raym, "fresnel_fac", text="Fac", slider=True)
317                 
318                 sub = split.column()
319                 sub.itemR(raym, "gloss", slider=True)
320                 colsub = sub.column()
321                 colsub.active = raym.gloss < 1
322                 colsub.itemR(raym, "gloss_threshold", slider=True, text="Threshold")
323                 colsub.itemR(raym, "gloss_samples", text="Samples")
324                 colsub.itemR(raym, "gloss_anisotropic", slider=True, text="Anisotropic")
325                 
326                 row = layout.row()
327                 row.itemR(raym, "distance", text="Max Dist")
328                 row.itemR(raym, "depth")
329                 
330                 layout.itemR(raym, "fade_to")
331                 
332 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
333         __idname__= "MATERIAL_PT_raytransp"
334         __label__= "Ray Transparency"
335         __default_closed__ = True
336                 
337         def poll(self, context):
338                 mat = context.material
339                 return (mat and mat.type == "SURFACE")
340
341         def draw_header(self, context):
342                 layout = self.layout
343                 rayt = context.material.raytrace_transparency
344
345                 layout.itemR(rayt, "enabled", text="")
346
347         def draw(self, context):
348                 layout = self.layout
349                 rayt = context.material.raytrace_transparency
350                 mat = context.material
351                 
352                 layout.active = rayt.enabled    
353                 
354                 split = layout.split()
355                 split.active = mat.shadeless== False
356                 
357                 sub = split.column()
358                 sub.itemR(rayt, "ior")
359                 sub.itemR(rayt, "fresnel")
360                 sub.itemR(rayt, "fresnel_fac", text="Fac", slider=True)
361                 
362                 sub = split.column()
363                 sub.itemR(rayt, "gloss", slider=True)
364                 colsub = sub.column()
365                 colsub.active = rayt.gloss < 1
366                 colsub.itemR(rayt, "gloss_threshold", slider=True, text="Threshold")
367                 colsub.itemR(rayt, "gloss_samples", text="Samples")
368                 
369                 flow = layout.column_flow()
370                 flow.active = mat.shadeless== False
371                 flow.itemR(rayt, "filter", slider=True)
372                 flow.itemR(rayt, "limit")
373                 flow.itemR(rayt, "falloff")
374                 flow.itemR(rayt, "specular_opacity", slider=True, text="Spec Opacity")
375                 flow.itemR(rayt, "depth")
376                 
377 class MATERIAL_PT_halo(MaterialButtonsPanel):
378         __idname__= "MATERIAL_PT_halo"
379         __label__= "Halo"
380         
381         def poll(self, context):
382                 mat = context.material
383                 return (mat and mat.type == "HALO")
384         
385         def draw(self, context):
386                 layout = self.layout
387                 
388                 mat = context.material
389                 halo = mat.halo
390
391                 split = layout.split()
392                 
393                 col = split.column()
394                 col.itemR(mat, "diffuse_color", text="")
395                 col.itemR(halo, "size")
396                 col.itemR(halo, "hardness")
397                 col.itemR(halo, "add", slider=True)
398                 
399                 col.itemL(text="Options:")
400                 col.itemR(halo, "use_texture", text="Texture")
401                 col.itemR(halo, "use_vertex_normal", text="Vertex Normal")
402                 col.itemR(halo, "xalpha")
403                 col.itemR(halo, "shaded")
404                 col.itemR(halo, "soft")
405
406                 col = split.column()
407                 col = col.column()
408                 col.itemR(halo, "ring")
409                 colsub = col.column()
410                 colsub.active = halo.ring
411                 colsub.itemR(halo, "rings")
412                 colsub.itemR(mat, "mirror_color", text="")
413                 col.itemR(halo, "lines")
414                 colsub = col.column()
415                 colsub.active = halo.lines
416                 colsub.itemR(halo, "line_number", text="Lines")
417                 colsub.itemR(mat, "specular_color", text="")
418                 col.itemR(halo, "star")
419                 colsub = col.column()
420                 colsub.active = halo.star
421                 colsub.itemR(halo, "star_tips")
422                 col.itemR(halo, "flare_mode")
423                 colsub = col.column()
424                 colsub.active = halo.flare_mode
425                 colsub.itemR(halo, "flare_size", text="Size")
426                 colsub.itemR(halo, "flare_subsize", text="Subsize")
427                 colsub.itemR(halo, "flare_boost", text="Boost")
428                 colsub.itemR(halo, "flare_seed", text="Seed")
429                 colsub.itemR(halo, "flares_sub", text="Sub")
430
431
432 bpy.types.register(MATERIAL_PT_context_material)
433 bpy.types.register(MATERIAL_PT_preview)
434 bpy.types.register(MATERIAL_PT_material)
435 bpy.types.register(MATERIAL_PT_diffuse)
436 bpy.types.register(MATERIAL_PT_specular)
437 bpy.types.register(MATERIAL_PT_raymir)
438 bpy.types.register(MATERIAL_PT_raytransp)
439 bpy.types.register(MATERIAL_PT_sss)
440 bpy.types.register(MATERIAL_PT_halo)
441 bpy.types.register(MATERIAL_PT_strand)
442 bpy.types.register(MATERIAL_PT_options)