Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
71ab2bba
宇宙模拟器
项目概览
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看板
提交
71ab2bba
编写于
6月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
d661e2df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
15 deletion
+26
-15
sim_scenes/solar_system/solarsystem_planets_size.py
sim_scenes/solar_system/solarsystem_planets_size.py
+26
-15
未找到文件。
sim_scenes/solar_system/solarsystem_planets_size.py
浏览文件 @
71ab2bba
...
...
@@ -10,24 +10,26 @@ from bodies import Sun, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Ne
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.ursina_event
import
UrsinaEvent
# 可以调整整体放大倍数 ,比例会保持不变
FACTOR
=
10
# 地球和月球之间的距离常量,距地距离约: 363104 至 405696 km,平均距离 384000 km
E_M_DISTANCE
=
405696
earth
=
Earth
(
"地球"
,
init_position
=
[
0
,
0
,
0
])
moon
=
Moon
(
"月球"
,
init_position
=
[
E_M_DISTANCE
,
0
,
0
])
E_M_DISTANCE
=
405696
*
FACTOR
earth
=
Earth
(
"地球"
,
size_scale
=
FACTOR
,
init_position
=
[
0
,
0
,
0
])
moon
=
Moon
(
"月球"
,
size_scale
=
FACTOR
,
init_position
=
[
E_M_DISTANCE
,
0
,
0
])
bodies
=
[
earth
,
moon
,
Mercury
(
name
=
"水星"
),
Venus
(
name
=
"金星"
),
Mars
(
name
=
"火星"
),
Jupiter
(
name
=
"木星"
),
Saturn
(
name
=
"土星"
).
show_rings
(
False
),
Uranus
(
name
=
"天王星"
),
Neptune
(
name
=
"海王星"
),
Pluto
(
name
=
"冥王星"
)
Mercury
(
name
=
"水星"
,
size_scale
=
FACTOR
),
Venus
(
name
=
"金星"
,
size_scale
=
FACTOR
),
Mars
(
name
=
"火星"
,
size_scale
=
FACTOR
),
Jupiter
(
name
=
"木星"
,
size_scale
=
FACTOR
),
Saturn
(
name
=
"土星"
,
size_scale
=
FACTOR
).
show_rings
(
False
),
Uranus
(
name
=
"天王星"
,
size_scale
=
FACTOR
),
Neptune
(
name
=
"海王星"
,
size_scale
=
FACTOR
),
Pluto
(
name
=
"冥王星"
,
size_scale
=
FACTOR
)
]
# 从第三个星球(水星)开始
...
...
@@ -35,14 +37,21 @@ index = 2
last_total_hours
=
0
if
__name__
==
'__main__'
:
last_diameter
=
earth
.
diameter
/
2
last_diameter
=
earth
.
diameter
*
FACTOR
/
2
plant_positions
=
[]
for
i
,
body
in
enumerate
(
bodies
):
body
.
ignore_mass
=
True
body
.
init_velocity
=
[
0
,
0
,
0
]
if
i
>=
2
:
# 从第三个星球(水星)开始
plant_positions
.
append
([(
body
.
diameter
/
2
)
+
last_diameter
,
0
,
0
])
last_diameter
+=
body
.
diameter
plant_positions
.
append
([(
body
.
diameter
*
FACTOR
/
2
)
+
last_diameter
,
0
,
0
])
last_diameter
+=
body
.
diameter
*
FACTOR
def
on_ready
():
# 运行前触发
# 为了较好的立体效果,可以增加太阳光线,光线直射地球(target=earth)
create_directional_light
(
position
=
(
E_M_DISTANCE
/
2
,
0
,
-
E_M_DISTANCE
*
100
),
light_num
=
3
,
target
=
earth
)
def
on_timer_changed
(
time_data
:
TimeData
):
global
index
,
last_total_hours
...
...
@@ -58,6 +67,8 @@ if __name__ == '__main__':
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录