poll() as a python '@staticmethod' was too limiting and didnt allow useful base class...
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23
24 class TEXTURE_MT_specials(bpy.types.Menu):
25     bl_label = "Texture Specials"
26     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
27
28     def draw(self, context):
29         layout = self.layout
30
31         layout.operator("texture.slot_copy", icon='COPYDOWN')
32         layout.operator("texture.slot_paste", icon='PASTEDOWN')
33
34
35 class TEXTURE_MT_envmap_specials(bpy.types.Menu):
36     bl_label = "Environment Map Specials"
37     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
38
39     def draw(self, context):
40         layout = self.layout
41
42         layout.operator("texture.envmap_save", icon='IMAGEFILE')
43         layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
44         layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
45
46 from properties_material import active_node_mat
47
48
49 def context_tex_datablock(context):
50     idblock = context.material
51     if idblock:
52         return active_node_mat(idblock)
53
54     idblock = context.lamp
55     if idblock:
56         return idblock
57
58     idblock = context.world
59     if idblock:
60         return idblock
61
62     idblock = context.brush
63     return idblock
64
65
66 class TextureButtonsPanel():
67     bl_space_type = 'PROPERTIES'
68     bl_region_type = 'WINDOW'
69     bl_context = "texture"
70
71     @classmethod
72     def poll(cls, context):
73         tex = context.texture
74         return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES)
75
76
77 class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
78     bl_label = "Preview"
79     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
80
81     def draw(self, context):
82         layout = self.layout
83
84         tex = context.texture
85         slot = getattr(context, "texture_slot", None)
86         idblock = context_tex_datablock(context)
87
88         if idblock:
89             layout.template_preview(tex, parent=idblock, slot=slot)
90         else:
91             layout.template_preview(tex, slot=slot)
92
93
94 class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
95     bl_label = ""
96     bl_show_header = False
97     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
98
99     @classmethod
100     def poll(cls, context):
101         engine = context.scene.render.engine
102         if not hasattr(context, "texture_slot"):
103             return False
104         return ((context.material or context.world or context.lamp or context.brush or context.texture)
105             and (engine in cls.COMPAT_ENGINES))
106
107     def draw(self, context):
108         layout = self.layout
109         slot = context.texture_slot
110         node = context.texture_node
111         space = context.space_data
112         tex = context.texture
113         idblock = context_tex_datablock(context)
114         tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node
115
116         if tex_collection:
117             row = layout.row()
118
119             row.template_list(idblock, "texture_slots", idblock, "active_texture_index", rows=2)
120
121             col = row.column(align=True)
122             col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
123             col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
124             col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
125
126         split = layout.split(percentage=0.65)
127         col = split.column()
128
129         if tex_collection:
130             col.template_ID(idblock, "active_texture", new="texture.new")
131         elif node:
132             col.template_ID(node, "texture", new="texture.new")
133         elif idblock:
134             col.template_ID(idblock, "texture", new="texture.new")
135
136         if space.pin_id:
137             col.template_ID(space, "pin_id")
138
139         col = split.column()
140
141         if not space.pin_id:
142             col.prop(space, "brush_texture", text="Brush", toggle=True)
143
144         if tex:
145             split = layout.split(percentage=0.2)
146
147             if tex.use_nodes:
148
149                 if slot:
150                     split.label(text="Output:")
151                     split.prop(slot, "output_node", text="")
152
153             else:
154                 split.label(text="Type:")
155                 split.prop(tex, "type", text="")
156
157
158 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel):
159     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
160     _context_path = "texture"
161
162
163 class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
164     bl_label = "Colors"
165     bl_default_closed = True
166     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
167
168     def draw(self, context):
169         layout = self.layout
170
171         tex = context.texture
172
173         layout.prop(tex, "use_color_ramp", text="Ramp")
174         if tex.use_color_ramp:
175             layout.template_color_ramp(tex, "color_ramp", expand=True)
176
177         split = layout.split()
178
179         col = split.column()
180         col.label(text="RGB Multiply:")
181         sub = col.column(align=True)
182         sub.prop(tex, "factor_red", text="R")
183         sub.prop(tex, "factor_green", text="G")
184         sub.prop(tex, "factor_blue", text="B")
185
186         col = split.column()
187         col.label(text="Adjust:")
188         col.prop(tex, "brightness")
189         col.prop(tex, "contrast")
190         col.prop(tex, "saturation")
191
192 # Texture Slot Panels #
193
194
195 class TextureSlotPanel(TextureButtonsPanel):
196     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
197
198     @classmethod
199     def poll(cls, context):
200         if not hasattr(context, "texture_slot"):
201             return False
202
203         engine = context.scene.render.engine
204         return TextureButtonsPanel.poll(self, context) and (engine in cls.COMPAT_ENGINES)
205
206
207 class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel):
208     bl_label = "Mapping"
209     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
210
211     @classmethod
212     def poll(cls, context):
213         idblock = context_tex_datablock(context)
214         if type(idblock) == bpy.types.Brush and not context.sculpt_object:
215             return False
216
217         if not getattr(context, "texture_slot", None):
218             return False
219
220         engine = context.scene.render.engine
221         return (engine in cls.COMPAT_ENGINES)
222
223     def draw(self, context):
224         layout = self.layout
225
226         idblock = context_tex_datablock(context)
227
228         tex = context.texture_slot
229         # textype = context.texture
230
231         if type(idblock) != bpy.types.Brush:
232             split = layout.split(percentage=0.3)
233             col = split.column()
234             col.label(text="Coordinates:")
235             col = split.column()
236             col.prop(tex, "texture_coordinates", text="")
237
238             if tex.texture_coordinates == 'ORCO':
239                 """
240                 ob = context.object
241                 if ob and ob.type == 'MESH':
242                     split = layout.split(percentage=0.3)
243                     split.label(text="Mesh:")
244                     split.prop(ob.data, "texco_mesh", text="")
245                 """
246             elif tex.texture_coordinates == 'UV':
247                 split = layout.split(percentage=0.3)
248                 split.label(text="Layer:")
249                 ob = context.object
250                 if ob and ob.type == 'MESH':
251                     split.prop_object(tex, "uv_layer", ob.data, "uv_textures", text="")
252                 else:
253                     split.prop(tex, "uv_layer", text="")
254
255             elif tex.texture_coordinates == 'OBJECT':
256                 split = layout.split(percentage=0.3)
257                 split.label(text="Object:")
258                 split.prop(tex, "object", text="")
259
260         if type(idblock) == bpy.types.Brush:
261             if context.sculpt_object:
262                 layout.label(text="Brush Mapping:")
263                 layout.prop(tex, "map_mode", expand=True)
264
265                 row = layout.row()
266                 row.active = tex.map_mode in ('FIXED', 'TILED')
267                 row.prop(tex, "angle")
268         else:
269             if type(idblock) == bpy.types.Material:
270                 split = layout.split(percentage=0.3)
271                 split.label(text="Projection:")
272                 split.prop(tex, "mapping", text="")
273
274                 split = layout.split()
275
276                 col = split.column()
277                 if tex.texture_coordinates in ('ORCO', 'UV'):
278                     col.prop(tex, "from_dupli")
279                 elif tex.texture_coordinates == 'OBJECT':
280                     col.prop(tex, "from_original")
281                 else:
282                     col.label()
283
284                 col = split.column()
285                 row = col.row()
286                 row.prop(tex, "x_mapping", text="")
287                 row.prop(tex, "y_mapping", text="")
288                 row.prop(tex, "z_mapping", text="")
289
290         split = layout.split()
291
292         col = split.column()
293         col.prop(tex, "offset")
294
295         col = split.column()
296
297         col.prop(tex, "size")
298
299
300 class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
301     bl_label = "Influence"
302     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
303
304     @classmethod
305     def poll(cls, context):
306         idblock = context_tex_datablock(context)
307         if type(idblock) == bpy.types.Brush:
308             return False
309
310         if not getattr(context, "texture_slot", None):
311             return False
312
313         engine = context.scene.render.engine
314         return (engine in cls.COMPAT_ENGINES)
315
316     def draw(self, context):
317
318         layout = self.layout
319
320         idblock = context_tex_datablock(context)
321
322         # textype = context.texture
323         tex = context.texture_slot
324
325         def factor_but(layout, active, toggle, factor, name):
326             row = layout.row(align=True)
327             row.prop(tex, toggle, text="")
328             sub = row.row()
329             sub.active = active
330             sub.prop(tex, factor, text=name, slider=True)
331
332         if type(idblock) == bpy.types.Material:
333             if idblock.type in ('SURFACE', 'HALO', 'WIRE'):
334                 split = layout.split()
335
336                 col = split.column()
337                 col.label(text="Diffuse:")
338                 factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
339                 factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
340                 factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
341                 factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
342
343                 col.label(text="Specular:")
344                 factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
345                 factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
346                 factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
347
348                 col = split.column()
349                 col.label(text="Shading:")
350                 factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
351                 factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
352                 factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
353                 factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
354
355                 col.label(text="Geometry:")
356                 # XXX replace 'or' when displacement is fixed to not rely on normal influence value.
357                 factor_but(col, (tex.map_normal or tex.map_displacement), "map_normal", "normal_factor", "Normal")
358                 factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
359                 factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
360
361                 #sub = col.column()
362                 #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
363                 #sub.prop(tex, "default_value", text="Amount", slider=True)
364             elif idblock.type == 'VOLUME':
365                 split = layout.split()
366
367                 col = split.column()
368                 factor_but(col, tex.map_density, "map_density", "density_factor", "Density")
369                 factor_but(col, tex.map_emission, "map_emission", "emission_factor", "Emission")
370                 factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering")
371                 factor_but(col, tex.map_reflection, "map_reflection", "reflection_factor", "Reflection")
372
373                 col = split.column()
374                 col.label(text=" ")
375                 factor_but(col, tex.map_coloremission, "map_coloremission", "coloremission_factor", "Emission Color")
376                 factor_but(col, tex.map_colortransmission, "map_colortransmission", "colortransmission_factor", "Transmission Color")
377                 factor_but(col, tex.map_colorreflection, "map_colorreflection", "colorreflection_factor", "Reflection Color")
378
379         elif type(idblock) == bpy.types.Lamp:
380             split = layout.split()
381
382             col = split.column()
383             factor_but(col, tex.map_color, "map_color", "color_factor", "Color")
384
385             col = split.column()
386             factor_but(col, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
387
388         elif type(idblock) == bpy.types.World:
389             split = layout.split()
390
391             col = split.column()
392             factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
393             factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
394
395             col = split.column()
396             factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
397             factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
398
399         layout.separator()
400
401         split = layout.split()
402
403         col = split.column()
404         col.prop(tex, "blend_type", text="Blend")
405         col.prop(tex, "rgb_to_intensity")
406         sub = col.column()
407         sub.active = tex.rgb_to_intensity
408         sub.prop(tex, "color", text="")
409
410         col = split.column()
411         col.prop(tex, "negate", text="Negative")
412         col.prop(tex, "stencil")
413
414         if type(idblock) in (bpy.types.Material, bpy.types.World):
415             col.prop(tex, "default_value", text="DVar", slider=True)
416
417 # Texture Type Panels #
418
419
420 class TextureTypePanel(TextureButtonsPanel):
421
422     @classmethod
423     def poll(cls, context):
424         tex = context.texture
425         engine = context.scene.render.engine
426         return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))
427
428
429 class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel):
430     bl_label = "Clouds"
431     tex_type = 'CLOUDS'
432     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
433
434     def draw(self, context):
435         layout = self.layout
436
437         tex = context.texture
438
439         layout.prop(tex, "stype", expand=True)
440         layout.label(text="Noise:")
441         layout.prop(tex, "noise_type", text="Type", expand=True)
442         layout.prop(tex, "noise_basis", text="Basis")
443
444         split = layout.split()
445
446         col = split.column()
447         col.prop(tex, "noise_size", text="Size")
448         col.prop(tex, "noise_depth", text="Depth")
449
450         col = split.column()
451         col.prop(tex, "nabla", text="Nabla")
452
453
454 class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel):
455     bl_label = "Wood"
456     tex_type = 'WOOD'
457     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
458
459     def draw(self, context):
460         layout = self.layout
461
462         tex = context.texture
463
464         layout.prop(tex, "noisebasis2", expand=True)
465         layout.prop(tex, "stype", expand=True)
466
467         col = layout.column()
468         col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
469         col.label(text="Noise:")
470         col.row().prop(tex, "noise_type", text="Type", expand=True)
471         layout.prop(tex, "noise_basis", text="Basis")
472
473         split = layout.split()
474         split.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
475
476         col = split.column()
477         col.prop(tex, "noise_size", text="Size")
478         col.prop(tex, "turbulence")
479
480         col = split.column()
481         col.prop(tex, "nabla")
482
483
484 class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel):
485     bl_label = "Marble"
486     tex_type = 'MARBLE'
487     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
488
489     def draw(self, context):
490         layout = self.layout
491
492         tex = context.texture
493
494         layout.prop(tex, "stype", expand=True)
495         layout.prop(tex, "noisebasis2", expand=True)
496         layout.label(text="Noise:")
497         layout.prop(tex, "noise_type", text="Type", expand=True)
498         layout.prop(tex, "noise_basis", text="Basis")
499
500         split = layout.split()
501
502         col = split.column()
503         col.prop(tex, "noise_size", text="Size")
504         col.prop(tex, "noise_depth", text="Depth")
505
506         col = split.column()
507         col.prop(tex, "turbulence")
508         col.prop(tex, "nabla")
509
510
511 class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel):
512     bl_label = "Magic"
513     tex_type = 'MAGIC'
514     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
515
516     def draw(self, context):
517         layout = self.layout
518
519         tex = context.texture
520
521         split = layout.split()
522
523         col = split.column()
524         col.prop(tex, "noise_depth", text="Depth")
525
526         col = split.column()
527         col.prop(tex, "turbulence")
528
529
530 class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel):
531     bl_label = "Blend"
532     tex_type = 'BLEND'
533     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
534
535     def draw(self, context):
536         layout = self.layout
537
538         tex = context.texture
539
540         layout.prop(tex, "progression")
541
542         sub = layout.row()
543
544         sub.active = (tex.progression in ('LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'))
545         sub.prop(tex, "flip_axis", expand=True)
546
547
548 class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel):
549     bl_label = "Stucci"
550     tex_type = 'STUCCI'
551     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
552
553     def draw(self, context):
554         layout = self.layout
555
556         tex = context.texture
557
558         layout.prop(tex, "stype", expand=True)
559         layout.label(text="Noise:")
560         layout.prop(tex, "noise_type", text="Type", expand=True)
561         layout.prop(tex, "noise_basis", text="Basis")
562
563         split = layout.split()
564
565         col = split.column()
566         col.prop(tex, "noise_size", text="Size")
567
568         col = split.column()
569         col.prop(tex, "turbulence")
570
571
572 class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel):
573     bl_label = "Image"
574     tex_type = 'IMAGE'
575     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
576
577     def draw(self, context):
578         layout = self.layout
579
580         tex = context.texture
581
582         layout.template_image(tex, "image", tex.image_user)
583
584
585 def texture_filter_common(tex, layout):
586     layout.label(text="Filter:")
587     layout.prop(tex, "filter", text="")
588     if tex.mipmap and tex.filter in ('AREA', 'EWA', 'FELINE'):
589         if tex.filter == 'FELINE':
590             layout.prop(tex, "filter_probes", text="Probes")
591         else:
592             layout.prop(tex, "filter_eccentricity", text="Eccentricity")
593
594     layout.prop(tex, "filter_size")
595     layout.prop(tex, "filter_size_minimum")
596
597
598 class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
599     bl_label = "Image Sampling"
600     bl_default_closed = True
601     tex_type = 'IMAGE'
602     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
603
604     def draw(self, context):
605         layout = self.layout
606
607         tex = context.texture
608         # slot = context.texture_slot
609
610         split = layout.split()
611
612         col = split.column()
613         col.label(text="Alpha:")
614         col.prop(tex, "use_alpha", text="Use")
615         col.prop(tex, "calculate_alpha", text="Calculate")
616         col.prop(tex, "invert_alpha", text="Invert")
617         col.separator()
618         col.prop(tex, "flip_axis", text="Flip X/Y Axis")
619
620         col = split.column()
621
622         col.prop(tex, "normal_map")
623         row = col.row()
624         row.active = tex.normal_map
625         row.prop(tex, "normal_space", text="")
626
627         col.prop(tex, "mipmap")
628         row = col.row()
629         row.active = tex.mipmap
630         row.prop(tex, "mipmap_gauss")
631         col.prop(tex, "interpolation")
632
633         texture_filter_common(tex, col)
634
635
636 class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel):
637     bl_label = "Image Mapping"
638     bl_default_closed = True
639     tex_type = 'IMAGE'
640     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
641
642     def draw(self, context):
643         layout = self.layout
644
645         tex = context.texture
646
647         layout.prop(tex, "extension")
648
649         split = layout.split()
650
651         if tex.extension == 'REPEAT':
652             col = split.column(align=True)
653             col.label(text="Repeat:")
654             col.prop(tex, "repeat_x", text="X")
655             col.prop(tex, "repeat_y", text="Y")
656
657             col = split.column(align=True)
658             col.label(text="Mirror:")
659             col.prop(tex, "mirror_x", text="X")
660             col.prop(tex, "mirror_y", text="Y")
661             layout.separator()
662
663         elif tex.extension == 'CHECKER':
664             col = split.column(align=True)
665             row = col.row()
666             row.prop(tex, "checker_even", text="Even")
667             row.prop(tex, "checker_odd", text="Odd")
668
669             col = split.column()
670             col.prop(tex, "checker_distance", text="Distance")
671
672             layout.separator()
673
674         split = layout.split()
675
676         col = split.column(align=True)
677         #col.prop(tex, "crop_rectangle")
678         col.label(text="Crop Minimum:")
679         col.prop(tex, "crop_min_x", text="X")
680         col.prop(tex, "crop_min_y", text="Y")
681
682         col = split.column(align=True)
683         col.label(text="Crop Maximum:")
684         col.prop(tex, "crop_max_x", text="X")
685         col.prop(tex, "crop_max_y", text="Y")
686
687
688 class TEXTURE_PT_plugin(TextureTypePanel, bpy.types.Panel):
689     bl_label = "Plugin"
690     tex_type = 'PLUGIN'
691     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
692
693     def draw(self, context):
694         layout = self.layout
695
696         # tex = context.texture
697
698         layout.label(text="Nothing yet")
699
700
701 class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel):
702     bl_label = "Environment Map"
703     tex_type = 'ENVIRONMENT_MAP'
704     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
705
706     def draw(self, context):
707         layout = self.layout
708
709         tex = context.texture
710         env = tex.environment_map
711
712
713         row = layout.row()
714         row.prop(env, "source", expand=True)
715         row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
716
717         if env.source == 'IMAGE_FILE':
718             layout.template_ID(tex, "image", open="image.open")
719             layout.template_image(tex, "image", tex.image_user, compact=True)
720         else:
721             layout.prop(env, "mapping")
722             if env.mapping == 'PLANE':
723                 layout.prop(env, "zoom")
724             layout.prop(env, "viewpoint_object")
725
726             split = layout.split()
727
728             col = split.column()
729             col.prop(env, "ignore_layers")
730             col.prop(env, "resolution")
731             col.prop(env, "depth")
732
733             col = split.column(align=True)
734
735             col.label(text="Clipping:")
736             col.prop(env, "clip_start", text="Start")
737             col.prop(env, "clip_end", text="End")
738
739
740 class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel):
741     bl_label = "Environment Map Sampling"
742     bl_default_closed = True
743     tex_type = 'ENVIRONMENT_MAP'
744     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
745
746     def draw(self, context):
747         layout = self.layout
748
749         tex = context.texture
750
751         texture_filter_common(tex, layout)
752
753
754 class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel):
755     bl_label = "Musgrave"
756     tex_type = 'MUSGRAVE'
757     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
758
759     def draw(self, context):
760         layout = self.layout
761
762         tex = context.texture
763
764         layout.prop(tex, "musgrave_type")
765
766         split = layout.split()
767
768         col = split.column()
769         col.prop(tex, "highest_dimension", text="Dimension")
770         col.prop(tex, "lacunarity")
771         col.prop(tex, "octaves")
772
773         col = split.column()
774         if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
775             col.prop(tex, "offset")
776         if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
777             col.prop(tex, "gain")
778             col.prop(tex, "noise_intensity", text="Intensity")
779
780         layout.label(text="Noise:")
781
782         layout.prop(tex, "noise_basis", text="Basis")
783
784         split = layout.split()
785
786         col = split.column()
787         col.prop(tex, "noise_size", text="Size")
788
789         col = split.column()
790         col.prop(tex, "nabla")
791
792
793 class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel):
794     bl_label = "Voronoi"
795     tex_type = 'VORONOI'
796     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
797
798     def draw(self, context):
799         layout = self.layout
800
801         tex = context.texture
802
803         split = layout.split()
804
805         col = split.column()
806         col.label(text="Distance Metric:")
807         col.prop(tex, "distance_metric", text="")
808         sub = col.column()
809         sub.active = tex.distance_metric == 'MINKOVSKY'
810         sub.prop(tex, "minkovsky_exponent", text="Exponent")
811         col.label(text="Coloring:")
812         col.prop(tex, "coloring", text="")
813         col.prop(tex, "noise_intensity", text="Intensity")
814
815         col = split.column()
816         sub = col.column(align=True)
817         sub.label(text="Feature Weights:")
818         sub.prop(tex, "weight_1", text="1", slider=True)
819         sub.prop(tex, "weight_2", text="2", slider=True)
820         sub.prop(tex, "weight_3", text="3", slider=True)
821         sub.prop(tex, "weight_4", text="4", slider=True)
822
823         layout.label(text="Noise:")
824
825         split = layout.split()
826
827         col = split.column()
828         col.prop(tex, "noise_size", text="Size")
829
830         col = split.column()
831         col.prop(tex, "nabla")
832
833
834 class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel):
835     bl_label = "Distorted Noise"
836     tex_type = 'DISTORTED_NOISE'
837     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
838
839     def draw(self, context):
840         layout = self.layout
841
842         tex = context.texture
843
844         layout.prop(tex, "noise_distortion")
845         layout.prop(tex, "noise_basis", text="Basis")
846
847         split = layout.split()
848
849         col = split.column()
850         col.prop(tex, "distortion", text="Distortion")
851         col.prop(tex, "noise_size", text="Size")
852
853         col = split.column()
854         col.prop(tex, "nabla")
855
856
857 class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel):
858     bl_label = "Voxel Data"
859     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
860
861     @classmethod
862     def poll(cls, context):
863         tex = context.texture
864         engine = context.scene.render.engine
865         return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES))
866
867     def draw(self, context):
868         layout = self.layout
869
870         tex = context.texture
871         vd = tex.voxeldata
872
873         layout.prop(vd, "file_format")
874         if vd.file_format in ['BLENDER_VOXEL', 'RAW_8BIT']:
875             layout.prop(vd, "source_path")
876         if vd.file_format == 'RAW_8BIT':
877             layout.prop(vd, "resolution")
878         elif vd.file_format == 'SMOKE':
879             layout.prop(vd, "domain_object")
880             layout.prop(vd, "smoke_data_type")
881         elif vd.file_format == 'IMAGE_SEQUENCE':
882             layout.template_ID(tex, "image", open="image.open")
883             layout.template_image(tex, "image", tex.image_user, compact=True)
884             #layout.prop(vd, "frames")
885
886         layout.prop(vd, "still")
887         row = layout.row()
888         row.active = vd.still
889         row.prop(vd, "still_frame_number")
890
891         layout.prop(vd, "interpolation")
892         layout.prop(vd, "extension")
893         layout.prop(vd, "intensity")
894
895
896 class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel):
897     bl_label = "Point Density"
898     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
899
900     @classmethod
901     def poll(cls, context):
902         tex = context.texture
903         engine = context.scene.render.engine
904         return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
905
906     def draw(self, context):
907         layout = self.layout
908
909         tex = context.texture
910         pd = tex.pointdensity
911
912         layout.prop(pd, "point_source", expand=True)
913
914         split = layout.split()
915
916         col = split.column()
917         if pd.point_source == 'PARTICLE_SYSTEM':
918             col.label(text="Object:")
919             col.prop(pd, "object", text="")
920
921             sub = col.column()
922             sub.enabled = bool(pd.object)
923             if pd.object:
924                 sub.label(text="System:")
925                 sub.prop_object(pd, "particle_system", pd.object, "particle_systems", text="")
926             sub.label(text="Cache:")
927             sub.prop(pd, "particle_cache", text="")
928         else:
929             col.label(text="Object:")
930             col.prop(pd, "object", text="")
931             col.label(text="Cache:")
932             col.prop(pd, "vertices_cache", text="")
933
934         col.separator()
935
936         col.label(text="Color Source:")
937         col.prop(pd, "color_source", text="")
938         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_VELOCITY'):
939             col.prop(pd, "speed_scale")
940         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'):
941             layout.template_color_ramp(pd, "color_ramp", expand=True)
942
943         col = split.column()
944         col.label()
945         col.prop(pd, "radius")
946         col.label(text="Falloff:")
947         col.prop(pd, "falloff", text="")
948         if pd.falloff == 'SOFT':
949             col.prop(pd, "falloff_softness")
950
951
952 class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel):
953     bl_label = "Turbulence"
954     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
955
956     @classmethod
957     def poll(cls, context):
958         tex = context.texture
959         engine = context.scene.render.engine
960         return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
961
962     def draw_header(self, context):
963         layout = self.layout
964
965         tex = context.texture
966         pd = tex.pointdensity
967
968         layout.prop(pd, "turbulence", text="")
969
970     def draw(self, context):
971         layout = self.layout
972
973         tex = context.texture
974         pd = tex.pointdensity
975         layout.active = pd.turbulence
976
977         split = layout.split()
978
979         col = split.column()
980         col.label(text="Influence:")
981         col.prop(pd, "turbulence_influence", text="")
982         col.label(text="Noise Basis:")
983         col.prop(pd, "noise_basis", text="")
984
985         col = split.column()
986         col.label()
987         col.prop(pd, "turbulence_size")
988         col.prop(pd, "turbulence_depth")
989         col.prop(pd, "turbulence_strength")
990
991
992 def register():
993     pass
994
995
996 def unregister():
997     pass
998
999 if __name__ == "__main__":
1000     register()