5
5
class Body(BodyBase):
6
6
def set_position(self, pos, rot=(0, 0, 0)):
8
Sets the position of the object and its orientation.
8
Sets the position of the body and its orientation.
11
11
pos: ``float[3]`` The x, y, z, position of the body.
25
25
def apply_force(self, force, pos=None):
27
Applies a force to the object for a single step at an optional offset in world coordinates.
27
Applies a force to the body for a single step at an optional offset in world coordinates.
30
30
force: ``float[3]`` The x, y, z, force vector to be applied body.
37
37
_pal.lib.body_apply_force(self._body, c.c_float(force[0]), c.c_float(force[1]), c.c_float(force[2]))
39
def apply_torque(self, force):
40
"""Applies a torque to the object for a single step."""
41
_pal.lib.body_apply_torque(self._body, c.c_float(force[0]), c.c_float(force[1]), c.c_float(force[2]))
39
def apply_torque(self, torque):
41
Applies a torque to the body for a single step.
44
torque: ``float[3]`` The x, y, z torque vector to be applied
46
_pal.lib.body_apply_torque(self._body, c.c_float(torque[0]), c.c_float(torque[1]), c.c_float(torque[2]))
43
48
def apply_impulse(self, impulse, pos=None):
45
Applies an impulse to the object for a single step at an optional offset in world coordinates.
50
Applies an impulse to the body for a single step at an optional offset in world coordinates.
48
53
impulse: ``float[3]`` The x, y, z, imulse vector to be applied body.
55
60
_pal.lib.body_apply_impulse(self._body, c.c_float(impulse[0]), c.c_float(impulse[1]), c.c_float(impulse[2]))
57
62
def apply_angular_impulse(self, impulse):
58
"""Applies an angular impulse to the object for a single step at an optional offset in world coordinates."""
64
Applies an angular impulse to the body for a single step.
67
impulse: ``float[3]`` The rx, ry, rz, angular imulse vector to be applied body.
59
69
_pal.lib.body_apply_angular_impulse(self._body, c.c_float(impulse[0]), c.c_float(impulse[1]), c.c_float(impulse[2]))
62
72
def get_linear_velocity(self):
63
"""Returns the linear velocity of the body."""
73
""" Returns the linear velocity of the body. """
65
75
_pal.lib.body_get_linear_velocity(self._body, ret)
66
76
return [x for x in ret]
68
78
def get_angular_velocity(self):
69
"""Returns the linear velocity of the body."""
79
""" Returns the angular velocity of the body. """
71
81
_pal.lib.body_get_angular_velocity(self._body, ret)
72
82
return [x for x in ret]
74
84
def set_linear_velocity(self, velocity):
75
"""sets the linear velocity og the object"""
86
Sets the linear velocity of the body.
89
velocity: ``float`` The x, y, z, velocity vectory to be set.
78
93
vec[i] = velocity[i]
79
94
_pal.lib.body_set_linear_velocity(self._body, vec)
81
96
def set_angular_velocity(self, velocity):
82
"""sets the angular velocity og the object"""
98
Sets the angular velocity of the body.
101
velocity: ``float`` The rx, ry, rz, angular vectory to be set.
84
104
for i in range(3):
85
105
vec[i] = velocity[i]
86
106
_pal.lib.body_set_angular_velocity(self._body, vec)
88
108
def is_active(self):
89
"""Returns true if the body is not asleep."""
109
""" Returns true if the body is not asleep. """
90
110
_pal.lib.body_is_active.restype = c.c_bool
91
111
return _pal.lib.body_is_active(self._body)
93
113
def set_active(self,active):
94
"""Sets the body to active or not."""
115
Sets the body to active or not.
118
active: ``bool`` Weather the body should be active or not
95
120
_pal.lib.body_set_active(self._body, c.c_bool(active))
b'\\ No newline at end of file'