提交 6a288ac4 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 f2d7524a
......@@ -19,6 +19,11 @@ class HalleComet(RockSnow):
近日点: 0.586 AU 上次通过近日点:1986年2月9日 下次通过近日点:2061年7月28日
平均密度: 0.6(估计的范围在0.2至1.5g/cm)
均密度: 1 g/cm³ -> 1✕10³ kg/m³
重要时间点:
1986年02月09日 近日点
1986年04月11日 距离地球最近
2023年12月09日 远日点
2061年07月28日 近日点
来源:https://www.cgmodel.com/model/500318.html
"""
......
......@@ -159,8 +159,9 @@ def ursina_run(bodies,
timer_enabled=False,
save_as_json=None,
save_cube_map=False,
save_as_video=False,
view_closely=False):
video_recoder=False,
view_closely=False,
camera_smooth_follow=False):
"""
ursina 模拟器运行天体
@param bodies: 天体集合
......@@ -178,10 +179,16 @@ def ursina_run(bodies,
@param show_timer: 是否显示计时器
@param timer_enabled: 计时器是否有效
@param save_as_json: 将所有天体的信息保存为 json 文件
@param save_cube_map: 保存 CudeMap 视频帧
@param video_recoder: 视频录制是否开启(按5录制,按6停止录制)
@param view_closely: 是否近距离查看天体
@param camera_smooth_follow: 摄像机圆滑跟踪
@return:
"""
from simulators.ursina.entities.video_recorder import CubeMapVideoRecorder
from simulators.ursina.entities.video_recorder import VideoRecorder
from ursina import camera, SmoothFollow
import sys
from simulators.ursina_simulator import UrsinaSimulator
from simulators.ursina.entities.ursina_player import UrsinaPlayer
body_sys = System(bodies)
......@@ -207,18 +214,15 @@ def ursina_run(bodies,
simulator = UrsinaSimulator(body_sys)
view_azimuth = 0 # 暂时未用
player = UrsinaPlayer(position, view_azimuth, simulator.ursina_views)
if camera_smooth_follow:
camera.add_script(SmoothFollow(target=player, offset=[0, 1, -30], speed=4))
if save_cube_map:
from simulators.ursina.entities.video_recorder import CubeMapVideoRecorder
from ursina import camera
import sys
sys.modules["__main__"].video_recorder = CubeMapVideoRecorder()
camera.fov = 90
if save_as_video:
from simulators.ursina.entities.video_recorder import VideoRecorder
from ursina import camera
import sys
if video_recoder:
sys.modules["__main__"].video_recorder = VideoRecorder()
def callback_input(key):
......@@ -263,7 +267,8 @@ def ursina_run(bodies,
show_exit_button=show_exit_button,
timer_enabled=timer_enabled,
bg_music=bg_music,
view_closely=view_closely)
view_closely=view_closely,
camera_smooth=camera_smooth_follow)
def mpl_run(bodies, dt=SECONDS_PER_WEEK, gif_file_name=None, gif_max_frame=200):
......
......@@ -30,6 +30,11 @@ from simulators.ursina.ursina_mesh import create_label
class HalleyCometSim(HalleyCometSimBase):
"""
哈雷彗星场景模拟
重要时间点:
1986年02月09日 近日点
1986年04月11日 距离地球最近
2023年12月09日 远日点
2061年07月28日 近日点
"""
def __init__(self, _params=None):
......@@ -71,7 +76,7 @@ class HalleyCometSim(HalleyCometSimBase):
@return:
"""
# 创建天空
create_sphere_sky(scale=200000)
create_sphere_sky(scale=50000)
# UrsinaConfig.trail_type = "curve_line"
# UrsinaConfig.trail_length = 300
UrsinaConfig.trail_type = "line"
......@@ -83,11 +88,12 @@ class HalleyCometSim(HalleyCometSimBase):
UrsinaConfig.trail_factor = 3
# camera.clip_plane_near = 0.1
camera.clip_plane_far = 1000000
camera.clip_plane_far = 51000
# camera.fov = 60
application.time_scale = 5
# application.time_scale = 0.01
# 摄像机移动 update
camera_move_update()
# camera_move_update()
# camera_move_to_target_update()
def create_orbit_lines(self):
......@@ -227,8 +233,8 @@ class HalleyCometSim(HalleyCometSimBase):
(2048, {"f": 3}),
(2062, {"y": -3}),
(2063, {"y": -10, "z": 2}),
(2081, {}),
(2082, {"exit": True})
(2181, {}),
# (2082, {"exit": True})
]
camera_move_control(camera_move_infos,
......@@ -391,6 +397,7 @@ class HalleyCometSim(HalleyCometSimBase):
dt = time_data.get_datetime(self.start_time)
# 摄像机看向哈雷彗星
camera_look_at(self.halley_comet, rotation_z=0)
# camera.look_at_2d(self.halley_comet.planet.position, axis='y')
time_total_hours = time_data.total_hours
......@@ -468,7 +475,7 @@ if __name__ == '__main__':
show_trail=True,
# bg_music='sounds/no_glory.mp3',
show_camera_info=False,
save_as_video=True,
# video_recoder=True,
show_control_info=False,
timer_enabled=True,
show_grid=False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册