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