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

Python超人-宇宙模拟器

上级 21977b99
......@@ -12,3 +12,5 @@ from objs.core_valaga_clas import CoreValagaClas
from objs.sci_fi_bomber import SciFiBomber
from objs.water_drop import WaterDrop
from objs.sci_fi_gunship import ScifiGunship
from objs.halley_comet import HalleComet
......@@ -6,22 +6,28 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from objs.obj import Obj
from objs import RockSnow
class HalleComet(Obj):
class HalleComet(RockSnow):
"""
哈雷彗星
根据最新信息,哈雷彗星的平均运行速度约为每小时 70,000 英里或每小时 126,000 公里 。
该速度表示彗星穿过太阳系的速度。 值得注意的是,截至 2023 年,所提供的信息都是准确的。
质量: 10^15kg
远日点: 35.1 AU(2023年12月9日)
近日点: 0.586 AU 上次通过近日点:1986年2月9日 下次通过近日点:2061年7月28日
平均密度: 0.6(估计的范围在0.2至1.5g/cm)
来源:https://www.cgmodel.com/model/500318.html
"""
def __init__(self, name="哈雷彗星", mass=5.97237e24,
def __init__(self, name="哈雷彗星", mass=10e15,
init_position=[0, 0, 0],
init_velocity=[0, 0, 0],
texture="drops.png", size_scale=1.0, distance_scale=1.0,
size_scale=1.0, distance_scale=1.0,
ignore_mass=False, density=1e3, color=(7, 0, 162),
trail_color=None, show_name=False,
model="drops.obj", rotation=(0, 0, 0),
rotation=(0, 0, 0),
parent=None, gravity_only_for=[]):
params = {
"name": name,
......@@ -30,7 +36,6 @@ class HalleComet(Obj):
"init_velocity": init_velocity,
"density": density,
"color": color,
"texture": texture,
"size_scale": size_scale,
"distance_scale": distance_scale,
"ignore_mass": ignore_mass,
......@@ -39,7 +44,6 @@ class HalleComet(Obj):
"parent": parent,
"rotation": rotation,
"gravity_only_for": gravity_only_for,
"model": model
}
super().__init__(**params)
......@@ -92,11 +96,7 @@ void main() {
if __name__ == '__main__':
shader = matcap_shader
halle_comet = HalleComet(
# texture="drops_normal.png"
# texture="drops_uvw.png"
texture="drops.png"
)
halle_comet = HalleComet()
halle_comet.init_velocity = [0, 0, -10]
print(halle_comet)
......@@ -107,6 +107,7 @@ if __name__ == '__main__':
halle_comet.planet.init_scale = halle_comet.planet.scale_x * 2
# halle_comet.planet.init_update = halle_comet.planet.update
def on_timer_changed(time_data):
# halle_comet.planet.init_update = body.planet.update
halle_comet.planet.scale_z = halle_comet.planet.init_scale
......
......@@ -12,8 +12,8 @@ from ursina import camera, application
from bodies import Sun, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto
from common.celestial_data_service import get_init_pos_vels, init_bodies_pos_vels
from common.consts import SECONDS_PER_WEEK, AU
from objs import QuadObj, CircleObj, Obj
from common.consts import SECONDS_PER_YEAR, AU
from objs import HalleComet, Obj
from sim_scenes.func import camera_look_at, two_bodies_colliding
from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent
......@@ -32,15 +32,15 @@ class HalleyCometSim:
self.sun = Sun(size_scale=0.8e2)
self.bodies = [
self.sun, # 太阳放大 80 倍
Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍
Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍
Earth(size_scale=4e3, distance_scale=1.3, rotate_angle=0), # 地球放大 4000 倍,距离放大 1.3 倍
Mars(size_scale=4e3, distance_scale=1.2), # 火星放大 4000 倍,距离放大 1.2 倍
Jupiter(size_scale=0.68e3, distance_scale=0.72), # 木星放大 680 倍,距离缩小到真实距离的 0.72
Saturn(size_scale=0.68e3, distance_scale=0.52), # 土星放大 680 倍,距离缩小到真实距离的 0.52
Uranus(size_scale=1.5e3, distance_scale=0.36), # 天王星放大 1500 倍,距离缩小到真实距离的 0.36
Neptune(size_scale=1.5e3, distance_scale=0.27), # 海王星放大 1500 倍,距离缩小到真实距离的 0.27
Pluto(size_scale=10e3, distance_scale=0.23), # 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除)
# Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍
# Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍
# Earth(size_scale=4e3, distance_scale=1.3, rotate_angle=0), # 地球放大 4000 倍,距离放大 1.3 倍
# Mars(size_scale=4e3, distance_scale=1.2), # 火星放大 4000 倍,距离放大 1.2 倍
Jupiter(size_scale=1.68e3, distance_scale=1), # 木星放大 680 倍,距离缩小到真实距离的 0.72
Saturn(size_scale=1.68e3, distance_scale=1), # 土星放大 680 倍,距离缩小到真实距离的 0.52
Uranus(size_scale=3.5e3, distance_scale=1), # 天王星放大 1500 倍,距离缩小到真实距离的 0.36
Neptune(size_scale=3.5e3, distance_scale=1), # 海王星放大 1500 倍,距离缩小到真实距离的 0.27
Pluto(size_scale=1.5e5, distance_scale=1), # 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除)
]
# endregion
......@@ -51,10 +51,14 @@ class HalleyCometSim:
创建哈雷彗星
@return:
"""
self.halley_comet = QuadObj(texture='two_way_foil.png',
# size_scale=4e7,
size_scale=1e7,
init_velocity=[20, -6, 150],
# 哈雷彗星的平均运行速度约为每小时 70,000 英里或每小时 126,000 公里 。(35公里/秒)
# 每76.1年环绕太阳一周的周期彗星
# 3.335, 0, 10.7 73
# 3.33, 0, 10.7 73
self.halley_comet = HalleComet(# size_scale=4e7,
size_scale=1e8,
init_velocity=[3.33, 0, 10.65], # [3.33, 0, 10.6] < ? <[3.34, 0, 10.7]
init_position=[0, 0.5 * AU, -10 * AU]) \
.set_light_disable(True)
......@@ -89,7 +93,7 @@ class HalleyCometSim:
self.halley_comet.planet.rotation_x += 0.1
self.halley_comet.planet.rotation_y += 1
# 摄像机始终看向二向箔
camera_look_at(self.halley_comet)
# camera_look_at(self.halley_comet)
......@@ -108,12 +112,13 @@ if __name__ == '__main__':
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run(sim.bodies,
SECONDS_PER_WEEK,
SECONDS_PER_YEAR,
# position=(0, 2 * AU, -11 * AU),
position=(0, 0.5 * AU, -5 * AU),
cosmic_bg='',
bg_music='sounds/no_glory.mp3',
show_trail=True,
# bg_music='sounds/no_glory.mp3',
show_camera_info=False,
show_control_info=False,
timer_enabled=True,
show_timer=True,
show_grid=False)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册