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

Python超人-宇宙模拟器

上级 abaf8cf2
......@@ -6,6 +6,8 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# ==============================================================================
import math
from ursina import camera
from bodies import Sun, Earth
......@@ -40,6 +42,7 @@ class LookAtSkyOnEarth(UniverseSimScenes):
self.show_china = show_china
self.show_name = show_name
self.exit_at_total_days = exit_at_total_days
self.angle = 55
earth_transparent = look_point is not None
......@@ -63,6 +66,7 @@ class LookAtSkyOnEarth(UniverseSimScenes):
earth_cn_size_factor=earth_cn_size_factor,
earth_clouds_size_factor=earth_clouds_size_factor)
self.earth.set_resolution(200)
self.earth.set_light_disable(True)
# # 地球立春的位置和速度
# self.earth.init_position = [-9.1507536e+07, 0.0000000e+00, 1.1907757e+08]
......@@ -96,26 +100,38 @@ class LookAtSkyOnEarth(UniverseSimScenes):
from simulators.ursina.ursina_mesh import create_sphere
from ursina import Entity, color
r = 0.5
y = 0.4
x = -0.26
watcher_e = Entity(parent=self.earth.planet,
model=create_sphere(r, 32),
scale=0.05,
y=0.0, x=x-0.17, z=pow(pow(r, 2) - pow(x-0.17, 2), 0.5), color=color.green)
scale = 0.05
# subdivisions = 16
x_y_angle = math.pi * self.angle / 180
xr = r * math.cos(x_y_angle)
y = r * math.sin(x_y_angle)
# z = pow(pow(r, 2) - pow(x, 2) - pow(y, 2), 0.5)
x_z_angle = math.pi * 45 / 180
x = r * math.cos(x_z_angle)
z = r * math.sin(x_z_angle)
watcher_e = Entity(parent=self.earth.planet,
model="sphere", # create_sphere(r, subdivisions),
scale=scale,
y=0.0, x=-x, z=z, color=color.red)
# y=0.0, x=x-0.17, z=pow(pow(r, 2) - pow(x-0.17, 2), 0.5), color=color.green)
x = xr * math.cos(x_z_angle)
z = xr * math.sin(x_z_angle)
watcher_n = Entity(parent=self.earth.planet,
model=create_sphere(r, 32),
scale=0.05,
y=y, x=x, z=pow(pow(r, 2) - pow(x, 2) - pow(y, 2), 0.5), color=color.red)
model="sphere", # create_sphere(r, subdivisions),
scale=scale,
y=y, x=-x, z=z, color=color.green)
# y=y, x=x, z=pow(pow(r, 2) - pow(x, 2) - pow(y, 2), 0.5), color=color.red)
watcher_s = Entity(parent=self.earth.planet,
model=create_sphere(r, 32),
scale=0.05,
y=-y, x=x, z=pow(pow(r, 2) - pow(x, 2) - pow(y, 2), 0.5), color=color.blue)
model="sphere", # create_sphere(r, subdivisions),
scale=scale,
y=-y, x=-x, z=z, color=color.blue)
# y=-y, x=x, z=pow(pow(r, 2) - pow(x, 2) - pow(y, 2), 0.5), color=color.blue)
def on_ready(self):
self.earth.planet.rotation_y -= 180 # 一开始就正对太阳
# self.earth.planet.alpha = 0.2
self.earth.planet.alpha = 0.8
# self.earth_cn.planet.rotation_y -= 185 # 一开始就正对太阳
if hasattr(self.earth_clouds, "planet"):
self.earth_clouds.planet.rotation_y -= 50 # 一开始就正对太阳
......@@ -175,7 +191,7 @@ class LookAtSkyOnEarth(UniverseSimScenes):
# if self.look_point == 1:
if self.look_point is not None:
camera.rotation_x = 50 * self.look_point
camera.rotation_x = self.angle * self.look_point
# camera.rotation_x = 50 # 1 南半球
# if self.look_at_earth:
if self.look_point is None:
......@@ -209,7 +225,7 @@ class LookAtSkyOnEarth(UniverseSimScenes):
self.create_sky_watchers()
def on_timer_changed(self, time_data: TimeData):
if abs(self.earth.planet.init_rotation_y - self.earth.planet.rotation_y) > 365:
if abs(self.earth.planet.init_rotation_y - self.earth.planet.rotation_y) > 380:
exit(0)
# if self.show_china and self.wait_days_count > 0:
# self.wait_days_count = self.wait_days - time_data.total_days
......@@ -261,4 +277,4 @@ if __name__ == '__main__':
"""
# -1:北半球 Northern Hemisphere, 1:南半球 Southern Hemisphere, 0:赤道 Equator
sim = LookAtSkyOnEarth()
sim.run()
sim.run(speed_factor=0.9)
......@@ -15,4 +15,4 @@ if __name__ == '__main__':
"""
# -1:北半球 Northern Hemisphere, 1:南半球 Southern Hemisphere, 0:赤道 Equator
sim = LookAtSkyOnEarth(look_point=0)
sim.run()
sim.run(speed_factor=0.85)
......@@ -15,4 +15,4 @@ if __name__ == '__main__':
"""
# -1:北半球 Northern Hemisphere, 1:南半球 Southern Hemisphere, 0:赤道 Equator
sim = LookAtSkyOnEarth(look_point=-1)
sim.run()
sim.run(speed_factor=0.85)
......@@ -15,4 +15,4 @@ if __name__ == '__main__':
"""
# -1:北半球 Northern Hemisphere, 1:南半球 Southern Hemisphere, 0:赤道 Equator
sim = LookAtSkyOnEarth(look_point=1)
sim.run()
sim.run(speed_factor=0.85)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册