Removed UI for point cache users.
[blender.git] / release / scripts / startup / bl_ui / properties_game.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Panel, Menu
22
23
24 class PhysicsButtonsPanel:
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "physics"
28
29
30 class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel):
31     bl_label = "Physics"
32     COMPAT_ENGINES = {'BLENDER_GAME'}
33
34     @classmethod
35     def poll(cls, context):
36         ob = context.active_object
37         rd = context.scene.render
38         return ob and ob.game and (rd.engine in cls.COMPAT_ENGINES)
39
40     def draw(self, context):
41         layout = self.layout
42
43         ob = context.active_object
44         game = ob.game
45         soft = ob.game.soft_body
46
47         layout.prop(game, "physics_type")
48         layout.separator()
49
50         physics_type = game.physics_type
51
52         if physics_type == 'CHARACTER':
53             layout.prop(game, "use_actor")
54             layout.prop(ob, "hide_render", text="Invisible")  # out of place but useful
55             layout.prop(game, "step_height", slider=True)
56             layout.prop(game, "jump_speed")
57             layout.prop(game, "fall_speed")
58             layout.prop(game, "jump_max")
59
60         elif physics_type in {'DYNAMIC', 'RIGID_BODY'}:
61             split = layout.split()
62
63             col = split.column()
64             col.prop(game, "use_actor")
65             col.prop(game, "use_ghost")
66             col.prop(ob, "hide_render", text="Invisible")  # out of place but useful
67
68             col = split.column()
69             col.prop(game, "use_material_physics_fh")
70             col.prop(game, "use_rotate_from_normal")
71             col.prop(game, "use_sleep")
72
73             layout.separator()
74
75             split = layout.split()
76
77             col = split.column()
78             col.label(text="Attributes:")
79             col.prop(game, "mass")
80             col.prop(game, "radius")
81             col.prop(game, "form_factor")
82
83             col = split.column()
84             sub = col.column()
85             sub.prop(game, "use_anisotropic_friction")
86             subsub = sub.column()
87             subsub.active = game.use_anisotropic_friction
88             subsub.prop(game, "friction_coefficients", text="", slider=True)
89
90             split = layout.split()
91
92             col = split.column()
93             col.label(text="Linear velocity:")
94             sub = col.column(align=True)
95             sub.prop(game, "velocity_min", text="Minimum")
96             sub.prop(game, "velocity_max", text="Maximum")
97             col.label(text="Angular velocity:")
98             sub = col.column(align=True)
99             sub.prop(game, "angular_velocity_min", text="Minimum")
100             sub.prop(game, "angular_velocity_max", text="Maximum")
101
102             col = split.column()
103             col.label(text="Damping:")
104             sub = col.column(align=True)
105             sub.prop(game, "damping", text="Translation", slider=True)
106             sub.prop(game, "rotation_damping", text="Rotation", slider=True)
107
108             layout.separator()
109
110             split = layout.split()
111
112             col = split.column()
113             col.label(text="Lock Translation:")
114             col.prop(game, "lock_location_x", text="X")
115             col.prop(game, "lock_location_y", text="Y")
116             col.prop(game, "lock_location_z", text="Z")
117
118         if physics_type == 'RIGID_BODY':
119             col = split.column()
120             col.label(text="Lock Rotation:")
121             col.prop(game, "lock_rotation_x", text="X")
122             col.prop(game, "lock_rotation_y", text="Y")
123             col.prop(game, "lock_rotation_z", text="Z")
124
125         elif physics_type == 'SOFT_BODY':
126             col = layout.column()
127             col.prop(game, "use_actor")
128             col.prop(game, "use_ghost")
129             col.prop(ob, "hide_render", text="Invisible")
130
131             layout.separator()
132
133             split = layout.split()
134
135             col = split.column()
136             col.label(text="Attributes:")
137             col.prop(game, "mass")
138             # disabled in the code
139             # col.prop(soft, "weld_threshold")
140             col.prop(soft, "location_iterations")
141             col.prop(soft, "linear_stiffness", slider=True)
142             col.prop(soft, "dynamic_friction", slider=True)
143             col.prop(soft, "collision_margin", slider=True)
144             col.prop(soft, "use_bending_constraints", text="Bending Constraints")
145
146             col = split.column()
147             col.prop(soft, "use_shape_match")
148             sub = col.column()
149             sub.active = soft.use_shape_match
150             sub.prop(soft, "shape_threshold", slider=True)
151
152             col.separator()
153
154             col.label(text="Cluster Collision:")
155             col.prop(soft, "use_cluster_rigid_to_softbody")
156             col.prop(soft, "use_cluster_soft_to_softbody")
157             sub = col.column()
158             sub.active = (soft.use_cluster_rigid_to_softbody or soft.use_cluster_soft_to_softbody)
159             sub.prop(soft, "cluster_iterations", text="Iterations")
160
161         elif physics_type == 'STATIC':
162             col = layout.column()
163             col.prop(game, "use_actor")
164             col.prop(game, "use_ghost")
165             col.prop(game, "use_record_animation")
166             col.prop(ob, "hide_render", text="Invisible")
167
168             layout.separator()
169
170             split = layout.split()
171
172             col = split.column()
173             col.label(text="Attributes:")
174             col.prop(game, "radius")
175
176             col = split.column()
177             sub = col.column()
178             sub.prop(game, "use_anisotropic_friction")
179             subsub = sub.column()
180             subsub.active = game.use_anisotropic_friction
181             subsub.prop(game, "friction_coefficients", text="", slider=True)
182
183         elif physics_type == 'SENSOR':
184             col = layout.column()
185             col.prop(game, "use_actor", text="Detect Actors")
186             col.prop(ob, "hide_render", text="Invisible")
187
188         elif physics_type in {'INVISIBLE', 'NO_COLLISION', 'OCCLUDER'}:
189             layout.prop(ob, "hide_render", text="Invisible")
190
191         elif physics_type == 'NAVMESH':
192             layout.operator("mesh.navmesh_face_copy")
193             layout.operator("mesh.navmesh_face_add")
194
195             layout.separator()
196
197             layout.operator("mesh.navmesh_reset")
198             layout.operator("mesh.navmesh_clear")
199
200
201 class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, Panel):
202     bl_label = "Collision Bounds"
203     COMPAT_ENGINES = {'BLENDER_GAME'}
204
205     @classmethod
206     def poll(cls, context):
207         game = context.object.game
208         rd = context.scene.render
209         return (rd.engine in cls.COMPAT_ENGINES) \
210                 and (game.physics_type in {'SENSOR', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'CHARACTER', 'SOFT_BODY'})
211
212     def draw_header(self, context):
213         game = context.active_object.game
214
215         self.layout.prop(game, "use_collision_bounds", text="")
216
217     def draw(self, context):
218         layout = self.layout
219
220         game = context.active_object.game
221         split = layout.split()
222         split.active = game.use_collision_bounds
223
224         col = split.column()
225         col.prop(game, "collision_bounds_type", text="Bounds")
226
227         row = col.row()
228         row.prop(game, "collision_margin", text="Margin", slider=True)
229
230         sub = row.row()
231         sub.active = game.physics_type not in {'SOFT_BODY', 'CHARACTER'}
232         sub.prop(game, "use_collision_compound", text="Compound")
233
234         layout.separator()
235         split = layout.split()
236         col = split.column()
237         col.prop(game, "collision_group")
238         col = split.column()
239         col.prop(game, "collision_mask")
240
241
242 class PHYSICS_PT_game_obstacles(PhysicsButtonsPanel, Panel):
243     bl_label = "Create Obstacle"
244     COMPAT_ENGINES = {'BLENDER_GAME'}
245
246     @classmethod
247     def poll(cls, context):
248         game = context.object.game
249         rd = context.scene.render
250         return (rd.engine in cls.COMPAT_ENGINES) \
251                 and (game.physics_type in {'SENSOR', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'SOFT_BODY', 'CHARACTER', 'NO_COLLISION'})
252
253     def draw_header(self, context):
254         game = context.active_object.game
255
256         self.layout.prop(game, "use_obstacle_create", text="")
257
258     def draw(self, context):
259         layout = self.layout
260
261         game = context.active_object.game
262
263         layout.active = game.use_obstacle_create
264
265         row = layout.row()
266         row.prop(game, "obstacle_radius", text="Radius")
267         row.label()
268
269
270 class RenderButtonsPanel:
271     bl_space_type = 'PROPERTIES'
272     bl_region_type = 'WINDOW'
273     bl_context = "render"
274
275     @classmethod
276     def poll(cls, context):
277         rd = context.scene.render
278         return (rd.engine in cls.COMPAT_ENGINES)
279
280
281 class RENDER_PT_embedded(RenderButtonsPanel, Panel):
282     bl_label = "Embedded Player"
283     COMPAT_ENGINES = {'BLENDER_GAME'}
284
285     def draw(self, context):
286         layout = self.layout
287
288         rd = context.scene.render
289
290         row = layout.row()
291         row.operator("view3d.game_start", text="Start")
292         row.label()
293         row = layout.row()
294         row.label(text="Resolution:")
295         row = layout.row(align=True)
296         row.prop(rd, "resolution_x", slider=False, text="X")
297         row.prop(rd, "resolution_y", slider=False, text="Y")
298
299
300 class RENDER_PT_game_player(RenderButtonsPanel, Panel):
301     bl_label = "Standalone Player"
302     COMPAT_ENGINES = {'BLENDER_GAME'}
303
304     def draw(self, context):
305         import sys
306         layout = self.layout
307         not_osx = sys.platform != "darwin"
308
309         gs = context.scene.game_settings
310
311         row = layout.row()
312         row.operator("wm.blenderplayer_start", text="Start")
313         row.label()
314
315         row = layout.row()
316         row.label(text="Resolution:")
317         row = layout.row(align=True)
318         row.active = not_osx or not gs.show_fullscreen
319         row.prop(gs, "resolution_x", slider=False, text="X")
320         row.prop(gs, "resolution_y", slider=False, text="Y")
321         row = layout.row()
322         col = row.column()
323         col.prop(gs, "show_fullscreen")
324
325         if not_osx:
326             col = row.column()
327             col.prop(gs, "use_desktop")
328             col.active = gs.show_fullscreen
329
330         col = layout.column()
331         col.label(text="Quality:")
332         col.prop(gs, "samples")
333         col = layout.column(align=True)
334         col.prop(gs, "depth", text="Bit Depth", slider=False)
335         col.prop(gs, "frequency", text="Refresh Rate", slider=False)
336
337
338 class RENDER_PT_game_stereo(RenderButtonsPanel, Panel):
339     bl_label = "Stereo"
340     COMPAT_ENGINES = {'BLENDER_GAME'}
341
342     def draw(self, context):
343         layout = self.layout
344
345         gs = context.scene.game_settings
346         stereo_mode = gs.stereo
347
348         # stereo options:
349         layout.prop(gs, "stereo", expand=True)
350
351         # stereo:
352         if stereo_mode == 'STEREO':
353             layout.prop(gs, "stereo_mode")
354             layout.prop(gs, "stereo_eye_separation")
355
356         # dome:
357         elif stereo_mode == 'DOME':
358             layout.prop(gs, "dome_mode", text="Dome Type")
359
360             dome_type = gs.dome_mode
361
362             split = layout.split()
363
364             if dome_type in {'FISHEYE', 'TRUNCATED_REAR', 'TRUNCATED_FRONT'}:
365                 col = split.column()
366                 col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
367                 col.prop(gs, "dome_angle", slider=True)
368
369                 col = split.column()
370                 col.prop(gs, "dome_tessellation", text="Tessellation")
371                 col.prop(gs, "dome_tilt")
372
373             elif dome_type == 'PANORAM_SPH':
374                 col = split.column()
375                 col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
376
377                 col = split.column()
378                 col.prop(gs, "dome_tessellation", text="Tessellation")
379
380             else:  # cube map
381                 col = split.column()
382                 col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
383
384                 col = split.column()
385
386             layout.prop(gs, "dome_text")
387
388
389 class RENDER_PT_game_shading(RenderButtonsPanel, Panel):
390     bl_label = "Shading"
391     COMPAT_ENGINES = {'BLENDER_GAME'}
392
393     def draw(self, context):
394         layout = self.layout
395
396         gs = context.scene.game_settings
397
398         layout.prop(gs, "material_mode", expand=True)
399
400         if gs.material_mode == 'GLSL':
401             split = layout.split()
402
403             col = split.column()
404             col.prop(gs, "use_glsl_lights", text="Lights")
405             col.prop(gs, "use_glsl_shaders", text="Shaders")
406             col.prop(gs, "use_glsl_shadows", text="Shadows")
407
408             col = split.column()
409             col.prop(gs, "use_glsl_ramps", text="Ramps")
410             col.prop(gs, "use_glsl_nodes", text="Nodes")
411             col.prop(gs, "use_glsl_extra_textures", text="Extra Textures")
412
413
414 class RENDER_PT_game_system(RenderButtonsPanel, Panel):
415     bl_label = "System"
416     COMPAT_ENGINES = {'BLENDER_GAME'}
417
418     def draw(self, context):
419         layout = self.layout
420
421         gs = context.scene.game_settings
422         col = layout.column()
423         row = col.row()
424         col = row.column()
425         col.prop(gs, "use_frame_rate")
426         col.prop(gs, "use_restrict_animation_updates")
427         col.prop(gs, "use_material_caching")
428         col = row.column()
429         col.prop(gs, "use_display_lists")
430         col.active = gs.raster_storage != 'VERTEX_BUFFER_OBJECT'
431
432         row = layout.row()
433         row.prop(gs, "vsync")
434
435         row = layout.row()
436         row.prop(gs, "raster_storage")
437
438         row = layout.row()
439         row.label("Exit Key")
440         row.prop(gs, "exit_key", text="", event=True)
441
442
443 class RENDER_PT_game_display(RenderButtonsPanel, Panel):
444     bl_label = "Display"
445     COMPAT_ENGINES = {'BLENDER_GAME'}
446
447     def draw(self, context):
448         layout = self.layout
449
450         gs = context.scene.game_settings
451
452         layout.prop(context.scene.render, "fps", text="Animation Frame Rate", slider=False)
453
454         flow = layout.column_flow()
455         flow.prop(gs, "show_debug_properties", text="Debug Properties")
456         flow.prop(gs, "show_framerate_profile", text="Framerate and Profile")
457         flow.prop(gs, "show_physics_visualization", text="Physics Visualization")
458         flow.prop(gs, "use_deprecation_warnings")
459         flow.prop(gs, "show_mouse", text="Mouse Cursor")
460
461         col = layout.column()
462         col.label(text="Framing:")
463         col.row().prop(gs, "frame_type", expand=True)
464         if gs.frame_type == 'LETTERBOX':
465             col.prop(gs, "frame_color", text="")
466
467
468 class SceneButtonsPanel:
469     bl_space_type = 'PROPERTIES'
470     bl_region_type = 'WINDOW'
471     bl_context = "scene"
472
473
474 class SCENE_PT_game_navmesh(SceneButtonsPanel, Panel):
475     bl_label = "Navigation mesh"
476     bl_options = {'DEFAULT_CLOSED'}
477     COMPAT_ENGINES = {'BLENDER_GAME'}
478
479     @classmethod
480     def poll(cls, context):
481         scene = context.scene
482         return (scene and scene.render.engine in cls.COMPAT_ENGINES)
483
484     def draw(self, context):
485         layout = self.layout
486
487         rd = context.scene.game_settings.recast_data
488
489         layout.operator("mesh.navmesh_make", text="Build navigation mesh")
490
491         col = layout.column()
492         col.label(text="Rasterization:")
493         row = col.row()
494         row.prop(rd, "cell_size")
495         row.prop(rd, "cell_height")
496
497         col = layout.column()
498         col.label(text="Agent:")
499         split = col.split()
500
501         col = split.column()
502         col.prop(rd, "agent_height", text="Height")
503         col.prop(rd, "agent_radius", text="Radius")
504
505         col = split.column()
506         col.prop(rd, "slope_max")
507         col.prop(rd, "climb_max")
508
509         col = layout.column()
510         col.label(text="Region:")
511         row = col.row()
512         row.prop(rd, "region_min_size")
513         if rd.partitioning != 'LAYERS':
514             row.prop(rd, "region_merge_size")
515
516         col = layout.column()
517         col.prop(rd, "partitioning")
518
519         col = layout.column()
520         col.label(text="Polygonization:")
521         split = col.split()
522
523         col = split.column()
524         col.prop(rd, "edge_max_len")
525         col.prop(rd, "edge_max_error")
526
527         split.prop(rd, "verts_per_poly")
528
529         col = layout.column()
530         col.label(text="Detail Mesh:")
531         row = col.row()
532         row.prop(rd, "sample_dist")
533         row.prop(rd, "sample_max_error")
534
535
536 class SCENE_PT_game_hysteresis(SceneButtonsPanel, Panel):
537     bl_label = "Level of Detail"
538     COMPAT_ENGINES = {'BLENDER_GAME'}
539
540     @classmethod
541     def poll(cls, context):
542         scene = context.scene
543         return (scene and scene.render.engine in cls.COMPAT_ENGINES)
544
545     def draw(self, context):
546         layout = self.layout
547         gs = context.scene.game_settings
548
549         row = layout.row()
550         row.prop(gs, "use_scene_hysteresis", text="Hysteresis")
551         row = layout.row()
552         row.active = gs.use_scene_hysteresis
553         row.prop(gs, "scene_hysteresis_percentage", text="")
554
555
556 class WorldButtonsPanel:
557     bl_space_type = 'PROPERTIES'
558     bl_region_type = 'WINDOW'
559     bl_context = "world"
560
561
562 class WORLD_PT_game_context_world(WorldButtonsPanel, Panel):
563     bl_label = ""
564     bl_options = {'HIDE_HEADER'}
565     COMPAT_ENGINES = {'BLENDER_GAME'}
566
567     @classmethod
568     def poll(cls, context):
569         rd = context.scene.render
570         return (context.scene) and (rd.use_game_engine)
571
572     def draw(self, context):
573         layout = self.layout
574
575         scene = context.scene
576         world = context.world
577         space = context.space_data
578
579         split = layout.split(percentage=0.65)
580         if scene:
581             split.template_ID(scene, "world", new="world.new")
582         elif world:
583             split.template_ID(space, "pin_id")
584
585
586 class WORLD_PT_game_world(WorldButtonsPanel, Panel):
587     bl_label = "World"
588     COMPAT_ENGINES = {'BLENDER_GAME'}
589
590     @classmethod
591     def poll(cls, context):
592         scene = context.scene
593         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
594
595     def draw(self, context):
596         layout = self.layout
597
598         world = context.world
599
600         row = layout.row()
601         row.column().prop(world, "horizon_color")
602         row.column().prop(world, "ambient_color")
603
604
605 class WORLD_PT_game_mist(WorldButtonsPanel, Panel):
606     bl_label = "Mist"
607     COMPAT_ENGINES = {'BLENDER_GAME'}
608
609     @classmethod
610     def poll(cls, context):
611         scene = context.scene
612         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
613
614     def draw_header(self, context):
615         world = context.world
616
617         self.layout.prop(world.mist_settings, "use_mist", text="")
618
619     def draw(self, context):
620         layout = self.layout
621
622         world = context.world
623
624         layout.active = world.mist_settings.use_mist
625
626         layout.prop(world.mist_settings, "falloff")
627
628         row = layout.row(align=True)
629         row.prop(world.mist_settings, "start")
630         row.prop(world.mist_settings, "depth")
631
632         layout.prop(world.mist_settings, "intensity", text="Minimum Intensity")
633
634
635 class WORLD_PT_game_physics(WorldButtonsPanel, Panel):
636     bl_label = "Physics"
637     COMPAT_ENGINES = {'BLENDER_GAME'}
638
639     @classmethod
640     def poll(cls, context):
641         scene = context.scene
642         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
643
644     def draw(self, context):
645         layout = self.layout
646
647         gs = context.scene.game_settings
648
649         layout.prop(gs, "physics_engine", text="Engine")
650         if gs.physics_engine != 'NONE':
651             layout.prop(gs, "physics_gravity", text="Gravity")
652
653             split = layout.split()
654
655             col = split.column()
656             col.label(text="Physics Steps:")
657             sub = col.column(align=True)
658             sub.prop(gs, "physics_step_max", text="Max")
659             sub.prop(gs, "physics_step_sub", text="Substeps")
660             col.prop(gs, "fps", text="FPS")
661
662             col = split.column()
663             col.label(text="Logic Steps:")
664             col.prop(gs, "logic_step_max", text="Max")
665
666             col = layout.column()
667             col.label(text="Physics Deactivation:")
668             sub = col.row(align=True)
669             sub.prop(gs, "deactivation_linear_threshold", text="Linear Threshold")
670             sub.prop(gs, "deactivation_angular_threshold", text="Angular Threshold")
671             sub = col.row()
672             sub.prop(gs, "deactivation_time", text="Time")
673
674             col = layout.column()
675             col.prop(gs, "use_occlusion_culling", text="Occlusion Culling")
676             sub = col.column()
677             sub.active = gs.use_occlusion_culling
678             sub.prop(gs, "occlusion_culling_resolution", text="Resolution")
679
680         else:
681             split = layout.split()
682
683             col = split.column()
684             col.label(text="Physics Steps:")
685             col.prop(gs, "fps", text="FPS")
686
687             col = split.column()
688             col.label(text="Logic Steps:")
689             col.prop(gs, "logic_step_max", text="Max")
690
691
692 class WORLD_PT_game_physics_obstacles(WorldButtonsPanel, Panel):
693     bl_label = "Obstacle simulation"
694     COMPAT_ENGINES = {'BLENDER_GAME'}
695
696     @classmethod
697     def poll(cls, context):
698         scene = context.scene
699         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
700
701     def draw(self, context):
702         layout = self.layout
703
704         gs = context.scene.game_settings
705
706         layout.prop(gs, "obstacle_simulation", text="Type")
707         if gs.obstacle_simulation != 'NONE':
708             layout.prop(gs, "level_height")
709             layout.prop(gs, "show_obstacle_simulation")
710
711
712 class DataButtonsPanel:
713     bl_space_type = 'PROPERTIES'
714     bl_region_type = 'WINDOW'
715     bl_context = "data"
716
717
718 class DATA_PT_shadow_game(DataButtonsPanel, Panel):
719     bl_label = "Shadow"
720     COMPAT_ENGINES = {'BLENDER_GAME'}
721
722     @classmethod
723     def poll(cls, context):
724         COMPAT_LIGHTS = {'SPOT', 'SUN'}
725         lamp = context.lamp
726         engine = context.scene.render.engine
727         return (lamp and lamp.type in COMPAT_LIGHTS) and (engine in cls.COMPAT_ENGINES)
728
729     def draw_header(self, context):
730         lamp = context.lamp
731
732         self.layout.prop(lamp, "use_shadow", text="")
733
734     def draw(self, context):
735         layout = self.layout
736
737         lamp = context.lamp
738
739         layout.active = lamp.use_shadow
740
741         split = layout.split()
742
743         col = split.column()
744         col.prop(lamp, "shadow_color", text="")
745         if lamp.type == 'SUN':
746             col.prop(lamp, "show_shadow_box")
747
748         col = split.column()
749         col.prop(lamp, "use_shadow_layer", text="This Layer Only")
750         col.prop(lamp, "use_only_shadow")
751
752         col = layout.column()
753         col.label("Buffer Type:")
754         col.prop(lamp, "ge_shadow_buffer_type", text="", toggle=True)
755         col.label("Quality:")
756         col = layout.column(align=True)
757         col.prop(lamp, "shadow_buffer_size", text="Size")
758         col.prop(lamp, "shadow_buffer_bias", text="Bias")
759         col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
760
761         row = layout.row()
762         row.label("Clipping:")
763         row = layout.row(align=True)
764         row.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
765         row.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
766
767         if lamp.type == 'SUN':
768             row = layout.row()
769             row.prop(lamp, "shadow_frustum_size", text="Frustum Size")
770
771
772 class ObjectButtonsPanel:
773     bl_space_type = 'PROPERTIES'
774     bl_region_type = 'WINDOW'
775     bl_context = "object"
776
777
778 class OBJECT_MT_lod_tools(Menu):
779     bl_label = "Level Of Detail Tools"
780
781     def draw(self, context):
782         layout = self.layout
783
784         layout.operator("object.lod_by_name", text="Set By Name")
785         layout.operator("object.lod_generate", text="Generate")
786         layout.operator("object.lod_clear_all", text="Clear All", icon='PANEL_CLOSE')
787
788
789 class OBJECT_PT_levels_of_detail(ObjectButtonsPanel, Panel):
790     bl_label = "Levels of Detail"
791     COMPAT_ENGINES = {'BLENDER_GAME'}
792
793     @classmethod
794     def poll(cls, context):
795         return context.scene.render.engine in cls.COMPAT_ENGINES
796
797     def draw(self, context):
798         layout = self.layout
799         ob = context.object
800         gs = context.scene.game_settings
801
802         col = layout.column()
803
804         for i, level in enumerate(ob.lod_levels):
805             if i == 0:
806                 continue
807             box = col.box()
808             row = box.row()
809             row.prop(level, "object", text="")
810             row.operator("object.lod_remove", text="", icon='PANEL_CLOSE').index = i
811
812             row = box.row()
813             row.prop(level, "distance")
814             row = row.row(align=True)
815             row.prop(level, "use_mesh", text="")
816             row.prop(level, "use_material", text="")
817
818             row = box.row()
819             row.active = gs.use_scene_hysteresis
820             row.prop(level, "use_object_hysteresis", text="Hysteresis Override")
821             row = box.row()
822             row.active = gs.use_scene_hysteresis and level.use_object_hysteresis
823             row.prop(level, "object_hysteresis_percentage", text="")
824
825         row = col.row(align=True)
826         row.operator("object.lod_add", text="Add", icon='ZOOMIN')
827         row.menu("OBJECT_MT_lod_tools", text="", icon='TRIA_DOWN')
828
829
830 if __name__ == "__main__":  # only for live edit.
831     bpy.utils.register_module(__name__)