Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
66927fa6
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
66927fa6
编写于
12月 13, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
b50558b1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
104 addition
and
42 deletion
+104
-42
sim_scenes/featured/the_lost_planet.py
sim_scenes/featured/the_lost_planet.py
+104
-42
未找到文件。
sim_scenes/featured/the_lost_planet.py
浏览文件 @
66927fa6
...
@@ -39,7 +39,8 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -39,7 +39,8 @@ class TheLostPlanetSim(UniverseSimScenes):
self
.
mars
=
Mars
(
size_scale
=
3e3
,
distance_scale
=
2.95
)
self
.
mars
=
Mars
(
size_scale
=
3e3
,
distance_scale
=
2.95
)
self
.
jupiter
=
Jupiter
(
size_scale
=
0.68e3
,
distance_scale
=
1.12
)
self
.
jupiter
=
Jupiter
(
size_scale
=
0.68e3
,
distance_scale
=
1.12
)
self
.
saturn
=
Saturn
(
size_scale
=
0.68e3
,
distance_scale
=
0.74
)
self
.
saturn
=
Saturn
(
size_scale
=
0.68e3
,
distance_scale
=
0.74
)
self
.
uranus
=
Uranus
(
size_scale
=
0.8e3
,
distance_scale
=
0.43
)
self
.
neptune
=
Neptune
(
size_scale
=
1e3
,
distance_scale
=
0.3
)
# self.ship = ScifiGunship(name="飞船", mass=1e30, color=(111, 140, 255),
# self.ship = ScifiGunship(name="飞船", mass=1e30, color=(111, 140, 255),
# init_position=self.mars.init_position,
# init_position=self.mars.init_position,
# init_velocity=[0, 0, 0],
# init_velocity=[0, 0, 0],
...
@@ -59,9 +60,10 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -59,9 +60,10 @@ class TheLostPlanetSim(UniverseSimScenes):
# Earth(size_scale=3e3, init_position=[0, 0, (3.64) * AU]), # 地球放大 4000 倍
# Earth(size_scale=3e3, init_position=[0, 0, (3.64) * AU]), # 地球放大 4000 倍
self
.
jupiter
,
# 木星放大 680 倍
self
.
jupiter
,
# 木星放大 680 倍
self
.
saturn
,
# 土星放大 680 倍
self
.
saturn
,
# 土星放大 680 倍
Uranus
(
size_scale
=
0.8e3
,
distance_scale
=
0.43
)
,
# 天王星放大 800 倍
self
.
uranus
,
# 天王星放大 800 倍
Neptune
(
size_scale
=
1e3
,
distance_scale
=
0.3
)
,
# 海王星放大 1000 倍
self
.
neptune
,
# 海王星放大 1000 倍
]
]
self
.
asteroids
=
[]
# 水星 0.4AU
# 水星 0.4AU
# 金星 0.4+0.3 AU
# 金星 0.4+0.3 AU
# 地球 0.4+0.6 AU
# 地球 0.4+0.6 AU
...
@@ -139,7 +141,7 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -139,7 +141,7 @@ class TheLostPlanetSim(UniverseSimScenes):
# self.asteroids.planet.enabled = False
# self.asteroids.planet.enabled = False
self
.
moon
.
planet
.
enabled
=
False
self
.
moon
.
planet
.
enabled
=
False
application
.
time_scale
=
0.1
application
.
time_scale
=
0.
0000
1
# ceres.planet.enabled = False
# ceres.planet.enabled = False
# self.moon.planet.look_at(self.mars.planet)
# self.moon.planet.look_at(self.mars.planet)
...
@@ -211,7 +213,6 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -211,7 +213,6 @@ class TheLostPlanetSim(UniverseSimScenes):
return
asteroid
return
asteroid
def
create_asteroids
(
self
):
def
create_asteroids
(
self
):
self
.
asteroids
=
[]
for
i
in
range
(
400
):
for
i
in
range
(
400
):
self
.
asteroids
.
append
(
self
.
create_asteroid
(
i
))
self
.
asteroids
.
append
(
self
.
create_asteroid
(
i
))
...
@@ -219,6 +220,20 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -219,6 +220,20 @@ class TheLostPlanetSim(UniverseSimScenes):
# for a in self.asteroids:
# for a in self.asteroids:
# a.enabled = False
# a.enabled = False
def
one_asteroid_fade_in
(
self
):
self
.
asteroids
.
append
(
self
.
create_asteroid
(
init_angle
=
180
))
# if not hasattr(self, "one_asteroid_fade_in_index"):
# self.one_asteroid_fade_in_index = 0
# self.one_asteroid_fade_in_last_time = time.time()
# self.asteroids.append(self.create_asteroid(init_angle=180))
# c_time = time.time()
# if c_time - self.one_asteroid_fade_in_last_time > 2:
# self.asteroids.append(self.create_asteroid(init_angle=180))
# self.one_asteroid_fade_in_last_time = c_time
# self.one_asteroid_fade_in_index += 1
# if self.one_asteroid_fade_in_index >= 4:
# self.step_index += 1
def
asteroid_fade_in
(
self
):
def
asteroid_fade_in
(
self
):
"""
"""
小行星群渐渐显示
小行星群渐渐显示
...
@@ -238,39 +253,77 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -238,39 +253,77 @@ class TheLostPlanetSim(UniverseSimScenes):
def
init_steps
(
self
):
def
init_steps
(
self
):
def
earth_orbit_the_sun
():
for
body_name
in
[
"earth"
,
"mars"
,
"venus"
,
"mercury"
,
self
.
body_orbit_the_sun
(
self
.
earth
,
90
)
"jupiter"
,
"saturn"
,
"uranus"
,
"neptune"
]:
def
fun
(
name
):
body
=
getattr
(
self
,
name
)
def
mars_orbit_the_sun
():
def
warp
():
self
.
body_orbit_the_sun
(
self
.
mars
,
90
)
self
.
body_orbit_the_sun
(
body
,
90
)
def
venus_orbit_the_sun
():
warp
.
__name__
=
f
"
{
body_name
}
_orbit_the_sun"
self
.
body_orbit_the_sun
(
self
.
venus
,
90
)
return
warp
def
mercury_orbit_the_sun
():
setattr
(
self
,
f
"
{
body_name
}
_orbit_the_sun"
,
fun
(
body_name
))
self
.
body_orbit_the_sun
(
self
.
mercury
,
90
)
def
jupter_orbit_the_sun
():
self
.
body_orbit_the_sun
(
self
.
jupiter
,
90
)
def
saturn_orbit_the_sun
():
self
.
body_orbit_the_sun
(
self
.
saturn
,
90
)
# def earth_orbit_the_sun():
# 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():
# self.body_orbit_the_sun(self.jupiter, 90)
#
# def saturn_orbit_the_sun():
# self.body_orbit_the_sun(self.saturn, 90)
# fun, wait_days, run_times
self
.
steps
=
[
self
.
steps
=
[
(
mercury_orbit_the_sun
,
100
,
1
),
# 第1波行星
(
venus
_orbit_the_sun
,
100
,
1
),
(
self
.
mercury
_orbit_the_sun
,
100
,
1
),
(
earth
_orbit_the_sun
,
100
,
1
),
(
self
.
venus
_orbit_the_sun
,
100
,
1
),
(
mars_orbit_the_sun
,
6
00
,
1
),
(
self
.
earth_orbit_the_sun
,
1
00
,
1
),
(
jupter_orbit_the_sun
,
1
00
,
1
),
(
self
.
mars_orbit_the_sun
,
6
00
,
1
),
(
saturn_orbit_the_sun
,
600
,
1
),
# 第2波行星
(
self
.
asteroid_fade_in
,
9
00
,
1
),
(
self
.
jupiter_orbit_the_sun
,
1
00
,
1
),
(
self
.
asteroid_fade_out
,
9
00
,
1
),
(
self
.
saturn_orbit_the_sun
,
6
00
,
1
),
#
fun, wait_days, run_times
#
第3波行星
(
self
.
camera_back_1
,
900
,
-
1
),
(
self
.
camera_back_1
,
900
,
-
1
),
(
self
.
camera_back_2
,
-
1
,
-
1
),
(
self
.
uranus_orbit_the_sun
,
900
,
1
),
# 发现几个小行星
(
self
.
one_asteroid_fade_in
,
100
,
1
),
(
self
.
one_asteroid_fade_in
,
100
,
1
),
(
self
.
one_asteroid_fade_in
,
100
,
1
),
(
self
.
one_asteroid_fade_in
,
900
,
1
),
(
self
.
asteroid_fade_out
,
300
,
1
),
# 发现小行星带
(
self
.
asteroid_fade_in
,
900
,
1
),
# (self.asteroid_fade_out, 900, 1),
# 第4波行星
(
self
.
camera_back_2
,
900
,
-
1
),
(
self
.
neptune_orbit_the_sun
,
900
,
1
),
(
lambda
:
None
,
-
1
,
-
1
)
(
lambda
:
None
,
-
1
,
-
1
)
]
]
self
.
_steps
=
[]
self
.
_fun_names
=
{}
for
s
in
self
.
steps
:
f_name
=
s
[
0
].
__name__
if
f_name
in
self
.
_fun_names
.
keys
():
self
.
_fun_names
[
f_name
]
+=
1
else
:
self
.
_fun_names
[
f_name
]
=
0
self
.
_steps
.
append
((
s
[
0
],
s
[
1
],
s
[
2
],
str
(
self
.
_fun_names
[
f_name
])))
self
.
steps
=
self
.
_steps
def
body_orbit_the_sun
(
self
,
body
,
start_angle
,
angle_speed
=
0.5
):
def
body_orbit_the_sun
(
self
,
body
,
start_angle
,
angle_speed
=
0.5
):
if
not
hasattr
(
body
,
"orbit_radius"
):
if
not
hasattr
(
body
,
"orbit_radius"
):
body
.
orbit_radius
=
body
.
position
[
0
]
*
UrsinaConfig
.
SCALE_FACTOR
*
body
.
distance_scale
body
.
orbit_radius
=
body
.
position
[
0
]
*
UrsinaConfig
.
SCALE_FACTOR
*
body
.
distance_scale
...
@@ -293,28 +346,37 @@ class TheLostPlanetSim(UniverseSimScenes):
...
@@ -293,28 +346,37 @@ class TheLostPlanetSim(UniverseSimScenes):
body
.
planet
.
update
=
orbit_update
body
.
planet
.
update
=
orbit_update
def
camera_back_1
(
self
):
def
camera_back_1
(
self
):
if
camera
.
position
[
2
]
<
460
:
if
camera
.
position
[
2
]
>
-
450
:
camera
.
position
+=
camera
.
back
camera
.
position
+=
camera
.
right
*
0.2
camera
.
position
+=
camera
.
back
*
0.5
print
(
camera
.
position
)
def
camera_back_2
(
self
):
def
camera_back_2
(
self
):
if
camera
.
position
[
2
]
<
550
:
if
camera
.
position
[
2
]
>
-
550
:
# camera.position += camera.right
camera
.
position
+=
camera
.
right
*
0.2
camera
.
position
+=
camera
.
back
camera
.
position
+=
camera
.
back
*
0.5
def
on_timer_changed
(
self
,
time_data
):
def
on_timer_changed
(
self
,
time_data
):
# camera.position += camera.right
# camera.position += camera.right
if
time_data
.
total_days
>
0
:
if
time_data
.
total_days
>
0
:
if
self
.
step_index
>
len
(
self
.
steps
)
-
1
:
if
self
.
step_index
>
len
(
self
.
steps
)
-
1
:
self
.
step_index
=
len
(
self
.
steps
)
-
1
self
.
step_index
=
len
(
self
.
steps
)
-
1
fun
,
wait_days
,
run_times
=
self
.
steps
[
self
.
step_index
]
step
=
self
.
steps
[
self
.
step_index
]
if
not
hasattr
(
self
,
f
"
{
fun
.
__name__
}
_wait_days"
):
if
len
(
step
)
==
3
:
setattr
(
self
,
f
"
{
fun
.
__name__
}
_wait_days"
,
time_data
.
total_days
)
fun
,
wait_days
,
run_times
=
step
setattr
(
self
,
f
"
{
fun
.
__name__
}
_run_times"
,
0
)
fun_name
=
fun
.
__name__
fun_run_times
=
getattr
(
self
,
f
"
{
fun
.
__name__
}
_run_times"
)
elif
len
(
step
)
==
4
:
fun
,
wait_days
,
run_times
,
fun_name
=
step
fun_name
=
fun
.
__name__
+
"_"
+
fun_name
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
:
if
fun_run_times
<
run_times
or
run_times
<
0
:
fun
()
fun
()
setattr
(
self
,
f
"
{
fun
.
__name__
}
_run_times"
,
fun_run_times
+
1
)
setattr
(
self
,
f
"
{
fun
_name
}
_run_times"
,
fun_run_times
+
1
)
fun_wait_days
=
getattr
(
self
,
f
"
{
fun
.
__name__
}
_wait_days"
)
fun_wait_days
=
getattr
(
self
,
f
"
{
fun
_name
}
_wait_days"
)
if
wait_days
+
fun_wait_days
<
time_data
.
total_days
and
wait_days
>
0
:
if
wait_days
+
fun_wait_days
<
time_data
.
total_days
and
wait_days
>
0
:
self
.
step_index
+=
1
self
.
step_index
+=
1
# print(self.step_index, fun.__name__)
# print(self.step_index, fun.__name__)
...
@@ -340,7 +402,7 @@ if __name__ == '__main__':
...
@@ -340,7 +402,7 @@ if __name__ == '__main__':
# position=(0, 2 * AU, -11 * AU),
# position=(0, 2 * AU, -11 * AU),
# position=(0, 20 * AU, 10 * AU),
# position=(0, 20 * AU, 10 * AU),
# position=(4.5 * AU, AU, 5 * AU),
# position=(4.5 * AU, AU, 5 * AU),
position
=
(
5
*
AU
,
AU
/
2
,
-
5
*
AU
),
position
=
(
5
*
AU
,
AU
/
1.5
,
-
5
*
AU
),
timer_enabled
=
True
,
timer_enabled
=
True
,
# show_timer=True,
# show_timer=True,
cosmic_bg
=
''
,
cosmic_bg
=
''
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录