5f953b1c8ebb2192250f0461d65c280b0c3af7ad
[blender-staging.git] / release / ui / buttons_game.py
1
2 import bpy
3  
4 class GameButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "game"
8
9 class GAME_PT_context_game(GameButtonsPanel):
10         __idname__ = "GAME_PT_context_game"
11         __no_header__ = True
12
13         def draw(self, context):
14                 layout = self.layout
15                 ob = context.object
16                 game = context.game
17
18                 split = layout.split(percentage=0.06)
19                 split.itemL(text="", icon="ICON_GAME")
20                 split.itemR(game, "name", text="")
21
22 class GAME_PT_data(GameButtonsPanel):
23         __idname__ = "GAME_PT_data"
24         __label__ = "Data"
25
26         def draw(self, context):
27                 layout = self.layout
28                 ob = context.object
29                 game = context.game
30
31 class GAME_PT_physics(GameButtonsPanel):
32         __idname__ = "GAME_PT_physics"
33         __label__ = "Physics"
34
35         def poll(self, context):
36                 ob = context.active_object
37                 return ob and ob.game
38
39         def draw(self, context):
40                 layout = self.layout
41                 ob = context.active_object
42                 
43                 game = ob.game
44
45                 layout.itemR(game, "physics_type")
46                 layout.itemS()
47                 
48                 split = layout.split()
49                 col = split.column()
50                 
51                 col.itemR(game, "actor")
52                 
53                 col.itemR(game, "ghost")
54                 col.itemR(ob, "restrict_render", text="Invisible") # out of place but useful
55                 col = split.column()
56                 col.itemR(game, "do_fh", text="Use Material Physics")
57                 col.itemR(game, "rotation_fh", text="Rotate From Normal")
58                 col.itemR(game, "no_sleeping")
59                 
60                 layout.itemS()
61                 split = layout.split()
62                 col = split.column()
63                 col.itemL(text="Attributes:")
64                 colsub = col.column(align=True)
65                 colsub.itemR(game, "mass")
66                 colsub.itemR(game, "radius")
67                 colsub.itemR(game, "form_factor")
68                 col.itemS()
69                 col.itemL(text="Damping:")
70                 colsub = col.column(align=True)
71                 colsub.itemR(game, "damping", text="Translation", slider=True)
72                 colsub.itemR(game, "rotation_damping", text="Rotation", slider=True)
73                 
74                 col = split.column()
75                 
76                 col.itemL(text="Velocity:")
77                 colsub = col.column(align=True)
78                 colsub.itemR(game, "minimum_velocity", text="Minimum")
79                 colsub.itemR(game, "maximum_velocity", text="Maximum")
80                 col.itemS()
81                 col.itemR(game, "anisotropic_friction")
82                 
83                 colsub = col.column()
84                 colsub.active = game.anisotropic_friction
85                 colsub.itemR(game, "friction_coefficients", text="", slider=True)
86                 
87                 layout.itemS()
88                 split = layout.split()
89                 sub = split.column()
90                 sub.itemL(text="Lock Translation:")
91                 sub.itemR(game, "lock_x_axis", text="X")
92                 sub.itemR(game, "lock_y_axis", text="Y")
93                 sub.itemR(game, "lock_z_axis", text="Z")
94                 sub = split.column()
95                 sub.itemL(text="Lock Rotation:")
96                 sub.itemR(game, "lock_x_rot_axis", text="X")
97                 sub.itemR(game, "lock_y_rot_axis", text="Y")
98                 sub.itemR(game, "lock_z_rot_axis", text="Z")
99
100
101 class GAME_PT_collision_bounds(GameButtonsPanel):
102         __idname__ = "GAME_PT_collision_bounds"
103         __label__ = "Collision Bounds"
104
105         def poll(self, context):
106                 ob = context.active_object
107                 return ob and ob.game
108         
109         def draw_header(self, context):
110                 layout = self.layout
111                 ob = context.active_object
112                 game = ob.game
113
114                 layout.itemR(game, "use_collision_bounds", text="")
115         
116         def draw(self, context):
117                 layout = self.layout
118                 
119                 ob = context.scene.objects[0]
120                 game = ob.game
121                 layout.active = game.use_collision_bounds
122                 
123                 
124                 
125                 layout.itemR(game, "collision_bounds", text="Bounds")
126                 
127                 split = layout.split()
128                 sub = split.column()
129                 sub.itemR(game, "collision_compound", text="Compound")
130                 sub = split.column()
131                 sub.itemR(game, "collision_margin", text="Margin", slider=True)
132
133
134 bpy.types.register(GAME_PT_context_game)
135 bpy.types.register(GAME_PT_data)
136 bpy.types.register(GAME_PT_physics)
137 bpy.types.register(GAME_PT_collision_bounds)