Continuing OBJ exporter conversion.
[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                 try:    return (context.active_object.active_material.active_texture.texture != None)
11                 except:return False
12
13 class TEXTURE_PT_preview(TextureButtonsPanel):
14         __idname__= "TEXTURE_PT_preview"
15         __label__ = "Preview"
16
17         def draw(self, context):
18                 layout = self.layout
19
20                 tex = context.active_object.active_material.active_texture.texture
21                 layout.template_preview(tex)
22
23 class TEXTURE_PT_texture(TextureButtonsPanel):
24         __idname__= "TEXTURE_PT_texture"
25         __label__ = "Texture"
26
27         def draw(self, context):
28                 layout = self.layout
29                 tex = context.active_object.active_material.active_texture.texture
30                 
31                 layout.itemR(tex, "type")
32
33 class TEXTURE_PT_clouds(TextureButtonsPanel):
34         __idname__= "TEXTURE_PT_clouds"
35         __label__ = "Clouds"
36         
37         def poll(self, context):
38                 try:    return (context.active_object.active_material.active_texture.texture.type == 'CLOUDS')
39                 except:return False
40
41         def draw(self, context):
42                 layout = self.layout
43                 tex = context.active_object.active_material.active_texture.texture
44                 
45                 layout.itemR(tex, "stype", expand=True)
46                 layout.itemL(text="Noise:")
47                 layout.itemR(tex, "noise_type", text="Type", expand=True)
48                 layout.itemR(tex, "noise_basis", text="Basis")
49                 
50                 col = layout.column_flow()
51                 col.itemR(tex, "noise_size", text="Size")
52                 col.itemR(tex, "noise_depth", text="Depth")
53                 col.itemR(tex, "nabla", text="Nabla")
54
55 class TEXTURE_PT_wood(TextureButtonsPanel):
56         __idname__= "TEXTURE_PT_wood"
57         __label__ = "Wood"
58         
59         def poll(self, context):
60                 try:    return (context.active_object.active_material.active_texture.texture.type == 'WOOD')
61                 except:return False
62
63         def draw(self, context):
64                 layout = self.layout
65                 tex = context.active_object.active_material.active_texture.texture
66                 
67                 layout.itemR(tex, "stype", expand=True)
68                 layout.itemR(tex, "noisebasis2", expand=True)
69                 layout.itemL(text="Noise:")
70                 layout.itemR(tex, "noise_type", text="Type", expand=True)
71                 layout.itemR(tex, "noise_basis", text="Basis")
72                 
73                 col = layout.column_flow()
74                 col.itemR(tex, "noise_size", text="Size")
75                 col.itemR(tex, "turbulence")
76                 col.itemR(tex, "nabla")
77                 
78 class TEXTURE_PT_marble(TextureButtonsPanel):
79         __idname__= "TEXTURE_PT_marble"
80         __label__ = "Marble"
81         
82         def poll(self, context):
83                 try:    return (context.active_object.active_material.active_texture.texture.type == 'MARBLE')
84                 except:return False
85
86         def draw(self, context):
87                 layout = self.layout
88                 tex = context.active_object.active_material.active_texture.texture
89                 
90                 layout.itemR(tex, "stype", expand=True)
91                 layout.itemR(tex, "noisebasis2", expand=True)
92                 layout.itemL(text="Noise:")
93                 layout.itemR(tex, "noise_type", text="Type", expand=True)
94                 layout.itemR(tex, "noise_basis", text="Basis")
95                 
96                 col = layout.column_flow()      
97                 col.itemR(tex, "noise_size", text="Size")
98                 col.itemR(tex, "noise_depth", text="Depth")
99                 col.itemR(tex, "turbulence")
100                 col.itemR(tex, "nabla")
101
102 class TEXTURE_PT_magic(TextureButtonsPanel):
103         __idname__= "TEXTURE_PT_magic"
104         __label__ = "Magic"
105         
106         def poll(self, context):
107                 try:    return (context.active_object.active_material.active_texture.texture.type == 'MAGIC')
108                 except:return False
109
110         def draw(self, context):
111                 layout = self.layout
112                 tex = context.active_object.active_material.active_texture.texture
113                         
114                 row = layout.row()
115                 row.itemR(tex, "noise_depth", text="Depth")
116                 row.itemR(tex, "turbulence")
117
118 class TEXTURE_PT_blend(TextureButtonsPanel):
119         __idname__= "TEXTURE_PT_blend"
120         __label__ = "Blend"
121         
122         def poll(self, context):
123                 try:    return (context.active_object.active_material.active_texture.texture.type == 'BLEND')
124                 except:return False
125
126         def draw(self, context):
127                 layout = self.layout
128                 tex = context.active_object.active_material.active_texture.texture
129
130                 layout.itemR(tex, "progression")
131                 layout.itemR(tex, "flip_axis")
132                         
133 class TEXTURE_PT_stucci(TextureButtonsPanel):
134         __idname__= "TEXTURE_PT_stucci"
135         __label__ = "Stucci"
136         
137         def poll(self, context):
138                 try:    return (context.active_object.active_material.active_texture.texture.type == 'STUCCI')
139                 except:return False
140
141         def draw(self, context):
142                 layout = self.layout
143                 tex = context.active_object.active_material.active_texture.texture
144                 
145                 layout.itemR(tex, "stype", expand=True)
146                 layout.itemL(text="Noise:")
147                 layout.itemR(tex, "noise_type", text="Type", expand=True)
148                 layout.itemR(tex, "noise_basis", text="Basis")
149                 
150                 row = layout.row()
151                 row.itemR(tex, "noise_size", text="Size")
152                 row.itemR(tex, "turbulence")
153                 
154 class TEXTURE_PT_image(TextureButtonsPanel):
155         __idname__= "TEXTURE_PT_image"
156         __label__ = "Image/Movie"
157         
158         def poll(self, context):
159                 try:    return (context.active_object.active_material.active_texture.texture.type == 'IMAGE')
160                 except:return False
161
162         def draw(self, context):
163                 layout = self.layout
164                 tex = context.active_object.active_material.active_texture.texture
165                 
166                 split = layout.split()
167                 
168                 sub = split.column()            
169                 sub.itemR(tex, "flip_axis")
170                 sub.itemR(tex, "normal_map")
171                 sub.itemL(text="Filter:")
172                 sub.itemR(tex, "mipmap")
173                 sub.itemR(tex, "mipmap_gauss")
174                 sub.itemR(tex, "interpolation")
175                 sub = split.column() 
176                 sub.itemL(text="Alpha:")
177                 sub.itemR(tex, "use_alpha")
178                 sub.itemR(tex, "calculate_alpha")
179                 sub.itemR(tex, "invert_alpha")
180
181 class TEXTURE_PT_mapping(TextureButtonsPanel):
182         __idname__= "TEXTURE_PT_mapping"
183         __label__ = "Mapping"
184         
185         def poll(self, context):
186                 try:    return (context.active_object.active_material.active_texture.texture.type == 'IMAGE')
187                 except:return False
188
189         def draw(self, context):
190                 layout = self.layout
191                 tex = context.active_object.active_material.active_texture.texture
192                                 
193                 split = layout.split()
194                 
195                 sub = split.column()
196                 #sub.itemR(tex, "crop_rectangle")
197                 sub.itemL(text="Crop Minimum:")
198                 sub.itemR(tex, "crop_min_x", text="X")
199                 sub.itemR(tex, "crop_min_y", text="Y")
200                 sub = split.column()
201                 sub.itemL(text="Crop Maximum:")
202                 sub.itemR(tex, "crop_max_x", text="X")
203                 sub.itemR(tex, "crop_max_y", text="Y")
204                 
205                 layout.itemR(tex, "extension")
206                 
207                 split = layout.split()
208                 
209                 sub = split.column()
210                 if tex.extension == 'REPEAT': 
211                         sub.itemL(text="Repeat:")
212                         sub.itemR(tex, "repeat_x", text="X")
213                         sub.itemR(tex, "repeat_y", text="Y")
214                         sub = split.column()
215                         sub.itemL(text="Mirror:")
216                         sub.itemR(tex, "mirror_x", text="X")
217                         sub.itemR(tex, "mirror_y", text="Y")
218                 elif tex.extension == 'CHECKER': 
219                         sub.itemR(tex, "checker_even", text="Even")
220                         sub.itemR(tex, "checker_odd", text="Odd")
221                         sub = split.column()
222                         sub.itemR(tex, "checker_distance", text="Distance")
223         
224 class TEXTURE_PT_plugin(TextureButtonsPanel):
225         __idname__= "TEXTURE_PT_plugin"
226         __label__ = "Plugin"
227         
228         def poll(self, context):
229                 try:    return (context.active_object.active_material.active_texture.texture.type == 'PLUGIN')
230                 except:return False
231
232         def draw(self, context):
233                 layout = self.layout
234                 tex = context.active_object.active_material.active_texture.texture
235                 
236                 layout.itemL(text="Nothing yet")
237                 
238 class TEXTURE_PT_envmap(TextureButtonsPanel):
239         __idname__= "TEXTURE_PT_envmap"
240         __label__ = "Environment Map"
241         
242         def poll(self, context):
243                 try:    return (context.active_object.active_material.active_texture.texture.type == 'ENVIRONMENT_MAP')
244                 except:return False
245
246         def draw(self, context):
247                 layout = self.layout
248                 tex = context.active_object.active_material.active_texture.texture
249                 
250                 layout.itemL(text="Nothing yet")
251                 
252 class TEXTURE_PT_musgrave(TextureButtonsPanel):
253         __idname__= "TEXTURE_PT_musgrave"
254         __label__ = "Musgrave"
255         
256         def poll(self, context):
257                 try:    return (context.active_object.active_material.active_texture.texture.type == 'MUSGRAVE')
258                 except:return False
259
260         def draw(self, context):
261                 layout = self.layout
262                 tex = context.active_object.active_material.active_texture.texture
263                 
264                 layout.itemR(tex, "musgrave_type")      
265                 
266                 split = layout.split()
267                 
268                 sub = split.column()
269                 sub.itemR(tex, "highest_dimension", text="Dimension")
270                 sub.itemR(tex, "lacunarity")
271                 sub.itemR(tex, "octaves")
272                 sub = split.column() 
273                 if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
274                         sub.itemR(tex, "offset")
275                 if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
276                         sub.itemR(tex, "gain")
277                         sub.itemR(tex, "noise_intensity", text="Intensity")
278                 
279                 layout.itemL(text="Noise:")
280                 
281                 layout.itemR(tex, "noise_basis", text="Basis")
282                 
283                 row = layout.row()
284                 row.itemR(tex, "noise_size", text="Size")
285                 row.itemR(tex, "nabla")
286
287 class TEXTURE_PT_voronoi(TextureButtonsPanel):
288         __idname__= "TEXTURE_PT_voronoi"
289         __label__ = "Voronoi"
290         
291         def poll(self, context):
292                 try:    return (context.active_object.active_material.active_texture.texture.type == 'VORONOI')
293                 except:return False
294
295
296         def draw(self, context):
297                 layout = self.layout
298                 tex = context.active_object.active_material.active_texture.texture
299         
300                 layout.itemR(tex, "distance_metric")
301                 layout.itemR(tex, "coloring")
302                 
303                 split = layout.split()
304                 
305                 sub = split.column()   
306                 
307                 sub.itemR(tex, "noise_intensity", text="Intensity")
308                 if tex.distance_metric == 'MINKOVSKY':
309                         sub.itemR(tex, "minkovsky_exponent", text="Exponent")
310                 sub = split.column()
311                 sub.itemR(tex, "feature_weights", slider=True)
312                 
313                 layout.itemL(text="Noise:")
314                 
315                 row = layout.row()
316                 row.itemR(tex, "noise_size", text="Size")
317                 row.itemR(tex, "nabla")
318                         
319 class TEXTURE_PT_distortednoise(TextureButtonsPanel):
320         __idname__= "TEXTURE_PT_distortednoise"
321         __label__ = "Distorted Noise"
322         
323         def poll(self, context):
324                 try:    return (context.active_object.active_material.active_texture.texture.type == 'DISTORTED_NOISE')
325                 except:return False
326
327         def draw(self, context):
328                 layout = self.layout
329                 tex = context.active_object.active_material.active_texture.texture
330
331                 layout.itemR(tex, "noise_distortion")
332                 layout.itemR(tex, "noise_basis", text="Basis")
333                 
334                 split = layout.split()
335                 
336                 sub = split.column()
337                 sub.itemR(tex, "distortion_amount", text="Amount")
338                 sub.itemR(tex, "noise_size", text="Size")
339                 
340                 sub = split.column()
341                 sub.itemR(tex, "nabla") 
342
343 bpy.types.register(TEXTURE_PT_preview)
344 bpy.types.register(TEXTURE_PT_texture)
345 bpy.types.register(TEXTURE_PT_clouds)
346 bpy.types.register(TEXTURE_PT_wood)
347 bpy.types.register(TEXTURE_PT_marble)
348 bpy.types.register(TEXTURE_PT_magic)
349 bpy.types.register(TEXTURE_PT_blend)
350 bpy.types.register(TEXTURE_PT_stucci)
351 bpy.types.register(TEXTURE_PT_image)
352 bpy.types.register(TEXTURE_PT_mapping)
353 bpy.types.register(TEXTURE_PT_plugin)
354 bpy.types.register(TEXTURE_PT_envmap)
355 bpy.types.register(TEXTURE_PT_musgrave)
356 bpy.types.register(TEXTURE_PT_voronoi)
357 bpy.types.register(TEXTURE_PT_distortednoise)
358