renamed buttons ui files to properties to match UI name change, needed to update...
[blender.git] / release / scripts / ui / properties_world.py
1
2 import bpy
3
4 class WorldButtonsPanel(bpy.types.Panel):
5     bl_space_type = 'PROPERTIES'
6     bl_region_type = 'WINDOW'
7     bl_context = "world"
8     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
9
10     def poll(self, context):
11         rd = context.scene.render_data
12         return (context.world) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
13
14 class WORLD_PT_preview(WorldButtonsPanel):
15     bl_label = "Preview"
16     COMPAT_ENGINES = set(['BLENDER_RENDER'])
17
18     def draw(self, context):
19         self.layout.template_preview(context.world)
20
21 class WORLD_PT_context_world(WorldButtonsPanel):
22     bl_label = ""
23     bl_show_header = False
24     COMPAT_ENGINES = set(['BLENDER_RENDER'])
25
26     def poll(self, context):
27         rd = context.scene.render_data
28         return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
29
30     def draw(self, context):
31         layout = self.layout
32
33         scene = context.scene
34         world = context.world
35         space = context.space_data
36
37         split = layout.split(percentage=0.65)
38
39         if scene:
40             split.template_ID(scene, "world", new="world.new")
41         elif world:
42             split.template_ID(space, "pin_id")
43
44 class WORLD_PT_world(WorldButtonsPanel):
45     bl_label = "World"
46     COMPAT_ENGINES = set(['BLENDER_RENDER'])
47
48     def draw(self, context):
49         layout = self.layout
50
51         world = context.world
52
53         row = layout.row()
54         row.itemR(world, "paper_sky")
55         row.itemR(world, "blend_sky")
56         row.itemR(world, "real_sky")
57
58         row = layout.row()
59         row.column().itemR(world, "horizon_color")
60         col = row.column()
61         col.itemR(world, "zenith_color")
62         col.active = world.blend_sky
63         row.column().itemR(world, "ambient_color")
64
65 class WORLD_PT_mist(WorldButtonsPanel):
66     bl_label = "Mist"
67     COMPAT_ENGINES = set(['BLENDER_RENDER'])
68
69     def draw_header(self, context):
70         world = context.world
71
72         self.layout.itemR(world.mist, "enabled", text="")
73
74     def draw(self, context):
75         layout = self.layout
76
77         world = context.world
78
79         layout.active = world.mist.enabled
80
81         flow = layout.column_flow()
82         flow.itemR(world.mist, "intensity", slider=True)
83         flow.itemR(world.mist, "start")
84         flow.itemR(world.mist, "depth")
85         flow.itemR(world.mist, "height")
86
87         layout.itemR(world.mist, "falloff")
88
89 class WORLD_PT_stars(WorldButtonsPanel):
90     bl_label = "Stars"
91     COMPAT_ENGINES = set(['BLENDER_RENDER'])
92
93     def draw_header(self, context):
94         world = context.world
95
96         self.layout.itemR(world.stars, "enabled", text="")
97
98     def draw(self, context):
99         layout = self.layout
100
101         world = context.world
102
103         layout.active = world.stars.enabled
104
105         flow = layout.column_flow()
106         flow.itemR(world.stars, "size")
107         flow.itemR(world.stars, "color_randomization", text="Colors")
108         flow.itemR(world.stars, "min_distance", text="Min. Dist")
109         flow.itemR(world.stars, "average_separation", text="Separation")
110
111 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
112     bl_label = "Ambient Occlusion"
113     COMPAT_ENGINES = set(['BLENDER_RENDER'])
114
115     def draw_header(self, context):
116         world = context.world
117
118         self.layout.itemR(world.ambient_occlusion, "enabled", text="")
119
120     def draw(self, context):
121         layout = self.layout
122
123         ao = context.world.ambient_occlusion
124
125         layout.active = ao.enabled
126
127         layout.itemR(ao, "gather_method", expand=True)
128
129         split = layout.split()
130
131         col = split.column()
132         col.itemL(text="Attenuation:")
133         if ao.gather_method == 'RAYTRACE':
134             col.itemR(ao, "distance")
135         col.itemR(ao, "falloff")
136         sub = col.row()
137         sub.active = ao.falloff
138         sub.itemR(ao, "falloff_strength", text="Strength")
139
140         if ao.gather_method == 'RAYTRACE':
141             col = split.column()
142
143             col.itemL(text="Sampling:")
144             col.itemR(ao, "sample_method", text="")
145
146             sub = col.column()
147             sub.itemR(ao, "samples")
148
149             if ao.sample_method == 'ADAPTIVE_QMC':
150                 sub.itemR(ao, "threshold")
151                 sub.itemR(ao, "adapt_to_speed", slider=True)
152             elif ao.sample_method == 'CONSTANT_JITTERED':
153                 sub.itemR(ao, "bias")
154
155         if ao.gather_method == 'APPROXIMATE':
156             col = split.column()
157
158             col.itemL(text="Sampling:")
159             col.itemR(ao, "passes")
160             col.itemR(ao, "error_tolerance", text="Error")
161             col.itemR(ao, "pixel_cache")
162             col.itemR(ao, "correction")
163
164         col = layout.column()
165         col.itemL(text="Influence:")
166
167         col.row().itemR(ao, "blend_mode", expand=True)
168
169         split = layout.split()
170
171         col = split.column()
172         col.itemR(ao, "energy")
173
174         col = split.column()
175         sub = col.split(percentage=0.3)
176         sub.itemL(text="Color:")
177         sub.itemR(ao, "color", text="")
178
179 bpy.types.register(WORLD_PT_context_world)
180 bpy.types.register(WORLD_PT_preview)
181 bpy.types.register(WORLD_PT_world)
182 bpy.types.register(WORLD_PT_ambient_occlusion)
183 bpy.types.register(WORLD_PT_mist)
184 bpy.types.register(WORLD_PT_stars)