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