def gui_interface_game(scene): if hg.ImGuiBegin("Game Settings"): if hg.ImGuiButton("Load game parameters"): load_game_parameters() hg.ImGuiSameLine() if hg.ImGuiButton("Save game parameters"): save_game_parameters() f, c = hg.ImGuiColorEdit("P1 Missiles smoke color", Main.p1_missiles_smoke_color, hg.ImGuiColorEditFlags_NoAlpha) if f: set_p1_missiles_smoke_color(c) f, c = hg.ImGuiColorEdit("P2 Missiles smoke color", Main.p2_missiles_smoke_color) if f: set_p2_missiles_smoke_color(c) f, c = hg.ImGuiColorEdit("P1 gun color", Main.bullets.colors[0]) if f: set_p1_gun_color(c) f, c = hg.ImGuiColorEdit("P2 gun color", Main.ennemy_bullets.colors[0]) if f: set_p2_gun_color(c) hg.ImGuiSeparator() d, f = hg.ImGuiSliderFloat("Radial blur strength", Main.radial_blur_strength, 0, 1) if d: Main.radial_blur_strength = f d, f = hg.ImGuiSliderFloat("Deceleration blur strength", Main.deceleration_blur_strength, 0, 1) if d: Main.deceleration_blur_strength = f d, f = hg.ImGuiSliderFloat("Acceleration blur strength", Main.acceleration_blur_strength, 0, 1) if d: Main.acceleration_blur_strength = f hg.ImGuiEnd()
def gui_interface_sea_render(sea_render: SeaRender, scene, fps): if hg.ImGuiBegin("Sea & Sky render Settings"): if hg.ImGuiButton("Load sea parameters"): sea_render.load_json_script() hg.ImGuiSameLine() if hg.ImGuiButton("Save sea parameters"): sea_render.save_json_script() d, f = hg.ImGuiCheckbox("Water reflection", sea_render.render_scene_reflection) if d: sea_render.render_scene_reflection = f d, f = hg.ImGuiSliderFloat("Texture North intensity", sea_render.tex_sky_N_intensity, 0, 1) if d: sea_render.tex_sky_N_intensity = f d, f = hg.ImGuiSliderFloat("Zenith falloff", sea_render.zenith_falloff, 1, 100) if d: sea_render.zenith_falloff = f f, c = hg.ImGuiColorEdit("Zenith color", sea_render.zenith_color) if f: sea_render.zenith_color = c f, c = hg.ImGuiColorEdit("Horizon color", sea_render.horizon_N_color) if f: sea_render.horizon_N_color = c f, c = hg.ImGuiColorEdit("Water color", sea_render.sea_color) if f: sea_render.sea_color = c f, c = hg.ImGuiColorEdit("Horizon Water color", sea_render.horizon_S_color) if f: sea_render.horizon_S_color = c f, c = hg.ImGuiColorEdit("Horizon line color", sea_render.horizon_line_color) if f: sea_render.horizon_line_color = c hg.ImGuiText("3/4 horizon line size: " + str(sea_render.horizon_line_size)) f, d = hg.ImGuiCheckbox("Sea texture filtering", bool(sea_render.sea_filtering)) if f: sea_render.sea_filtering = int(d) hg.ImGuiText("5/6 max filter samples: " + str(sea_render.max_filter_samples)) hg.ImGuiText("7/8 filter precision: " + str(sea_render.filter_precision)) hg.ImGuiText("A/Q sea scale x: " + str(sea_render.sea_scale.x)) hg.ImGuiText("Z/S sea scale y: " + str(sea_render.sea_scale.y)) hg.ImGuiText("E/D sea scale z: " + str(sea_render.sea_scale.z)) d, f = hg.ImGuiSliderFloat("Sea reflection", sea_render.sea_reflection, 0, 1) if d: sea_render.sea_reflection = f d, f = hg.ImGuiSliderFloat("Reflect offset", Main.sea_render.reflect_offset, 1, 1000) if d: Main.sea_render.reflect_offset = f hg.ImGuiSeparator() hg.ImGuiEnd()
def gui_interface(terrain: TerrainMarching, scene, fps): camera = scene.GetNode("Camera") if hg.ImGuiBegin("Settings"): #f = hg.ImGuiInputVector2("Map 1 scale",terrain.facteur_echelle_terrain_l1,1) if hg.ImGuiButton("Load parameters"): terrain.load_json_script() hg.ImGuiSameLine() if hg.ImGuiButton("Save parameters"): terrain.save_json_script() if hg.ImGuiButton("Load camera"): load_fps_matrix(fps) hg.ImGuiSameLine() if hg.ImGuiButton("Save camera"): save_json_matrix(camera.GetTransform().GetPosition(), camera.GetTransform().GetRotation()) f = hg.ImGuiColorEdit("Water color", terrain.couleur_eau, False) hg.ImGuiText("A/Q facteur_echelle_terrain_l1.x: " + str(terrain.facteur_echelle_terrain_l1.x)) hg.ImGuiText("Z/S facteur_echelle_terrain_l1.y: " + str(terrain.facteur_echelle_terrain_l1.y)) hg.ImGuiText("E/D facteur_echelle_terrain_l2.x: " + str(terrain.facteur_echelle_terrain_l2.x)) hg.ImGuiText("R/F facteur_echelle_terrain_l2.y: " + str(terrain.facteur_echelle_terrain_l2.y)) hg.ImGuiText("T/G facteur_echelle_terrain_l3.x: " + str(terrain.facteur_echelle_terrain_l3.x)) hg.ImGuiText("Y/H facteur_echelle_terrain_l3.y: " + str(terrain.facteur_echelle_terrain_l3.y)) hg.ImGuiText("U/J amplitude_l1: " + str(terrain.amplitude_l1)) hg.ImGuiText("I/K amplitude_l2: " + str(terrain.amplitude_l2)) hg.ImGuiText("O/L amplitude_l3: " + str(terrain.amplitude_l3)) hg.ImGuiText("P/M facteur_precision_distance: " + str(terrain.facteur_precision_distance)) hg.ImGuiText("1/2 altitude_eau: " + str(terrain.altitude_eau)) hg.ImGuiText("3/4 reflexion_eau: " + str(terrain.reflexion_eau)) hg.ImGuiText("5/6 offset terrain X: " + str(terrain.offset_terrain.x)) hg.ImGuiText("7/8 offset terrain Y: " + str(terrain.offset_terrain.y)) hg.ImGuiText("9/0 offset terrain Z: " + str(terrain.offset_terrain.z)) hg.ImGuiText("CTRL+S sauve paramètres") hg.ImGuiText("CTRL+L charge paramètres") hg.ImGuiEnd()
def gui_ScreenModeRequester(): global flag_windowed global current_monitor,current_mode,monitors_names,modes dt = hg.TickClock() # ImGui frame hg.ImGuiBeginFrame(res_w, res_h, dt, hg.ReadMouse(), hg.ReadKeyboard()) hg.ImGuiSetNextWindowPosCenter(hg.ImGuiCond_Always) hg.ImGuiSetNextWindowSize(hg.Vec2(res_w, res_h), hg.ImGuiCond_Always) if hg.ImGuiBegin("Choose screen mode", True, hg.ImGuiWindowFlags_NoTitleBar | hg.ImGuiWindowFlags_MenuBar | hg.ImGuiWindowFlags_NoMove | hg.ImGuiWindowFlags_NoSavedSettings | hg.ImGuiWindowFlags_NoCollapse): if hg.ImGuiBeginCombo("Monitor", monitors_names[current_monitor]): for i in range(len(monitors_names)): f = hg.ImGuiSelectable(monitors_names[i], current_monitor == i) if f: current_monitor = i hg.ImGuiEndCombo() if hg.ImGuiBeginCombo("Screen size", modes[current_monitor][current_mode].name): for i in range(len(modes[current_monitor])): f = hg.ImGuiSelectable(modes[current_monitor][i].name+"##"+str(i), current_mode == i) if f: current_mode = i hg.ImGuiEndCombo() f, d = hg.ImGuiCheckbox("Windowed", flag_windowed) if f: flag_windowed = d ok=hg.ImGuiButton("Ok") hg.ImGuiSameLine() cancel=hg.ImGuiButton("Quit") hg.ImGuiEndFrame(0) if ok: return "ok" elif cancel: return "quit" else: return ""
def gui_ScreenModeRequester(): global flag_windowed global current_monitor, current_mode, monitors_names, modes hg.ImGuiSetNextWindowPosCenter(hg.ImGuiCond_Always) hg.ImGuiSetNextWindowSize(hg.Vector2(res_w, res_h), hg.ImGuiCond_Always) if hg.ImGuiBegin( "Choose screen mode", hg.ImGuiWindowFlags_NoTitleBar | hg.ImGuiWindowFlags_MenuBar | hg.ImGuiWindowFlags_NoMove | hg.ImGuiWindowFlags_NoSavedSettings | hg.ImGuiWindowFlags_NoCollapse): if hg.ImGuiBeginCombo("Monitor", monitors_names[current_monitor]): for i in range(len(monitors_names)): f = hg.ImGuiSelectable(monitors_names[i], current_monitor == i) if f: current_monitor = i hg.ImGuiEndCombo() '''if hg.ImGuiBeginCombo("Screen size", modes[current_monitor][current_mode].name): for i in range(len(modes[current_monitor])): f = hg.ImGuiSelectable(modes[current_monitor][i].name+"##"+str(i), current_mode == i) if f: current_mode = i hg.ImGuiEndCombo() f, d = hg.ImGuiCheckbox("Windowed", flag_windowed) if f: flag_windowed = d''' # 指定解析度視窗畫 current_mode = 1 flag_windowed = True ok = hg.ImGuiButton("Ok") hg.ImGuiSameLine() cancel = hg.ImGuiButton("Quit") hg.ImGuiEnd() return "ok" '''if ok:
def gui_post_rendering(): if hg.ImGuiBegin("Post-rendering Settings"): if hg.ImGuiButton("Load post-render settings"): post_processes_load_parameters() hg.ImGuiSameLine() if hg.ImGuiButton("Save post-render settings"): post_processes_save_parameters() hg.ImGuiSeparator() d, f = hg.ImGuiSliderFloat("Hue", Main.HSL_postProcess.GetH(), -1, 1) if d: Main.HSL_postProcess.SetH(f) d, f = hg.ImGuiSliderFloat("Saturation", Main.HSL_postProcess.GetS(), 0, 1) if d: Main.HSL_postProcess.SetS(f) d, f = hg.ImGuiSliderFloat("Luminance", Main.HSL_postProcess.GetL(), 0, 1) if d: Main.HSL_postProcess.SetL(f) hg.ImGuiSeparator() d, f = hg.ImGuiCheckbox("Motion Blur", Main.flag_MotionBlur) if d: Main.flag_MotionBlur=f if f: Main.camera.AddComponent(Main.MotionBlur_postProcess) else: Main.camera.RemoveComponent(Main.MotionBlur_postProcess) if Main.flag_MotionBlur: pp=Main.MotionBlur_postProcess d, i = hg.ImGuiSliderInt("Blur Radius", pp.GetBlurRadius(), 1, 100) if d: pp.SetBlurRadius(i) d, f = hg.ImGuiSliderFloat("Exposure", pp.GetExposure(), 0, 10) if d : pp.SetExposure(f) d, f = hg.ImGuiSliderInt("SampleCount", pp.GetSampleCount(), 1, 100) if d : pp.SetSampleCount(f) hg.ImGuiEnd()
hg.SetViewClear(0, hg.ClearColor | hg.ClearDepth, 0x1f001fff, 1.0, 0) hg.SetViewRect(0, 0, 0, res_x, res_y) hg.SubmitSceneToPipeline(0, scene, hg.IntRect(0, 0, res_x, res_y), True, pipeline, res) # imgui hg.ImGuiBeginFrame(res_x, res_y, dt, hg.ReadMouse(), hg.ReadKeyboard()) if hg.ImGuiBegin("GUI"): _, check = hg.ImGuiCheckbox("Check", check) _, open = hg.ImGuiCollapsingHeader("Header", open) if _: if hg.ImGuiButton("Button"): print("Button pressed") _, combo = hg.ImGuiCombo("Combo", combo, ['item 1', 'item 2', 'item 3']) _, color = hg.ImGuiColorButton("Color", color) hg.ImGuiEnd() hg.ImGuiEndFrame(255) hg.Frame() hg.UpdateWindow(win) hg.RenderShutdown() hg.DestroyWindow(win)
def gui_clouds(scene: hg.Scene, cloud: Clouds): global link_altitudes, link_morphs, clouds_altitude, clouds_morph_level if hg.ImGuiBegin("Clouds Settings"): if hg.ImGuiButton("Load clouds parameters"): cloud.load_json_script() # fps.Reset(cloud.cam_pos,hg.Vector3(0,0,0)) hg.ImGuiSameLine() if hg.ImGuiButton("Save clouds parameters"): cloud.save_json_script(scene) hg.ImGuiSeparator() hg.ImGuiText("Map position: X=" + str(cloud.map_position.x)) hg.ImGuiText("Map position: Y=" + str(cloud.map_position.y)) """ d, f = hg.ImGuiSliderFloat("Far Clouds scale x", sky_render.clouds_scale.x, 100, 10000) if d: sky_render.clouds_scale.x = f d, f = hg.ImGuiSliderFloat("Far Clouds scale y", sky_render.clouds_scale.y, 0, 1) if d: sky_render.clouds_scale.y = f d, f = hg.ImGuiSliderFloat("Far Clouds scale z", sky_render.clouds_scale.z, 100, 10000) if d: sky_render.clouds_scale.z = f d, f = hg.ImGuiSliderFloat("Far Clouds absorption", sky_render.clouds_absorption, 0, 1) if d: sky_render.clouds_absorption = f """ d, f = hg.ImGuiSliderFloat("Clouds scale x", cloud.map_scale.x, 100, 10000) if d: cloud.set_map_scale_x(f) d, f = hg.ImGuiSliderFloat("Clouds scale z", cloud.map_scale.y, 100, 10000) if d: cloud.set_map_scale_z(f) d, f = hg.ImGuiSliderFloat("Wind speed x", cloud.v_wind.x, -1000, 1000) if d: cloud.v_wind.x = f d, f = hg.ImGuiSliderFloat("Wind speed z", cloud.v_wind.y, -1000, 1000) if d: cloud.v_wind.y = f d, f = hg.ImGuiCheckbox("Link layers altitudes", link_altitudes) if d: link_altitudes = f d, f = hg.ImGuiCheckbox("Link layers morph levels", link_morphs) if d: link_morphs = f d, f = hg.ImGuiSliderFloat("Clouds altitude", clouds_altitude, 100, 10000) if d: clouds_altitude = f if link_altitudes: for layer in cloud.layers: layer.set_altitude(f) d, f = hg.ImGuiSliderFloat("Clouds morph level", clouds_morph_level, 0, 1) if d: clouds_morph_level = f if link_morphs: for layer in cloud.layers: layer.morph_level = f for layer in cloud.layers: hg.ImGuiSeparator() gui_layer(layer) hg.ImGuiEnd()
def gui_interface_scene(scene, fps): camera = scene.GetNode("Camera") l1_color = Main.ligth_sun.GetLight().GetDiffuseColor() l2_color = Main.ligth_sky.GetLight().GetDiffuseColor() environment = scene.GetEnvironment() amb_color = environment.GetAmbientColor() amb_intensity = environment.GetAmbientIntensity() if hg.ImGuiBegin("Scene Settings"): if hg.ImGuiButton("Load scene parameters"): load_scene_parameters() hg.ImGuiSameLine() if hg.ImGuiButton("Save scene parameters"): save_scene_parameters() d, f = hg.ImGuiCheckbox("Display collisions shapes", Main.show_debug_displays) if d: Main.show_debug_displays = f scene.GetPhysicSystem().SetDebugVisuals(Main.show_debug_displays) d, f = hg.ImGuiCheckbox("Volumetric clouds", Main.render_volumetric_clouds) if d: Main.render_volumetric_clouds = f if not f: Main.clouds.clear_particles() pos = camera.GetTransform().GetPosition() hg.ImGuiText("Camera X " + str(pos.x)) hg.ImGuiText("Camera Y " + str(pos.y)) hg.ImGuiText("Camera Z " + str(pos.z)) if hg.ImGuiButton("Load camera"): # load_fps_matrix(fps) pos, rot = load_json_matrix("assets/scripts/camera_position.json") camera.GetTransform().SetPosition(pos) camera.GetTransform().SetRotation(rot) hg.ImGuiSameLine() if hg.ImGuiButton("Save camera"): save_json_matrix(camera.GetTransform().GetPosition(), camera.GetTransform().GetRotation(), "assets/scripts/camera_position.json") if hg.ImGuiButton("Load aircraft matrix"): pos, rot = load_json_matrix("assets/scripts/aircraft_position.json") Main.p1_aircraft.reset(pos, rot) hg.ImGuiSameLine() if hg.ImGuiButton("Save aircraft matrix"): nd = Main.p1_aircraft.get_parent_node() save_json_matrix(nd.GetTransform().GetPosition(), nd.GetTransform().GetRotation(), "assets/scripts/aircraft_position.json") f, c = hg.ImGuiColorEdit("Ambient color", amb_color) if f: amb_color = hg.Color(c) environment.SetAmbientColor(amb_color) d, f = hg.ImGuiSliderFloat("Ambient intensity", amb_intensity, 0, 1) if d: amb_intensity = f environment.SetAmbientIntensity(amb_intensity) f, c = hg.ImGuiColorEdit("Sunlight color", l1_color) if f: l1_color = hg.Color(c) Main.ligth_sun.GetLight().SetDiffuseColor(l1_color) f, c2 = hg.ImGuiColorEdit("Skylight color", l2_color) if f: l2_color = hg.Color(c2) Main.ligth_sky.GetLight().SetDiffuseColor(l2_color) hg.ImGuiEnd()