svn merge -r 20822:21041 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.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_lamp(DataButtonsPanel):
23         __idname__ = "DATA_PT_lamp"
24         __label__ = "Lamp"
25         
26         def poll(self, context):
27                 return ((context.object and context.object.type == 'LAMP') or context.lamp)
28
29         def draw(self, context):
30                 layout = self.layout
31                 
32                 ob = context.object
33                 lamp = context.lamp
34                 space = context.space_data
35
36                 split = layout.split(percentage=0.65)
37
38                 if ob:
39                         split.template_ID(context, ob, "data")
40                         split.itemS()
41                 elif lamp:
42                         split.template_ID(context, space, "pin_id")
43                         split.itemS()
44
45                 layout.itemS()
46
47                 layout.itemR(lamp, "type", expand=True)
48                 
49                 split = layout.split()
50                 
51                 sub = split.column()
52                 sub.itemR(lamp, "color")
53                 sub.itemR(lamp, "energy")
54                 sub.itemR(lamp, "distance")
55                 sub.itemR(lamp, "negative")
56         
57                 sub = split.column()
58                 sub.itemR(lamp, "layer", text="This Layer Only")
59                 sub.itemR(lamp, "specular")
60                 sub.itemR(lamp, "diffuse")
61                 
62                 if lamp.type in ('POINT', 'SPOT'):
63                         sub.itemR(lamp, "falloff_type")
64                         sub.itemR(lamp, "sphere")
65                         
66                         if (lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED'):
67                                 sub.itemR(lamp, "linear_attenuation")
68                                 sub.itemR(lamp, "quadratic_attenuation")
69                         
70                 if lamp.type == 'AREA':
71                         sub.column()
72                         sub.itemR(lamp, "gamma")
73                         sub.itemR(lamp, "shape")
74                         if (lamp.shape == 'SQUARE'):
75                                 sub.itemR(lamp, "size")
76                         if (lamp.shape == 'RECTANGLE'):
77                                 sub.itemR(lamp, "size", text="Size X")
78                                 sub.itemR(lamp, "size_y")
79                                 
80 class DATA_PT_sunsky(DataButtonsPanel):
81         __idname__ = "DATA_PT_sunsky"
82         __label__ = "Sun/Sky"
83         
84         def poll(self, context):
85                 lamp = context.lamp
86                 return (lamp and lamp.type == 'SUN')
87
88         def draw(self, context):
89                 layout = self.layout
90                 lamp = context.lamp.sky
91
92                 row = layout.row()
93                 row.itemR(lamp, "sky")
94                 row.itemR(lamp, "atmosphere")
95                 
96                 row = layout.row()
97                 row.active = lamp.sky or lamp.atmosphere
98                 row.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
99                         
100                 split = layout.split()
101
102                 col = split.column()
103                 sub = col.column()
104                 sub.active = lamp.sky
105                 sub.itemR(lamp, "sky_blend_type", text="Blend Type")
106                 sub.itemR(lamp, "sky_blend")
107                 sub.itemR(lamp, "sky_color_space", text="Color Space")
108                 sub.itemR(lamp, "sky_exposure")
109                 sub.itemR(lamp, "horizon_brightness", text="Hor Bright")
110                 sub.itemR(lamp, "spread", text="Hor Spread")
111                 sub.itemR(lamp, "sun_brightness", text="Sun Bright")
112                 sub.itemR(lamp, "sun_size")
113                 sub.itemR(lamp, "backscattered_light", text="Back Light")
114                                 
115                 sub = split.column()
116                 sub.active = lamp.atmosphere
117                 sub.itemR(lamp, "sun_intensity", text="Sun Intens")
118                 sub.itemR(lamp, "atmosphere_inscattering", text="Inscattering")
119                 sub.itemR(lamp, "atmosphere_extinction", text="Extinction")
120                 sub.itemR(lamp, "atmosphere_distance_factor", text="Distance")
121                                 
122 class DATA_PT_shadow(DataButtonsPanel):
123         __idname__ = "DATA_PT_shadow"
124         __label__ = "Shadow"
125         
126         def poll(self, context):
127                 lamp = context.lamp
128                 return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
129
130         def draw(self, context):
131                 layout = self.layout
132                 lamp = context.lamp
133
134                 layout.itemR(lamp, "shadow_method", expand=True)
135                 
136                 if lamp.shadow_method in ('BUFFER_SHADOW', 'RAY_SHADOW'):
137                 
138                         split = layout.split()
139                         
140                         sub = split.column()
141                         sub.itemR(lamp, "shadow_color")
142                         
143                         sub = split.column()
144                         sub.itemR(lamp, "shadow_layer", text="This Layer Only")
145                         sub.itemR(lamp, "only_shadow")
146                 
147                 if lamp.shadow_method == 'RAY_SHADOW':
148                 
149                         col = layout.column()
150                         col.itemL(text="Sampling:")
151                         col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
152                                 
153                         if lamp.type in ('POINT', 'SUN', 'SPOT'):
154                                 flow = layout.column_flow()
155                                 flow.itemR(lamp, "shadow_soft_size", text="Soft Size")
156                                 flow.itemR(lamp, "shadow_ray_samples", text="Samples")
157                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
158                                         flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
159                                                 
160                         if lamp.type == 'AREA':
161                                 flow = layout.column_flow()
162                                 flow.itemR(lamp, "shadow_ray_samples_x", text="Samples")
163                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
164                                         flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
165                                 if lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
166                                         flow.itemR(lamp, "umbra")
167                                         flow.itemR(lamp, "dither")
168                                         flow.itemR(lamp, "jitter")      
169         
170                 if lamp.shadow_method == 'BUFFER_SHADOW':
171                         col = layout.column()
172                         col.itemL(text="Buffer Type:")
173                         col.row().itemR(lamp, "shadow_buffer_type", expand=True)
174
175                         if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY'):
176                                 flow = layout.column_flow()
177                                 flow.itemL(text="Sample Buffers:")
178                                 flow.itemR(lamp, "shadow_sample_buffers", text="")
179                                 flow.itemL(text="Filter Type:")
180                                 flow.itemR(lamp, "shadow_filter_type", text="")
181                                 
182                                 flow = layout.column_flow()
183                                 flow.itemR(lamp, "shadow_buffer_size", text="Size")
184                                 flow.itemR(lamp, "shadow_buffer_samples", text="Samples")
185                                 flow.itemR(lamp, "shadow_buffer_bias", text="Bias")
186                                 flow.itemR(lamp, "shadow_buffer_soft", text="Soft")
187                                 
188                         if (lamp.shadow_buffer_type == 'IRREGULAR'):
189                                 row = layout.row()
190                                 row.itemR(lamp, "shadow_buffer_bias", text="Bias")
191                         
192                         row = layout.row()
193                         row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
194                         if not (lamp.auto_clip_start):
195                                 row.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
196                         row = layout.row()
197                         row.itemR(lamp, "auto_clip_end", text="Autoclip End")
198                         if not (lamp.auto_clip_end):
199                                 row.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
200
201 class DATA_PT_spot(DataButtonsPanel):
202         __idname__ = "DATA_PT_spot"
203         __label__ = "Spot"
204         
205         def poll(self, context):
206                 lamp = context.lamp
207                 return (lamp and lamp.type == 'SPOT')
208
209         def draw(self, context):
210                 layout = self.layout
211                 lamp = context.lamp
212
213                 split = layout.split()
214                 
215                 sub = split.column()
216                 sub.itemR(lamp, "spot_size", text="Size")
217                 sub.itemR(lamp, "spot_blend", text="Blend")
218                 sub.itemR(lamp, "square")
219                 
220                 col = split.column()
221                 col.itemR(lamp, "halo")
222                 colsub = col.column()
223                 colsub.active = lamp.halo
224                 colsub.itemR(lamp, "halo_intensity", text="Intensity")
225                 if lamp.shadow_method == 'BUFFER_SHADOW':
226                         colsub.itemR(lamp, "halo_step", text="Step")
227
228 class DATA_PT_falloff_curve(DataButtonsPanel):
229         __idname__ = "DATA_PT_falloff_curve"
230         __label__ = "Falloff Curve"
231         
232         def poll(self, context):
233                 lamp = context.lamp
234
235                 if lamp and lamp.type in ('POINT', 'SPOT'):
236                         if lamp.falloff_type == 'CUSTOM_CURVE':
237                                 return True
238
239                 return False
240
241         def draw(self, context):
242                 layout = self.layout
243                 lamp = context.lamp
244
245                 layout.template_curve_mapping(lamp.falloff_curve)
246
247 bpy.types.register(DATA_PT_preview)
248 bpy.types.register(DATA_PT_lamp)
249 bpy.types.register(DATA_PT_shadow)
250 bpy.types.register(DATA_PT_sunsky)
251 bpy.types.register(DATA_PT_spot)
252 bpy.types.register(DATA_PT_falloff_curve)