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