def show_ui(self):
        super().show_ui()

        self.axial = imgui.slider_float(f'Strength##{self.ui_index}', self.axial, 0.0, 1.0)[1]
        #self.transverse = imgui.slider_float(f'Transverse Aberration##{self.ui_index}', self.transverse, 0.0, 1.0)[1]

        self.distance_scale = imgui.slider_float(f'Distance Scale##{self.ui_index}', self.distance_scale, 0.0, 0.1)[1]
Ejemplo n.º 2
0
 def drawUi(self):
     if imgui.tree_node("FreeCamera", imgui.TREE_NODE_DEFAULT_OPEN):
         _, self.yawDeg = imgui.slider_float("Yaw (Deg)", self.yawDeg,
                                             -180.00, 180.0)
         _, self.pitchDeg = imgui.slider_float("Pitch (Deg)", self.pitchDeg,
                                               -89.00, 89.0)
         imgui.tree_pop()
Ejemplo n.º 3
0
    def make_gui(self, width, height):
        imgui.begin("Lighting", True)

        ch, val = imgui.checkbox("Move sun", self._scene.time_enabled)
        if ch:
            self._scene.time_enabled = val

        ch, val = imgui.slider_float(
            "Roughness", self._scene.object.materials.values()[0].specular_tint, 0, 1
        )
        if ch:
            self._scene.object.materials.values()[0].specular_tint = val

        ch, val = imgui.slider_float(
            "Metallic", self._scene.object.materials.values()[0].metallic_tint, 0, 1
        )
        if ch:
            self._scene.object.materials.values()[0].metallic_tint = val

        ch, val = imgui.color_edit3(
            "Material colour", *self._scene.object.materials.values()[0].diffuse_tint
        )
        if ch:
            self._scene.object.materials.values()[0].diffuse_tint = np.array(val)

        ch, val = imgui.color_edit3("Sun colour", *self._scene.sun_color)
        if ch:
            self._scene.sun_color = np.array(val)

        ch, val = imgui.slider_float("Sun intensity", self._scene.sun_intensity, 0, 100)
        if ch:
            self._scene.sun_intensity = val
        imgui.end()
Ejemplo n.º 4
0
def update(dt, keyStateMap, mouseDelta):
    global g_sunPosition
    global g_sunAngle
    global g_globalAmbientLight
    global g_sunLightColour
    global g_sunAngle
    global g_updateSun
    global g_viewTarget
    global g_viewPosition
    global g_followCamOffset
    global g_followCamLookOffset

    if g_updateSun:
        g_sunAngle += dt * 0.25
        g_sunAngle = g_sunAngle % (2.0 * math.pi)

    g_sunPosition = lu.Mat3(
        lu.make_rotation_x(g_sunAngle)) * g_sunStartPosition

    g_sunLightColour = sampleKeyFrames(
        lu.dot(lu.normalize(g_sunPosition), vec3(0.0, 0.0, 1.0)),
        g_sunKeyFrames)
    g_globalAmbientLight = sampleKeyFrames(
        lu.dot(lu.normalize(g_sunPosition), vec3(0.0, 0.0, 1.0)),
        g_ambientKeyFrames)

    g_racer.update(dt, keyStateMap)

    # TODO 1.2: Make the camera look at the racer. Code for updating the camera should be done after the
    # racer, otherwise the offset will lag and it generally looks weird.

    if imgui.tree_node("Camera", imgui.TREE_NODE_DEFAULT_OPEN):
        _, g_followCamOffset = imgui.slider_float("FollowCamOffset ",
                                                  g_followCamOffset, 2.0,
                                                  100.0)
        _, g_followCamLookOffset = imgui.slider_float("FollowCamLookOffset",
                                                      g_followCamLookOffset,
                                                      0.0, 100.0)
        imgui.tree_pop()

    if imgui.tree_node("Racer", imgui.TREE_NODE_DEFAULT_OPEN):
        g_racer.drawUi()
        imgui.tree_pop()

    if imgui.tree_node("Terrain", imgui.TREE_NODE_DEFAULT_OPEN):
        g_terrain.drawUi()
        imgui.tree_pop()

    if imgui.tree_node("Lighting", imgui.TREE_NODE_DEFAULT_OPEN):
        _, g_globalAmbientLight = lu.imguiX_color_edit3_list(
            "GlobalAmbientLight", g_globalAmbientLight
        )  #, imgui.GuiColorEditFlags_Float);// | ImGuiColorEditFlags_HSV);
        _, g_sunLightColour = lu.imguiX_color_edit3_list(
            "SunLightColour", g_sunLightColour
        )  #, imgui.GuiColorEditFlags_Float);// | ImGuiColorEditFlags_HSV);
        _, g_sunAngle = imgui.slider_float("SunAngle", g_sunAngle, 0.0,
                                           2.0 * math.pi)
        _, g_updateSun = imgui.checkbox("UpdateSun", g_updateSun)
        imgui.tree_pop()
Ejemplo n.º 5
0
    def show_ui(self):
        super().show_ui()

        self.power = imgui.slider_float(f'Strength##{self.ui_index}',
                                        self.power, 0.0, 5.0)[1]
        self.threshold = imgui.slider_float(f'Threshold##{self.ui_index}',
                                            self.threshold,
                                            0.0,
                                            16.0,
                                            power=2.0)[1]
Ejemplo n.º 6
0
 def ui(self):
     """Create the imgui UI node to control lighting
     """
     if imgui.tree_node("Lighting", imgui.TREE_NODE_DEFAULT_OPEN):
         _, self.sun_yaw = imgui.slider_float("Yaw (Deg)", self.sun_yaw,
                                              -180.00, 180.0)
         _, self.sun_pitch = imgui.slider_float("Pitch (Deg)",
                                                self.sun_pitch, -180.00,
                                                180.0)
         imgui.tree_pop()
Ejemplo n.º 7
0
 def ui(self):
     """Basic UI node to adjust yaw, pitch, and distance
     Yaw can also be controlled with arrow keys (see above)
     """
     if imgui.tree_node("Camera", imgui.TREE_NODE_DEFAULT_OPEN):
         _, self.yaw = imgui.slider_float("Yaw (Deg)", self.yaw, -180.00,
                                          180.0)
         _, self.pitch = imgui.slider_float("Pitch (Deg)", self.pitch,
                                            -89.00, 89.0)
         _, self.distance = imgui.slider_float("Distance", self.distance,
                                               1.00, 1000.0)
         imgui.tree_pop()
Ejemplo n.º 8
0
    def ui(self):
        """Super lame UI for adjusting the position of the object
        """
        if True:
            return

        if imgui.tree_node("Object", imgui.TREE_NODE_DEFAULT_OPEN):
            _, x = imgui.slider_float("X", self.position[0], -10, 10)
            _, y = imgui.slider_float("Y", self.position[1], -10, 10)
            _, z = imgui.slider_float("Z", self.position[2], -10, 10)
            self.position = gltypes.vec3(x, y, z)
            imgui.tree_pop()
Ejemplo n.º 9
0
def update(world: World, g_renderingSystem: RenderingSystem, dt, keyStateMap,
           mouseDelta):

    if world.should_update_sun:
        world.sun_angle += dt * 0.25
        world.sun_angle = world.sun_angle % (2.0 * math.pi)

    world.sun_position = lu.Mat3(lu.make_rotation_x(
        world.sun_angle)) * world.sun_start_position

    world.sunlight_color = sampleKeyFrames(
        lu.dot(lu.normalize(world.sun_position), vec3(0.0, 0.0, 1.0)),
        world.sun_keyframes)
    world.global_ambient_light = sampleKeyFrames(
        lu.dot(lu.normalize(world.sun_position), vec3(0.0, 0.0, 1.0)),
        world.ambient_keyframes)

    world.racer.update(dt, keyStateMap)

    world.view_position = world.racer.position - \
                          (world.racer.heading * world.follow_cam_offset) + \
                          [0, 0, world.follow_cam_offset]
    world.view_target = world.racer.position + vec3(
        0, 0, world.follow_cam_look_offset)

    if imgui.tree_node("Camera", imgui.TREE_NODE_DEFAULT_OPEN):
        _, world.follow_cam_offset = imgui.slider_float(
            "FollowCamOffset ", world.follow_cam_offset, 2.0, 100.0)
        _, world.follow_cam_look_offset = imgui.slider_float(
            "FollowCamLookOffset", world.follow_cam_look_offset, 0.0, 100.0)
        imgui.tree_pop()

    if imgui.tree_node("Racer", imgui.TREE_NODE_DEFAULT_OPEN):
        world.racer.draw_ui()
        imgui.tree_pop()

    if imgui.tree_node("Terrain", imgui.TREE_NODE_DEFAULT_OPEN):
        world.terrain.draw_ui()
        imgui.tree_pop()

    if imgui.tree_node("Lighting", imgui.TREE_NODE_DEFAULT_OPEN):
        _, world.global_ambient_light = lu.imguiX_color_edit3_list(
            "GlobalAmbientLight", world.global_ambient_light
        )  # , imgui.GuiColorEditFlags_Float);// | ImGuiColorEditFlags_HSV);
        _, world.sunlight_color = lu.imguiX_color_edit3_list(
            "SunLightColour", world.sunlight_color
        )  # , imgui.GuiColorEditFlags_Float);// | ImGuiColorEditFlags_HSV);
        _, world.sun_angle = imgui.slider_float("SunAngle", world.sun_angle,
                                                0.0, 2.0 * math.pi)
        _, world.should_update_sun = imgui.checkbox("UpdateSun",
                                                    world.should_update_sun)
        imgui.tree_pop()
Ejemplo n.º 10
0
    def show_ui(self):
        super().show_ui()

        self.inner_distance = imgui.slider_float(
            f'Start Distance##{self.ui_index}', self.inner_distance, -1.0,
            3.0)[1]
        self.outer_distance = imgui.slider_float(
            f'End Distance##{self.ui_index}', self.outer_distance, -1.0,
            3.0)[1]
        #self.strength = imgui.slider_float(f'Strength##{self.ui_index}', self.strength, 0.0, 2.0)[1]
        #self.scale = imgui.slider_float2(f'Scale##{self.ui_index}', self._scale[0], self._scale[1], 0.0,4.0)[1]

        self.color = imgui.color_edit4(f'Color##{self.ui_index}',
                                       *self.color)[1]
Ejemplo n.º 11
0
def drawUi(width, height):
    global g_triangleVerts
    global g_cameraDistance
    global g_cameraYawDeg
    global g_cameraPitchDeg
    global g_yFovDeg

    imgui.push_item_width(200)
    _, g_cameraDistance = imgui.slider_float("CameraDistance",
                                             g_cameraDistance, 1.00, 20.0)
    _, g_yFovDeg = imgui.slider_float("Y-Fov (Deg)", g_yFovDeg, 1.00, 90.0)
    _, g_cameraYawDeg = imgui.slider_float("Camera Yaw (Deg)", g_cameraYawDeg,
                                           -180.00, 180.0)
    _, g_cameraPitchDeg = imgui.slider_float("Camera Pitch (Deg)",
                                             g_cameraPitchDeg, -89.00, 89.0)
    imgui.pop_item_width()
Ejemplo n.º 12
0
 def show_ui(self):
     super().show_ui()
     self.white_point = imgui.slider_float(f'Threshold##{self.ui_index}',
                                           self.white_point,
                                           0.0,
                                           10.0,
                                           power=2.0)[1]
Ejemplo n.º 13
0
    def draw_hand_gui(self):
        imgui.begin("Hand", True)

        changed, new_color = imgui.color_edit4('hand', *self.hand_color)
        if changed or self.load_hand:
            self.hand.set_color(np.array(new_color))
            self.hand_color = new_color

        changed, new_color = imgui.color_edit4('baton', *self.baton_color)
        if changed or self.load_hand:
            self.baton.set_color(np.array(new_color))
            self.baton_color = new_color

        imgui.text('state')
        dofs = self.system.get_state()
        for i in range(self.system.num_dofs()):
            changed, value = imgui.slider_float('b%d' % i, dofs[i], -np.pi, np.pi)
            if changed:
                dofs[i] = value
            if i < self.hand.num_dofs():
                imgui.same_line()
                if imgui.button('step###%d'%i):
                    self.close(i)
                    dofs = self.system.get_state()
        self.system.set_state(dofs)
        
        self.load_hand = False
        imgui.end()
Ejemplo n.º 14
0
 def show_ui(self):
     super().show_ui()
     self.strength = imgui.slider_float(f'Strength##{self.ui_index}',
                                        self.strength, 0.0, 1.0)[1]
     self.shadow_color = imgui.color_edit3(f'Shadow Color##{self.ui_index}',
                                           *self.shadow_color)[1]
     self.highlight_color = imgui.color_edit3(
         f'Highlight Color##{self.ui_index}', *self.highlight_color)[1]
Ejemplo n.º 15
0
    def update(self, deltaTime):
        # Base game class will update all gameobjects in list.
        super().update( deltaTime )
        self.totalTimeElapsed += deltaTime

        # Debug info displayed using imgui.
        imgui.begin( "Dissolve", True )
        changed, self.dissolvePercentage = imgui.slider_float( "Percentage", self.dissolvePercentage, 0, 1 )
        imgui.end()
Ejemplo n.º 16
0
 def drawUi(self):
     # height scale is read-only as it is not run-time changable (since we use it to compute normals at load-time)
     imgui.label_text("terrainHeightScale", "%0.2f" % self.heightScale)
     #_,self.heightScale = imgui.slider_float("terrainHeightScale", self.heightScale, 1.0, 100.0)
     _, self.textureXyScale = imgui.slider_float("terrainTextureXyScale",
                                                 self.textureXyScale, 0.01,
                                                 10.0)
     _, self.renderWireFrame = imgui.checkbox("WireFrame",
                                              self.renderWireFrame)
Ejemplo n.º 17
0
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
Ejemplo n.º 18
0
 def onUpdateUIOverlay(self, overlay):
     #return
     if imgui.collapsing_header("Settings"):
         res, value = imgui.slider_float("LOD bias",
                                         self.uboVS['lodBias'].x, 0.0,
                                         self.texture.mipLevels)
         #res = False
         if res:
             overlay.updated = True
             self.uboVS['lodBias'].x = value
             self.updateUniformBuffers()
Ejemplo n.º 19
0
    def menu(self):

        imgui.new_frame()

        #menu bar
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Ctrl+Q', False, True)

                if clicked_quit:
                    glfw.set_window_should_close(self.window, True)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Demo window", True)
        imgui.text('ImGuiDemo')
        imgui.text_colored("* hold Left Mouse Button and drag to translate",
                           0.2, 1., 0.)
        imgui.text_colored("* use scroll wheel to zoom", 0.4, 1., 0.)
        imgui.text_colored("* press SPACE to toggle animation", 0.6, 1., 0.)

        changed, self.ui.animate = imgui.checkbox("Animate", self.ui.animate)
        changed, self.ui.gamma = imgui.slider_float("Gamma", self.ui.gamma,
                                                    0.3, 3.3)
        changed, self.ui.blue = imgui.slider_float("Blue", self.ui.blue, 0.0,
                                                   1.0)
        imgui.text("Animation Angle: {:0.2f}".format(self.ui.theta /
                                                     (2.0 * np.pi) * 360.0))
        changed, self.ui.speed = imgui.slider_float("Speed", self.ui.speed,
                                                    0.0, np.pi / 2.0)

        #transfer changed variables to shader programs
        self.quad['blue'] = self.ui.blue
        self.quad['gamma'] = self.ui.gamma

        imgui.end()
Ejemplo n.º 20
0
    def render_ui(self):
        imgui.new_frame()
        imgui.begin("camera")

        is_change_y, self.u_campos.y = imgui.slider_float(
            "y", self.u_campos.y, -3.14159 * 4.0, 3.14159 * 4.0)
        if is_change_y:
            self.uniform("u_campos", self.u_campos)

        imgui.end()
        imgui.render()
        self.imgui.render(imgui.get_draw_data())
Ejemplo n.º 21
0
    def plan(self):
        ''' choose an action which optimizes our speed around the track '''
        x, y = self.car.x, self.car.y
        closesti = np.argmin((self.track[:, 0] - x)**2 +
                             (self.track[:, 1] - y)**2)
        tx, ty, nx, ny, nk = self.track[closesti]
        c, s = np.cos(self.car.theta), np.sin(self.car.theta)
        ye = (x - tx) * nx + (y - ty) * ny
        Cp = -s * nx + c * ny
        Sp = s * ny + c * nx
        imgui.slider_float2("psie", Cp, Sp, -1, 1)
        imgui.slider_float("ye", ye, -2, 2)

        Np = 6
        path = np.zeros((Np + 1, 2))
        pts = []
        bestdk, R = self.search(self.car, self.k, closesti, Np, 0.11, path,
                                pts)
        imgui.slider_float("R", R, -10, 10)
        imgui.slider_float("searched pts", len(pts), 0, 1024)
        #for dk in np.linspace(-3, 3, 21):
        #    # R, posk = self.shoot(closesti, 30, 0.05, self.k + dk)
        #    poss.append(posk)
        #    imgui.slider_float("R_%0.1f" % dk, R, -10, 10)
        #    if bestR is None or R > bestR:
        #        bestdk, bestR = dk, R
        self.shots = [path, np.array(pts)]

        return np.clip(self.k + bestdk, -2, 2)
Ejemplo n.º 22
0
async def filter_box_window(filter_box_state: FilterBoxState,
                            ui_settings) -> Eff[[ACTIONS], IMGui[None]]:

    name = None
    if filter_box_state.filter_state.is_Filter():
        filter_id = filter_box_state.filter_state.filter_id
        filter = available_filters[filter_id]
        name = "{f_name} (id={id})###{id}".format(f_name=filter.name,
                                                  id=filter_box_state.id_)
    else:
        name = "Filter###{id}".format(id=filter_box_state.id_)

    with window(name=name):

        # # filter type combo
        # filter_ids = sorted(available_filters.keys())
        # o_filter_id = None if filter_box_state.filter_state.is_NoFilter() else  filter_box_state.filter_state.filter_id

        # changed, o_filter_id = str_combo_with_none("filter", o_filter_id, filter_ids)
        # if changed:
        # 	if o_filter_id != None:
        # 		await emit( SetFilter(id_=filter_box_state.id_, filter_id=o_filter_id) )
        # 	else:
        # 		await emit( UnsetFilter(id_=filter_box_state.id_) )

        # param inputs
        slider_power = ui_settings['filter_slider_power']

        if filter_box_state.filter_state.is_Filter():

            filter_id = filter_box_state.filter_state.filter_id
            filter_params = filter_box_state.filter_state.params
            filter = available_filters[filter_id]

            for param_name in sorted(filter.func_sig):
                changed, new_param_val = im.slider_float(
                    param_name,
                    filter_params[param_name],
                    min_value=0.001,
                    max_value=95.,
                    power=slider_power)
                if changed:
                    await emit(
                        FilterAction.SetParam(id_=filter_box_state.id_,
                                              name=param_name,
                                              value=new_param_val))

        else:
            im.text("No filter selected")

        return util.get_window_rect()
Ejemplo n.º 23
0
def transformGuiOverlay(locationX, locationY, angle, color):

    # start new frame context
    imgui.new_frame()

    # open new window context
    imgui.begin("2D Transformations control", False,
                imgui.WINDOW_ALWAYS_AUTO_RESIZE)

    # draw text label inside of current window
    imgui.text("Configuration sliders")

    edited, locationX = imgui.slider_float("location X", locationX, -1.0, 1.0)
    edited, locationY = imgui.slider_float("location Y", locationY, -1.0, 1.0)
    edited, angle = imgui.slider_float("Angle", angle, -np.pi, np.pi)
    edited, color = imgui.color_edit3("Modulation Color", color[0], color[1],
                                      color[2])
    if imgui.button("Random Modulation Color!"):
        color = (random.uniform(0.0, 1.0), random.uniform(0.0, 1.0),
                 random.uniform(0.0, 1.0))
    imgui.same_line()
    if imgui.button("White Modulation Color"):
        color = (1.0, 1.0, 1.0)

    global controller
    edited, checked = imgui.checkbox("wireframe", not controller.fillPolygon)
    if edited:
        controller.fillPolygon = not checked

    # close current window context
    imgui.end()

    # pass all drawing comands to the rendering pipeline
    # and close frame context
    imgui.render()
    imgui.end_frame()

    return locationX, locationY, angle, color
Ejemplo n.º 24
0
    def render_map(self):
        imgui.begin("map")
        imgui.slider_float("x (m)", self.track[self.i, 0] * ceiltrack.CEIL_HEIGHT * 0.3048, -80, 80)
        imgui.slider_float("y (m)", self.track[self.i, 1] * ceiltrack.CEIL_HEIGHT * 0.3048, -80, 80)
        imgui.slider_float("theta", self.track[self.i, 2] % (np.pi*2), -7, 7)
        imgui.slider_float("x (grid)", self.track[self.i, 0] / ceiltrack.X_GRID, -10, 10)
        imgui.slider_float("y (grid)", self.track[self.i, 1] / ceiltrack.X_GRID, -10, 10)

        dl = imgui.get_window_draw_list()
        pos = imgui.get_cursor_screen_pos()
        siz = imgui.get_content_region_available()
        if siz[1] == 0:
            siz = [400, 300]
        # just use a fixed size
        w = siz[0]
        imgui.image_button(self.floortex, w, w/2, frame_padding=0)
        # imgui.image_button(self.floortex, siz[0], siz[0])
        origin = [pos[0], pos[1]]
        scale = 50 * ceiltrack.CEIL_HEIGHT * w/1000
        trackcolor = imgui.get_color_u32_rgba(0.3, 0.5, 0.3, 1)
        for i in range(1, self.i):
            dl.add_line(
                origin[0] + scale * self.track[i-1, 0],
                origin[1] + scale * self.track[i-1, 1],
                origin[0] + scale * self.track[i, 0],
                origin[1] + scale * self.track[i, 1],
                trackcolor, 1.5)

        carcolor = imgui.get_color_u32_rgba(0, 1, 0.6, 1)
        B = self.track[self.i]
        dl.add_line(
            origin[0] + scale * B[0],
            origin[1] + scale * B[1],
            origin[0] + scale * (B[0] + np.cos(B[2])),
            origin[1] + scale * (B[1] - np.sin(B[2])),
            carcolor, 1.5)

        imgui.end()
Ejemplo n.º 25
0
    def render_controllearn(self):
        _, self.learn_controls = imgui.begin("control system tuning", True)
        if not self.learn_controls:
            imgui.end()
            return

        n = max(self.i + 1, 10)
        # use history from 0..i to learn motor model
        # dv/dt = k1*DC*V + k2*DC*v + k3*v
        XTX = np.eye(2)
        XTY = np.array([5., 1])
        v = self.controlstate[1:n, 3].copy()
        dv = v.copy()
        dv[1:] = dv[1:] - dv[:-1]
        u = self.controls[:n - 1, 0]
        DC = np.abs(u / 127.0)
        V = (1 + np.sign(u)) / 2
        dt = 1.0 / 30  # FIXME
        X = np.vstack([DC * V, -DC * v])
        Y = dv / dt
        XTX += np.dot(X, X.T)
        XTY += np.dot(X, Y.T)
        ks = np.linalg.lstsq(XTX, XTY, rcond=None)[0]
        imgui.slider_float("motor k1", ks[0], 0, 10)
        imgui.slider_float("motor k2", ks[1], 0, 2)

        imgui.plot_lines("dv/dt", dv / dt)
        imgui.plot_lines("DC*V", DC * V)
        imgui.plot_lines("v", v)
        imgui.plot_lines("step response",
                         motor_step_response([ks[0], ks[1], 0], 120))

        # let's also solve for steering ratios
        XTX = np.eye(2)
        XTY = np.array([1., 0])
        w = self.controlstate[1:n, 4].copy()
        u = self.controls[:n - 1, 1] / 127.0
        X = np.vstack([u * v, v])
        XTX += np.dot(X, X.T)
        XTY += np.dot(X, w.T)
        ks = np.linalg.lstsq(XTX, XTY, rcond=None)[0]
        imgui.slider_float("servo ratio", ks[0], -2, 2)
        imgui.slider_float("servo bias", ks[1], -1, 1)

        imgui.end()
Ejemplo n.º 26
0
    def __init__(self, export, uniform, type_str: str):
        self.name = export["name"]
        self.min = export["min"]
        self.max = export["max"]
        self.power = export.get("power", 1.0)

        self.uniform = uniform

        self._draw = {
            "float":
            lambda: imgui.slider_float(self.name, self.uniform.value, self.min,
                                       self.max, "%.5f", self.power),
            "int":
            lambda: imgui.slider_int(self.name, self.uniform.value, self.min,
                                     self.max)
        }[type_str]
Ejemplo n.º 27
0
 def draw_layers_window(self, width, height):
     imgui.set_next_window_size(width / 6, height / 4)
     imgui.set_next_window_position(width * 5 / 6, height * 2 / 4)
     imgui.begin("Layers", flags=default_flags)
     _, self.show_grid = imgui.checkbox("Show Grid", self.show_grid)
     _, self.show_points = imgui.checkbox("Show Places", self.show_points)
     _, self.show_lines = imgui.checkbox("Show Connections",
                                         self.show_lines)
     _, self.point_size = imgui.slider_int("Point Size",
                                           self.point_size,
                                           min_value=1,
                                           max_value=6)
     clicked, self.font_scale = imgui.slider_float("Font Scale",
                                                   self.font_scale, 0.1,
                                                   0.9, "%.1f")
     if clicked:
         self.update_font_scale(self.font_scale)
     imgui.end()
Ejemplo n.º 28
0
    def Vplan(self):
        w, h = imgui.get_window_size()
        h = self.V.shape[1] * w / self.V.shape[2]
        _, self.lookstep = imgui.slider_float("lookahead step",
                                              self.lookstep,
                                              0,
                                              1,
                                              power=1.5)
        imgui.image(self.Vtex[int(48 * self.car.theta / np.pi % 96)], w, h)
        shots = []
        c = self.car
        bestk = None
        for i in range(50):
            k, v, c = self.bestkv(c, self.lookstep)
            if bestk is None:
                bestk = k
            shots.append([c.x, c.y])
        self.shots = np.array([shots])

        return bestk
Ejemplo n.º 29
0
def on_draw(dt):
    # GUI
    imguiRenderer.process_inputs()
    imgui.new_frame()

    if imgui.begin_main_menu_bar():
        if imgui.begin_menu("File", True):
            clicked, selected = imgui.menu_item("Quit", 'ESC', False, True)
            if clicked:
                exit(0)
            imgui.end_menu()

        imgui.end_main_menu_bar()

    imgui.begin('Cube')
    changed, zoom = imgui.slider_float('zoom', trackball.zoom, 15, 90)
    if changed: trackball.zoom = zoom
    imgui.end()

    imgui.end_frame()
    imgui.render()


    window.clear()

    # Filled cube
    gl.glDisable(gl.GL_BLEND)
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glEnable(gl.GL_POLYGON_OFFSET_FILL)
    cube['u_color'] = 1, 1, 1, 1
    cube.draw(gl.GL_TRIANGLES, faces)

    # Outlined cube
    gl.glDisable(gl.GL_POLYGON_OFFSET_FILL)
    gl.glEnable(gl.GL_BLEND)
    gl.glDepthMask(gl.GL_FALSE)
    cube['u_color'] = 0, 0, 0, 1
    cube.draw(gl.GL_LINES, outline)
    gl.glDepthMask(gl.GL_TRUE)

    imguiRenderer.render(imgui.get_draw_data())
Ejemplo n.º 30
0
    def ui(self):
        """Use the imgui module here to draw the UI"""
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Esc', False, True
                )

                if clicked_quit:
                    self.should_close()

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.begin("Hello, world!", True)
        self.shape_need_update = False
        changed, self.some_slider = imgui.slider_float(
            "Some Slider", self.some_slider,
            min_value=0.0, max_value=1.0,
            format="%.02f"
        )
        imgui.end()