rna renaming (manual edits)
[blender.git] / release / scripts / ui / properties_world.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23 # TODO, "color_range" not in the UI
24
25
26 class WorldButtonsPanel():
27     bl_space_type = 'PROPERTIES'
28     bl_region_type = 'WINDOW'
29     bl_context = "world"
30     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
31
32     @classmethod
33     def poll(cls, context):
34         return (context.world and context.scene.render.engine in cls.COMPAT_ENGINES)
35
36
37 class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel):
38     bl_label = ""
39     bl_show_header = False
40     COMPAT_ENGINES = {'BLENDER_RENDER'}
41
42     @classmethod
43     def poll(cls, context):
44         rd = context.scene.render
45         return (not rd.use_game_engine) and (rd.engine in cls.COMPAT_ENGINES)
46
47     def draw(self, context):
48         layout = self.layout
49
50         scene = context.scene
51         world = context.world
52         space = context.space_data
53
54         split = layout.split(percentage=0.65)
55         if scene:
56             split.template_ID(scene, "world", new="world.new")
57         elif world:
58             split.template_ID(space, "pin_id")
59
60
61 class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel):
62     bl_label = "Preview"
63     COMPAT_ENGINES = {'BLENDER_RENDER'}
64
65     @classmethod
66     def poll(cls, context):
67         rd = context.scene.render
68         return (context.world) and (not rd.use_game_engine) and (rd.engine in cls.COMPAT_ENGINES)
69
70     def draw(self, context):
71         self.layout.template_preview(context.world)
72
73
74 class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel):
75     bl_label = "World"
76     COMPAT_ENGINES = {'BLENDER_RENDER'}
77
78     def draw(self, context):
79         layout = self.layout
80         world = context.world
81
82         row = layout.row()
83         row.prop(world, "use_sky_paper")
84         row.prop(world, "use_sky_blend")
85         row.prop(world, "use_sky_real")
86
87         row = layout.row()
88         row.column().prop(world, "horizon_color")
89         col = row.column()
90         col.prop(world, "zenith_color")
91         col.active = world.use_sky_blend
92         row.column().prop(world, "ambient_color")
93
94
95 class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel):
96     bl_label = "Ambient Occlusion"
97     COMPAT_ENGINES = {'BLENDER_RENDER'}
98
99     def draw_header(self, context):
100         light = context.world.light_settings
101         self.layout.prop(light, "use_ambient_occlusion", text="")
102
103     def draw(self, context):
104         layout = self.layout
105         light = context.world.light_settings
106
107         layout.active = light.use_ambient_occlusion
108
109         split = layout.split()
110         split.prop(light, "ao_factor", text="Factor")
111         split.prop(light, "ao_blend_type", text="")
112
113
114 class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel):
115     bl_label = "Environment Lighting"
116     COMPAT_ENGINES = {'BLENDER_RENDER'}
117
118     def draw_header(self, context):
119         light = context.world.light_settings
120         self.layout.prop(light, "use_environment_light", text="")
121
122     def draw(self, context):
123         layout = self.layout
124         light = context.world.light_settings
125
126         layout.active = light.use_environment_light
127
128         split = layout.split()
129         split.prop(light, "environment_energy", text="Energy")
130         split.prop(light, "environment_color", text="")
131
132
133 class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel):
134     bl_label = "Indirect Lighting"
135     COMPAT_ENGINES = {'BLENDER_RENDER'}
136
137     @classmethod
138     def poll(cls, context):
139         light = getattr(context.world, "light_settings", None)
140         return light and light.gather_method == 'APPROXIMATE'
141
142     def draw_header(self, context):
143         light = context.world.light_settings
144         self.layout.prop(light, "use_indirect_light", text="")
145
146     def draw(self, context):
147         layout = self.layout
148         light = context.world.light_settings
149
150         layout.active = light.use_indirect_light
151
152         split = layout.split()
153         split.prop(light, "indirect_factor", text="Factor")
154         split.prop(light, "indirect_bounces", text="Bounces")
155
156
157 class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel):
158     bl_label = "Gather"
159     COMPAT_ENGINES = {'BLENDER_RENDER'}
160
161     def draw(self, context):
162         layout = self.layout
163         light = context.world.light_settings
164
165         layout.active = light.use_ambient_occlusion or light.use_environment_light or light.use_indirect_light
166
167         layout.prop(light, "gather_method", expand=True)
168
169         split = layout.split()
170
171         col = split.column()
172         col.label(text="Attenuation:")
173         if light.gather_method == 'RAYTRACE':
174             col.prop(light, "distance")
175         col.prop(light, "use_falloff")
176         sub = col.row()
177         sub.active = light.use_falloff
178         sub.prop(light, "falloff_strength", text="Strength")
179
180         if light.gather_method == 'RAYTRACE':
181             col = split.column()
182
183             col.label(text="Sampling:")
184             col.prop(light, "sample_method", text="")
185
186             sub = col.column()
187             sub.prop(light, "samples")
188
189             if light.sample_method == 'ADAPTIVE_QMC':
190                 sub.prop(light, "threshold")
191                 sub.prop(light, "adapt_to_speed", slider=True)
192             elif light.sample_method == 'CONSTANT_JITTERED':
193                 sub.prop(light, "bias")
194
195         if light.gather_method == 'APPROXIMATE':
196             col = split.column()
197
198             col.label(text="Sampling:")
199             col.prop(light, "passes")
200             col.prop(light, "error_threshold", text="Error")
201             col.prop(light, "use_cache")
202             col.prop(light, "correction")
203
204
205 class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel):
206     bl_label = "Mist"
207     bl_default_closed = True
208     COMPAT_ENGINES = {'BLENDER_RENDER'}
209
210     def draw_header(self, context):
211         world = context.world
212
213         self.layout.prop(world.mist_settings, "use_mist", text="")
214
215     def draw(self, context):
216         layout = self.layout
217         world = context.world
218
219         layout.active = world.mist_settings.use_mist
220
221         split = layout.split()
222
223         col = split.column()
224         col.prop(world.mist_settings, "intensity", slider=True)
225         col.prop(world.mist_settings, "start")
226
227         col = split.column()
228         col.prop(world.mist_settings, "depth")
229         col.prop(world.mist_settings, "height")
230
231         layout.prop(world.mist_settings, "falloff")
232
233
234 class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel):
235     bl_label = "Stars"
236     bl_default_closed = True
237     COMPAT_ENGINES = {'BLENDER_RENDER'}
238
239     def draw_header(self, context):
240         world = context.world
241
242         self.layout.prop(world.star_settings, "use_stars", text="")
243
244     def draw(self, context):
245         layout = self.layout
246         world = context.world
247
248         layout.active = world.star_settings.use_stars
249
250         split = layout.split()
251
252         col = split.column()
253         col.prop(world.star_settings, "size")
254         col.prop(world.star_settings, "color_random", text="Colors")
255
256         col = split.column()
257         col.prop(world.star_settings, "distance_min", text="Min. Dist")
258         col.prop(world.star_settings, "average_separation", text="Separation")
259
260
261 class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, bpy.types.Panel):
262     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
263     _context_path = "world"
264
265
266 def register():
267     pass
268
269
270 def unregister():
271     pass
272
273 if __name__ == "__main__":
274     register()