Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
4145fa26
宇宙模拟器
项目概览
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看板
提交
4145fa26
编写于
7月 05, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
f00033a8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
13 deletion
+28
-13
sim_scenes/science/speed_of_light_3d.py
sim_scenes/science/speed_of_light_3d.py
+26
-11
sim_scenes/science/speed_of_light_init.py
sim_scenes/science/speed_of_light_init.py
+2
-2
未找到文件。
sim_scenes/science/speed_of_light_3d.py
浏览文件 @
4145fa26
...
@@ -29,13 +29,18 @@ init = SpeedOfLightInit(camera_follow_light)
...
@@ -29,13 +29,18 @@ init = SpeedOfLightInit(camera_follow_light)
# 创建太阳系天体(忽略质量,引力无效,初速度全部为0)
# 创建太阳系天体(忽略质量,引力无效,初速度全部为0)
bodies
=
create_solar_system_bodies
(
ignore_mass
=
True
,
init_velocity
=
[
0
,
0
,
0
])
bodies
=
create_solar_system_bodies
(
ignore_mass
=
True
,
init_velocity
=
[
0
,
0
,
0
])
distance_scales
=
[
1
,
2.4
,
2.05
,
2.03
,
2.1
,
1.8
,
0.72
,
0.6
,
0.40
,
0.30
,
0.26
]
jupiter
,
saturn
,
uranus
,
neptune
=
bodies
[
6
:
10
]
for
big_body
in
[
jupiter
,
saturn
,
uranus
,
neptune
]:
big_body
.
init_position
[
0
]
=
big_body
.
radius
*
big_body
.
size_scale
distance_scales
=
[
1
,
2.0
,
1.5
,
1.48
,
1.65
,
1.5
,
0.82
,
0.75
,
0.50
,
0.40
,
0.33
]
for
idx
,
body
in
enumerate
(
bodies
):
for
idx
,
body
in
enumerate
(
bodies
):
body
.
distance_scale
=
distance_scales
[
idx
]
body
.
distance_scale
=
distance_scales
[
idx
]
if
idx
>
0
:
#
if idx > 0:
body
.
init_position
[
0
]
=
-
body
.
radius
*
body
.
size_scale
# body.init_position[0] = body.diameter
* body.size_scale
body
.
init_position
[
1
]
=
-
body
.
diameter
*
body
.
size_scale
# body.init_position[1] = -body.radius * body.size_scale / 10
body
.
rotation_speed
*=
20
body
.
rotation_speed
*=
20
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
...
@@ -53,7 +58,7 @@ elif camera_pos == "left": # 摄像机左眼
...
@@ -53,7 +58,7 @@ elif camera_pos == "left": # 摄像机左眼
init
.
light_init_position
[
0
]
-=
camera_l2r
init
.
light_init_position
[
0
]
-=
camera_l2r
init
.
light_init_position
[
0
]
=
5000000
init
.
light_init_position
[
0
]
=
5000000
init
.
light_init_position
[
1
]
=
150000
0
init
.
light_init_position
[
1
]
=
150000
# init.auto_control_speed = True
# init.auto_control_speed = True
init
.
camera_position
=
(
0
,
-
AU
/
100
,
-
AU
/
50
)
init
.
camera_position
=
(
0
,
-
AU
/
100
,
-
AU
/
50
)
...
@@ -126,17 +131,27 @@ UrsinaEvent.on_before_evolving_subscription(on_before_evolving)
...
@@ -126,17 +131,27 @@ UrsinaEvent.on_before_evolving_subscription(on_before_evolving)
def
body_arrived
(
body
):
def
body_arrived
(
body
):
# # 到达每个行星都会触发,对光速飞船进行加速,超光速前进(使用未来曲率引擎技术)
# # 到达每个行星都会触发,对光速飞船进行加速,超光速前进(使用未来曲率引擎技术)
# if body.name == "火星": # 到达火星,加速前进,并进行攀升
if
body
.
name
==
"金星"
:
# 到达金星,木星开始调整位置
# light_ship.acceleration = [120, 150, 1000]
jupiter
.
acceleration
[
0
]
=
-
35
# elif body.name == "木星": # 到达木星,加速前进,并进行下降
jupiter
.
acceleration
[
1
]
=
-
15
# light_ship.acceleration = [-200, -600, 5000]
elif
body
.
name
==
"火星"
:
# 到达火星,土星开始调整位置
saturn
.
acceleration
[
0
]
=
-
16
saturn
.
acceleration
[
1
]
=
-
8
elif
body
.
name
==
"木星"
:
# 到达木星,天王星开始调整位置
uranus
.
acceleration
[
0
]
=
-
8
uranus
.
acceleration
[
1
]
=
-
5
elif
body
.
name
==
"土星"
:
# 到达土星,海王星开始调整位置
neptune
.
acceleration
[
0
]
=
-
20
neptune
.
acceleration
[
1
]
=
-
8
# saturn, uranus, neptune
# elif body.name == "土星": # 到达土星,加速前进,并进行攀升
# elif body.name == "土星": # 到达土星,加速前进,并进行攀升
# light_ship.acceleration = [-150, 100, 0]
# light_ship.acceleration = [-150, 100, 0]
# elif body.name == "天王星": # 到达天王星,加速前进,并进行下降
# elif body.name == "天王星": # 到达天王星,加速前进,并进行下降
# light_ship.acceleration = [0, 200, 0]
# light_ship.acceleration = [0, 200, 0]
# elif body.name == "海王星": # 到达海王星,加速前进,并进行攀升
# elif body.name == "海王星": # 到达海王星,加速前进,并进行攀升
# light_ship.acceleration = [150, -550, -2500]
# light_ship.acceleration = [150, -550, -2500]
if
body
.
name
==
"冥王星"
:
elif
body
.
name
==
"冥王星"
:
exit
(
0
)
exit
(
0
)
# print(body)
# print(body)
...
@@ -160,7 +175,7 @@ init.body_arrived = body_arrived
...
@@ -160,7 +175,7 @@ init.body_arrived = body_arrived
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
1
0
,
ursina_run
(
bodies
,
3
0
,
position
=
init
.
camera_position
,
position
=
init
.
camera_position
,
# show_trail=init.show_trail,
# show_trail=init.show_trail,
# show_timer=True,
# show_timer=True,
...
...
sim_scenes/science/speed_of_light_init.py
浏览文件 @
4145fa26
...
@@ -282,10 +282,10 @@ class SpeedOfLightInit:
...
@@ -282,10 +282,10 @@ class SpeedOfLightInit:
# 对于光速天体、太阳、小行星群、“已到达天体列表”中的天体无需计算
# 对于光速天体、太阳、小行星群、“已到达天体列表”中的天体无需计算
continue
continue
# 计算判断,如果光速天体距离到达了某个天体,就记录到“已到达天体列表”中
# 计算判断,如果光速天体距离到达了某个天体,就记录到“已到达天体列表”中
if
self
.
light_ship
.
position
[
2
]
>=
body
.
position
[
2
]:
if
self
.
light_ship
.
position
[
2
]
>=
body
.
position
[
2
]
*
body
.
distance_scale
:
if
callable
(
self
.
body_arrived
):
if
callable
(
self
.
body_arrived
):
self
.
body_arrived
(
body
)
self
.
body_arrived
(
body
)
self
.
arrived_bodies
.
append
(
body
)
self
.
arrived_bodies
.
append
(
body
)
if
self
.
text_panel
is
not
None
:
if
self
.
text_panel
is
not
None
:
self
.
arrived_info
+=
f
"[
{
time_data
.
time_text
}
]
\t
到达
\t
[
{
body
.
name
}
]
\n\n
"
self
.
arrived_info
+=
f
"[
{
time_data
.
time_text
}
]
\t
到达
\t
[
{
body
.
name
}
]
\n\n
"
# distance = round(self.light_body.position[2] / AU, 4)
# distance = round(self.light_body.position[2] / AU, 4)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录