Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
5bc3009e
宇宙模拟器
项目概览
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看板
提交
5bc3009e
编写于
11月 03, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
a6914400
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
7 deletion
+65
-7
sim_lab/solarsystem_planets_size.py
sim_lab/solarsystem_planets_size.py
+65
-7
未找到文件。
sim_lab/solarsystem_planets_size.py
浏览文件 @
5bc3009e
...
@@ -6,9 +6,11 @@
...
@@ -6,9 +6,11 @@
# link :https://gitcode.net/pythoncr/
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# python_version :3.8
# ==============================================================================
# ==============================================================================
import
threading
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
AU
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
ursina_run
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
simulators.ursina.entities.body_timer
import
TimeData
,
AppTimeUtil
from
simulators.ursina.entities.body_timer
import
TimeData
,
AppTimeUtil
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
...
@@ -27,7 +29,7 @@ bodies = [
...
@@ -27,7 +29,7 @@ bodies = [
Venus
(
name
=
"金星"
,
size_scale
=
FACTOR
),
Venus
(
name
=
"金星"
,
size_scale
=
FACTOR
),
earth2
,
earth2
,
Mars
(
name
=
"火星"
,
size_scale
=
FACTOR
),
Mars
(
name
=
"火星"
,
size_scale
=
FACTOR
),
Jupiter
(
name
=
"木星"
,
size_scale
=
FACTOR
),
Jupiter
(
name
=
"木星"
,
texture
=
'jupiter_hd.jpg'
,
size_scale
=
FACTOR
),
Saturn
(
name
=
"土星"
,
size_scale
=
FACTOR
).
show_rings
(
False
),
Saturn
(
name
=
"土星"
,
size_scale
=
FACTOR
).
show_rings
(
False
),
Uranus
(
name
=
"天王星"
,
size_scale
=
FACTOR
),
Uranus
(
name
=
"天王星"
,
size_scale
=
FACTOR
),
Neptune
(
name
=
"海王星"
,
size_scale
=
FACTOR
),
Neptune
(
name
=
"海王星"
,
size_scale
=
FACTOR
),
...
@@ -59,8 +61,12 @@ if __name__ == '__main__':
...
@@ -59,8 +61,12 @@ if __name__ == '__main__':
create_directional_light
(
position
=
(
E_M_DISTANCE
/
2
,
E_M_DISTANCE
*
20
,
-
E_M_DISTANCE
*
100
),
create_directional_light
(
position
=
(
E_M_DISTANCE
/
2
,
E_M_DISTANCE
*
20
,
-
E_M_DISTANCE
*
100
),
light_num
=
3
,
light_num
=
3
,
target
=
earth1
)
target
=
earth1
)
application
.
time_scale
=
0.01
application
.
time_scale
=
0.001
sky
=
create_sphere_sky
(
scale
=
2000
)
sky
.
alpha
=
0.5
# sky.rotation_y = -90
sky
.
rotation_x
=
200
# sky.rotation_z = 200
key_points
=
[(
E_M_DISTANCE
/
2
,
0
,
-
E_M_DISTANCE
),
key_points
=
[(
E_M_DISTANCE
/
2
,
0
,
-
E_M_DISTANCE
),
(
0
,
0
,
-
E_M_DISTANCE
/
4
),
(
0
,
0
,
-
E_M_DISTANCE
/
4
),
...
@@ -83,6 +89,29 @@ if __name__ == '__main__':
...
@@ -83,6 +89,29 @@ if __name__ == '__main__':
interval
=
3
interval
=
3
# def move_planet(planet_body, target_pos):
# planet_body.planet.origin_update = planet_body.planet.update
#
# def new_update():
# import numpy as np
# current_pos = planet_body.init_position
# c_pos = current_pos * UrsinaConfig.SCALE_FACTOR
# t_pos = np.array(target_pos) * UrsinaConfig.SCALE_FACTOR
# # for _ in range(10):
# # current_pos = planet_body.init_position
# # new_pos = ursina.lerp(Vec3(current_pos[0], current_pos[1], current_pos[2]),
# # Vec3(target_pos[0], target_pos[1], target_pos[2]), 1e9)
# # planet_body.init_position = [new_pos[0], new_pos[1], new_pos[2]]
# n_pos = ursina.lerp(Vec3(c_pos[0], c_pos[1], c_pos[2]),
# Vec3(t_pos[0], t_pos[1], t_pos[2]), 3e-2)
# planet_body.planet.origin_update()
# new_pos = np.array([n_pos[0], n_pos[1], n_pos[2]]) / UrsinaConfig.SCALE_FACTOR
# planet_body.init_position = new_pos
#
# planet_body.planet.update = new_update
# # return warp
def
on_timer_changed
(
time_data
:
TimeData
):
def
on_timer_changed
(
time_data
:
TimeData
):
# camera_time = app_time_util.get_param("camera_time", 2)
# camera_time = app_time_util.get_param("camera_time", 2)
...
@@ -97,7 +126,34 @@ if __name__ == '__main__':
...
@@ -97,7 +126,34 @@ if __name__ == '__main__':
last_time
=
app_time_util
.
get_param
(
"last_time"
,
interval
+
3
)
# 间隔3秒出现水星
last_time
=
app_time_util
.
get_param
(
"last_time"
,
interval
+
3
)
# 间隔3秒出现水星
# 判断是否第一个到达指定的时间
# 判断是否第一个到达指定的时间
if
app_time_util
.
is_first_arrival
(
last_time
,
time_data
):
if
app_time_util
.
is_first_arrival
(
last_time
,
time_data
):
bodies
[
body_index
].
init_position
=
plant_positions
[
body_index
-
2
]
# target_position = plant_positions[body_index - 2]
def
move_planet
(
planet_body
,
target_pos
):
import
numpy
as
np
def
warp
():
# current_pos = planet_body.init_position
t_pos
=
np
.
array
(
target_pos
)
*
UrsinaConfig
.
SCALE_FACTOR
for
_
in
range
(
200
):
current_pos
=
planet_body
.
init_position
c_pos
=
current_pos
*
UrsinaConfig
.
SCALE_FACTOR
n_pos
=
ursina
.
lerp
(
Vec3
(
c_pos
[
0
],
c_pos
[
1
],
c_pos
[
2
]),
Vec3
(
t_pos
[
0
],
t_pos
[
1
],
t_pos
[
2
]),
6e-2
)
new_pos
=
np
.
array
([
n_pos
[
0
],
n_pos
[
1
],
n_pos
[
2
]])
/
UrsinaConfig
.
SCALE_FACTOR
planet_body
.
init_position
=
new_pos
time
.
sleep
(
0.0001
)
planet_body
.
init_position
=
target_pos
return
warp
f
=
move_planet
(
bodies
[
body_index
],
plant_positions
[
body_index
-
2
])
# f()
t
=
threading
.
Thread
(
target
=
f
)
t
.
start
()
# time.sleep(0.1)
app_time_util
.
inc_param
(
"body_index"
,
1
)
app_time_util
.
inc_param
(
"body_index"
,
1
)
app_time_util
.
inc_param
(
"last_time"
,
interval
)
# 间隔3秒出现下一个行星
app_time_util
.
inc_param
(
"last_time"
,
interval
)
# 间隔3秒出现下一个行星
...
@@ -123,7 +179,9 @@ if __name__ == '__main__':
...
@@ -123,7 +179,9 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_HOUR
,
ursina_run
(
bodies
,
SECONDS_PER_HOUR
*
2
,
position
=
key_points
[
0
],
position
=
key_points
[
0
],
view_closely
=
True
,
cosmic_bg
=
''
,
show_grid
=
False
,
# view_closely=True,
timer_enabled
=
True
)
timer_enabled
=
True
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录