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

Python超人-宇宙模拟器

上级 10a5eca8
...@@ -68,6 +68,10 @@ class HalleyCometSimBase: ...@@ -68,6 +68,10 @@ class HalleyCometSimBase:
self.pluto = None self.pluto = None
self.bodies = [] self.bodies = []
def set_window_size(self, size=(1536, 684)):
from ursina import window
window.size = size
def build_solar_system(self, ignore_gravity=False, start_time=None): def build_solar_system(self, ignore_gravity=False, start_time=None):
# region 构建太阳系 # region 构建太阳系
show_trail = False show_trail = False
......
...@@ -71,6 +71,10 @@ class HalleyCometSim(HalleyCometSimBase): ...@@ -71,6 +71,10 @@ class HalleyCometSim(HalleyCometSimBase):
# UrsinaConfig.trail_length = 180 # UrsinaConfig.trail_length = 180
UrsinaConfig.trail_factor = 3 UrsinaConfig.trail_factor = 3
# self.set_window_size((3500, 1024))
# self.set_window_size((1920, 1080))
# camera.clip_plane_near = 0.1 # camera.clip_plane_near = 0.1
camera.clip_plane_far = 1000000 camera.clip_plane_far = 1000000
...@@ -297,13 +301,17 @@ class HalleyCometSim(HalleyCometSimBase): ...@@ -297,13 +301,17 @@ class HalleyCometSim(HalleyCometSimBase):
if not hasattr(self, "last_total_hours"): if not hasattr(self, "last_total_hours"):
self.last_total_hours = time_total_hours self.last_total_hours = time_total_hours
if time_total_hours - self.last_total_hours > 240: # 每个一段时间运行一次更新(不要太频繁更新,会导致摄像机抖动)
if time_total_hours - self.last_total_hours > 100:
# 更新天体的位置
self.set_bodies_position(time_data) self.set_bodies_position(time_data)
# 更新时钟
self.show_clock(dt) self.show_clock(dt)
self.last_total_hours = time_total_hours # 更新轨道的位置
for i, orbit_line in enumerate(self.orbit_lines):
orbit_line.position = self.sun.planet.position
# for i, orbit_line in enumerate(self.orbit_lines): self.last_total_hours = time_total_hours
# orbit_line.position = self.sun.planet.position
if __name__ == '__main__': if __name__ == '__main__':
...@@ -336,13 +344,12 @@ if __name__ == '__main__': ...@@ -336,13 +344,12 @@ if __name__ == '__main__':
# position=(0, 2 * AU, -11 * AU), # position=(0, 2 * AU, -11 * AU),
# position=(0, 0.5 * AU, -5 * AU), # position=(0, 0.5 * AU, -5 * AU),
# position=(2 * AU, -5 * AU, -20 * AU), # position=(2 * AU, -5 * AU, -20 * AU),
show_name=True,
position=(2 * AU, -6 * AU, -20 * AU), position=(2 * AU, -6 * AU, -20 * AU),
cosmic_bg='', cosmic_bg='',
show_trail=True, show_trail=True,
# bg_music='sounds/no_glory.mp3', # bg_music='sounds/no_glory.mp3',
show_camera_info=False, show_camera_info=False,
save_as_video=True, # save_as_video=True,
show_control_info=False, show_control_info=False,
timer_enabled=True, timer_enabled=True,
show_grid=False show_grid=False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册