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

Python超人-宇宙模拟器

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