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

Python超人-宇宙模拟器

上级 faf489ba
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
# ============================================================================== # ==============================================================================
from bodies import Earth from bodies import Earth
from common.consts import SECONDS_PER_HOUR, SECONDS_PER_DAY from common.consts import SECONDS_PER_HOUR, SECONDS_PER_DAY
from sim_scenes.func import ursina_run from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent
if __name__ == '__main__': if __name__ == '__main__':
""" """
...@@ -29,10 +30,23 @@ if __name__ == '__main__': ...@@ -29,10 +30,23 @@ if __name__ == '__main__':
bodies = [earth, earth_with_clouds, clouds] bodies = [earth, earth_with_clouds, clouds]
def on_ready():
from ursina import camera
# camera.fov = 30
# 运行前触发
create_sphere_sky(scale=10000).rotation_y = 220
# 订阅事件后,上面的函数功能才会起作用
# 运行前会触发 on_ready
UrsinaEvent.on_ready_subscription(on_ready)
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后- # position = 左-右+、上+下-、前+后-
ursina_run(bodies, SECONDS_PER_HOUR / 2, ursina_run(bodies, SECONDS_PER_HOUR / 2,
position=(1.5 * earth.radius, 0, -30000), position=(1.5 * earth.radius, 0, -30000),
show_grid=False, show_grid=False,
cosmic_bg='',
show_camera_info=False,
show_control_info=False,
view_closely=0.001) # 近距离观看 view_closely=True或0.001 view_closely=0.001) # 近距离观看 view_closely=True或0.001
...@@ -668,7 +668,9 @@ def create_sphere_sky(texture="bg_pan.jpg", scale=8000): ...@@ -668,7 +668,9 @@ def create_sphere_sky(texture="bg_pan.jpg", scale=8000):
from simulators.ursina.entities.sphere_sky import SphereSky from simulators.ursina.entities.sphere_sky import SphereSky
sky_texture = find_texture(texture, None) sky_texture = find_texture(texture, None)
if sky_texture is not None: if sky_texture is not None:
SphereSky(texture=sky_texture).scale = scale sky = SphereSky(texture=sky_texture)
sky.scale = scale
return sky
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
# ============================================================================== # ==============================================================================
from bodies import Sun, Earth from bodies import Sun, Earth
from common.consts import SECONDS_PER_DAY, SECONDS_PER_WEEK, SECONDS_PER_YEAR, AU from common.consts import SECONDS_PER_DAY, SECONDS_PER_WEEK, SECONDS_PER_YEAR, AU
from sim_scenes.func import mayavi_run, mpl_run, ursina_run from sim_scenes.func import mayavi_run, mpl_run, ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent
if __name__ == '__main__': if __name__ == '__main__':
""" """
...@@ -37,7 +38,21 @@ if __name__ == '__main__': ...@@ -37,7 +38,21 @@ if __name__ == '__main__':
size_scale=SIZE_SCALE, texture="fixed_star.png"), size_scale=SIZE_SCALE, texture="fixed_star.png"),
] ]
def on_ready():
from ursina import camera
# camera.fov = 30
# 运行前触发
create_sphere_sky(scale=10000)
# 订阅事件后,上面的函数功能才会起作用
# 运行前会触发 on_ready
UrsinaEvent.on_ready_subscription(on_ready)
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后- # position = 左-右+、上+下-、前+后-
ursina_run(bodies, SECONDS_PER_WEEK, position=(0 * AU, 0, -3 * AU), show_trail=True) ursina_run(bodies, SECONDS_PER_WEEK*2,
position=(0 * AU, 0, -3 * AU),
cosmic_bg='',
show_grid=False,
show_trail=True)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册