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