69540f7dea72e8c81e1e626a9922087547d259a1
[blender.git] / release / scripts / ui / properties_texture.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
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,
15 #  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 def active_node_mat(mat):
24     if mat:
25         mat_node = mat.active_node_material
26         if mat_node:
27             return mat_node
28         else:
29             return mat
30
31     return None
32
33
34 def context_tex_datablock(context):
35
36         idblock = active_node_mat(context.material)
37         if idblock:
38             return idblock
39
40         idblock = context.lamp
41         if idblock:
42             return idblock
43
44         idblock = context.world
45         if idblock:
46             return idblock
47
48         idblock = context.brush
49         return idblock
50
51
52 class TextureButtonsPanel(bpy.types.Panel):
53     bl_space_type = 'PROPERTIES'
54     bl_region_type = 'WINDOW'
55     bl_context = "texture"
56
57     def poll(self, context):
58         tex = context.texture
59         return (tex and (tex.type != 'NONE' or tex.use_nodes))
60
61
62 class TEXTURE_PT_preview(TextureButtonsPanel):
63     bl_label = "Preview"
64
65     def draw(self, context):
66         layout = self.layout
67
68         tex = context.texture
69         slot = context.texture_slot
70
71         idblock = context_tex_datablock(context)
72
73         if idblock:
74             layout.template_preview(tex, parent=idblock, slot=slot)
75         else:
76             layout.template_preview(tex, slot=slot)
77
78
79 class TEXTURE_PT_context_texture(TextureButtonsPanel):
80     bl_label = ""
81     bl_show_header = False
82
83     def poll(self, context):
84         return (context.material or context.world or context.lamp or context.brush or context.texture)
85
86     def draw(self, context):
87         layout = self.layout
88
89         tex = context.texture
90
91         idblock = context_tex_datablock(context)
92
93         space = context.space_data
94
95         if idblock:
96             row = layout.row()
97
98             row.template_list(idblock, "textures", idblock, "active_texture_index", rows=2)
99
100             col = row.column(align=True)
101             col.item_enumO("texture.slot_move", "type", 'UP', text="", icon='ICON_TRIA_UP')
102             col.item_enumO("texture.slot_move", "type", 'DOWN', text="", icon='ICON_TRIA_DOWN')
103
104
105         split = layout.split(percentage=0.65)
106
107         if idblock:
108             split.template_ID(idblock, "active_texture", new="texture.new")
109         elif tex:
110             split.template_ID(space, "pin_id")
111
112         if (not space.pin_id) and (
113             context.sculpt_object or
114             context.vertex_paint_object or
115             context.weight_paint_object or
116             context.texture_paint_object):
117
118             split.itemR(space, "brush_texture", text="Brush", toggle=True)
119
120         if tex:
121             layout.itemR(tex, "use_nodes")
122
123             split = layout.split(percentage=0.2)
124
125             if tex.use_nodes:
126                 slot = context.texture_slot
127
128                 if slot:
129                     split.itemL(text="Output:")
130                     split.itemR(slot, "output_node", text="")
131
132             else:
133                 split.itemL(text="Type:")
134                 split.itemR(tex, "type", text="")
135
136
137 class TEXTURE_PT_colors(TextureButtonsPanel):
138     bl_label = "Colors"
139     bl_default_closed = True
140
141     def draw(self, context):
142         layout = self.layout
143
144         tex = context.texture
145
146         layout.itemR(tex, "use_color_ramp", text="Ramp")
147         if tex.use_color_ramp:
148             layout.template_color_ramp(tex, "color_ramp", expand=True)
149
150         split = layout.split()
151
152         col = split.column()
153         col.itemL(text="RGB Multiply:")
154         sub = col.column(align=True)
155         sub.itemR(tex, "factor_red", text="R")
156         sub.itemR(tex, "factor_green", text="G")
157         sub.itemR(tex, "factor_blue", text="B")
158
159         col = split.column()
160         col.itemL(text="Adjust:")
161         col.itemR(tex, "brightness")
162         col.itemR(tex, "contrast")
163
164 # Texture Slot Panels #
165
166
167 class TextureSlotPanel(TextureButtonsPanel):
168
169     def poll(self, context):
170         return (context.texture_slot and
171                 TextureButtonsPanel.poll(self, context))
172
173
174 class TEXTURE_PT_mapping(TextureSlotPanel):
175     bl_label = "Mapping"
176
177     def draw(self, context):
178         layout = self.layout
179
180         idblock = context_tex_datablock(context)
181
182         tex = context.texture_slot
183         textype = context.texture
184
185         if type(idblock) != bpy.types.Brush:
186             split = layout.split(percentage=0.3)
187             col = split.column()
188             col.itemL(text="Coordinates:")
189             col = split.column()
190             col.itemR(tex, "texture_coordinates", text="")
191
192             if tex.texture_coordinates == 'ORCO':
193                 """
194                 ob = context.object
195                 if ob and ob.type == 'MESH':
196                     split = layout.split(percentage=0.3)
197                     split.itemL(text="Mesh:")
198                     split.itemR(ob.data, "texco_mesh", text="")
199                 """
200             elif tex.texture_coordinates == 'UV':
201                 split = layout.split(percentage=0.3)
202                 split.itemL(text="Layer:")
203                 ob = context.object
204                 if ob and ob.type == 'MESH':
205                     split.item_pointerR(tex, "uv_layer", ob.data, "uv_textures", text="")
206                 else:
207                     split.itemR(tex, "uv_layer", text="")
208
209             elif tex.texture_coordinates == 'OBJECT':
210                 split = layout.split(percentage=0.3)
211                 split.itemL(text="Object:")
212                 split.itemR(tex, "object", text="")
213
214         if type(idblock) == bpy.types.Brush:
215             layout.itemR(tex, "map_mode", expand=True)
216
217             row = layout.row()
218             row.active = tex.map_mode in ('FIXED', 'TILED')
219             row.itemR(tex, "angle")
220
221             row = layout.row()
222             row.active = tex.map_mode in ('TILED', '3D')
223             row.column().itemR(tex, "size")
224         else:
225             if type(idblock) == bpy.types.Material:
226                 split = layout.split(percentage=0.3)
227                 split.itemL(text="Projection:")
228                 split.itemR(tex, "mapping", text="")
229
230                 split = layout.split()
231
232                 col = split.column()
233                 if tex.texture_coordinates in ('ORCO', 'UV'):
234                     col.itemR(tex, "from_dupli")
235                 elif tex.texture_coordinates == 'OBJECT':
236                     col.itemR(tex, "from_original")
237                 else:
238                     col.itemL()
239
240                 col = split.column()
241                 row = col.row()
242                 row.itemR(tex, "x_mapping", text="")
243                 row.itemR(tex, "y_mapping", text="")
244                 row.itemR(tex, "z_mapping", text="")
245
246             # any non brush
247             row = layout.row()
248             row.column().itemR(tex, "offset")
249             row.column().itemR(tex, "size")
250
251
252 class TEXTURE_PT_influence(TextureSlotPanel):
253     bl_label = "Influence"
254
255     def poll(self, context):
256         return context.texture_slot
257
258     def draw(self, context):
259
260         layout = self.layout
261
262         idblock = context_tex_datablock(context)
263
264         textype = context.texture
265         tex = context.texture_slot
266
267         def factor_but(layout, active, toggle, factor, name):
268             row = layout.row(align=True)
269             row.itemR(tex, toggle, text="")
270             sub = row.row()
271             sub.active = active
272             sub.itemR(tex, factor, text=name, slider=True)
273
274         if type(idblock) == bpy.types.Material:
275             if idblock.type in ('SURFACE', 'HALO', 'WIRE'):
276                 split = layout.split()
277
278                 col = split.column()
279                 col.itemL(text="Diffuse:")
280                 factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
281                 factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
282                 factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
283                 factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
284
285                 col.itemL(text="Specular:")
286                 factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
287                 factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
288                 factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
289
290                 col = split.column()
291                 col.itemL(text="Shading:")
292                 factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
293                 factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
294                 factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
295                 factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
296
297                 col.itemL(text="Geometry:")
298                 factor_but(col, tex.map_normal, "map_normal", "normal_factor", "Normal")
299                 factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
300                 factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
301
302                 #sub = col.column()
303                 #sub.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
304                 #sub.itemR(tex, "default_value", text="Amount", slider=True)
305             elif idblock.type == 'VOLUME':
306                 split = layout.split()
307
308                 col = split.column()
309                 factor_but(col, tex.map_density, "map_density", "density_factor", "Density")
310                 factor_but(col, tex.map_emission, "map_emission", "emission_factor", "Emission")
311                 factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering")
312                 factor_but(col, tex.map_reflection, "map_reflection", "reflection_factor", "Reflection")
313
314                 col = split.column()
315                 col.itemL(text=" ")
316                 factor_but(col, tex.map_alpha, "map_coloremission", "coloremission_factor", "Emission Color")
317                 factor_but(col, tex.map_colortransmission, "map_colortransmission", "colortransmission_factor", "Transmission Color")
318                 factor_but(col, tex.map_colorreflection, "map_colorreflection", "colorreflection_factor", "Reflection Color")
319
320         elif type(idblock) == bpy.types.Lamp:
321             row = layout.row()
322             factor_but(row, tex.map_color, "map_color", "color_factor", "Color")
323             factor_but(row, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
324
325         elif type(idblock) == bpy.types.World:
326             split = layout.split()
327
328             col = split.column()
329             factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
330             factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
331
332             col = split.column()
333             factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
334             factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
335
336         layout.itemS()
337
338         split = layout.split()
339
340         col = split.column()
341         col.itemR(tex, "blend_type", text="Blend")
342         col.itemR(tex, "rgb_to_intensity")
343         sub = col.column()
344         sub.active = tex.rgb_to_intensity
345         sub.itemR(tex, "color", text="")
346
347         col = split.column()
348         col.itemR(tex, "negate", text="Negative")
349         col.itemR(tex, "stencil")
350
351         if type(idblock) in (bpy.types.Material, bpy.types.World):
352             col.itemR(tex, "default_value", text="DVar", slider=True)
353
354 # Texture Type Panels #
355
356
357 class TextureTypePanel(TextureButtonsPanel):
358
359     def poll(self, context):
360         tex = context.texture
361         return (tex and tex.type == self.tex_type and not tex.use_nodes)
362
363
364 class TEXTURE_PT_clouds(TextureTypePanel):
365     bl_label = "Clouds"
366     tex_type = 'CLOUDS'
367
368     def draw(self, context):
369         layout = self.layout
370
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         flow = layout.column_flow()
379         flow.itemR(tex, "noise_size", text="Size")
380         flow.itemR(tex, "noise_depth", text="Depth")
381         flow.itemR(tex, "nabla", text="Nabla")
382
383
384 class TEXTURE_PT_wood(TextureTypePanel):
385     bl_label = "Wood"
386     tex_type = 'WOOD'
387
388     def draw(self, context):
389         layout = self.layout
390
391         tex = context.texture
392
393         layout.itemR(tex, "noisebasis2", expand=True)
394         layout.itemR(tex, "stype", expand=True)
395
396         col = layout.column()
397         col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
398         col.itemL(text="Noise:")
399         col.row().itemR(tex, "noise_type", text="Type", expand=True)
400         col.itemR(tex, "noise_basis", text="Basis")
401
402         flow = layout.column_flow()
403         flow.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
404         flow.itemR(tex, "noise_size", text="Size")
405         flow.itemR(tex, "turbulence")
406         flow.itemR(tex, "nabla")
407
408
409 class TEXTURE_PT_marble(TextureTypePanel):
410     bl_label = "Marble"
411     tex_type = 'MARBLE'
412
413     def draw(self, context):
414         layout = self.layout
415
416         tex = context.texture
417
418         layout.itemR(tex, "stype", expand=True)
419         layout.itemR(tex, "noisebasis2", expand=True)
420         layout.itemL(text="Noise:")
421         layout.itemR(tex, "noise_type", text="Type", expand=True)
422         layout.itemR(tex, "noise_basis", text="Basis")
423
424         flow = layout.column_flow()
425         flow.itemR(tex, "noise_size", text="Size")
426         flow.itemR(tex, "noise_depth", text="Depth")
427         flow.itemR(tex, "turbulence")
428         flow.itemR(tex, "nabla")
429
430
431 class TEXTURE_PT_magic(TextureTypePanel):
432     bl_label = "Magic"
433     tex_type = 'MAGIC'
434
435     def draw(self, context):
436         layout = self.layout
437
438         tex = context.texture
439
440         row = layout.row()
441         row.itemR(tex, "noise_depth", text="Depth")
442         row.itemR(tex, "turbulence")
443
444
445 class TEXTURE_PT_blend(TextureTypePanel):
446     bl_label = "Blend"
447     tex_type = 'BLEND'
448
449     def draw(self, context):
450         layout = self.layout
451
452         tex = context.texture
453
454         layout.itemR(tex, "progression")
455         sub = layout.row()
456
457         sub.active = (tex.progression in ('LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'))
458         sub.itemR(tex, "flip_axis", expand=True)
459
460
461 class TEXTURE_PT_stucci(TextureTypePanel):
462     bl_label = "Stucci"
463     tex_type = 'STUCCI'
464
465     def draw(self, context):
466         layout = self.layout
467
468         tex = context.texture
469
470         layout.itemR(tex, "stype", expand=True)
471         layout.itemL(text="Noise:")
472         layout.itemR(tex, "noise_type", text="Type", expand=True)
473         layout.itemR(tex, "noise_basis", text="Basis")
474
475         row = layout.row()
476         row.itemR(tex, "noise_size", text="Size")
477         row.itemR(tex, "turbulence")
478
479
480 class TEXTURE_PT_image(TextureTypePanel):
481     bl_label = "Image"
482     tex_type = 'IMAGE'
483
484     def draw(self, context):
485         layout = self.layout
486
487         tex = context.texture
488
489         layout.template_image(tex, "image", tex.image_user)
490
491
492 class TEXTURE_PT_image_sampling(TextureTypePanel):
493     bl_label = "Image Sampling"
494     bl_default_closed = True
495     tex_type = 'IMAGE'
496
497     def draw(self, context):
498         layout = self.layout
499
500         tex = context.texture
501         slot = context.texture_slot
502
503         split = layout.split()
504
505         col = split.column()
506         col.itemL(text="Alpha:")
507         col.itemR(tex, "use_alpha", text="Use")
508         col.itemR(tex, "calculate_alpha", text="Calculate")
509         col.itemR(tex, "invert_alpha", text="Invert")
510
511         col.itemL(text="Flip:")
512         col.itemR(tex, "flip_axis", text="X/Y Axis")
513
514         col = split.column()
515         col.itemR(tex, "normal_map")
516         row = col.row()
517         row.active = tex.normal_map
518         row.itemR(tex, "normal_space", text="")
519
520         col.itemL(text="Filter:")
521         col.itemR(tex, "filter", text="")
522         col.itemR(tex, "filter_size")
523         col.itemR(tex, "filter_size_minimum")
524         col.itemR(tex, "mipmap")
525
526         row = col.row()
527         row.active = tex.mipmap
528         row.itemR(tex, "mipmap_gauss")
529
530         col.itemR(tex, "interpolation")
531         if tex.mipmap and tex.filter != 'DEFAULT':
532             if tex.filter == 'FELINE':
533                 col.itemR(tex, "filter_probes", text="Probes")
534             else:
535                 col.itemR(tex, "filter_eccentricity", text="Eccentricity")
536
537
538 class TEXTURE_PT_image_mapping(TextureTypePanel):
539     bl_label = "Image Mapping"
540     bl_default_closed = True
541     tex_type = 'IMAGE'
542
543     def draw(self, context):
544         layout = self.layout
545
546         tex = context.texture
547
548         layout.itemR(tex, "extension")
549
550         split = layout.split()
551
552         if tex.extension == 'REPEAT':
553             col = split.column(align=True)
554             col.itemL(text="Repeat:")
555             col.itemR(tex, "repeat_x", text="X")
556             col.itemR(tex, "repeat_y", text="Y")
557
558             col = split.column(align=True)
559             col.itemL(text="Mirror:")
560             col.itemR(tex, "mirror_x", text="X")
561             col.itemR(tex, "mirror_y", text="Y")
562             layout.itemS()
563
564         elif tex.extension == 'CHECKER':
565             col = split.column(align=True)
566             row = col.row()
567             row.itemR(tex, "checker_even", text="Even")
568             row.itemR(tex, "checker_odd", text="Odd")
569
570             split.itemR(tex, "checker_distance", text="Distance")
571             layout.itemS()
572
573         split = layout.split()
574
575         col = split.column(align=True)
576         #col.itemR(tex, "crop_rectangle")
577         col.itemL(text="Crop Minimum:")
578         col.itemR(tex, "crop_min_x", text="X")
579         col.itemR(tex, "crop_min_y", text="Y")
580
581         col = split.column(align=True)
582         col.itemL(text="Crop Maximum:")
583         col.itemR(tex, "crop_max_x", text="X")
584         col.itemR(tex, "crop_max_y", text="Y")
585
586
587 class TEXTURE_PT_plugin(TextureTypePanel):
588     bl_label = "Plugin"
589     tex_type = 'PLUGIN'
590
591     def draw(self, context):
592         layout = self.layout
593
594         tex = context.texture
595
596         layout.itemL(text="Nothing yet")
597
598
599 class TEXTURE_PT_envmap(TextureTypePanel):
600     bl_label = "Environment Map"
601     tex_type = 'ENVIRONMENT_MAP'
602
603     def draw(self, context):
604         layout = self.layout
605
606         tex = context.texture
607
608         layout.itemL(text="Nothing yet")
609
610
611 class TEXTURE_PT_musgrave(TextureTypePanel):
612     bl_label = "Musgrave"
613     tex_type = 'MUSGRAVE'
614
615     def draw(self, context):
616         layout = self.layout
617
618         tex = context.texture
619
620         layout.itemR(tex, "musgrave_type")
621
622         split = layout.split()
623
624         col = split.column()
625         col.itemR(tex, "highest_dimension", text="Dimension")
626         col.itemR(tex, "lacunarity")
627         col.itemR(tex, "octaves")
628
629         col = split.column()
630         if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
631             col.itemR(tex, "offset")
632         if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
633             col.itemR(tex, "gain")
634             col.itemR(tex, "noise_intensity", text="Intensity")
635
636         layout.itemL(text="Noise:")
637
638         layout.itemR(tex, "noise_basis", text="Basis")
639
640         row = layout.row()
641         row.itemR(tex, "noise_size", text="Size")
642         row.itemR(tex, "nabla")
643
644
645 class TEXTURE_PT_voronoi(TextureTypePanel):
646     bl_label = "Voronoi"
647     tex_type = 'VORONOI'
648
649     def draw(self, context):
650         layout = self.layout
651
652         tex = context.texture
653
654         split = layout.split()
655
656         col = split.column()
657         col.itemL(text="Distance Metric:")
658         col.itemR(tex, "distance_metric", text="")
659         sub = col.column()
660         sub.active = tex.distance_metric == 'MINKOVSKY'
661         sub.itemR(tex, "minkovsky_exponent", text="Exponent")
662         col.itemL(text="Coloring:")
663         col.itemR(tex, "coloring", text="")
664         col.itemR(tex, "noise_intensity", text="Intensity")
665
666         col = split.column(align=True)
667         col.itemL(text="Feature Weights:")
668         col.itemR(tex, "weight_1", text="1", slider=True)
669         col.itemR(tex, "weight_2", text="2", slider=True)
670         col.itemR(tex, "weight_3", text="3", slider=True)
671         col.itemR(tex, "weight_4", text="4", slider=True)
672
673         layout.itemL(text="Noise:")
674
675         row = layout.row()
676         row.itemR(tex, "noise_size", text="Size")
677         row.itemR(tex, "nabla")
678
679
680 class TEXTURE_PT_distortednoise(TextureTypePanel):
681     bl_label = "Distorted Noise"
682     tex_type = 'DISTORTED_NOISE'
683
684     def draw(self, context):
685         layout = self.layout
686
687         tex = context.texture
688
689         layout.itemR(tex, "noise_distortion")
690         layout.itemR(tex, "noise_basis", text="Basis")
691
692         flow = layout.column_flow()
693         flow.itemR(tex, "distortion", text="Distortion")
694         flow.itemR(tex, "noise_size", text="Size")
695         flow.itemR(tex, "nabla")
696
697
698 class TEXTURE_PT_voxeldata(TextureButtonsPanel):
699     bl_label = "Voxel Data"
700
701     def poll(self, context):
702         tex = context.texture
703         return (tex and tex.type == 'VOXEL_DATA')
704
705     def draw(self, context):
706         layout = self.layout
707
708         tex = context.texture
709         vd = tex.voxeldata
710
711         layout.itemR(vd, "file_format")
712         if vd.file_format in ['BLENDER_VOXEL', 'RAW_8BIT']:
713             layout.itemR(vd, "source_path")
714         if vd.file_format == 'RAW_8BIT':
715             layout.itemR(vd, "resolution")
716         elif vd.file_format == 'SMOKE':
717             layout.itemR(vd, "domain_object")
718
719         layout.itemR(vd, "still")
720         row = layout.row()
721         row.active = vd.still
722         row.itemR(vd, "still_frame_number")
723
724         layout.itemR(vd, "interpolation")
725         layout.itemR(vd, "extension")
726         layout.itemR(vd, "intensity")
727
728
729 class TEXTURE_PT_pointdensity(TextureButtonsPanel):
730     bl_label = "Point Density"
731
732     def poll(self, context):
733         tex = context.texture
734         return (tex and tex.type == 'POINT_DENSITY')
735
736     def draw(self, context):
737         layout = self.layout
738
739         tex = context.texture
740         pd = tex.pointdensity
741
742         layout.itemR(pd, "point_source", expand=True)
743
744         split = layout.split()
745
746         col = split.column()
747         if pd.point_source == 'PARTICLE_SYSTEM':
748             col.itemL(text="Object:")
749             col.itemR(pd, "object", text="")
750
751             sub = col.column()
752             sub.enabled = pd.object
753             if pd.object:
754                 sub.itemL(text="System:")
755                 sub.item_pointerR(pd, "particle_system", pd.object, "particle_systems", text="")
756             sub.itemL(text="Cache:")
757             sub.itemR(pd, "particle_cache", text="")
758         else:
759             col.itemL(text="Object:")
760             col.itemR(pd, "object", text="")
761             col.itemL(text="Cache:")
762             col.itemR(pd, "vertices_cache", text="")
763
764         col.itemS()
765
766         col.itemL(text="Color Source:")
767         col.itemR(pd, "color_source", text="")
768         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_VELOCITY'):
769             col.itemR(pd, "speed_scale")
770         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'):
771             layout.template_color_ramp(pd, "color_ramp", expand=True)
772
773         col = split.column()
774         col.itemL()
775         col.itemR(pd, "radius")
776         col.itemL(text="Falloff:")
777         col.itemR(pd, "falloff", text="")
778         if pd.falloff == 'SOFT':
779             col.itemR(pd, "falloff_softness")
780
781
782 class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel):
783     bl_label = "Turbulence"
784
785     def poll(self, context):
786         tex = context.texture
787         return (tex and tex.type == 'POINT_DENSITY')
788
789     def draw_header(self, context):
790         layout = self.layout
791
792         tex = context.texture
793         pd = tex.pointdensity
794
795         layout.itemR(pd, "turbulence", text="")
796
797     def draw(self, context):
798         layout = self.layout
799
800         tex = context.texture
801         pd = tex.pointdensity
802         layout.active = pd.turbulence
803
804         split = layout.split()
805
806         col = split.column()
807         col.itemL(text="Influence:")
808         col.itemR(pd, "turbulence_influence", text="")
809         col.itemL(text="Noise Basis:")
810         col.itemR(pd, "noise_basis", text="")
811
812         col = split.column()
813         col.itemL()
814         col.itemR(pd, "turbulence_size")
815         col.itemR(pd, "turbulence_depth")
816         col.itemR(pd, "turbulence_strength")
817
818 bpy.types.register(TEXTURE_PT_context_texture)
819 bpy.types.register(TEXTURE_PT_preview)
820
821 bpy.types.register(TEXTURE_PT_clouds) # Texture Type Panels
822 bpy.types.register(TEXTURE_PT_wood)
823 bpy.types.register(TEXTURE_PT_marble)
824 bpy.types.register(TEXTURE_PT_magic)
825 bpy.types.register(TEXTURE_PT_blend)
826 bpy.types.register(TEXTURE_PT_stucci)
827 bpy.types.register(TEXTURE_PT_image)
828 bpy.types.register(TEXTURE_PT_image_sampling)
829 bpy.types.register(TEXTURE_PT_image_mapping)
830 bpy.types.register(TEXTURE_PT_plugin)
831 bpy.types.register(TEXTURE_PT_envmap)
832 bpy.types.register(TEXTURE_PT_musgrave)
833 bpy.types.register(TEXTURE_PT_voronoi)
834 bpy.types.register(TEXTURE_PT_distortednoise)
835 bpy.types.register(TEXTURE_PT_voxeldata)
836 bpy.types.register(TEXTURE_PT_pointdensity)
837 bpy.types.register(TEXTURE_PT_pointdensity_turbulence)
838
839 bpy.types.register(TEXTURE_PT_colors)
840 bpy.types.register(TEXTURE_PT_mapping)
841 bpy.types.register(TEXTURE_PT_influence)