From a62d38502946679bff46e94bdaf03d272d5a0ab1 Mon Sep 17 00:00:00 2001 From: march3 Date: Mon, 9 Oct 2023 16:06:13 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sim_scenes/solar_system/hd_pluto_3d.py | 39 +++++++++++++++++++++ sim_scenes/solar_system/hd_venus_3d.py | 39 +++++++++++++++++++++ sim_scenes/tri_bodies/tri_bodies_perfect.py | 2 +- sim_scenes/tri_bodies/two_bodies_01.py | 4 +-- sim_scenes/tri_bodies/water_drop_01.py | 7 ++-- sim_scenes/tri_bodies/water_drop_02.py | 21 +++++------ 6 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 sim_scenes/solar_system/hd_pluto_3d.py create mode 100644 sim_scenes/solar_system/hd_venus_3d.py diff --git a/sim_scenes/solar_system/hd_pluto_3d.py b/sim_scenes/solar_system/hd_pluto_3d.py new file mode 100644 index 0000000..30915bd --- /dev/null +++ b/sim_scenes/solar_system/hd_pluto_3d.py @@ -0,0 +1,39 @@ +# -*- coding:utf-8 -*- +# title :高清冥王星3D效果 +# description :高清冥王星3D效果 +# author :Python超人 +# date :2023-10-09 +# link :https://gitcode.net/pythoncr/ +# python_version :3.8 +# ============================================================================== +from bodies import Pluto +from common.consts import SECONDS_PER_WEEK, SECONDS_PER_DAY +from sim_scenes.func import ursina_run + +if __name__ == '__main__': + """ + 高清冥王星3D效果 + """ + bodies = [ + Pluto(texture="pluto.png", + init_position=[0, 0, 0], init_velocity=[0, 0, 0], + size_scale=2, show_name=False) + ] + pluto = bodies[0] + + # TODO: 开启3D摄像机 + from simulators.ursina.entities.camera3d import Camera3d + + # 3D摄像机初始化(两眼到鼻梁的距离为1000公里效果) + Camera3d.init(eye_distance=1000) + + # 使用 ursina 查看的运行效果 + # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 + # position = 左-右+、上+下-、前+后- + ursina_run(bodies, SECONDS_PER_DAY, + position=(4 * pluto.radius, 0, -13500), + # cosmic_bg="", # 无背景(黑色) + show_grid=False, # 不显示网格 + show_camera_info=False, # 不显示摄像机信息 + show_control_info=False, # 不显示控制提示信息 + view_closely=0.001) diff --git a/sim_scenes/solar_system/hd_venus_3d.py b/sim_scenes/solar_system/hd_venus_3d.py new file mode 100644 index 0000000..359cf58 --- /dev/null +++ b/sim_scenes/solar_system/hd_venus_3d.py @@ -0,0 +1,39 @@ +# -*- coding:utf-8 -*- +# title :高清金星3D效果 +# description :高清金星3D效果 +# author :Python超人 +# date :2023-10-09 +# link :https://gitcode.net/pythoncr/ +# python_version :3.8 +# ============================================================================== +from bodies import Venus +from common.consts import SECONDS_PER_WEEK, SECONDS_PER_DAY +from sim_scenes.func import ursina_run + +if __name__ == '__main__': + """ + 高清金星3D效果 + """ + bodies = [ + Venus(texture="venus_hd.jpg", + init_position=[0, 0, 0], init_velocity=[0, 0, 0], + size_scale=1, show_name=False) + ] + venus = bodies[0] + + # TODO: 开启3D摄像机 + from simulators.ursina.entities.camera3d import Camera3d + + # 3D摄像机初始化(两眼到鼻梁的距离为1000公里效果) + Camera3d.init(eye_distance=1000) + + # 使用 ursina 查看的运行效果 + # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 + # position = 左-右+、上+下-、前+后- + ursina_run(bodies, SECONDS_PER_DAY, + position=(1.4 * venus.radius, 0, -28000), + # cosmic_bg="", # 无背景(黑色) + show_grid=False, # 不显示网格 + show_camera_info=False, # 不显示摄像机信息 + show_control_info=False, # 不显示控制提示信息 + view_closely=0.001) diff --git a/sim_scenes/tri_bodies/tri_bodies_perfect.py b/sim_scenes/tri_bodies/tri_bodies_perfect.py index a736b63..fce5c8d 100644 --- a/sim_scenes/tri_bodies/tri_bodies_perfect.py +++ b/sim_scenes/tri_bodies/tri_bodies_perfect.py @@ -1,5 +1,5 @@ # -*- coding:utf-8 -*- -# title :三体场景模拟01 +# title :三体场景模拟 # description :三体场景模拟(3个太阳、1个地球) # author :Python超人 # date :2023-02-11 diff --git a/sim_scenes/tri_bodies/two_bodies_01.py b/sim_scenes/tri_bodies/two_bodies_01.py index 3b075b8..f2c61da 100644 --- a/sim_scenes/tri_bodies/two_bodies_01.py +++ b/sim_scenes/tri_bodies/two_bodies_01.py @@ -1,6 +1,6 @@ # -*- coding:utf-8 -*- -# title :三体场景模拟01 -# description :三体场景模拟(2个太阳、1个地球) +# title :两体场景模拟01 +# description :两体场景模拟01(2个太阳、1个地球) # author :Python超人 # date :2023-02-11 # link :https://gitcode.net/pythoncr/ diff --git a/sim_scenes/tri_bodies/water_drop_01.py b/sim_scenes/tri_bodies/water_drop_01.py index 746de41..6ef1426 100644 --- a/sim_scenes/tri_bodies/water_drop_01.py +++ b/sim_scenes/tri_bodies/water_drop_01.py @@ -1,6 +1,6 @@ # -*- coding:utf-8 -*- -# title :地月场景模拟 -# description :地月场景模拟(月球始终一面朝向地球、月球对地球的扰动) +# title :三体水滴场景模拟 +# description :三体水滴场景模拟 # author :Python超人 # date :2023-05-01 # link :https://gitcode.net/pythoncr/ @@ -20,8 +20,7 @@ from ursina import camera if __name__ == '__main__': """ - 月球始终一面朝向地球 - 月球对地球的扰动 + 三体水滴场景模拟 """ OFFSETTING = 0 WATER_SPEED = 400 diff --git a/sim_scenes/tri_bodies/water_drop_02.py b/sim_scenes/tri_bodies/water_drop_02.py index 44dcea6..8d73ac1 100644 --- a/sim_scenes/tri_bodies/water_drop_02.py +++ b/sim_scenes/tri_bodies/water_drop_02.py @@ -1,6 +1,6 @@ # -*- coding:utf-8 -*- -# title :地月场景模拟 -# description :地月场景模拟(月球始终一面朝向地球、月球对地球的扰动) +# title :三体水滴场景模拟 +# description :三体水滴场景模拟 # author :Python超人 # date :2023-05-01 # link :https://gitcode.net/pythoncr/ @@ -20,8 +20,7 @@ from ursina import camera if __name__ == '__main__': """ - 月球始终一面朝向地球 - 月球对地球的扰动 + 三体水滴场景模拟 """ OFFSETTING = 0 WATER_SPEED = 400 @@ -46,12 +45,12 @@ if __name__ == '__main__': water_drop = WaterDrop( init_position=[0, 0, 0], - # texture="drops_bright.png", - # trail_color=[200, 200, 255], - init_velocity=[0, 0, 0], - # size_scale=4e4, - size_scale=3e3 - ).set_ignore_gravity(True).set_light_disable(True) + # texture="drops_bright.png", + # trail_color=[200, 200, 255], + init_velocity=[0, 0, 0], + # size_scale=4e4, + size_scale=3e3 + ).set_ignore_gravity(True).set_light_disable(True) # moon = Moon(init_position=[0, 0, 363104], # 距地距离约: 363104 至 405696 km # init_velocity=[-1.03, 0, 0], size_scale=2e1) # 月球放大 10 倍,距离保持不变 # moon.set_light_disable(True) @@ -114,12 +113,10 @@ if __name__ == '__main__': application.time_scale = 1 - # # 订阅事件后,上面2个函数功能才会起作用 # # 运行前会触发 on_ready UrsinaEvent.on_ready_subscription(on_ready) - # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- -- GitLab