BGE: Adding a Max Jumps value to the character physic window
[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, "max_jumps")
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         row.prop(rd, "region_merge_size")
514
515         col = layout.column()
516         col.label(text="Polygonization:")
517         split = col.split()
518
519         col = split.column()
520         col.prop(rd, "edge_max_len")
521         col.prop(rd, "edge_max_error")
522
523         split.prop(rd, "verts_per_poly")
524
525         col = layout.column()
526         col.label(text="Detail Mesh:")
527         row = col.row()
528         row.prop(rd, "sample_dist")
529         row.prop(rd, "sample_max_error")
530
531
532 class SCENE_PT_game_hysteresis(SceneButtonsPanel, Panel):
533     bl_label = "Level of Detail"
534     COMPAT_ENGINES = {'BLENDER_GAME'}
535
536     @classmethod
537     def poll(cls, context):
538         scene = context.scene
539         return (scene and scene.render.engine in cls.COMPAT_ENGINES)
540
541     def draw(self, context):
542         layout = self.layout
543         gs = context.scene.game_settings
544
545         row = layout.row()
546         row.prop(gs, "use_scene_hysteresis", text="Hysteresis")
547         row = layout.row()
548         row.active = gs.use_scene_hysteresis
549         row.prop(gs, "scene_hysteresis_percentage", text="")
550
551
552 class WorldButtonsPanel:
553     bl_space_type = 'PROPERTIES'
554     bl_region_type = 'WINDOW'
555     bl_context = "world"
556
557
558 class WORLD_PT_game_context_world(WorldButtonsPanel, Panel):
559     bl_label = ""
560     bl_options = {'HIDE_HEADER'}
561     COMPAT_ENGINES = {'BLENDER_GAME'}
562
563     @classmethod
564     def poll(cls, context):
565         rd = context.scene.render
566         return (context.scene) and (rd.use_game_engine)
567
568     def draw(self, context):
569         layout = self.layout
570
571         scene = context.scene
572         world = context.world
573         space = context.space_data
574
575         split = layout.split(percentage=0.65)
576         if scene:
577             split.template_ID(scene, "world", new="world.new")
578         elif world:
579             split.template_ID(space, "pin_id")
580
581
582 class WORLD_PT_game_world(WorldButtonsPanel, Panel):
583     bl_label = "World"
584     COMPAT_ENGINES = {'BLENDER_GAME'}
585
586     @classmethod
587     def poll(cls, context):
588         scene = context.scene
589         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
590
591     def draw(self, context):
592         layout = self.layout
593
594         world = context.world
595
596         row = layout.row()
597         row.column().prop(world, "horizon_color")
598         row.column().prop(world, "ambient_color")
599
600
601 class WORLD_PT_game_mist(WorldButtonsPanel, Panel):
602     bl_label = "Mist"
603     COMPAT_ENGINES = {'BLENDER_GAME'}
604
605     @classmethod
606     def poll(cls, context):
607         scene = context.scene
608         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
609
610     def draw_header(self, context):
611         world = context.world
612
613         self.layout.prop(world.mist_settings, "use_mist", text="")
614
615     def draw(self, context):
616         layout = self.layout
617
618         world = context.world
619
620         layout.active = world.mist_settings.use_mist
621
622         layout.prop(world.mist_settings, "falloff")
623
624         row = layout.row(align=True)
625         row.prop(world.mist_settings, "start")
626         row.prop(world.mist_settings, "depth")
627
628         layout.prop(world.mist_settings, "intensity", text="Minimum Intensity")
629
630
631 class WORLD_PT_game_physics(WorldButtonsPanel, Panel):
632     bl_label = "Physics"
633     COMPAT_ENGINES = {'BLENDER_GAME'}
634
635     @classmethod
636     def poll(cls, context):
637         scene = context.scene
638         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
639
640     def draw(self, context):
641         layout = self.layout
642
643         gs = context.scene.game_settings
644
645         layout.prop(gs, "physics_engine", text="Engine")
646         if gs.physics_engine != 'NONE':
647             layout.prop(gs, "physics_gravity", text="Gravity")
648
649             split = layout.split()
650
651             col = split.column()
652             col.label(text="Physics Steps:")
653             sub = col.column(align=True)
654             sub.prop(gs, "physics_step_max", text="Max")
655             sub.prop(gs, "physics_step_sub", text="Substeps")
656             col.prop(gs, "fps", text="FPS")
657
658             col = split.column()
659             col.label(text="Logic Steps:")
660             col.prop(gs, "logic_step_max", text="Max")
661
662             col = layout.column()
663             col.label(text="Physics Deactivation:")
664             sub = col.row(align=True)
665             sub.prop(gs, "deactivation_linear_threshold", text="Linear Threshold")
666             sub.prop(gs, "deactivation_angular_threshold", text="Angular Threshold")
667             sub = col.row()
668             sub.prop(gs, "deactivation_time", text="Time")
669
670             col = layout.column()
671             col.prop(gs, "use_occlusion_culling", text="Occlusion Culling")
672             sub = col.column()
673             sub.active = gs.use_occlusion_culling
674             sub.prop(gs, "occlusion_culling_resolution", text="Resolution")
675
676         else:
677             split = layout.split()
678
679             col = split.column()
680             col.label(text="Physics Steps:")
681             col.prop(gs, "fps", text="FPS")
682
683             col = split.column()
684             col.label(text="Logic Steps:")
685             col.prop(gs, "logic_step_max", text="Max")
686
687
688 class WORLD_PT_game_physics_obstacles(WorldButtonsPanel, Panel):
689     bl_label = "Obstacle simulation"
690     COMPAT_ENGINES = {'BLENDER_GAME'}
691
692     @classmethod
693     def poll(cls, context):
694         scene = context.scene
695         return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
696
697     def draw(self, context):
698         layout = self.layout
699
700         gs = context.scene.game_settings
701
702         layout.prop(gs, "obstacle_simulation", text="Type")
703         if gs.obstacle_simulation != 'NONE':
704             layout.prop(gs, "level_height")
705             layout.prop(gs, "show_obstacle_simulation")
706
707
708 class DataButtonsPanel:
709     bl_space_type = 'PROPERTIES'
710     bl_region_type = 'WINDOW'
711     bl_context = "data"
712
713
714 class DATA_PT_shadow_game(DataButtonsPanel, Panel):
715     bl_label = "Shadow"
716     COMPAT_ENGINES = {'BLENDER_GAME'}
717
718     @classmethod
719     def poll(cls, context):
720         COMPAT_LIGHTS = {'SPOT', 'SUN'}
721         lamp = context.lamp
722         engine = context.scene.render.engine
723         return (lamp and lamp.type in COMPAT_LIGHTS) and (engine in cls.COMPAT_ENGINES)
724
725     def draw_header(self, context):
726         lamp = context.lamp
727
728         self.layout.prop(lamp, "use_shadow", text="")
729
730     def draw(self, context):
731         layout = self.layout
732
733         lamp = context.lamp
734
735         layout.active = lamp.use_shadow
736
737         split = layout.split()
738
739         col = split.column()
740         col.prop(lamp, "shadow_color", text="")
741         if lamp.type == 'SUN':
742             col.prop(lamp, "show_shadow_box")
743
744         col = split.column()
745         col.prop(lamp, "use_shadow_layer", text="This Layer Only")
746         col.prop(lamp, "use_only_shadow")
747
748         col = layout.column()
749         col.label("Buffer Type:")
750         col.prop(lamp, "ge_shadow_buffer_type", text="", toggle=True)
751         col.label("Quality:")
752         col = layout.column(align=True)
753         col.prop(lamp, "shadow_buffer_size", text="Size")
754         col.prop(lamp, "shadow_buffer_bias", text="Bias")
755         col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
756
757         row = layout.row()
758         row.label("Clipping:")
759         row = layout.row(align=True)
760         row.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
761         row.prop(lamp, "shadow_buffer_clip_end", text="Clip End")
762
763         if lamp.type == 'SUN':
764             row = layout.row()
765             row.prop(lamp, "shadow_frustum_size", text="Frustum Size")
766
767
768 class ObjectButtonsPanel:
769     bl_space_type = 'PROPERTIES'
770     bl_region_type = 'WINDOW'
771     bl_context = "object"
772
773
774 class OBJECT_MT_lod_tools(Menu):
775     bl_label = "Level Of Detail Tools"
776
777     def draw(self, context):
778         layout = self.layout
779
780         layout.operator("object.lod_by_name", text="Set By Name")
781         layout.operator("object.lod_generate", text="Generate")
782         layout.operator("object.lod_clear_all", text="Clear All", icon='PANEL_CLOSE')
783
784
785 class OBJECT_PT_levels_of_detail(ObjectButtonsPanel, Panel):
786     bl_label = "Levels of Detail"
787     COMPAT_ENGINES = {'BLENDER_GAME'}
788
789     @classmethod
790     def poll(cls, context):
791         return context.scene.render.engine in cls.COMPAT_ENGINES
792
793     def draw(self, context):
794         layout = self.layout
795         ob = context.object
796         gs = context.scene.game_settings
797
798         col = layout.column()
799
800         for i, level in enumerate(ob.lod_levels):
801             if i == 0:
802                 continue
803             box = col.box()
804             row = box.row()
805             row.prop(level, "object", text="")
806             row.operator("object.lod_remove", text="", icon='PANEL_CLOSE').index = i
807
808             row = box.row()
809             row.prop(level, "distance")
810             row = row.row(align=True)
811             row.prop(level, "use_mesh", text="")
812             row.prop(level, "use_material", text="")
813
814             row = box.row()
815             row.active = gs.use_scene_hysteresis
816             row.prop(level, "use_object_hysteresis", text="Hysteresis Override")
817             row = box.row()
818             row.active = gs.use_scene_hysteresis and level.use_object_hysteresis
819             row.prop(level, "object_hysteresis_percentage", text="")
820
821         row = col.row(align=True)
822         row.operator("object.lod_add", text="Add", icon='ZOOMIN')
823         row.menu("OBJECT_MT_lod_tools", text="", icon='TRIA_DOWN')
824
825
826 if __name__ == "__main__":  # only for live edit.
827     bpy.utils.register_module(__name__)