Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
d28fe8b2
宇宙模拟器
项目概览
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看板
提交
d28fe8b2
编写于
12月 09, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
5283ee67
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
44 addition
and
9 deletion
+44
-9
sim_scenes/featured/eight_stars_alignment.py
sim_scenes/featured/eight_stars_alignment.py
+44
-9
未找到文件。
sim_scenes/featured/eight_stars_alignment.py
浏览文件 @
d28fe8b2
...
@@ -13,7 +13,7 @@ from bodies import Sun, Mercury, Venus, Earth, Mars, Asteroids, Jupiter, Saturn,
...
@@ -13,7 +13,7 @@ from bodies import Sun, Mercury, Venus, Earth, Mars, Asteroids, Jupiter, Saturn,
from
common.celestial_data_service
import
get_body_posvel
,
recalc_moon_position
,
calc_solar_acceleration
,
\
from
common.celestial_data_service
import
get_body_posvel
,
recalc_moon_position
,
calc_solar_acceleration
,
\
set_solar_system_celestial_position
,
set_earth_rotation
set_solar_system_celestial_position
,
set_earth_rotation
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HOUR
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HOUR
,
AU
from
sim_scenes.func
import
ursina_run
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
,
two_bodies_colliding
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ui.control_ui
import
ControlUI
...
@@ -33,6 +33,7 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -33,6 +33,7 @@ class SolarSystemRealitySim(UniverseSimScenes):
self
.
show_earth_clouds
=
False
self
.
show_earth_clouds
=
False
self
.
debug_mode
=
False
self
.
debug_mode
=
False
self
.
recalc_moon_pos
=
True
self
.
recalc_moon_pos
=
True
self
.
target_index
=
0
def
create_bodies
(
self
):
def
create_bodies
(
self
):
"""
"""
...
@@ -75,13 +76,19 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -75,13 +76,19 @@ class SolarSystemRealitySim(UniverseSimScenes):
# 所有天体
# 所有天体
self
.
bodies
=
[
self
.
sun
]
+
self
.
planets
+
[
self
.
moon
]
self
.
bodies
=
[
self
.
sun
]
+
self
.
planets
+
[
self
.
moon
]
self
.
camera_target
=
self
.
create_camera_target
(
init_position
=
[
0
,
0
,
-
AU
],
size_scale
=
1e4
)
self
.
ship
=
self
.
create_camera_target
(
init_position
=
[
0
,
AU
/
10
,
AU
],
size_scale
=
1e4
)
if
self
.
show_earth_clouds
:
if
self
.
show_earth_clouds
:
self
.
bodies
+=
[
self
.
earth_clouds
]
self
.
bodies
+=
[
self
.
earth_clouds
]
if
self
.
show_asteroids
:
if
self
.
show_asteroids
:
self
.
bodies
+=
[
self
.
asteroids
,
self
.
camera_target
]
self
.
bodies
+=
[
self
.
asteroids
]
self
.
bodies
+=
[
self
.
ship
]
self
.
targets
=
[
self
.
earth
,
self
.
venus
,
self
.
mercury
,
self
.
saturn
,
self
.
mars
,
self
.
jupiter
,
self
.
uranus
,
self
.
neptune
,
self
.
sun
]
def
init_earth
(
self
):
def
init_earth
(
self
):
"""
"""
...
@@ -129,10 +136,9 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -129,10 +136,9 @@ class SolarSystemRealitySim(UniverseSimScenes):
@return:
@return:
"""
"""
# 运行前触发
# 运行前触发
self
.
set_window_size
((
1919
,
1080
),
False
)
if
self
.
sky_texture
is
not
None
:
self
.
sky
=
create_sphere_sky
(
scale
=
80000
)
from
simulators.ursina.entities.sphere_sky
import
SphereSky
SphereSky
(
texture
=
self
.
sky_texture
).
scale
=
80000
camera
.
clip_plane_near
=
0.1
camera
.
clip_plane_near
=
0.1
camera
.
clip_plane_far
=
100000
camera
.
clip_plane_far
=
100000
...
@@ -144,16 +150,45 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -144,16 +150,45 @@ class SolarSystemRealitySim(UniverseSimScenes):
# 需要按照时间和日期来控制地球的自转,所以删除控制地球自转的属性
# 需要按照时间和日期来控制地球的自转,所以删除控制地球自转的属性
delattr
(
self
.
earth
.
planet
,
"rotation_speed"
)
delattr
(
self
.
earth
.
planet
,
"rotation_speed"
)
delattr
(
self
.
earth
.
planet
,
"rotspeed"
)
delattr
(
self
.
earth
.
planet
,
"rotspeed"
)
self
.
ship
.
planet
.
update
=
lambda
:
None
# 设置后,可以调整鼠标键盘的控制速度
# 设置后,可以调整鼠标键盘的控制速度
application
.
time_scale
=
1
application
.
time_scale
=
1
self
.
ship
.
planet
.
position
=
self
.
earth
.
planet
.
position
def
ship_go_target
(
self
):
from
ursina
import
distance
if
self
.
target_index
>
len
(
self
.
targets
)
-
1
:
exit
(
0
)
target
=
self
.
targets
[
self
.
target_index
]
planet
=
target
.
planet
.
main_entity
d
=
distance
(
planet
,
self
.
ship
.
planet
)
# r = d * 10
# if r<100:
# r = 100
r
=
500
self
.
ship
.
planet
.
look_at
(
planet
)
self
.
ship
.
planet
.
position
+=
self
.
ship
.
planet
.
forward
*
r
# d = distance(planet, self.ship.planet)
# if d / UrsinaConfig.SCALE_FACTOR < 900000:
if
two_bodies_colliding
(
target
,
self
.
ship
):
if
not
hasattr
(
planet
,
"arrived"
):
self
.
target_index
+=
1
planet
.
arrived
=
True
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
"""
"""
事件绑定后,时时刻刻都会触发
事件绑定后,时时刻刻都会触发
@param time_data:
@param time_data:
@return:
@return:
"""
"""
self
.
ship_go_target
()
dt
=
time_data
.
get_datetime
(
str
(
self
.
start_time
))
dt
=
time_data
.
get_datetime
(
str
(
self
.
start_time
))
# 设置天体的位置(包含速度和加速度的信息)
# 设置天体的位置(包含速度和加速度的信息)
self
.
set_bodies_position
(
time_data
)
self
.
set_bodies_position
(
time_data
)
...
@@ -236,8 +271,8 @@ if __name__ == '__main__':
...
@@ -236,8 +271,8 @@ if __name__ == '__main__':
sim
=
SolarSystemRealitySim
()
sim
=
SolarSystemRealitySim
()
sim
.
run
(
sim
.
run
(
# debug_mode=True, # 是否调试模式
# debug_mode=True, # 是否调试模式
#
dt=SECONDS_PER_DAY , # 1秒=1天
dt
=
SECONDS_PER_DAY
,
# 1秒=1天
dt
=
SECONDS_PER_HOUR
,
# 1秒=1小时
#
dt=SECONDS_PER_HOUR, # 1秒=1小时
# dt=SECONDS_PER_HOUR, # 1秒=1小时
# dt=SECONDS_PER_HOUR, # 1秒=1小时
start_time
=
'2149-12-10 12:00:00'
,
# 九(八)星连珠的时间 # https://baijiahao.baidu.com/s?id=1654160345900112362
start_time
=
'2149-12-10 12:00:00'
,
# 九(八)星连珠的时间 # https://baijiahao.baidu.com/s?id=1654160345900112362
# show_asteroids=True, # 是否显示小行星带(图片模拟)
# show_asteroids=True, # 是否显示小行星带(图片模拟)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录