예제 #1
0
    def __init__(self, gui):
        Framework.__init__(self, gui)

        ground = self.world.create_body()

        body = self.world.create_static_body(
            position=(0, -8),
            allow_sleep=False,
            shape_fixture=b2d.fixture_def(density=5.0),
            shapes=[
                b2d.polygon_shape((0.5, 10), (10, 0), 0),
                b2d.polygon_shape((0.5, 10), (-10, 0), 0),
                b2d.polygon_shape((10, 0.5), (0, 10), 0),
                b2d.polygon_shape((10, 0.5), (0, -10), 0),
            ]
        )

        pdef = b2d.particle_system_def(viscous_strength=100,spring_strength=0.0)
        self.psystem = self.world.create_particle_system(pdef)
        self.psystem.radius = 0.3
        self.psystem.damping = 0.2


        pgDef = b2d.particle_group_def(flags=b2d.ParticleFlag.waterParticle, 
                                      group_flags=b2d.ParticleGroupFlag.solidParticleGroup,
                                     strength=0.0)

        self.group = self.psystem.create_particle_group(pgDef)
예제 #2
0
파일: cli.py 프로젝트: peterfillmore/needle
    def __init__(self):
        Framework.__init__(self, 'cli')
        self._name = Constants.NAME
        self._prompt_template = '{color_main}{main}{color_module}[{module}]{color_reset} > '
        self._base_prompt = self._prompt_template.format(color_main=Colors.C,
                                                         main='',
                                                         color_module=Colors.O,
                                                         module=self._name,
                                                         color_reset=Colors.N)

        # Establish dynamic paths for framework elements
        self.path_app = Framework.path_app = sys.path[0]
        self.path_core = Framework.path_core = os.path.join(
            self.path_app, 'core')
        self.path_libs = Framework.path_libs = os.path.join(
            self.path_app, 'libs')
        self.path_modules = Framework.path_modules = os.path.join(
            self.path_app, 'modules')

        # Init framework
        self.options = self._global_options
        self._init_global_options()
        self._init_global_vars()
        self._init_home()
        self.show_banner()
        self.do_reload(None)
        self._history_load()
예제 #3
0
 def __init__(self, source):
     Framework.__init__(self)
     self.output_type = type(BaseMessage)
     self.input_type = type(BaseMessage)
     assert issubclass(source, Source)
     assert source.output_type == self.input_type
     self.next = source
     self.iterator_style = True
     info("using self.iterator_style = %s" % str(self.iterator_style))
예제 #4
0
    def __init__(self, source):

        info("init")
        Framework.__init__(self)
        self.output_type = type(BaseMessage)
        self.input_type = type(BaseMessage)
        assert issubclass(type(source), Source)
        assert source.output_type == self.input_type
        self.next = source
예제 #5
0
    def __init__(self):
        Framework.__init__(self)
        
        world = self.world

        ground = world.create_static_body(shapes=b2.Edge((-20, 0),( 20, 0))) 

        controller = world.create_buoyancy_controller(
                                        offset=15, normal=(0, 1), density=2, 
                                        linear_drag=2, angular_drag=1)
       
        # Create a few spheres to bob around
        for i in range(7):
            body = self.world.create_dynamic_body(
                    position=(-10+4.0*i, 20), 
                    fixtures=b2.Fixture(shape=b2.Circle(radius=1.0), 
                                density=1.0)
                    )

            controller.add_body(body)

        # Create a bridge, and add it to the controller
        num_planks = 30
        plank_bodies = create_bridge(self.world, ground, (1.0, 0.25), (-14.5, 5), num_planks, 0.2, 1)
        for body in plank_bodies:
            controller.add_body(body)

        # Create a circle underneath the bridge
        body = self.world.create_dynamic_body(
                position=(-10.0, 0), 
                fixtures=b2.Fixture(shape=b2.Circle(radius=1.0), 
                            density=1.0)
                )

        controller.add_body(body)

        # And finally, some triangles
        for i in range(5):
            body = self.world.create_dynamic_body(
                    position=(-10+3.0*i, 20), 
                    fixtures=b2.Fixture(
                                shape=b2.Polygon(
                                    vertices=[(-0.5,0),(0,-0.5),(0.5, 0.0)]),
                                density=1.0)
                    )

            controller.add_body(body)

        # And (really) finally this time, just something so we can be sure 
        # edges work, too.
        edge = world.create_dynamic_body(
                    fixtures=b2.Fixture(shape=b2.Edge((5, 0),(5, 3)),
                                density=1.0)
                    )
        controller.add_body(edge)
예제 #6
0
    def __init__(self):
        Framework.__init__(self)
        
        world = self.world

        # Turn off normal gravity
        world.gravity = (0, 0)

        ground = world.create_static_body(shapes=b2.Edge((-20, 0),( 20, 0))) 

        controller = world.create_gravity_controller(G=0.8, inv_sqr=True)
       
        # Create a few spheres to bob around
        for i in range(1,4):
            body = self.world.create_dynamic_body(
                    position=(0.25 * i, 2.0 + 7.5 * i),
                    fixtures=b2.Fixture(shape=b2.Circle(radius=0.25 * i), 
                                density=1.0),
                    bullet=True,
                    )

            controller.add_body(body)

        # Create a bridge, and add it to the controller
        num_planks = 30
        plank_bodies = create_bridge(self.world, ground, (1.0, 0.25), (-14.5, 5), num_planks, 0.2, 10)
        for body in plank_bodies:
            controller.add_body(body)

        # Create a circle underneath the bridge
        body = self.world.create_dynamic_body(
                position=(-10.0, 0), 
                fixtures=b2.Fixture(shape=b2.Circle(radius=1.0), 
                            density=10.0)
                )

        controller.add_body(body)

        # And finally, some triangles
        for i in range(5):
            body = self.world.create_dynamic_body(
                    position=(-10+3.0*i, 20), 
                    fixtures=b2.Fixture(shape=b2.Polygon(vertices=[(-0.5,0),(0,-0.5),(0.5, 0.0)]),
                                density=1.0)
                    )

            controller.add_body(body)
예제 #7
0
    def __init__(self, framework, method=None):
        super(Params, self).__init__()
        Framework.__init__(self, framework)

        self.method = method
        self.protpred_param = []
        self.protpred_eda_param = []
        self.meamt_param = []
        self.rw_param = []
        self.mcm_param = []
        self.ga_param = []
        self.rboa_param = []
        self.de_param = []
        self.eda_param = []
        self.ceda_param = []
        self.fgm_param = []

        self.__build_param_lists()
예제 #8
0
    def __init__(self, gui):
        Framework.__init__(self, gui)

        ground = self.world.create_body()

        body = self.world.create_dynamic_body(
            position=(0, 10),
            allow_sleep=False,
            shape_fixture=fixture_def(density=5.0),
            shapes=[
                polygon_shape((0.5, 10), (10, 0), 0),
                polygon_shape((0.5, 10), (-10, 0), 0),
                polygon_shape((10, 0.5), (0, 10), 0),
                polygon_shape((10, 0.5), (0, -10), 0),
            ]
        )

        self.joint = self.world.create_revolute_joint(body_a=ground, body_b=body,
                                                    local_anchor_a=(0, 10), local_anchor_b=(0, 0),
                                                    reference_angle=0, motor_speed=0.7 * math.pi,
                                                    enable_motor=True, max_motor_torque=1.0e8)
예제 #9
0
    def __init__(self, gui):
        Framework.__init__(self, gui)

        ground = self.world.create_body()

        body = self.world.create_dynamic_body(
            position=(0, 10),
            allow_sleep=False,
            shape_fixture=b2d.fixture_def(density=5.0),
            shapes=[
                b2d.polygon_shape((0.5, 10), (10, 0), 0),
                b2d.polygon_shape((0.5, 10), (-10, 0), 0),
                b2d.polygon_shape((10, 0.5), (0, 10), 0),
                b2d.polygon_shape((10, 0.5), (0, -10), 0),
            ]
        )

        self.joint = self.world.create_revolute_joint(body_a=ground, body_b=body,
                                                    local_anchor_a=(0, 10), local_anchor_b=(0, 0),
                                                    reference_angle=0, motor_speed=0.3 * math.pi,
                                                    enable_motor=True, max_motor_torque=5000)



        pdef = b2d.particle_system_def(viscous_strength=5.0,spring_strength=0.0)
        psystem = self.world.create_particle_system(pdef)
        psystem.radius = 0.1
        psystem.damping = 0.2


        shape = b2d.polygon_shape(box=(5.0,5.0),center=b2d.vec2(0,7.01),angle=0)
        pgDef = b2d.particle_group_def(flags=b2d.ParticleFlag.waterParticle, 
                                      group_flags=b2d.ParticleGroupFlag.solidParticleGroup,
                                 shape=shape,strength=0.0
                                 )

        group = psystem.create_particle_group(pgDef)
예제 #10
0
    def __init__(self, gui):
        Framework.__init__(self, gui)

        ground = self.world.create_body()

        body = self.world.create_static_body(
            position=(0, -10),
            allow_sleep=False,
            shape_fixture=b2d.fixture_def(density=5.0),
            shapes=[
                b2d.polygon_shape((3, 200), (200, 0), 0),
                b2d.polygon_shape((3, 200), (-200, 0), 0),
                b2d.polygon_shape((200, 3), (0, 200), 0),
                b2d.polygon_shape((200, 3), (0, -200), 0),
            ]
        )

        pdef = b2d.particle_system_def(viscous_strength=10,spring_strength=0.0,
            density=0.1)
        self.psystem = self.world.create_particle_system(pdef)
        self.psystem.radius = 0.2
        self.psystem.damping = 0.2


        empty_group = b2d.particle_group_def(flags=b2d.ParticleFlag.waterParticle, 
                                      group_flags=b2d.ParticleGroupFlag.solidParticleGroup & b2d.ParticleGroupFlag.particleGroupCanBeEmpty,
                                    )

        self.group = self.psystem.create_particle_group(empty_group)




        self.emitter_body = self.world.create_dynamic_body(
            position=(0, 0),
            allow_sleep=False,
            fixtures=b2d.fixture_def(
                density=1.0, 
                shape=b2d.polygon_shape(box=(3, 0.5))
            ),
        )


        if True:
            edef  = b2d.LinearEmitterDef()
            edef.body = self.emitter_body
            edef.transform = b2d.transform((0,0),0)
            edef.size = b2d.vec2(6,1)
            edef.velocity = b2d.vec2(0,1)
            edef.emite_rate = 2000
            edef.lifetime = 1.0
            self.emitter = b2d.LinearEmitter(self.psystem, self.group, edef)
        else:
            edef  = b2d.RadialEmitterDef()
            edef.position = b2d.vec2(3,-3)
            edef.inner_radius = 3.0
            edef.outer_radius = 5.0
            edef.velocity_magnitude = 200.0
            edef.emite_rate = 10
            edef.lifetime = 8.0
            edef.start_angle = 0 + math.pi
            edef.stop_angle = math.pi /4.0 + math.pi
            self.emitter = b2d.RadialEmitter(self.psystem, self.group, edef)
예제 #11
0
 def __init__(self):
     Framework.__init__(self)
예제 #12
0
 def __init__(self):
     Framework.__init__(self)
     self.output_type = type(BaseMessage)
     self.iterator_style = True
     info("using self.iterator_style = %s" % str(self.iterator_style))