4 class PhysicsButtonsPanel(bpy.types.Panel):
5 __space_type__ = "BUTTONS_WINDOW"
6 __region_type__ = "WINDOW"
7 __context__ = "physics"
9 def poll(self, context):
10 ob = context.active_object
11 rd = context.scene.render_data
12 return ob and ob.game and (rd.engine == 'BLENDER_GAME')
14 class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
15 __idname__ = "PHYSICS_PT_game_physics"
18 def draw(self, context):
20 ob = context.active_object
24 layout.itemR(game, "physics_type")
27 split = layout.split()
30 col.itemR(game, "actor")
32 col.itemR(game, "ghost")
33 col.itemR(ob, "restrict_render", text="Invisible") # out of place but useful
35 col.itemR(game, "do_fh", text="Use Material Physics")
36 col.itemR(game, "rotation_fh", text="Rotate From Normal")
37 col.itemR(game, "no_sleeping")
40 split = layout.split()
42 col.itemL(text="Attributes:")
43 colsub = col.column(align=True)
44 colsub.itemR(game, "mass")
45 colsub.itemR(game, "radius")
46 colsub.itemR(game, "form_factor")
48 col.itemL(text="Damping:")
49 colsub = col.column(align=True)
50 colsub.itemR(game, "damping", text="Translation", slider=True)
51 colsub.itemR(game, "rotation_damping", text="Rotation", slider=True)
55 col.itemL(text="Velocity:")
56 colsub = col.column(align=True)
57 colsub.itemR(game, "minimum_velocity", text="Minimum")
58 colsub.itemR(game, "maximum_velocity", text="Maximum")
60 col.itemR(game, "anisotropic_friction")
63 colsub.active = game.anisotropic_friction
64 colsub.itemR(game, "friction_coefficients", text="", slider=True)
67 split = layout.split()
69 sub.itemL(text="Lock Translation:")
70 sub.itemR(game, "lock_x_axis", text="X")
71 sub.itemR(game, "lock_y_axis", text="Y")
72 sub.itemR(game, "lock_z_axis", text="Z")
74 sub.itemL(text="Lock Rotation:")
75 sub.itemR(game, "lock_x_rot_axis", text="X")
76 sub.itemR(game, "lock_y_rot_axis", text="Y")
77 sub.itemR(game, "lock_z_rot_axis", text="Z")
79 class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel):
80 __idname__ = "PHYSICS_PT_game_collision_bounds"
81 __label__ = "Collision Bounds"
83 def draw_header(self, context):
85 ob = context.active_object
88 layout.itemR(game, "use_collision_bounds", text="")
90 def draw(self, context):
93 ob = context.scene.objects[0]
95 layout.active = game.use_collision_bounds
99 layout.itemR(game, "collision_bounds", text="Bounds")
101 split = layout.split()
103 sub.itemR(game, "collision_compound", text="Compound")
105 sub.itemR(game, "collision_margin", text="Margin", slider=True)
107 bpy.types.register(PHYSICS_PT_game_physics)
108 bpy.types.register(PHYSICS_PT_game_collision_bounds)
110 class SceneButtonsPanel(bpy.types.Panel):
111 __space_type__ = "BUTTONS_WINDOW"
112 __region_type__ = "WINDOW"
113 __context__ = "scene"
115 def poll(self, context):
116 rd = context.scene.render_data
117 return (rd.engine == 'BLENDER_GAME')
119 class SCENE_PT_game(SceneButtonsPanel):
122 def draw(self, context):
124 rd = context.scene.render_data
127 row.itemO("view3d.game_start", text="Start")
130 class SCENE_PT_game_player(SceneButtonsPanel):
133 def draw(self, context):
135 gs = context.scene.game_data
137 row.itemR(gs, "fullscreen")
139 split = layout.split()
141 col.itemL(text="Resolution:")
142 colsub = col.column(align=True)
143 colsub.itemR(gs, "resolution_x", slider=False, text="X")
144 colsub.itemR(gs, "resolution_y", slider=False, text="Y")
147 col.itemL(text="Quality:")
148 colsub = col.column(align=True)
149 colsub.itemR(gs, "depth", text="Bit Depth", slider=False)
150 colsub.itemR(gs, "frequency", text="FPS", slider=False)
153 col = layout.column()
154 col.itemL(text="Framing:")
155 col.row().itemR(gs, "framing_type", expand=True)
157 colsub = col.column()
158 colsub.itemR(gs, "framing_color", text="")
160 class SCENE_PT_game_stereo(SceneButtonsPanel):
163 def draw(self, context):
165 gs = context.scene.game_data
170 row.itemR(gs, "stereo", expand=True)
172 stereo_mode = gs.stereo
175 if stereo_mode == 'STEREO':
177 row.itemR(gs, "stereo_mode")
180 if stereo_mode == 'DOME':
182 row.itemR(gs, "dome_mode", text="Dome Type")
186 col.itemR(gs, "dome_angle", slider=True)
187 col.itemR(gs, "dome_tesselation", text="Tesselation")
189 col.itemR(gs, "dome_tilt")
190 col.itemR(gs, "dome_buffer_resolution", text="Resolution", slider=True)
192 col.itemR(gs, "dome_text")
194 bpy.types.register(SCENE_PT_game)
195 bpy.types.register(SCENE_PT_game_player)
196 bpy.types.register(SCENE_PT_game_stereo)
198 class WorldButtonsPanel(bpy.types.Panel):
199 __space_type__ = "BUTTONS_WINDOW"
200 __region_type__ = "WINDOW"
201 __context__ = "world"
203 def poll(self, context):
204 rd = context.scene.render_data
205 return (rd.engine == 'BLENDER_GAME')
207 class WORLD_PT_game_context_world(WorldButtonsPanel):
210 def poll(self, context):
211 rd = context.scene.render_data
212 return (context.scene != None) and (rd.use_game_engine)
214 def draw(self, context):
217 scene = context.scene
218 world = context.world
219 space = context.space_data
221 split = layout.split(percentage=0.65)
224 split.template_ID(scene, "world", new="world.new")
226 split.template_ID(space, "pin_id")
228 class WORLD_PT_game_world(WorldButtonsPanel):
231 def draw(self, context):
233 world = context.world
236 row.column().itemR(world, "horizon_color")
237 row.column().itemR(world, "ambient_color")
239 layout.itemR(world.mist, "enabled", text="Mist")
241 row = layout.column_flow()
242 row.active = world.mist.enabled
243 row.itemR(world.mist, "start")
244 row.itemR(world.mist, "depth")
248 class WORLD_PT_game(WorldButtonsPanel):
249 __space_type__ = "LOGIC_EDITOR"
250 __region_type__ = "UI"
251 __label__ = "Game Settings"
253 def draw(self, context):
255 world = context.world
257 flow = layout.column_flow()
258 flow.itemR(world, "physics_engine")
259 flow.itemR(world, "physics_gravity")
261 flow.itemR(world, "game_fps")
262 flow.itemR(world, "game_logic_step_max")
263 flow.itemR(world, "game_physics_substep")
264 flow.itemR(world, "game_physics_step_max")
266 flow.itemR(world, "game_use_occlusion_culling", text="Enable Occlusion Culling")
267 flow.itemR(world, "game_occlusion_culling_resolution")
270 class WORLD_PT_game_physics(WorldButtonsPanel):
271 __label__ = "Physics"
273 def draw(self, context):
275 gs = context.scene.game_data
276 flow = layout.column_flow()
277 flow.itemR(gs, "physics_engine")
278 if gs.physics_engine != "NONE":
279 flow.itemR(gs, "physics_gravity", text="Gravity")
281 split = layout.split()
283 col.itemL(text="Physics Steps:")
284 colsub = col.column(align=True)
285 colsub.itemR(gs, "physics_step_max", text="Max")
286 colsub.itemR(gs, "physics_step_sub", text="Substeps")
287 col.itemR(gs, "fps", text="FPS")
290 col.itemL(text="Logic Steps:")
291 col.itemR(gs, "logic_step_max", text="Max")
293 col.itemR(gs, "use_occlusion_culling", text="Occlusion Culling")
294 colsub = col.column()
295 colsub.active = gs.use_occlusion_culling
296 colsub.itemR(gs, "occlusion_culling_resolution", text="Resolution")
300 split = layout.split()
302 col.itemL(text="Physics Steps:")
303 col.itemR(gs, "fps", text="FPS")
305 col.itemL(text="Logic Steps:")
306 col.itemR(gs, "logic_step_max", text="Max")
308 bpy.types.register(WORLD_PT_game_context_world)
309 bpy.types.register(WORLD_PT_game_world)
310 bpy.types.register(WORLD_PT_game_physics)