Improved layout of voronoi texture. There was some strange empty space.
[blender.git] / release / ui / buttons_texture.py
1
2 import bpy
3
4 class TextureButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "texture"
8         
9         def poll(self, context):
10                 return (context.texture != None and context.texture.type != 'NONE')
11                 
12 class TEXTURE_PT_preview(TextureButtonsPanel):
13         __idname__= "TEXTURE_PT_preview"
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18                 tex = context.texture
19                 ma = context.material
20                 la = context.lamp
21                 wo = context.world
22                 br = context.brush
23                 
24                 if ma:
25                         layout.template_preview(tex, parent=ma)
26                 elif la:
27                         layout.template_preview(tex, parent=la)
28                 elif wo:
29                         layout.template_preview(tex, parent=wo)
30                 elif br:
31                         layout.template_preview(tex, parent=br)
32                 else:
33                         layout.template_preview(tex)
34
35 class TEXTURE_PT_context_texture(TextureButtonsPanel):
36         __idname__= "TEXTURE_PT_context_texture"
37         __show_header__ = False
38
39         def poll(self, context):
40                 return (context.material or context.world or context.lamp or context.brush or context.texture)
41
42         def draw(self, context):
43                 layout = self.layout
44
45                 tex = context.texture
46                 
47                 id =                            context.material
48                 if not id: id = context.lamp
49                 if not id: id = context.world
50                 if not id: id = context.brush
51                 
52                 space = context.space_data
53
54                 if id:
55                         row = layout.row()
56                         row.template_list(id, "textures", id, "active_texture_index", rows=2)
57                         
58                 split = layout.split(percentage=0.65)
59
60                 if id:
61                         split.template_ID(id, "active_texture", new="texture.new")
62                 elif tex:
63                         split.template_ID(space, "pin_id")
64
65                 if (not space.pin_id) and (     context.sculpt_object or \
66                                                                                 context.vertex_paint_object or \
67                                                                                 context.weight_paint_object or \
68                                                                                 context.texture_paint_object \
69                                                                         ):
70                         split.itemR(space, "brush_texture", text="Brush", toggle=True)
71                 
72                 layout.itemS()
73
74                 if tex:
75                         split = layout.split(percentage=0.2)
76                 
77                         col = split.column()
78                         col.itemL(text="Type:")
79                         col = split.column()
80                         col.itemR(tex, "type", text="")
81
82 class TEXTURE_PT_mapping(TextureButtonsPanel):
83         __idname__= "TEXTURE_PT_mapping"
84         __label__ = "Mapping"
85         
86         def poll(self, context):
87                 return (context.texture_slot and context.texture and context.texture.type != 'NONE')
88
89         def draw(self, context):
90                 layout = self.layout
91                 ma = context.material
92                 la = context.lamp
93                 wo = context.world
94                 br = context.brush
95                 tex = context.texture_slot
96                 textype = context.texture
97
98                 if not br:
99                         split = layout.split(percentage=0.3)
100                         col = split.column()
101                         col.itemL(text="Coordinates:")
102                         col = split.column()
103                         col.itemR(tex, "texture_coordinates", text="")
104
105                         if tex.texture_coordinates == 'ORCO':
106                                 """
107                                 ob = context.object
108                                 if ob and ob.type == 'MESH':
109                                         split = layout.split(percentage=0.3)
110                                         split.itemL(text="Mesh:")
111                                         split.itemR(ob.data, "texco_mesh", text="")
112                                 """
113                         elif tex.texture_coordinates == 'UV':
114                                 split = layout.split(percentage=0.3)
115                                 split.itemL(text="Layer:")
116                                 split.itemR(tex, "uv_layer", text="")
117                         elif tex.texture_coordinates == 'OBJECT':
118                                 split = layout.split(percentage=0.3)
119                                 split.itemL(text="Object:")
120                                 split.itemR(tex, "object", text="")
121                         
122                 if ma:
123                         split = layout.split(percentage=0.3)
124                         col = split.column()
125                         col.itemL(text="Projection:")
126                         col = split.column()
127                         col.itemR(tex, "mapping", text="")
128
129                         split = layout.split()
130                         
131                         col = split.column()
132                         if tex.texture_coordinates in ('ORCO', 'UV'):
133                                 col.itemR(tex, "from_dupli")
134                         elif tex.texture_coordinates == 'OBJECT':
135                                 col.itemR(tex, "from_original")
136                         else:
137                                 col.itemL()
138                         
139                         col = split.column()
140                         row = col.row()
141                         row.itemR(tex, "x_mapping", text="")
142                         row.itemR(tex, "y_mapping", text="")
143                         row.itemR(tex, "z_mapping", text="")
144
145                 row = layout.row()
146                 row.column().itemR(tex, "offset")
147                 row.column().itemR(tex, "size")
148
149 class TEXTURE_PT_influence(TextureButtonsPanel):
150         __idname__= "TEXTURE_PT_influence"
151         __label__ = "Influence"
152         
153         def poll(self, context):
154                 return (context.texture_slot and context.texture and context.texture.type != 'NONE' and (not context.brush))
155
156         def draw(self, context):
157                 layout = self.layout
158                 
159                 ma = context.material
160                 la = context.lamp
161                 wo = context.world
162                 br = context.brush
163                 textype = context.texture
164                 tex = context.texture_slot
165
166                 def factor_but(layout, active, toggle, factor, name):
167                         row = layout.row(align=True)
168                         row.itemR(tex, toggle, text="")
169                         sub = row.row()
170                         sub.active = active
171                         sub.itemR(tex, factor, text=name, slider=True)
172                 
173                 if ma:
174                         split = layout.split()
175                         
176                         col = split.column()
177
178                         col.itemL(text="Diffuse:")
179                         factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
180                         factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
181                         factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
182                         factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
183
184                         col.itemL(text="Specular:")
185                         factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
186                         factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
187                         factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
188
189                         col = split.column()
190                         col.itemL(text="Shading:")
191                         factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
192                         factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
193                         factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
194                         factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
195
196                         col.itemL(text="Geometry:")
197                         factor_but(col, tex.map_normal, "map_normal", "normal_factor", "Normal")
198                         factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
199                         factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
200
201                         #colsub = col.column()
202                         #colsub.active = tex.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
203                         #colsub.itemR(tex, "default_value", text="Amount", slider=True)
204                 elif la:
205                         row = layout.row()
206                         factor_but(row, tex.map_color, "map_color", "color_factor", "Color")
207                         factor_but(row, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
208                 elif wo:
209                         split = layout.split()
210                         col = split.column()
211                         factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
212                         factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
213
214                         col = split.column()
215                         factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
216                         factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
217
218                 layout.itemS()
219                 split = layout.split()
220
221                 col = split.column()
222
223                 col.itemR(tex, "blend_type", text="Blend")
224                 col.itemR(tex, "rgb_to_intensity")
225                 colsub = col.column()
226                 colsub.active = tex.rgb_to_intensity
227                 colsub.itemR(tex, "color", text="")
228
229                 col = split.column()
230                 col.itemR(tex, "negate", text="Negative")
231                 col.itemR(tex, "stencil")
232                 if ma or wo:
233                         col.itemR(tex, "default_value", text="DVar", slider=True)
234
235 class TEXTURE_PT_colors(TextureButtonsPanel):
236         __idname__= "TEXTURE_PT_colors"
237         __label__ = "Colors"
238         __default_closed__ = True
239
240         def draw(self, context):
241                 layout = self.layout
242                 tex = context.texture
243
244                 layout.itemR(tex, "use_color_ramp", text="Ramp")
245                 if tex.use_color_ramp:
246                         layout.template_color_ramp(tex.color_ramp, expand=True)
247
248                 split = layout.split()
249                 col = split.column()
250                 col.itemR(tex, "rgb_factor", text="Multiply RGB")
251
252                 col = split.column()
253                 col.itemL(text="Adjust:")
254                 col.itemR(tex, "brightness")
255                 col.itemR(tex, "contrast")
256
257 class TEXTURE_PT_clouds(TextureButtonsPanel):
258         __idname__= "TEXTURE_PT_clouds"
259         __label__ = "Clouds"
260         
261         def poll(self, context):
262                 tex = context.texture
263                 return (tex and tex.type == 'CLOUDS')
264
265         def draw(self, context):
266                 layout = self.layout
267                 tex = context.texture
268                 
269                 layout.itemR(tex, "stype", expand=True)
270                 layout.itemL(text="Noise:")
271                 layout.itemR(tex, "noise_type", text="Type", expand=True)
272                 layout.itemR(tex, "noise_basis", text="Basis")
273                 
274                 col = layout.column_flow()
275                 col.itemR(tex, "noise_size", text="Size")
276                 col.itemR(tex, "noise_depth", text="Depth")
277                 col.itemR(tex, "nabla", text="Nabla")
278
279 class TEXTURE_PT_wood(TextureButtonsPanel):
280         __idname__= "TEXTURE_PT_wood"
281         __label__ = "Wood"
282         
283         def poll(self, context):
284                 tex = context.texture
285                 return (tex and tex.type == 'WOOD')
286
287         def draw(self, context):
288                 layout = self.layout
289                 tex = context.texture
290                 
291                 layout.itemR(tex, "noisebasis2", expand=True)
292                 layout.itemR(tex, "stype", expand=True)
293                 
294                 col = layout.column()
295                 col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
296                 col.itemL(text="Noise:")
297                 col.row().itemR(tex, "noise_type", text="Type", expand=True)
298                 col.itemR(tex, "noise_basis", text="Basis")
299                 
300                 col = layout.column_flow()
301                 col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
302                 col.itemR(tex, "noise_size", text="Size")
303                 col.itemR(tex, "turbulence")
304                 col.itemR(tex, "nabla")
305                 
306 class TEXTURE_PT_marble(TextureButtonsPanel):
307         __idname__= "TEXTURE_PT_marble"
308         __label__ = "Marble"
309         
310         def poll(self, context):
311                 tex = context.texture
312                 return (tex and tex.type == 'MARBLE')
313
314         def draw(self, context):
315                 layout = self.layout
316                 tex = context.texture
317                 
318                 layout.itemR(tex, "stype", expand=True)
319                 layout.itemR(tex, "noisebasis2", expand=True)
320                 layout.itemL(text="Noise:")
321                 layout.itemR(tex, "noise_type", text="Type", expand=True)
322                 layout.itemR(tex, "noise_basis", text="Basis")
323                 
324                 col = layout.column_flow()      
325                 col.itemR(tex, "noise_size", text="Size")
326                 col.itemR(tex, "noise_depth", text="Depth")
327                 col.itemR(tex, "turbulence")
328                 col.itemR(tex, "nabla")
329
330 class TEXTURE_PT_magic(TextureButtonsPanel):
331         __idname__= "TEXTURE_PT_magic"
332         __label__ = "Magic"
333         
334         def poll(self, context):
335                 tex = context.texture
336                 return (tex and tex.type == 'MAGIC')
337
338         def draw(self, context):
339                 layout = self.layout
340                 tex = context.texture
341                         
342                 row = layout.row()
343                 row.itemR(tex, "noise_depth", text="Depth")
344                 row.itemR(tex, "turbulence")
345
346 class TEXTURE_PT_blend(TextureButtonsPanel):
347         __idname__= "TEXTURE_PT_blend"
348         __label__ = "Blend"
349         
350         def poll(self, context):
351                 tex = context.texture
352                 return (tex and tex.type == 'BLEND')
353
354         def draw(self, context):
355                 layout = self.layout
356                 tex = context.texture
357
358                 layout.itemR(tex, "progression")
359                 layout.itemR(tex, "flip_axis")
360                         
361 class TEXTURE_PT_stucci(TextureButtonsPanel):
362         __idname__= "TEXTURE_PT_stucci"
363         __label__ = "Stucci"
364         
365         def poll(self, context):
366                 tex = context.texture
367                 return (tex and tex.type == 'STUCCI')
368
369         def draw(self, context):
370                 layout = self.layout
371                 tex = context.texture
372                 
373                 layout.itemR(tex, "stype", expand=True)
374                 layout.itemL(text="Noise:")
375                 layout.itemR(tex, "noise_type", text="Type", expand=True)
376                 layout.itemR(tex, "noise_basis", text="Basis")
377                 
378                 row = layout.row()
379                 row.itemR(tex, "noise_size", text="Size")
380                 row.itemR(tex, "turbulence")
381                 
382 class TEXTURE_PT_image(TextureButtonsPanel):
383         __idname__= "TEXTURE_PT_image"
384         __label__ = "Image"
385         
386         def poll(self, context):
387                 tex = context.texture
388                 return (tex and tex.type == 'IMAGE')
389
390         def draw(self, context):
391                 layout = self.layout
392                 tex = context.texture
393
394                 layout.template_texture_image(tex)
395
396 class TEXTURE_PT_image_sampling(TextureButtonsPanel):
397         __idname__= "TEXTURE_PT_image_sampling"
398         __label__ = "Image Sampling"
399         __default_closed__ = True
400         
401         def poll(self, context):
402                 tex = context.texture
403                 return (tex and tex.type == 'IMAGE')
404
405         def draw(self, context):
406                 layout = self.layout
407                 tex = context.texture
408                 slot = context.texture_slot
409                 
410                 split = layout.split()
411                 
412                 """
413                 sub = split.column()            
414                 sub.itemR(tex, "flip_axis")
415                 sub.itemR(tex, "normal_map")
416                 if slot:
417                         row = sub.row()
418                         row.active = tex.normal_map
419                         row.itemR(slot, "normal_map_space", text="")
420                 """
421
422                 sub = split.column()
423
424                 sub.itemL(text="Alpha:")
425                 sub.itemR(tex, "use_alpha", text="Use")
426                 sub.itemR(tex, "calculate_alpha", text="Calculate")
427                 sub.itemR(tex, "invert_alpha", text="Invert")
428
429                 sub.itemL(text="Flip:")
430                 sub.itemR(tex, "flip_axis", text="X/Y Axis")
431
432                 sub = split.column() 
433                 sub.itemL(text="Filter:")
434                 sub.itemR(tex, "filter", text="")
435                 sub.itemR(tex, "mipmap")
436                 row = sub.row()
437                 row.itemR(tex, "mipmap_gauss", text="Gauss")
438                 row.active = tex.mipmap
439                 sub.itemR(tex, "interpolation")
440                 if tex.mipmap and tex.filter != 'DEFAULT':
441                         if tex.filter == 'FELINE':
442                                 sub.itemR(tex, "filter_probes", text="Probes")
443                         else:
444                                 sub.itemR(tex, "filter_eccentricity", text="Eccentricity")
445
446 class TEXTURE_PT_image_mapping(TextureButtonsPanel):
447         __idname__= "TEXTURE_PT_image_mapping"
448         __label__ = "Image Mapping"
449         __default_closed__ = True
450         
451         def poll(self, context):
452                 tex = context.texture
453                 return (tex and tex.type == 'IMAGE')
454
455         def draw(self, context):
456                 layout = self.layout
457                 tex = context.texture
458                 
459                 layout.itemR(tex, "extension")
460                 
461                 split = layout.split()
462                 
463                 if tex.extension == 'REPEAT': 
464                         sub = split.column(align=True)
465                         sub.itemL(text="Repeat:")
466                         sub.itemR(tex, "repeat_x", text="X")
467                         sub.itemR(tex, "repeat_y", text="Y")
468                         sub = split.column(align=True)
469                         sub.itemL(text="Mirror:")
470                         sub.itemR(tex, "mirror_x", text="X")
471                         sub.itemR(tex, "mirror_y", text="Y")
472                 elif tex.extension == 'CHECKER': 
473                         sub = split.column(align=True)
474                         row = sub.row()
475                         row.itemR(tex, "checker_even", text="Even")
476                         row.itemR(tex, "checker_odd", text="Odd")
477                         sub = split.column()
478                         sub.itemR(tex, "checker_distance", text="Distance")
479
480                 layout.itemS()
481
482                 split = layout.split()
483                 
484                 sub = split.column(align=True)
485                 #sub.itemR(tex, "crop_rectangle")
486                 sub.itemL(text="Crop Minimum:")
487                 sub.itemR(tex, "crop_min_x", text="X")
488                 sub.itemR(tex, "crop_min_y", text="Y")
489                 sub = split.column(align=True)
490                 sub.itemL(text="Crop Maximum:")
491                 sub.itemR(tex, "crop_max_x", text="X")
492                 sub.itemR(tex, "crop_max_y", text="Y")
493         
494 class TEXTURE_PT_plugin(TextureButtonsPanel):
495         __idname__= "TEXTURE_PT_plugin"
496         __label__ = "Plugin"
497         
498         def poll(self, context):
499                 tex = context.texture
500                 return (tex and tex.type == 'PLUGIN')
501
502         def draw(self, context):
503                 layout = self.layout
504                 tex = context.texture
505                 
506                 layout.itemL(text="Nothing yet")
507                 
508 class TEXTURE_PT_envmap(TextureButtonsPanel):
509         __idname__= "TEXTURE_PT_envmap"
510         __label__ = "Environment Map"
511         
512         def poll(self, context):
513                 tex = context.texture
514                 return (tex and tex.type == 'ENVIRONMENT_MAP')
515
516         def draw(self, context):
517                 layout = self.layout
518                 tex = context.texture
519                 
520                 layout.itemL(text="Nothing yet")
521                 
522 class TEXTURE_PT_musgrave(TextureButtonsPanel):
523         __idname__= "TEXTURE_PT_musgrave"
524         __label__ = "Musgrave"
525         
526         def poll(self, context):
527                 tex = context.texture
528                 return (tex and tex.type == 'MUSGRAVE')
529
530         def draw(self, context):
531                 layout = self.layout
532                 tex = context.texture
533                 
534                 layout.itemR(tex, "musgrave_type")      
535                 
536                 split = layout.split()
537                 
538                 sub = split.column()
539                 sub.itemR(tex, "highest_dimension", text="Dimension")
540                 sub.itemR(tex, "lacunarity")
541                 sub.itemR(tex, "octaves")
542                 sub = split.column() 
543                 if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
544                         sub.itemR(tex, "offset")
545                 if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
546                         sub.itemR(tex, "gain")
547                         sub.itemR(tex, "noise_intensity", text="Intensity")
548                 
549                 layout.itemL(text="Noise:")
550                 
551                 layout.itemR(tex, "noise_basis", text="Basis")
552                 
553                 row = layout.row()
554                 row.itemR(tex, "noise_size", text="Size")
555                 row.itemR(tex, "nabla")
556
557 class TEXTURE_PT_voronoi(TextureButtonsPanel):
558         __idname__= "TEXTURE_PT_voronoi"
559         __label__ = "Voronoi"
560         
561         def poll(self, context):
562                 tex = context.texture
563                 return (tex and tex.type == 'VORONOI')
564
565         def draw(self, context):
566                 layout = self.layout
567                 tex = context.texture
568                 
569                 split = layout.split()
570                 
571                 sub = split.column()   
572                 sub.itemL(text="Distance Metric:")
573                 sub.itemR(tex, "distance_metric", text="")
574                 subsub = sub.column()
575                 subsub.active = tex.distance_metric == 'MINKOVSKY'
576                 subsub.itemR(tex, "minkovsky_exponent", text="Exponent")
577                 sub.itemL(text="Coloring:")
578                 sub.itemR(tex, "coloring", text="")
579                 sub.itemR(tex, "noise_intensity", text="Intensity")
580                 
581                 sub = split.column(align=True) 
582                 sub.itemL(text="Feature Weights:")
583                 sub.itemR(tex, "weight_1", text="1", slider=True)
584                 sub.itemR(tex, "weight_2", text="2", slider=True)
585                 sub.itemR(tex, "weight_3", text="3", slider=True)
586                 sub.itemR(tex, "weight_4", text="4", slider=True)
587                 
588                 layout.itemL(text="Noise:")
589                 
590                 row = layout.row()
591                 row.itemR(tex, "noise_size", text="Size")
592                 row.itemR(tex, "nabla")
593                         
594 class TEXTURE_PT_distortednoise(TextureButtonsPanel):
595         __idname__= "TEXTURE_PT_distortednoise"
596         __label__ = "Distorted Noise"
597         
598         def poll(self, context):
599                 tex = context.texture
600                 return (tex and tex.type == 'DISTORTED_NOISE')
601
602         def draw(self, context):
603                 layout = self.layout
604                 tex = context.texture
605
606                 layout.itemR(tex, "noise_distortion")
607                 layout.itemR(tex, "noise_basis", text="Basis")
608                 
609                 split = layout.split()
610                 
611                 sub = split.column()
612                 sub.itemR(tex, "distortion_amount", text="Distortion")
613                 sub.itemR(tex, "noise_size", text="Size")
614                 
615                 sub = split.column()
616                 sub.itemR(tex, "nabla") 
617
618 bpy.types.register(TEXTURE_PT_context_texture)
619 bpy.types.register(TEXTURE_PT_preview)
620 bpy.types.register(TEXTURE_PT_clouds)
621 bpy.types.register(TEXTURE_PT_wood)
622 bpy.types.register(TEXTURE_PT_marble)
623 bpy.types.register(TEXTURE_PT_magic)
624 bpy.types.register(TEXTURE_PT_blend)
625 bpy.types.register(TEXTURE_PT_stucci)
626 bpy.types.register(TEXTURE_PT_image)
627 bpy.types.register(TEXTURE_PT_image_sampling)
628 bpy.types.register(TEXTURE_PT_image_mapping)
629 bpy.types.register(TEXTURE_PT_plugin)
630 bpy.types.register(TEXTURE_PT_envmap)
631 bpy.types.register(TEXTURE_PT_musgrave)
632 bpy.types.register(TEXTURE_PT_voronoi)
633 bpy.types.register(TEXTURE_PT_distortednoise)
634 bpy.types.register(TEXTURE_PT_colors)
635 bpy.types.register(TEXTURE_PT_mapping)
636 bpy.types.register(TEXTURE_PT_influence)
637