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