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

Python超人-宇宙模拟器

上级 3a0f31d4
......@@ -198,9 +198,9 @@ class SolarSystemRealitySim(UniverseSimScenes):
target = self.targets[self.target_index]
planet = target.planet.main_entity
camera.look_at(planet)
camera.position = self.ship.planet.position + Vec3(10, 10, 10)
# camera.look_at(planet)
#
# camera.position = self.ship.planet.position + Vec3(10, 10, 10)
dt = time_data.get_datetime(str(self.start_time))
# 设置天体的位置(包含速度和加速度的信息)
self.set_bodies_position(time_data)
......@@ -286,7 +286,7 @@ if __name__ == '__main__':
dt=SECONDS_PER_DAY , # 1秒=1天
# dt=SECONDS_PER_WEEK, # 1秒=1周
# dt=SECONDS_PER_HOUR, # 1秒=1小时
start_time='2149-12-10 12:00:00', # 九(八)星连珠的时间 # https://baijiahao.baidu.com/s?id=1654160345900112362
start_time='2149-01-01 12:00:00', # 九(八)星连珠的时间 # https://baijiahao.baidu.com/s?id=1654160345900112362
# show_asteroids=True, # 是否显示小行星带(图片模拟)
show_earth_clouds=True, # 地球是否显示云层(图片效果,不是真实的云层)
# recalc_moon_pos=False, # 为了更好的展示效果,需要对月球的位置重新计算(使得地月距离放大,月球相对地球方向不变)
......
......@@ -239,27 +239,34 @@ class TheLostPlanetSim(UniverseSimScenes):
def init_steps(self):
def earth_orbit_the_sun():
if not hasattr(self, "moon_aroundearth"):
# setattr(self, "step_04", True)
self.body_orbit_the_sun(self.earth, 90)
self.body_orbit_the_sun(self.mars, 90)
self.body_orbit_the_sun(self.venus, 90)
self.body_orbit_the_sun(self.mercury, 90)
self.body_orbit_the_sun(self.earth, 90)
def mars_orbit_the_sun():
self.body_orbit_the_sun(self.mars, 90)
def venus_orbit_the_sun():
self.body_orbit_the_sun(self.venus, 90)
def mercury_orbit_the_sun():
self.body_orbit_the_sun(self.mercury, 90)
def jupter_orbit_the_sun():
if not hasattr(self, "moon_aroundearth"):
# setattr(self, "step_04", True)
self.body_orbit_the_sun(self.jupiter, 90)
self.body_orbit_the_sun(self.saturn, 90)
self.body_orbit_the_sun(self.jupiter, 90)
def saturn_orbit_the_sun():
self.body_orbit_the_sun(self.saturn, 90)
self.steps = [
(earth_orbit_the_sun, 3, 1),
(jupter_orbit_the_sun, 3, 1),
(self.asteroid_fade_in, 3, 1),
(self.asteroid_fade_out, 3, 1),
# fun, wait_years, run_times
(self.camera_back_1, 3, -1),
(mercury_orbit_the_sun, 100, 1),
(venus_orbit_the_sun, 100, 1),
(earth_orbit_the_sun, 100, 1),
(mars_orbit_the_sun, 600, 1),
(jupter_orbit_the_sun, 100, 1),
(saturn_orbit_the_sun,600, 1),
(self.asteroid_fade_in, 900, 1),
(self.asteroid_fade_out, 900, 1),
# fun, wait_days, run_times
(self.camera_back_1, 900, -1),
(self.camera_back_2, -1, -1),
(lambda: None, -1, -1)
]
......@@ -286,31 +293,29 @@ class TheLostPlanetSim(UniverseSimScenes):
body.planet.update = orbit_update
def camera_back_1(self):
return
if camera.position[0] < 460:
if camera.position[2] < 460:
camera.position += camera.back
def camera_back_2(self):
return
if camera.position[0] < 550:
if camera.position[2] < 550:
# camera.position += camera.right
camera.position += camera.back
def on_timer_changed(self, time_data):
# camera.position += camera.right
if time_data.years > 1:
if time_data.total_days > 0:
if self.step_index > len(self.steps) - 1:
self.step_index = len(self.steps) - 1
fun, wait_years, run_times = self.steps[self.step_index]
if not hasattr(self, f"{fun.__name__}_wait_years"):
setattr(self, f"{fun.__name__}_wait_years", time_data.years)
fun, wait_days, run_times = self.steps[self.step_index]
if not hasattr(self, f"{fun.__name__}_wait_days"):
setattr(self, f"{fun.__name__}_wait_days", time_data.total_days)
setattr(self, f"{fun.__name__}_run_times", 0)
fun_run_times = getattr(self, f"{fun.__name__}_run_times")
if fun_run_times < run_times or run_times < 0:
fun()
setattr(self, f"{fun.__name__}_run_times", fun_run_times + 1)
fun_wait_years = getattr(self, f"{fun.__name__}_wait_years")
if wait_years + fun_wait_years < time_data.years and wait_years > 0:
fun_wait_days = getattr(self, f"{fun.__name__}_wait_days")
if wait_days + fun_wait_days < time_data.total_days and wait_days > 0:
self.step_index += 1
# print(self.step_index, fun.__name__)
......@@ -335,7 +340,7 @@ if __name__ == '__main__':
# position=(0, 2 * AU, -11 * AU),
# position=(0, 20 * AU, 10 * AU),
# position=(4.5 * AU, AU, 5 * AU),
position=(5 * AU, AU/2, -5 * AU),
position=(5 * AU, AU / 2, -5 * AU),
timer_enabled=True,
# show_timer=True,
cosmic_bg='',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册