コード例 #1
0
ファイル: Gui.py プロジェクト: skg44444/pyOpenGL
def slider(count, label, value, minvalue, maxvalue):
    if count == 1:
        _, value = imgui.slider_float(label, value, minvalue, maxvalue, "%.0f", 1.0)
        return value
    elif count == 2:
        _, value = imgui.slider_float2(label, *value, minvalue, maxvalue, "%.0f", 1.0)
        return value
    elif count == 3:
        _, value = imgui.slider_float3(label, *value, minvalue, maxvalue, "%.0f", 1.0)
        return value
コード例 #2
0
    def draw_scene_gui(self):
        if not self.scene_controls:
            return
        _, opened = imgui.begin("Scene", True)
        if not opened:
            self.scene_controls = False
        
        changed, new_color = imgui.color_edit4('object', *self.object_color)
        if changed or self.load_scene:
            [body.get_shape().set_color(np.array(new_color)) for body in self.system.bodies]
            self.object_color = new_color

        changed, new_color = imgui.color_edit4('obs', *self.obstacle_color)
        if changed or self.load_scene:
            [o.get_shape().set_color(np.array(new_color)) for o in self.system.obstacles]
            self.obstacle_color = new_color

        changed, new_pos = imgui.slider_float3('light', *self.light_pos, -10.0, 10.0)
        if changed or self.load_scene:
            self.light_pos = new_pos

        self.load_scene = True

        imgui.end()
コード例 #3
0
ファイル: root.py プロジェクト: indigames/pyxieTutorials
        _particle.set_dynamic_input(_handle, _dynamic)
        _particle.set_location(_handle, _position[0], _position[1],
                               _position[2])
        _particle.set_scale(_handle, _scale[0], _scale[1], _scale[2])

    changed, _show_enabled = imgui.checkbox("Show", _show_enabled)
    if changed is True:
        _particle.set_shown(_handle, _show_enabled, True)
    imgui.same_line()
    changed, _loop_enabled = imgui.checkbox("Loop", _loop_enabled)
    if changed is True:
        _particle.set_loop(_handle, _loop_enabled)

    changed, _position = imgui.slider_float3("Position",
                                             *_position,
                                             min_value=-10.0,
                                             max_value=10.0,
                                             format="%.0f",
                                             power=1)
    if changed is True:
        _particle.set_location(_handle, _position[0], _position[1],
                               _position[2])

    changed, _rotation = imgui.slider_float3("Rotation",
                                             *_rotation,
                                             min_value=0.0,
                                             max_value=3.14 * 2,
                                             format="%.2f",
                                             power=1)
    if changed is True:
        _particle.set_rotation(_handle, _rotation[0], _rotation[1],
                               _rotation[2])
コード例 #4
0
def draw_ui():
    """ Draws the imgui UI """
    global g_cube
    global g_cam
    global g_light_1
    global g_light_color_1
    global g_light_2
    global g_light_color_2
    global g_light_3
    global g_light_color_3
    global g_light_4
    global g_light_color_4
    global g_ambi_color
    global g_spec_color
    global g_fog_color
    global g_fog_density
    global g_fog_height
    global g_fog_max

    global g_move_string

    btn_w = 25
    imgui.set_window_font_scale(1.2)

    _, g_cam = imgui.slider_float3(
        "Camera Position", *g_cam, min_value=-20.0, max_value=150.0)
    g_cam = list(g_cam)

    expanded, _ = imgui.collapsing_header("Controls", True)
    if expanded:
        # Rubiks Cube Moves
        imgui.begin_group()
        imgui.text("Moves:")

        add_move_buttons("F", g_cube.move_f, btn_w)
        imgui.same_line(spacing=20)
        add_move_buttons("B", g_cube.move_b, btn_w)
        add_move_buttons("R", g_cube.move_r, btn_w)
        imgui.same_line(spacing=20)
        add_move_buttons("L", g_cube.move_l, btn_w)
        add_move_buttons("U", g_cube.move_u, btn_w)
        imgui.same_line(spacing=20)
        add_move_buttons("D", g_cube.move_d, btn_w)

        imgui.end_group()

        imgui.same_line(spacing=50)

        # Cube Rotations
        imgui.begin_group()
        imgui.text("Rotations:")
        add_move_buttons("x", g_cube.rotate_x, btn_w)
        add_move_buttons("y", g_cube.rotate_y, btn_w)
        add_move_buttons("z", g_cube.rotate_z, btn_w)
        imgui.end_group()

        _, g_move_string = imgui.core.input_text("", g_move_string, 64)
        imgui.same_line(spacing=10)
        clicked = imgui.button("Perform")
        if clicked:
            parse_moves()

    expanded, _ = imgui.collapsing_header("View Settings", True)
    if expanded:
        # Light 1
        expanded, _ = imgui.collapsing_header("Light 1", True)
        if expanded:
            _, g_light_1 = imgui.slider_float3(
                "Position 1", *g_light_1, min_value=-20.0, max_value=20.0)
            _, g_light_color_1 = imgui.color_edit3("Colour 1", *g_light_color_1)
            g_light_1 = list(g_light_1)
            g_light_color_1 = list(g_light_color_1)
        # Light 2
        expanded, _ = imgui.collapsing_header("Light 2", True)
        if expanded:
            _, g_light_2 = imgui.slider_float3(
                "Position 2", *g_light_2, min_value=-20.0, max_value=20.0)
            _, g_light_color_2 = imgui.color_edit3("Colour 2", *g_light_color_2)
            g_light_2 = list(g_light_2)
            g_light_color_2 = list(g_light_color_2)
        # Light 3
        expanded, _ = imgui.collapsing_header("Light 3", True)
        if expanded:
            _, g_light_3 = imgui.slider_float3(
                "Position 3 ", *g_light_3, min_value=-20.0, max_value=20.0)
            _, g_light_color_3 = imgui.color_edit3("Colour 3", *g_light_color_3)
            g_light_3 = list(g_light_3)
            g_light_color_3 = list(g_light_color_3)
        # Light 4
        expanded, _ = imgui.collapsing_header("Light 4", True)
        if expanded:
            _, g_light_4 = imgui.slider_float3(
                "Position 4", *g_light_4, min_value=-20.0, max_value=20.0)
            _, g_light_color_4 = imgui.color_edit3("Colour 4", *g_light_color_4)
            g_light_4 = list(g_light_4)
            g_light_color_4 = list(g_light_color_4)
        # Other Light constants
        expanded, _ = imgui.collapsing_header("Other Lighting", True)
        if expanded:
            _, g_ambi_color = imgui.color_edit3("Ambient Light Colour",
                                                *g_ambi_color)
            _, g_spec_color = imgui.color_edit3("Specular Light Colour",
                                                *g_spec_color)
            g_ambi_color = list(g_ambi_color)
            g_spec_color = list(g_spec_color)
        expanded, _ = imgui.collapsing_header("Fog Settings", True)
        if expanded:
            _, g_fog_color = imgui.color_edit3("Fog Colour", *g_fog_color)
            g_fog_color = list(g_fog_color)
            _, g_fog_density = imgui.input_float("Fog Density Coefficient",
                                                 g_fog_density)
            _, g_fog_height = imgui.input_float("Fog Height Coefficient",
                                                g_fog_height)
            _, g_fog_max = imgui.input_float("Max Fog", g_fog_max)
コード例 #5
0
ファイル: modes-demo.py プロジェクト: yifan-hou/contact_modes
    def draw_scene_gui(self):
        imgui.begin("Scene", True)

        imgui.text('test:')

        changed0, self.solver_index = imgui.combo('solver', self.solver_index, 
                                                 self.solver_list)
        
        changed1, self.case_index = imgui.combo('case', self.case_index, 
                                                 self.case_list)

        if changed0 or changed1:
            self.load_scene = True
            new_scene = self.case_list[self.case_index]
            if 'box-case' in new_scene:
                self.build_mode_case(lambda: box_case(int(new_scene[-1])))
            if new_scene == 'peg-in-hole-4':
                self.build_mode_case(lambda: peg_in_hole(4))
            if new_scene == 'peg-in-hole-8':
                self.build_mode_case(lambda: peg_in_hole(8))
            if 'box-box' in new_scene:
                self.build_mode_case(lambda: box_box_case(int(new_scene[-1])))
            if new_scene == 'hand-football':
                self.build_mode_case(lambda: hand_football(False))
            if new_scene == 'hand-football-fixed':
                self.build_mode_case(lambda: hand_football(True))

        imgui.text('control:')
        changed, self.lattice_height = imgui.slider_float('height', self.lattice_height, 0, 500)
        changed, self.plot_gui = imgui.checkbox('plot', self.plot_gui)
        changed, self.max_steps = imgui.drag_float('max steps', self.max_steps,
                                                    1, 0, 200)
        changed, self.h = imgui.drag_float('h', self.h, 0.0001, 0, 0.05)

        imgui.text('render:')
        changed, self.alpha = imgui.slider_float('alpha', self.alpha, 0.0, 1.0)
        if changed or self.load_scene:
            self.renderer.opacity = self.alpha

        changed, self.peel_depth = imgui.slider_int(
            'peel', self.peel_depth, 0, self.renderer.max_peel_depth)
        if changed or self.load_scene:
            self.renderer.peel_depth = self.peel_depth

        changed, new_color = imgui.color_edit4('object', *self.object_color)
        if changed or self.load_scene:
            [body.set_color(np.array(new_color)) for body in self.system.bodies]
            self.object_color = new_color
        
        changed, new_scale = imgui.drag_float3('frame', 
                                               *self.frame_scale,
                                               0.005, 0.0, 5.0)
        if changed or self.load_scene:
            self.frame.set_radius(new_scale[0])
            self.frame.set_length(new_scale[1])
            self.frame.set_alpha(new_scale[2])
            self.frame_scale = new_scale

        changed, new_color = imgui.color_edit4('contact', *self.contact_color)
        if changed or self.load_scene:
            self.contact_spheres[0].set_color(np.array(new_color))
            self.contact_arrows[0].set_color(np.array(new_color))
            self.contact_color = new_color

        changed, new_color = imgui.color_edit4('separate', *self.separating_color)
        if changed or self.load_scene:
            self.contact_spheres[1].set_color(np.array(new_color))
            self.contact_arrows[1].set_color(np.array(new_color))
            self.separating_color = new_color

        changed, new_scale = imgui.drag_float('sphere r',
                                              self.contact_scale,
                                              0.005, 0.0, 1.0)
        if changed or self.load_scene:
            for sphere in self.contact_spheres:
                sphere.set_radius(self.contact_scale)
            self.contact_scale = new_scale
        
        changed, new_scale = imgui.drag_float4('vel', 
                                               *self.velocity_scale,
                                               0.005, 0.0, 100.0)
        if changed or self.load_scene:
            for arrow in self.contact_arrows:
                arrow.set_shaft_length(new_scale[0])
                arrow.set_shaft_radius(new_scale[1])
                arrow.set_head_length(new_scale[2])
                arrow.set_head_radius(new_scale[3])
            self.velocity_scale = new_scale

        changed, new_color = imgui.color_edit4('obs', *self.obstacle_color)
        if changed or self.load_scene:
            [o.set_color(np.array(new_color)) for o in self.system.obstacles]
            self.obstacle_color = new_color

        changed, new_pos = imgui.slider_float3('light', *self.light_pos, -10.0, 10.0)
        if changed or self.load_scene:
            self.light_pos = new_pos
        
        # changed, new_pos = imgui.slider_float3('cam', *self.cam_focus, -10.0, 10.0)
        # if changed or self.load_scene:
        #     self.cam_focus = new_pos

        changed, self.show_grid = imgui.checkbox('grid', self.show_grid)

        changed, self.big_lattice = imgui.checkbox('big lattice', self.big_lattice)

        changed, self.show_contact_frames = imgui.checkbox('frames', self.show_contact_frames)

        changed, self.show_contacts = imgui.checkbox('contacts', self.show_contacts)

        changed, self.show_velocities = imgui.checkbox('velocities', self.show_velocities)
        
        self.load_scene = False
        imgui.end()
コード例 #6
0
ファイル: imgui_test.py プロジェクト: xmshaka/ZeloEngine
 def on_gui(self):
     return
     imgui.slider_float3("Translation", 1, 2, 3, 0, 100)
     fps = imgui.get_io().framerate
     imgui.text("Application average {:>.3f} ms/frame {:>.1f} FPS".format(1000. / fps, fps))
コード例 #7
0
ファイル: root.py プロジェクト: indigames/pyxieTutorials
    if imgui.button("play"):
        sfxr_handle = igeSound.play(sfxr_preset,
                                    is_3d=True,
                                    position=position_3d,
                                    loop=True)
    imgui.same_line()
    if imgui.button("stop"):
        igeSound.stop(sfxr_handle)
    _, sfxr_preset = imgui.slider_int("preset",
                                      sfxr_preset,
                                      min_value=0,
                                      max_value=6,
                                      format="%d")
    position_changed, position_3d = imgui.slider_float3("position",
                                                        *position_3d,
                                                        min_value=0,
                                                        max_value=500,
                                                        format="%.1f",
                                                        power=1.0)
    if position_changed is True:
        igeSound.set3dSourcePosition(sfxr_handle, position_3d)
        igeSound.set3dAttenuation(sfxr_handle, igeSound.EXPONENTIAL_DISTANCE,
                                  0.25)
    imgui.pop_id()

    if imgui.button("Stop All"):
        igeSound.stopAll()

    imgui.end()

    imgui.render()
    impl.render(imgui.get_draw_data())