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

Python超人-宇宙模拟器

上级 6b7d2d3c
...@@ -191,10 +191,11 @@ def find_texture_root_path(): ...@@ -191,10 +191,11 @@ def find_texture_root_path():
return None return None
def find_texture(texture): def find_texture(texture, default_val=""):
""" """
尝试在多个路径下寻找纹理图片 尝试在多个路径下寻找纹理图片
@param texture: 纹理图片 @param texture: 纹理图片
@param default_val: 如果没有找到,返回的默认值
@return: 纹理图片的路径 @return: 纹理图片的路径
""" """
if os.path.exists(texture): if os.path.exists(texture):
...@@ -214,7 +215,7 @@ def find_texture(texture): ...@@ -214,7 +215,7 @@ def find_texture(texture):
p = p[:-4] p = p[:-4]
return p return p
return "" return default_val
def gen_color_body_texture(color, save_file, color_body_img="color_body.jpg", bright=None, contrast=None): def gen_color_body_texture(color, save_file, color_body_img="color_body.jpg", bright=None, contrast=None):
......
...@@ -85,13 +85,11 @@ class SolarSystemRealitySim: ...@@ -85,13 +85,11 @@ class SolarSystemRealitySim:
@return: @return:
""" """
# 让地球显示自转轴线 # 让地球显示自转轴线
self.earth.rotate_axis_color = (255, 255, 50) # self.earth.rotate_axis_color = (255, 255, 50)
# 如果为调试模式,则太阳光对地球无效,方便查看 # 如果为调试模式,则太阳光对地球无效,方便查看
if self.debug_mode: if self.debug_mode:
self.earth.set_light_disable(True) self.earth.set_light_disable(True)
def set_earth_rotation(self, dt): def set_earth_rotation(self, dt):
""" """
根据指定的时间控制地球的旋转角度(保证地球的自转和北京时间同步) 根据指定的时间控制地球的旋转角度(保证地球的自转和北京时间同步)
...@@ -196,9 +194,9 @@ class SolarSystemRealitySim: ...@@ -196,9 +194,9 @@ class SolarSystemRealitySim:
""" """
# 运行前触发 # 运行前触发
# from simulators.ursina.entities.sphere_sky import SphereSky if self.sky_texture is not None:
# from common.image_utils import find_texture from simulators.ursina.entities.sphere_sky import SphereSky
# SphereSky(texture=find_texture("bg_pan.jpg")).scale = 10000 SphereSky(texture=self.sky_texture).scale = 10000
camera.rotation_z = -20 camera.rotation_z = -20
if self.debug_mode: if self.debug_mode:
...@@ -269,6 +267,13 @@ class SolarSystemRealitySim: ...@@ -269,6 +267,13 @@ class SolarSystemRealitySim:
self.start_time = Time(datetime.strptime(start_time + '+0800', '%Y-%m-%d %H:%M:%S%z'), self.start_time = Time(datetime.strptime(start_time + '+0800', '%Y-%m-%d %H:%M:%S%z'),
format='datetime') format='datetime')
from common.image_utils import find_texture
self.sky_texture = find_texture("bg_pan.jpg", None)
if self.sky_texture is None:
cosmic_bg = None
else:
cosmic_bg = ''
dt = SECONDS_PER_DAY # 1秒=1天 dt = SECONDS_PER_DAY # 1秒=1天
dt = 1 # 1秒=1秒 dt = 1 # 1秒=1秒
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
...@@ -278,7 +283,7 @@ class SolarSystemRealitySim: ...@@ -278,7 +283,7 @@ class SolarSystemRealitySim:
position=(0, 0.2 * AU, -3 * AU), position=(0, 0.2 * AU, -3 * AU),
gravity_works=False, # 关闭万有引力的计算 gravity_works=False, # 关闭万有引力的计算
show_grid=False, show_grid=False,
# cosmic_bg='', cosmic_bg=cosmic_bg,
show_camera_info=False, show_camera_info=False,
timer_enabled=True) timer_enabled=True)
...@@ -288,7 +293,7 @@ if __name__ == '__main__': ...@@ -288,7 +293,7 @@ if __name__ == '__main__':
sim = SolarSystemRealitySim() sim = SolarSystemRealitySim()
sim.run( sim.run(
# debug_mode=True, # 是否调试模式 # debug_mode=True, # 是否调试模式
# start_time='2023-01-01 02:20:00', # 指定运行的开始时间,不指定为当前时间 start_time='2050-01-01 00:00:00', # 指定运行的开始时间,不指定为当前时间
# show_asteroids=True, # 是否显示小行星带(图片模拟) # show_asteroids=True, # 是否显示小行星带(图片模拟)
# show_earth_clouds=True, # 地球是否显示云层(图片效果,不是真实的云层) # show_earth_clouds=True, # 地球是否显示云层(图片效果,不是真实的云层)
# recalc_moon_pos=False, # 为了更好的展示效果,需要对月球的位置重新计算(使得地月距离放大,月球相对地球方向不变) # recalc_moon_pos=False, # 为了更好的展示效果,需要对月球的位置重新计算(使得地月距离放大,月球相对地球方向不变)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册