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