~codeforger/pypal/docs

« back to all changes in this revision

Viewing changes to pypal/body/compound.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:
3
3
import weakref
4
4
from body import Body
5
5
class Compound(Body):
 
6
    """ A Rigid Body With No Initial Geometry """
6
7
    def __init__(self, pos):
7
8
        """
8
 
        constructs a compound and adds it to the world
9
 
        
10
 
        pos: a 3 part tuple with x,y,z.
11
 
        size: a 3 part tuple with width, height, depth
12
 
        mass: the mass of the object, if mass is specified it will be used.
 
9
        Parameters:
 
10
          pos: ``float[3]`` The x, y, z position of the Compound body.
13
11
        """
14
12
        self.obj = _pal.lib.body_compound_create(c.c_float(pos[0]),c.c_float(pos[1]),c.c_float(pos[2]))
15
13
        self._body_base = _pal.lib.cast_compound_body_base(self.obj)
19
17
        x, y, z = self.get_position()
20
18
        return "A CompoundBody at : %.2f, %.2f, %.2f" % (x, y, z)
21
19
 
22
 
    def add_box(self,pos,mass,rotation=(0,0,0)):
23
 
        """adds a box geometry to the compound body"""
 
20
    def add_box(self, pos, mass=1.,rotation=(0,0,0)):
 
21
        """
 
22
        Adds a box geometry to the compound body.
 
23
 
 
24
        Parameters:
 
25
          pos: ``float[3]`` The x, y, z, positional offsett for the new geometry
 
26
          mass: ``float`` The mass of the new geometry 
 
27
        """
24
28
        _pal.lib.body_compound_add_box(self.obj, c.c_float(pos[0]), c.c_float(pos[1]), c.c_float(pos[2]), c.c_float(rotation[0]), c.c_float(rotation[1]), c.c_float(rotation[2]), c.c_float(pos[3]), c.c_float(pos[4]), c.c_float(pos[5]),c.c_float(mass))
25
29
 
26
 
    def add_sphere(self,pos,mass,rotation=(0,0,0)):
27
 
        """adds a sphere geometry to the compound body"""
 
30
    def add_sphere(self, pos, mass=1.,rotation=(0,0,0)):
 
31
        """
 
32
        Adds a sphere geometry to the compound body.
 
33
 
 
34
        Parameters:
 
35
          pos: ``float[3]`` The x, y, z, positional offsett for the new geometry
 
36
          mass: ``float`` The mass of the new geometry 
 
37
        """
28
38
        _pal.lib.body_compound_add_sphere(self.obj, c.c_float(pos[0]), c.c_float(pos[1]), c.c_float(pos[2]), c.c_float(rotation[0]), c.c_float(rotation[1]), c.c_float(rotation[2]), c.c_float(pos[3]),c.c_float(mass))
29
39
 
30
 
    def add_capsule(self,pos,mass,rotation=(0,0,0)):
31
 
        """adds a sphere geometry to the compound body"""
 
40
    def add_capsule(self, pos, mass=1.,rotation=(0,0,0)):
 
41
        """
 
42
        Adds a sphere geometry to the compound body.
 
43
 
 
44
        Parameters:
 
45
          pos: ``float[3]`` The x, y, z, positional offsett for the new geometry
 
46
          mass: ``float`` The mass of the new geometry 
 
47
        """
32
48
        _pal.lib.body_compound_add_capsule(self.obj, c.c_float(pos[0]), c.c_float(pos[1]), c.c_float(pos[2]), c.c_float(rotation[0]), c.c_float(rotation[1]), c.c_float(rotation[2]), c.c_float(pos[3]), c.c_float(pos[4]),c.c_float(mass))
33
49
 
34
 
    def add_convex(self,pos,points,mass,rotation=(0,0,0)):
35
 
        """adds a sphere geometry to the compound body"""
 
50
    def add_convex(self, pos, points, mass=1., rotation=(0,0,0)):
 
51
        """
 
52
        Adds a sphere geometry to the compound body.
 
53
 
 
54
        Parameters:
 
55
          pos: ``float[3]`` The x, y, z, positional offsett for the new geometry
 
56
          mass: ``float`` The mass of the new geometry 
 
57
        """
36
58
        CPoints = c.c_float * (len(points) * 3)
37
59
        cpoints = CPoints()
38
60
        for i in xrange(len(points)):