bf9bf24221bb9ff09c63b76d3b2993b1c6ae6dc6
[blender-staging.git] / release / ui / buttons_data_lamp.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return (context.lamp != None)
11                 
12 class DATA_PT_preview(DataButtonsPanel):
13         __idname__= "DATA_PT_preview"
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18
19                 lamp = context.lamp
20                 layout.template_preview(lamp)
21         
22 class DATA_PT_context_lamp(DataButtonsPanel):
23         __show_header__ = False
24         
25         def draw(self, context):
26                 layout = self.layout
27                 
28                 ob = context.object
29                 lamp = context.lamp
30                 space = context.space_data
31
32                 split = layout.split(percentage=0.65)
33
34                 if ob:
35                         split.template_ID(ob, "data")
36                         split.itemS()
37                 elif lamp:
38                         split.template_ID(space, "pin_id")
39                         split.itemS()
40
41 class DATA_PT_lamp(DataButtonsPanel):
42         __label__ = "Lamp"
43
44         def draw(self, context):
45                 layout = self.layout
46                 
47                 lamp = context.lamp
48                 
49                 layout.itemR(lamp, "type", expand=True)
50                 
51                 split = layout.split()
52                 col = split.column()
53                 #col.itemL(text="Type:")
54                 #col.itemR(lamp, "type", text="")
55                 colsub = col.column()
56                 colsub.itemR(lamp, "color", text="")
57                 colsub.itemR(lamp, "energy")
58                 
59                 col.itemR(lamp, "negative")
60                 #col.itemR(lamp, "distance")
61         
62                 sub = split.column()
63                 #sub.itemL(text="Influence:")
64                 sub.itemR(lamp, "layer", text="This Layer Only")
65                 sub.itemR(lamp, "specular")
66                 sub.itemR(lamp, "diffuse")
67                 #sub.itemR(lamp, "negative")
68                 
69                 if lamp.type in ('POINT', 'SPOT'):
70                         split = layout.split()
71                         col = split.column()
72                         col.itemL(text="Falloff:")
73                         col = col.column(align=True)
74                         col.itemR(lamp, "falloff_type", text="")
75                         col.itemR(lamp, "distance")
76                         col.itemR(lamp, "sphere")
77                         
78                         if lamp.falloff_type != 'LINEAR_QUADRATIC_WEIGHTED':
79                                 col = split.column()
80                         
81                         else:
82                                 sub = split.column()
83                                 sub.itemL(text="Attenuation Distance:")
84                                 sub = sub.column(align=True)
85                                 sub.itemR(lamp, "linear_attenuation", slider=True, text="Linear")
86                                 sub.itemR(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
87                         
88                 if lamp.type == 'AREA':
89                         split = layout.split()
90                         col = split.column()
91                         col.itemL(text="Shape:")
92                         col = col.column(align=True)
93                         col.itemR(lamp, "shape", text="")
94                         if (lamp.shape == 'SQUARE'):
95                                 col.itemR(lamp, "size")
96                         if (lamp.shape == 'RECTANGLE'):
97                                 col.itemR(lamp, "size", text="Size X")
98                                 col.itemR(lamp, "size_y", text="Size Y")
99                         
100                         sub = split.column()
101                         sub.itemL(text="Gamma:")
102                         sub.itemR(lamp, "gamma", text="Value")
103                                 
104 class DATA_PT_sunsky(DataButtonsPanel):
105         __label__ = "Sun/Sky"
106         
107         def poll(self, context):
108                 lamp = context.lamp
109                 return (lamp and lamp.type == 'SUN')
110
111         def draw(self, context):
112                 layout = self.layout
113                 lamp = context.lamp.sky
114
115                 row = layout.row()
116                 row.itemR(lamp, "sky")
117                 row.itemR(lamp, "atmosphere")
118                 
119                 row = layout.row()
120                 row.active = lamp.sky or lamp.atmosphere
121                 row.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
122                         
123                 split = layout.split()
124                 
125                 col = split.column()
126                 col.active = lamp.sky
127                 col.itemL(text="Blend Mode:")
128                 colsub = col.column(align=True)
129                 colsub.itemR(lamp, "sky_blend_type", text="")
130                 colsub.itemR(lamp, "sky_blend", text="Factor")
131                 
132                 col.itemL(text="Color Space:")
133                 colsub = col.column(align=True)
134                 colsub.itemR(lamp, "sky_color_space", text="")
135                 colsub.itemR(lamp, "sky_exposure", text="Exposure")
136                         
137                 col = split.column()
138                 col.active = lamp.sky
139                 col.itemL(text="Horizon:")
140                 colsub = col.column(align=True)
141                 colsub.itemR(lamp, "horizon_brightness", text="Brightness")
142                 colsub.itemR(lamp, "spread", text="Spread")
143                 
144                 col.itemL(text="Sun:")
145                 colsub = col.column(align=True)
146                 colsub.itemR(lamp, "sun_brightness", text="Brightness")
147                 colsub.itemR(lamp, "sun_size", text="Size")
148                 colsub.itemR(lamp, "backscattered_light", slider=True,text="Back Light")
149                 
150                 row = layout.row()
151                 row.itemS()
152                 
153                 split = layout.split()
154                 
155                 col = split.column()
156                 col.active = lamp.atmosphere
157                 col.itemL(text="Sun:")
158                 col.itemR(lamp, "sun_intensity", text="Intensity")
159                 col.itemL(text="Scale Distance:")
160                 col.itemR(lamp, "atmosphere_distance_factor", text="Distance")
161                         
162                 col = split.column()
163                 col.active = lamp.atmosphere
164                 col.itemL(text="Scattering:")
165                 sub = col.column(align=True)
166                 sub.itemR(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
167                 sub.itemR(lamp, "atmosphere_extinction", slider=True ,text="Extinction")
168                 
169 class DATA_PT_shadow(DataButtonsPanel):
170         __label__ = "Shadow"
171         
172         def poll(self, context):
173                 lamp = context.lamp
174                 return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
175
176         def draw(self, context):
177                 layout = self.layout
178                 lamp = context.lamp
179
180                 layout.itemR(lamp, "shadow_method", expand=True)
181                 
182                 if lamp.shadow_method != 'NOSHADOW':
183                 
184                         split = layout.split()
185                         
186                         col = split.column()
187                         col.itemR(lamp, "shadow_color", text="")
188                         
189                         sub = split.column()
190                         sub.itemR(lamp, "shadow_layer", text="This Layer Only")
191                         sub.itemR(lamp, "only_shadow")
192                 
193                 if lamp.shadow_method == 'RAY_SHADOW':
194                 
195                         col = layout.column()
196                         col.itemL(text="Sampling:")
197                         col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
198                                 
199                         if lamp.type in ('POINT', 'SUN', 'SPOT'):
200                                 split = layout.split()
201                                 col = split.column(align=True)
202                                 col.itemR(lamp, "shadow_soft_size", text="Soft Size")
203                                 col = split.column(align=True)
204                                 col.itemR(lamp, "shadow_ray_samples", text="Samples")
205                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
206                                         col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
207                                                 
208                         if lamp.type == 'AREA':
209                                 split = layout.split()
210                                 col = split.column()
211
212                                 if lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
213                                         col.itemR(lamp, "umbra")
214                                         col.itemR(lamp, "dither")
215                                         col.itemR(lamp, "jitter")       
216                                 else:
217                                         col.itemL()
218
219                                 col = split.column(align=True)
220                                 col.itemR(lamp, "shadow_ray_samples_x", text="Samples")
221                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
222                                         col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
223         
224                 if lamp.shadow_method == 'BUFFER_SHADOW':
225                         col = layout.column()
226                         col.itemL(text="Buffer Type:")
227                         col.row().itemR(lamp, "shadow_buffer_type", expand=True)
228
229                         if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY'):
230                                 
231                                 split = layout.split()
232                                 col = split.column()
233                                 col.itemL(text="Filter Type:")
234                                 col.itemR(lamp, "shadow_filter_type", text="")
235                                 
236                                 colsub = col.column(align=True)
237                                 colsub.itemR(lamp, "shadow_buffer_soft", text="Soft")
238                                 colsub.itemR(lamp, "shadow_buffer_bias", text="Bias")
239                                 
240                                 col = split.column()
241                                 col.itemL(text="Sample Buffers:")
242                                 col.itemR(lamp, "shadow_sample_buffers", text="")
243                                 
244                                 colsub = col.column(align=True)
245                                 colsub.itemR(lamp, "shadow_buffer_size", text="Size")
246                                 colsub.itemR(lamp, "shadow_buffer_samples", text="Samples")
247                                 
248                         if (lamp.shadow_buffer_type == 'IRREGULAR'):
249                                 row = layout.row()
250                                 row.itemR(lamp, "shadow_buffer_bias", text="Bias")
251                         
252                         row = layout.row()
253                         row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
254                         if not (lamp.auto_clip_start):
255                                 row.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
256                         row = layout.row()
257                         row.itemR(lamp, "auto_clip_end", text="Autoclip End")
258                         if not (lamp.auto_clip_end):
259                                 row.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
260
261 class DATA_PT_spot(DataButtonsPanel):
262         __label__ = "Spot"
263         
264         def poll(self, context):
265                 lamp = context.lamp
266                 return (lamp and lamp.type == 'SPOT')
267
268         def draw(self, context):
269                 layout = self.layout
270                 lamp = context.lamp
271
272                 split = layout.split()
273                 col = split.column()
274                 sub = col.column(align=True)
275                 sub.itemR(lamp, "spot_size", text="Size")
276                 sub.itemR(lamp, "spot_blend", text="Blend")
277                 col.itemR(lamp, "square")
278                 
279                 col = split.column()
280                 col.itemR(lamp, "halo")
281                 colsub = col.column(align=True)
282                 colsub.active = lamp.halo
283                 colsub.itemR(lamp, "halo_intensity", text="Intensity")
284                 if lamp.shadow_method == 'BUFFER_SHADOW':
285                         colsub.itemR(lamp, "halo_step", text="Step")
286
287 class DATA_PT_falloff_curve(DataButtonsPanel):
288         __label__ = "Falloff Curve"
289         __default_closed__ = True
290         
291         def poll(self, context):
292                 lamp = context.lamp
293
294                 if lamp and lamp.type in ('POINT', 'SPOT'):
295                         if lamp.falloff_type == 'CUSTOM_CURVE':
296                                 return True
297
298                 return False
299
300         def draw(self, context):
301                 layout = self.layout
302                 lamp = context.lamp
303
304                 layout.template_curve_mapping(lamp.falloff_curve)
305
306 bpy.types.register(DATA_PT_context_lamp)
307 bpy.types.register(DATA_PT_preview)
308 bpy.types.register(DATA_PT_lamp)
309 bpy.types.register(DATA_PT_falloff_curve)
310 bpy.types.register(DATA_PT_spot)
311 bpy.types.register(DATA_PT_shadow)
312 bpy.types.register(DATA_PT_sunsky)
313