~codeforger/pypal/docs

« back to all changes in this revision

Viewing changes to pypal/body/body.py

  • Committer: Michael Rochester
  • Date: 2014-07-20 14:25:45 UTC
  • Revision ID: m.rochester93@googlemail.com-20140720142545-z14oaetu1ls4hy4s
updated some documentation and switched the implimentation of the character class to be a generic body.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
class Body(BodyBase):
6
6
    def set_position(self, pos, rot=(0, 0, 0)):
7
7
        """
8
 
        Sets the position of the object and its orientation.
 
8
        Sets the position of the body and its orientation.
9
9
 
10
10
        Parameters:
11
11
          pos: ``float[3]`` The x, y, z, position of the body.
15
15
 
16
16
    def set_orientation(self, rot):
17
17
        """
18
 
        Sets the rotation of the object.
 
18
        Sets the rotation of the body.
19
19
 
20
20
        Parameters:
21
21
          rot: ``float[3]`` The rx, ry, rz, rotation of the body.
24
24
 
25
25
    def apply_force(self, force, pos=None):
26
26
        """
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.
28
28
 
29
29
        Parameters:
30
30
          force: ``float[3]`` The x, y, z, force vector to be applied body.
36
36
        else:
37
37
            _pal.lib.body_apply_force(self._body, c.c_float(force[0]), c.c_float(force[1]), c.c_float(force[2]))
38
38
 
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):
 
40
        """
 
41
        Applies a torque to the body for a single step.
 
42
 
 
43
        Parameters:
 
44
          torque: ``float[3]`` The x, y, z torque vector to be applied
 
45
        """
 
46
        _pal.lib.body_apply_torque(self._body, c.c_float(torque[0]), c.c_float(torque[1]), c.c_float(torque[2]))
42
47
 
43
48
    def apply_impulse(self, impulse, pos=None):
44
49
        """
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.
46
51
 
47
52
        Parameters:
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]))
56
61
 
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."""
 
63
        """
 
64
        Applies an angular impulse to the body for a single step.
 
65
 
 
66
        Parameters:
 
67
          impulse: ``float[3]`` The rx, ry, rz, angular imulse vector to be applied body.
 
68
        """
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]))
60
70
 
61
71
 
62
72
    def get_linear_velocity(self):
63
 
        """Returns the linear velocity of the body."""
 
73
        """ Returns the linear velocity of the body. """
64
74
        ret = _pal.Vec3()
65
75
        _pal.lib.body_get_linear_velocity(self._body, ret)
66
76
        return [x for x in ret]
67
77
 
68
78
    def get_angular_velocity(self):
69
 
        """Returns the linear velocity of the body."""
 
79
        """ Returns the angular velocity of the body. """
70
80
        ret = _pal.Vec3()
71
81
        _pal.lib.body_get_angular_velocity(self._body, ret)
72
82
        return [x for x in ret]
73
83
 
74
84
    def set_linear_velocity(self, velocity):
75
 
        """sets the linear velocity og the object"""
 
85
        """
 
86
        Sets the linear velocity of the body.
 
87
 
 
88
        Parameters:
 
89
          velocity: ``float`` The x, y, z, velocity vectory to be set.
 
90
        """
76
91
        vec = _pal.Vec3()
77
92
        for i in range(3):
78
93
            vec[i] = velocity[i]
79
94
        _pal.lib.body_set_linear_velocity(self._body, vec)
80
95
 
81
96
    def set_angular_velocity(self, velocity):
82
 
        """sets the angular velocity og the object"""
 
97
        """
 
98
        Sets the angular velocity of the body.
 
99
 
 
100
        Parameters:
 
101
          velocity: ``float`` The rx, ry, rz, angular vectory to be set.
 
102
        """
83
103
        vec = _pal.Vec3()
84
104
        for i in range(3):
85
105
            vec[i] = velocity[i]
86
106
        _pal.lib.body_set_angular_velocity(self._body, vec)
87
107
        
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)
92
112
 
93
113
    def set_active(self,active):
94
 
        """Sets the body to active or not."""
 
114
        """
 
115
        Sets the body to active or not.
 
116
        
 
117
        Parameters:
 
118
          active: ``bool`` Weather the body should be active or not
 
119
        """
95
120
        _pal.lib.body_set_active(self._body, c.c_bool(active))
 
 
b'\\ No newline at end of file'