Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
2d83330b
宇宙模拟器
项目概览
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看板
提交
2d83330b
编写于
6月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
71ab2bba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
6 deletion
+12
-6
bodies/earth.py
bodies/earth.py
+1
-1
sim_scenes/solar_system/solarsystem_planets_size.py
sim_scenes/solar_system/solarsystem_planets_size.py
+11
-5
未找到文件。
bodies/earth.py
浏览文件 @
2d83330b
...
@@ -26,7 +26,7 @@ class Earth(Body):
...
@@ -26,7 +26,7 @@ class Earth(Body):
def
__init__
(
self
,
name
=
"地球"
,
mass
=
5.97237e24
,
rotate_angle
=
23.44
,
def
__init__
(
self
,
name
=
"地球"
,
mass
=
5.97237e24
,
rotate_angle
=
23.44
,
init_position
=
[
0
,
0
,
1
*
AU
],
init_position
=
[
0
,
0
,
1
*
AU
],
init_velocity
=
[
-
29.79
,
0
,
0
],
init_velocity
=
[
-
29.79
,
0
,
0
],
color
=
(
7
,
0
,
162
),
texture
=
"earth1.jpg"
,
text_color
=
None
,
color
=
(
7
,
0
,
162
),
texture
=
"earth1.jpg"
,
text_color
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
15
,
ignore_mass
=
False
,
rotation_speed
=
15
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
,
trail_color
=
None
,
show_name
=
False
,
...
...
sim_scenes/solar_system/solarsystem_planets_size.py
浏览文件 @
2d83330b
...
@@ -17,13 +17,14 @@ from simulators.ursina.ursina_event import UrsinaEvent
...
@@ -17,13 +17,14 @@ from simulators.ursina.ursina_event import UrsinaEvent
FACTOR
=
10
FACTOR
=
10
# 地球和月球之间的距离常量,距地距离约: 363104 至 405696 km,平均距离 384000 km
# 地球和月球之间的距离常量,距地距离约: 363104 至 405696 km,平均距离 384000 km
E_M_DISTANCE
=
405696
*
FACTOR
E_M_DISTANCE
=
405696
*
FACTOR
earth
=
Earth
(
"地球
"
,
size_scale
=
FACTOR
,
init_position
=
[
0
,
0
,
0
])
earth
1
=
Earth
(
"地球1
"
,
size_scale
=
FACTOR
,
init_position
=
[
0
,
0
,
0
])
moon
=
Moon
(
"月球"
,
size_scale
=
FACTOR
,
init_position
=
[
E_M_DISTANCE
,
0
,
0
])
moon
=
Moon
(
"月球"
,
size_scale
=
FACTOR
,
init_position
=
[
E_M_DISTANCE
,
0
,
0
])
earth2
=
Earth
(
"地球2"
,
texture
=
"earth2.jpg"
,
size_scale
=
FACTOR
)
bodies
=
[
bodies
=
[
earth
,
moon
,
earth
1
,
moon
,
Mercury
(
name
=
"水星"
,
size_scale
=
FACTOR
),
Mercury
(
name
=
"水星"
,
size_scale
=
FACTOR
),
Venus
(
name
=
"金星"
,
size_scale
=
FACTOR
),
Venus
(
name
=
"金星"
,
size_scale
=
FACTOR
),
earth2
,
Mars
(
name
=
"火星"
,
size_scale
=
FACTOR
),
Mars
(
name
=
"火星"
,
size_scale
=
FACTOR
),
Jupiter
(
name
=
"木星"
,
size_scale
=
FACTOR
),
Jupiter
(
name
=
"木星"
,
size_scale
=
FACTOR
),
Saturn
(
name
=
"土星"
,
size_scale
=
FACTOR
).
show_rings
(
False
),
Saturn
(
name
=
"土星"
,
size_scale
=
FACTOR
).
show_rings
(
False
),
...
@@ -37,20 +38,24 @@ index = 2
...
@@ -37,20 +38,24 @@ index = 2
last_total_hours
=
0
last_total_hours
=
0
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
last_diameter
=
earth
.
diameter
*
FACTOR
/
2
last_diameter
=
earth
1
.
diameter
*
FACTOR
/
2
plant_positions
=
[]
plant_positions
=
[]
for
i
,
body
in
enumerate
(
bodies
):
for
i
,
body
in
enumerate
(
bodies
):
body
.
rotation_speed
/=
10
# 星体的旋转速度减小10倍
body
.
ignore_mass
=
True
body
.
ignore_mass
=
True
body
.
init_velocity
=
[
0
,
0
,
0
]
body
.
init_velocity
=
[
0
,
0
,
0
]
if
i
>=
2
:
# 从第三个星球(水星)开始
if
i
>=
2
:
# 从第三个星球(水星)开始
plant_positions
.
append
([(
body
.
diameter
*
FACTOR
/
2
)
+
last_diameter
,
0
,
0
])
plant_positions
.
append
([(
body
.
diameter
*
FACTOR
/
2
)
+
last_diameter
,
0
,
0
])
last_diameter
+=
body
.
diameter
*
FACTOR
last_diameter
+=
body
.
diameter
*
FACTOR
# print(body)
def
on_ready
():
def
on_ready
():
# 运行前触发
# 运行前触发
# 为了较好的立体效果,可以增加太阳光线,光线直射地球(target=earth)
# 为了较好的立体效果,可以增加太阳光线,光线直射地球(target=earth)
create_directional_light
(
position
=
(
E_M_DISTANCE
/
2
,
0
,
-
E_M_DISTANCE
*
100
),
light_num
=
3
,
target
=
earth
)
create_directional_light
(
position
=
(
E_M_DISTANCE
/
2
,
E_M_DISTANCE
*
20
,
-
E_M_DISTANCE
*
100
),
light_num
=
3
,
target
=
earth1
)
def
on_timer_changed
(
time_data
:
TimeData
):
def
on_timer_changed
(
time_data
:
TimeData
):
...
@@ -59,6 +64,7 @@ if __name__ == '__main__':
...
@@ -59,6 +64,7 @@ if __name__ == '__main__':
if
index
>=
len
(
bodies
):
if
index
>=
len
(
bodies
):
return
return
total_hours
=
int
(
time_data
.
total_hours
)
total_hours
=
int
(
time_data
.
total_hours
)
# 每间隔3个小时,将行星按顺序进行摆放在地球和月球之间
if
total_hours
%
3
==
0
and
last_total_hours
!=
total_hours
:
if
total_hours
%
3
==
0
and
last_total_hours
!=
total_hours
:
last_total_hours
=
total_hours
last_total_hours
=
total_hours
bodies
[
index
].
init_position
=
plant_positions
[
index
-
2
]
bodies
[
index
].
init_position
=
plant_positions
[
index
-
2
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录