Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24152...
[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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class WorldButtonsPanel(bpy.types.Panel):
24     bl_space_type = 'PROPERTIES'
25     bl_region_type = 'WINDOW'
26     bl_context = "world"
27     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
28
29     def poll(self, context):
30         rd = context.scene.render_data
31         return (context.world) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
32
33
34 class WORLD_PT_preview(WorldButtonsPanel):
35     bl_label = "Preview"
36     COMPAT_ENGINES = set(['BLENDER_RENDER'])
37
38     def draw(self, context):
39         self.layout.template_preview(context.world)
40
41
42 class WORLD_PT_context_world(WorldButtonsPanel):
43     bl_label = ""
44     bl_show_header = False
45     COMPAT_ENGINES = set(['BLENDER_RENDER'])
46
47     def poll(self, context):
48         rd = context.scene.render_data
49         return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
50
51     def draw(self, context):
52         layout = self.layout
53
54         scene = context.scene
55         world = context.world
56         space = context.space_data
57
58         split = layout.split(percentage=0.65)
59
60         if scene:
61             split.template_ID(scene, "world", new="world.new")
62         elif world:
63             split.template_ID(space, "pin_id")
64
65
66 class WORLD_PT_world(WorldButtonsPanel):
67     bl_label = "World"
68     COMPAT_ENGINES = set(['BLENDER_RENDER'])
69
70     def draw(self, context):
71         layout = self.layout
72
73         world = context.world
74
75         row = layout.row()
76         row.itemR(world, "paper_sky")
77         row.itemR(world, "blend_sky")
78         row.itemR(world, "real_sky")
79
80         row = layout.row()
81         row.column().itemR(world, "horizon_color")
82         col = row.column()
83         col.itemR(world, "zenith_color")
84         col.active = world.blend_sky
85         row.column().itemR(world, "ambient_color")
86
87
88 class WORLD_PT_mist(WorldButtonsPanel):
89     bl_label = "Mist"
90     COMPAT_ENGINES = set(['BLENDER_RENDER'])
91
92     def draw_header(self, context):
93         world = context.world
94
95         self.layout.itemR(world.mist, "enabled", text="")
96
97     def draw(self, context):
98         layout = self.layout
99
100         world = context.world
101
102         layout.active = world.mist.enabled
103
104         flow = layout.column_flow()
105         flow.itemR(world.mist, "intensity", slider=True)
106         flow.itemR(world.mist, "start")
107         flow.itemR(world.mist, "depth")
108         flow.itemR(world.mist, "height")
109
110         layout.itemR(world.mist, "falloff")
111
112
113 class WORLD_PT_stars(WorldButtonsPanel):
114     bl_label = "Stars"
115     COMPAT_ENGINES = set(['BLENDER_RENDER'])
116
117     def draw_header(self, context):
118         world = context.world
119
120         self.layout.itemR(world.stars, "enabled", text="")
121
122     def draw(self, context):
123         layout = self.layout
124
125         world = context.world
126
127         layout.active = world.stars.enabled
128
129         flow = layout.column_flow()
130         flow.itemR(world.stars, "size")
131         flow.itemR(world.stars, "color_randomization", text="Colors")
132         flow.itemR(world.stars, "min_distance", text="Min. Dist")
133         flow.itemR(world.stars, "average_separation", text="Separation")
134
135
136 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
137     bl_label = "Ambient Occlusion"
138     COMPAT_ENGINES = set(['BLENDER_RENDER'])
139
140     def draw_header(self, context):
141         world = context.world
142
143         self.layout.itemR(world.ambient_occlusion, "enabled", text="")
144
145     def draw(self, context):
146         layout = self.layout
147
148         ao = context.world.ambient_occlusion
149
150         layout.active = ao.enabled
151
152         layout.itemR(ao, "gather_method", expand=True)
153
154         split = layout.split()
155
156         col = split.column()
157         col.itemL(text="Attenuation:")
158         if ao.gather_method == 'RAYTRACE':
159             col.itemR(ao, "distance")
160         col.itemR(ao, "falloff")
161         sub = col.row()
162         sub.active = ao.falloff
163         sub.itemR(ao, "falloff_strength", text="Strength")
164
165         if ao.gather_method == 'RAYTRACE':
166             col = split.column()
167
168             col.itemL(text="Sampling:")
169             col.itemR(ao, "sample_method", text="")
170
171             sub = col.column()
172             sub.itemR(ao, "samples")
173
174             if ao.sample_method == 'ADAPTIVE_QMC':
175                 sub.itemR(ao, "threshold")
176                 sub.itemR(ao, "adapt_to_speed", slider=True)
177             elif ao.sample_method == 'CONSTANT_JITTERED':
178                 sub.itemR(ao, "bias")
179
180         if ao.gather_method == 'APPROXIMATE':
181             col = split.column()
182
183             col.itemL(text="Sampling:")
184             col.itemR(ao, "passes")
185             col.itemR(ao, "error_tolerance", text="Error")
186             col.itemR(ao, "pixel_cache")
187             col.itemR(ao, "correction")
188
189         col = layout.column()
190         col.itemL(text="Influence:")
191
192         col.row().itemR(ao, "blend_mode", expand=True)
193
194         split = layout.split()
195
196         col = split.column()
197         col.itemR(ao, "energy")
198
199         col = split.column()
200         sub = col.split(percentage=0.3)
201         sub.itemL(text="Color:")
202         sub.itemR(ao, "color", text="")
203
204 bpy.types.register(WORLD_PT_context_world)
205 bpy.types.register(WORLD_PT_preview)
206 bpy.types.register(WORLD_PT_world)
207 bpy.types.register(WORLD_PT_ambient_occlusion)
208 bpy.types.register(WORLD_PT_mist)
209 bpy.types.register(WORLD_PT_stars)