Example #1
0
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()
Example #2
0
def autopilot_controller(aircraft: Aircraft):
	if hg.ImGuiBegin("Auto pilot"):
		f, d = hg.ImGuiCheckbox("Autopilot", aircraft.autopilot_activated)
		if f:
			aircraft.autopilot_activated = d

		f, d = hg.ImGuiCheckbox("IA", aircraft.IA_activated)
		if f:
			aircraft.IA_activated = d

		d, f = hg.ImGuiSliderFloat("Pitch", aircraft.autopilot_pitch_attitude, -180, 180)
		if d: aircraft.set_autopilot_pitch_attitude(f)
		d, f = hg.ImGuiSliderFloat("Roll", aircraft.autopilot_roll_attitude, -180, 180)
		if d: aircraft.set_autopilot_roll_attitude(f)
		d, f = hg.ImGuiSliderFloat("Cap", aircraft.autopilot_cap, 0, 360)
		if d: aircraft.set_autopilot_cap(f)
		d, f = hg.ImGuiSliderFloat("Altitude", aircraft.autopilot_altitude, 0, 10000)
		if d: aircraft.set_autopilot_altitude(f)
	hg.ImGuiEnd()
Example #3
0
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 ""
Example #4
0
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()
Example #5
0
    cam.GetTransform().SetRot(cam_rot)

    scene.Update(dt)

    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()
Example #6
0
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()
Example #7
0
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()