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