Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
f13243c5
宇宙模拟器
项目概览
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看板
提交
f13243c5
编写于
11月 09, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
7461139e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
41 addition
and
11 deletion
+41
-11
sim_scenes/solar_system/halley_comet_sim.py
sim_scenes/solar_system/halley_comet_sim.py
+39
-9
simulators/ursina/ursina_mesh.py
simulators/ursina/ursina_mesh.py
+2
-2
未找到文件。
sim_scenes/solar_system/halley_comet_sim.py
浏览文件 @
f13243c5
...
@@ -14,7 +14,7 @@ from common.celestial_data_service import init_bodies_reality_pos_vels, conv_to_
...
@@ -14,7 +14,7 @@ from common.celestial_data_service import init_bodies_reality_pos_vels, conv_to_
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.func
import
calculate_distance
from
common.func
import
calculate_distance
from
objs
import
HalleComet
from
objs
import
HalleComet
from
sim_scenes.func
import
create_text_panel
from
sim_scenes.func
import
create_text_panel
,
camera_look_at
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.solar_system.halley_comet_lib
import
HalleyCometSimBase
,
HalleyCometParams
,
\
from
sim_scenes.solar_system.halley_comet_lib
import
HalleyCometSimBase
,
HalleyCometParams
,
\
create_halley_comet
,
create_orbit_line
create_halley_comet
,
create_orbit_line
...
@@ -63,10 +63,11 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -63,10 +63,11 @@ class HalleyCometSim(HalleyCometSimBase):
# 创建天空
# 创建天空
create_sphere_sky
(
scale
=
200000
)
create_sphere_sky
(
scale
=
200000
)
# UrsinaConfig.trail_type = "curve_line"
# UrsinaConfig.trail_type = "curve_line"
# UrsinaConfig.trail_
thickness_factor = 3
# UrsinaConfig.trail_
length = 300
UrsinaConfig
.
trail_type
=
"line"
UrsinaConfig
.
trail_type
=
"line"
UrsinaConfig
.
trail_thickness_factor
=
3
UrsinaConfig
.
trail_length
=
152
UrsinaConfig
.
trail_length
=
152
UrsinaConfig
.
trail_thickness_factor
=
5
# UrsinaConfig.trail_length = 180
# UrsinaConfig.trail_length = 180
UrsinaConfig
.
trail_factor
=
3
UrsinaConfig
.
trail_factor
=
3
# camera.clip_plane_near = 0.1
# camera.clip_plane_near = 0.1
...
@@ -111,7 +112,7 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -111,7 +112,7 @@ class HalleyCometSim(HalleyCometSimBase):
t
=
self
.
start_time
+
time_data
.
total_days
t
=
self
.
start_time
+
time_data
.
total_days
set_solar_system_celestial_position
(
self
.
bodies
,
t
,
False
)
set_solar_system_celestial_position
(
self
.
bodies
,
t
,
False
)
def
create_year_label
(
self
,
trail
,
year
,
halley_comet_pos
):
def
create_year_label
(
self
,
trail
,
year
,
halley_comet_pos
=
None
,
pos
=
None
,
scale
=
40
,
background
=
False
):
"""
"""
在界面上创建年份的标签
在界面上创建年份的标签
@param trail:
@param trail:
...
@@ -119,11 +120,18 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -119,11 +120,18 @@ class HalleyCometSim(HalleyCometSimBase):
@param halley_comet_pos:
@param halley_comet_pos:
@return:
@return:
"""
"""
# 为了不影响 2023年12月9日的显示,附近的 Label 就不显示
if
year
in
[
"1986"
,
"2061"
,
"2023"
,
"2024"
,
"2025"
]:
return
if
trail
is
None
:
if
trail
is
None
:
pos
=
halley_comet_pos
_
pos
=
halley_comet_pos
else
:
else
:
pos
=
(
0
,
0
,
0
)
_pos
=
pos
label
=
create_label
(
trail
,
label
=
year
,
pos
=
pos
,
color
=
(
255
,
255
,
255
),
scale
=
40
,
alpha
=
1.0
)
if
_pos
is
None
:
_pos
=
(
0
,
0
,
0
)
label
=
create_label
(
trail
,
label
=
year
,
pos
=
_pos
,
color
=
(
255
,
255
,
255
),
scale
=
scale
,
alpha
=
1.0
,
background
=
background
)
label
.
set_light_off
()
label
.
set_light_off
()
def
set_comet_trail_alpha
(
self
,
distance_sun
):
def
set_comet_trail_alpha
(
self
,
distance_sun
):
...
@@ -150,6 +158,23 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -150,6 +158,23 @@ class HalleyCometSim(HalleyCometSimBase):
c
=
self
.
halley_comet
.
planet
.
children
[
0
]
c
=
self
.
halley_comet
.
planet
.
children
[
0
]
c
.
alpha
=
alpha
c
.
alpha
=
alpha
def
show_milestone_lable
(
self
,
last_trail
,
dt
):
"""
远日点: 35.1 AU(2023年12月9日)
近日点: 0.586 AU 上次通过近日点:1986年2月9日 下次通过近日点:2061年7月28日
@param last_trail:
@param dt:
@return:
"""
milestones
=
[
"1986-02-09"
,
"2023-12-09"
,
"2061-07-28"
]
for
milestone
in
milestones
:
prop_name
=
f
"milestone_
{
milestone
}
"
if
not
hasattr
(
self
,
prop_name
)
and
dt
.
strftime
(
"%Y-%m-%d"
)
>=
milestone
:
setattr
(
self
,
prop_name
,
milestone
)
self
.
create_year_label
(
last_trail
,
milestone
,
pos
=
(
0
,
2
,
0
),
scale
=
100
,
background
=
True
)
application
.
paused
=
True
UrsinaEvent
.
on_pause
()
def
on_timer_changed
(
self
,
time_data
):
def
on_timer_changed
(
self
,
time_data
):
"""
"""
...
@@ -159,6 +184,8 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -159,6 +184,8 @@ class HalleyCometSim(HalleyCometSimBase):
dt
=
time_data
.
get_datetime
(
str
(
self
.
start_time
))
dt
=
time_data
.
get_datetime
(
str
(
self
.
start_time
))
year
=
dt
.
strftime
(
"%Y"
)
year
=
dt
.
strftime
(
"%Y"
)
camera_look_at
(
self
.
halley_comet
)
if
hasattr
(
self
,
"halley_comet"
):
if
hasattr
(
self
,
"halley_comet"
):
if
self
.
halley_comet
.
planet
.
enabled
:
if
self
.
halley_comet
.
planet
.
enabled
:
self
.
halley_comet
.
planet
.
look_at
(
self
.
sun
.
planet
)
self
.
halley_comet
.
planet
.
look_at
(
self
.
sun
.
planet
)
...
@@ -177,7 +204,9 @@ class HalleyCometSim(HalleyCometSimBase):
...
@@ -177,7 +204,9 @@ class HalleyCometSim(HalleyCometSimBase):
import
copy
import
copy
if
not
hasattr
(
self
,
"last_year"
):
if
self
.
show_milestone_lable
(
last_trail
,
dt
):
pass
elif
not
hasattr
(
self
,
"last_year"
):
self
.
create_year_label
(
last_trail
,
year
,
pos
)
self
.
create_year_label
(
last_trail
,
year
,
pos
)
elif
self
.
last_year
!=
year
:
elif
self
.
last_year
!=
year
:
if
not
hasattr
(
self
,
"last_label_pos"
):
if
not
hasattr
(
self
,
"last_label_pos"
):
...
@@ -272,7 +301,8 @@ if __name__ == '__main__':
...
@@ -272,7 +301,8 @@ if __name__ == '__main__':
ursina_run
(
sim
.
bodies
,
ursina_run
(
sim
.
bodies
,
SECONDS_PER_YEAR
,
SECONDS_PER_YEAR
,
# position=(0, 2 * AU, -11 * AU),
# position=(0, 2 * AU, -11 * AU),
position
=
(
0
,
0.5
*
AU
,
-
5
*
AU
),
# position=(0, 0.5 * AU, -5 * AU),
position
=
(
0
,
AU
,
-
20
*
AU
),
cosmic_bg
=
''
,
cosmic_bg
=
''
,
show_trail
=
True
,
show_trail
=
True
,
# bg_music='sounds/no_glory.mp3',
# bg_music='sounds/no_glory.mp3',
...
...
simulators/ursina/ursina_mesh.py
浏览文件 @
f13243c5
...
@@ -194,14 +194,14 @@ def create_arrow(height=0.5, width=0.1):
...
@@ -194,14 +194,14 @@ def create_arrow(height=0.5, width=0.1):
return
arrow_mesh
return
arrow_mesh
def
create_label
(
parent
,
label
,
pos
,
color
,
scale
=
50
,
alpha
=
1.0
):
def
create_label
(
parent
,
label
,
pos
,
color
,
scale
=
50
,
alpha
=
1.0
,
background
=
False
):
if
isinstance
(
color
,
tuple
)
or
isinstance
(
color
,
list
):
if
isinstance
(
color
,
tuple
)
or
isinstance
(
color
,
list
):
color
=
conv_to_vec4_color
(
color
)
color
=
conv_to_vec4_color
(
color
)
if
alpha
<
1
:
if
alpha
<
1
:
color
[
3
]
=
alpha
color
[
3
]
=
alpha
text
=
Text
(
label
,
parent
=
parent
,
scale
=
scale
,
billboard
=
True
,
color
=
color
,
text
=
Text
(
label
,
parent
=
parent
,
scale
=
scale
,
billboard
=
True
,
color
=
color
,
position
=
Vec3
(
pos
)
+
Vec3
(
1
,
1
,
1
),
alpha
=
alpha
,
position
=
Vec3
(
pos
)
+
Vec3
(
1
,
1
,
1
),
alpha
=
alpha
,
font
=
UrsinaConfig
.
CN_FONT
,
background
=
False
)
font
=
UrsinaConfig
.
CN_FONT
,
background
=
background
)
return
text
return
text
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录