Пример #1
0
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()
Пример #2
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()
Пример #3
0
def simulation_step(simple_graphic_scene_overlay, dt):
	global visc, diff, base_force_u, base_force_v, base_force_dens
	hg.ImGuiLock()
	if hg.ImGuiBegin("params"):
		visc = hg.ImGuiSliderFloat("visc", visc, 0.0, 10.0)[1]
		diff = hg.ImGuiSliderFloat("diff", diff, 0.0, 1000.0)[1]
		base_force_u = hg.ImGuiSliderFloat("base_force_u", base_force_u, 0.0, 1000.0)[1]		
		base_force_v = hg.ImGuiSliderFloat("base_force_v", base_force_v, 0.0, 1000.0)[1]		
		base_force_dens = hg.ImGuiSliderFloat("base_force_dens", base_force_dens, 0.0, 1000.0)[1]		
	hg.ImGuiEnd()
	hg.ImGuiUnlock()

	get_from_UI(dens_prev, u_prev, v_prev)
	vel_step(N, u, v, u_prev, v_prev, visc, dt)
	dens_step(N, dens, dens_prev, u, v, diff, dt)
	draw_dens(simple_graphic_scene_overlay, N, dens, u, v)
Пример #4
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()
Пример #5
0
def simulation_step(simple_graphic_scene_overlay, dt):
    global visc, diff, base_force_u, base_force_v, base_force_dens
    hg.ImGuiLock()
    if hg.ImGuiBegin("params"):
        visc = hg.ImGuiSliderFloat("visc", visc, 0.0, 10.0)[1]
        diff = hg.ImGuiSliderFloat("diff", diff, 0.0, 1000.0)[1]
        base_force_u = hg.ImGuiSliderFloat("base_force_u", base_force_u, 0.0,
                                           1000.0)[1]
        base_force_v = hg.ImGuiSliderFloat("base_force_v", base_force_v, 0.0,
                                           1000.0)[1]
        base_force_dens = hg.ImGuiSliderFloat("base_force_dens",
                                              base_force_dens, 0.0, 1000.0)[1]
    hg.ImGuiEnd()
    hg.ImGuiUnlock()

    renderer = plus.GetRenderer()
    prev_viewport = renderer.GetViewport()

    get_from_UI(dens_prev, u_prev, v_prev)
    vel_step(N, u, v, u_prev, v_prev, visc, dt)
    #dens_step(N, dens, dens_prev, u, v, diff, dt)
    draw_dens(simple_graphic_scene_overlay, N, dens, u, v)

    # compute the shader

    #renderer.SetRenderTarget(uvdens_render_target_prev)
    #renderer.SetViewport(hg.Rect(0, 0, size, size))
    #renderer.Clear(col.Blue)
    #renderer.EnableDepthTest(False)
    #renderer.Set2DMatrices()
    #renderer.SetShader(shader)
    #renderer.SetShaderFloat2(renderer.GetShaderVariable("size_pixel"), 1.0/size, 1.0/size)
    #renderer.SetShaderTexture(renderer.GetShaderVariable("tex_in"), uvdens_tex)
    #hg.SetShaderEngineValues(plus.GetRenderSystem())
    #hg.DrawBuffers(renderer, 6, idx, vtx, vtx_layout)

    # reset matrices and draw the texture
    renderer.SetIdentityMatrices()
    renderer.SetViewport(prev_viewport)
    renderer.ClearRenderTarget()
    helper_2d.draw_quad(simple_graphic_scene_overlay, mat4.Identity, 1, 1,
                        uvdens_tex, col.White)
Пример #6
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()
Пример #7
0
def gui_layer(layer: CloudsLayer):
	nm = layer.name
	hg.ImGuiText(layer.name)

	d, f = hg.ImGuiSliderFloat(nm + " particles rotation speed", layer.particles_rot_speed, -10, 10)
	if d:
		layer.set_particles_rot_speed(f)

	d, f = hg.ImGuiSliderFloat(nm + " particles morph level", layer.morph_level, -1, 1)
	if d:
		layer.morph_level = f

	d, f = hg.ImGuiSliderFloat(nm + " Absorption factor", layer.absorption * 100, 0.01, 10)
	if d:
		layer.set_absorption(f / 100)

	d, f = hg.ImGuiSliderFloat(nm + " Altitude floor", layer.altitude_floor, -2, 2)
	if d: layer.set_altitude_floor(f)

	d, f = hg.ImGuiSliderFloat(nm + " Altitude", layer.altitude, 0, 10000)
	if d: layer.set_altitude(f)

	d, f = hg.ImGuiSliderFloat(nm + " Altitude falloff", layer.altitude_falloff, 0.1, 100)
	if d: layer.set_altitude_falloff(f)

	d, f = hg.ImGuiSliderFloat(nm + " Particles min scale", layer.particles_scale_range.x, 1, 5000)
	if d:
		layer.set_particles_min_scale(f)
	d, f = hg.ImGuiSliderFloat(nm + " Particles max scale", layer.particles_scale_range.y, 1, 5000)
	if d:
		layer.set_particles_max_scale(f)
	d, f = hg.ImGuiSliderFloat(nm + " Alpha threshold", layer.alpha_threshold, 0, 1)
	if d:
		layer.alpha_threshold = f

	d, f = hg.ImGuiSliderFloat(nm + " Scale falloff", layer.scale_falloff, 1, 10)
	if d:
		layer.scale_falloff = f

	d, f = hg.ImGuiSliderFloat(nm + " Alpha scale falloff", layer.alpha_scale_falloff, 1, 10)
	if d:
		layer.alpha_scale_falloff = f

	d, f = hg.ImGuiSliderFloat(nm + " Perturbation", layer.perturbation, 0, 200)
	if d:
		layer.perturbation = f
	d, f = hg.ImGuiSliderFloat(nm + " Tile size", layer.tile_size, 1, 500)
	if d:
		layer.tile_size = f
	d, f = hg.ImGuiSliderFloat(nm + " Distance min", layer.distance_min, 0, 5000)
	if d:
		layer.set_distance_min(f)
	d, f = hg.ImGuiSliderFloat(nm + " Distance max", layer.distance_max, 100, 5000)
	if d:
		layer.set_distance_max(f)

	d, f = hg.ImGuiSliderFloat(nm + " Margin", layer.margin, 0.5, 2)
	if d:
		layer.margin = f
	d, f = hg.ImGuiSliderFloat(nm + " Focal margin", layer.focal_margin, 0.5, 2)
	if d:
		layer.focal_margin = f
Пример #8
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()
Пример #9
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()