Exemple #1
0
    def __init__(self,
                 shapes,
                 dynamic,
                 object_type,
                 diameter=None,
                 phantom_vertices=None):
        # Create Thrift body.
        x = y = 0.0
        body = scene_if.Body(
            position=scene_if.Vector(x, y),
            angle=0.,
            shapes=shapes,
        )
        assert dynamic in [True, False]
        body.bodyType = (scene_if.BodyType.DYNAMIC
                         if dynamic else scene_if.BodyType.STATIC)

        self.set_object_type(object_type)
        if object_type is not None:
            obj_name = 'wall' if 'wall' in object_type else object_type
            shape_type = shapes_lib.get_builders()[obj_name].SHAPE_TYPE
            if shape_type:
                body.shapeType = shape_type
        if diameter is not None:
            body.diameter = diameter
        self.phantom_vertices = phantom_vertices

        # Set all class variables.
        self._thrift_body = body
        self._scene = None
        self.dynamic = dynamic
        color = (_role_to_color_name('DYNAMIC')
                 if dynamic else _role_to_color_name('STATIC'))
        self.set_color(color)
Exemple #2
0
    def __init__(self,
                 shapes,
                 dynamic,
                 object_type,
                 diameter=None,
                 phantom_vertices=None):
        # Create Thrift body.
        x = y = 0.0
        body = scene_if.Body(
            position=scene_if.Vector(x, y),
            angle=0.,
            linVelocity=scene_if.Vector(0.0, 0.0),
            angVelocity=0.0,
            shapes=shapes,
        )
        assert dynamic in [True, False]
        body.bodyType = (scene_if.BodyType.DYNAMIC
                         if dynamic else scene_if.BodyType.STATIC)

        if diameter is not None:
            body.diameter = diameter
        self.phantom_vertices = phantom_vertices

        # Set all class variables.
        self._thrift_body = body
        self._scene = None
        self.dynamic = dynamic
        color = (_role_to_color_name('DYNAMIC')
                 if dynamic else _role_to_color_name('STATIC'))
        self.set_object_type(object_type)
        self.set_color(color)