Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / release / ui / buttons_world.py
1
2 import bpy
3
4 class WorldButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
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, "paper_sky")
59                         row.itemR(world, "blend_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, "intensity", slider=True)
87                 flow.itemR(world.mist, "start")
88                 flow.itemR(world.mist, "depth")
89                 flow.itemR(world.mist, "height")
90                 
91
92                 layout.itemR(world.mist, "falloff")
93                 
94 class WORLD_PT_stars(WorldButtonsPanel):
95         __label__ = "Stars"
96         COMPAT_ENGINES = set(['BLENDER_RENDER'])
97
98         def draw_header(self, context):
99                 layout = self.layout
100                 world = context.world
101
102                 layout.itemR(world.stars, "enabled", text="")
103
104         def draw(self, context):
105                 layout = self.layout
106                 world = context.world
107
108                 layout.active = world.stars.enabled
109
110                 flow = layout.column_flow()
111                 flow.itemR(world.stars, "size")
112                 flow.itemR(world.stars, "color_randomization", text="Colors")
113                 flow.itemR(world.stars, "min_distance", text="Min. Dist")
114                 flow.itemR(world.stars, "average_separation", text="Separation")
115                 
116 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
117         __label__ = "Ambient Occlusion"
118         COMPAT_ENGINES = set(['BLENDER_RENDER'])
119
120         def draw_header(self, context):
121                 layout = self.layout
122                 world = context.world
123
124                 layout.itemR(world.ambient_occlusion, "enabled", text="")
125
126         def draw(self, context):
127                 layout = self.layout
128                 ao = context.world.ambient_occlusion
129                 
130                 layout.active = ao.enabled
131                 
132                 layout.itemR(ao, "gather_method", expand=True)
133
134                 split = layout.split()
135                 
136                 col = split.column()
137                 col.itemL(text="Attenuation:")
138                 col.itemR(ao, "distance")
139                 col.itemR(ao, "falloff")
140                 sub = col.row()
141                 sub.active = ao.falloff
142                 sub.itemR(ao, "falloff_strength", text="Strength")
143         
144                 if ao.gather_method == 'RAYTRACE':
145                         col = split.column()
146                         
147                         col.itemL(text="Sampling:")
148                         col.itemR(ao, "sample_method", text="")
149
150                         sub = col.column()
151                         sub.itemR(ao, "samples")
152
153                         if ao.sample_method == 'ADAPTIVE_QMC':
154                                 sub.itemR(ao, "threshold")
155                                 sub.itemR(ao, "adapt_to_speed", slider=True)
156                         elif ao.sample_method == 'CONSTANT_JITTERED':
157                                 sub.itemR(ao, "bias")
158                                                 
159                 if ao.gather_method == 'APPROXIMATE':
160                         col = split.column()
161                         
162                         col.itemL(text="Sampling:")
163                         col.itemR(ao, "error_tolerance", text="Error")
164                         col.itemR(ao, "pixel_cache")
165                         col.itemR(ao, "correction")
166                         
167                 col = layout.column()
168                 col.itemL(text="Influence:")
169                 
170                 col.row().itemR(ao, "blend_mode", expand=True)
171                 
172                 split = layout.split()
173                 
174                 col = split.column()
175                 col.itemR(ao, "energy")
176                 
177                 col = split.column()
178                 colsub = col.split(percentage=0.3)
179                 colsub.itemL(text="Color:")
180                 colsub.itemR(ao, "color", text="")
181                 
182
183 bpy.types.register(WORLD_PT_context_world)      
184 bpy.types.register(WORLD_PT_preview)
185 bpy.types.register(WORLD_PT_world)
186 bpy.types.register(WORLD_PT_ambient_occlusion)
187 bpy.types.register(WORLD_PT_mist)
188 bpy.types.register(WORLD_PT_stars)
189