Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
b1a0aa58
宇宙模拟器
项目概览
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看板
提交
b1a0aa58
编写于
4月 02, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
b4b2d814
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
30 deletion
+58
-30
sim_scenes/featured/center_point_moving_sun_to_earth.py
sim_scenes/featured/center_point_moving_sun_to_earth.py
+58
-30
未找到文件。
sim_scenes/featured/center_point_moving_sun_to_earth.py
浏览文件 @
b1a0aa58
...
...
@@ -12,6 +12,7 @@ from bodies import *
from
common.celestial_data_service
import
set_solar_system_celestial_position
,
conv_to_astropy_time
,
get_body_posvel
,
\
get_reality_orbit_points
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
common.func
import
calculate_distance
from
sim_scenes.featured.earth_seasons_base
import
EarthSeasonsSimBase
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
from
sim_scenes.science.earth_season_func
import
create_important_pos_earths
,
get_solar_terms_angles
,
create_earth
...
...
@@ -30,13 +31,13 @@ import math
class
CenterPointMovingSimLive
(
EarthSeasonsSimBase
):
def
__init__
(
self
):
super
(
CenterPointMovingSimLive
,
self
).
__init__
(
sun_transparent
=
False
,
exit_at_total_days
=
3700
,
exit_at_total_days
=
3700
0
,
delay_run
=
False
,
look_at_earth
=
False
,
earth_cn_size_factor
=
1.01
,
earth_clouds_size_factor
=
1.015
)
self
.
start_time
=
'2023-12-20 00:00:00'
self
.
sun
.
size_scale
=
3
e1
self
.
sun
.
size_scale
=
4
e1
self
.
earth
.
size_scale
=
2e3
self
.
earth_clouds
.
size_scale
=
self
.
earth
.
size_scale
self
.
earth_cn
.
size_scale
=
self
.
earth
.
size_scale
...
...
@@ -68,21 +69,6 @@ class CenterPointMovingSimLive(EarthSeasonsSimBase):
self
.
season_earths
=
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]
self
.
planets
=
[]
# self.jieqis = {
# "春分-2023": '2023-03-21 00:00:00',
# "夏至-2023": '2023-06-21 00:00:00',
# "秋分-2023": '2023-09-23 00:00:00',
# "冬至-2023": '2023-12-22 00:00:00',
# "春分-2024": '2024-03-20 00:00:00',
# "夏至-2024": '2024-06-21 00:00:00',
# "秋分-2024": '2024-09-22 00:00:00',
# "冬至-2024": '2024-12-21 00:00:00',
# "春分-2025": '2025-03-20 00:00:00',
# "夏至-2025": '2025-06-21 00:00:00',
# "秋分-2025": '2025-09-23 00:00:00',
# "冬至-2025": '2024-12-21 00:00:00',
# }
font
=
"fonts/DroidSansFallback.ttf"
from
common.func
import
find_file
self
.
font
=
find_file
(
f
"
{
font
}
"
,
UrsinaConfig
.
CN_FONT
)
...
...
@@ -106,7 +92,7 @@ class CenterPointMovingSimLive(EarthSeasonsSimBase):
segments
=
100
)
# print(points)
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
,
alpha
=
alpha
,
thickness
=
2
)
alpha
=
alpha
,
thickness
=
2
)
return
orbit_line
def
create_orbit_lines
(
self
):
...
...
@@ -128,16 +114,39 @@ class CenterPointMovingSimLive(EarthSeasonsSimBase):
self
.
orbit_lines
.
append
(
orbit_line
)
return
self
.
orbit_lines
def
count_days
(
self
,
key
,
time_data
,
days
):
key
=
"k_"
+
str
(
key
)
days_counter_key
=
f
"
{
key
}
_days_counter"
days_counter_init_val_key
=
f
"
{
key
}
_days_counter_init_val"
if
not
hasattr
(
self
,
days_counter_key
):
setattr
(
self
,
days_counter_key
,
0
)
setattr
(
self
,
days_counter_init_val_key
,
time_data
.
total_days
)
else
:
d
=
time_data
.
total_days
-
getattr
(
self
,
days_counter_init_val_key
)
setattr
(
self
,
days_counter_key
,
d
)
rd
=
getattr
(
self
,
days_counter_key
)
if
rd
>=
days
:
delattr
(
self
,
days_counter_key
)
delattr
(
self
,
days_counter_init_val_key
)
return
True
return
False
# if days is None:
# return self.days_counter
# else:
# self.days_counter = days
# self.days_counter_init_val = time_data.total_days
def
get_center_pos
(
self
,
dt
,
time_data
):
ec
=
UrsinaSimulator
.
EditorCamera
d_sun
=
distance
(
ec
.
world_position
,
self
.
sun
.
planet
.
world_position
)
d_sun
=
self
.
get_distance_sun
(
)
if
not
hasattr
(
self
,
"moving_factor"
):
self
.
moving_factor
=
1e-6
self
.
phase_num
=
1
# elif time_data.total_days > 1500 and self.moving_factor < 1:
elif
d_sun
>
4500
and
self
.
moving_factor
<
1
:
self
.
moving_factor
+=
0.01
elif
(
d_sun
<
7
or
self
.
phase_num
==
2
)
and
self
.
moving_factor
<
1
:
self
.
moving_factor
+=
0.01
*
UrsinaConfig
.
run_speed_factor
if
self
.
phase_num
==
1
:
for
b
in
self
.
bodies
:
from
simulators.ursina.entities.entity_utils
import
clear_trails
...
...
@@ -153,7 +162,8 @@ class CenterPointMovingSimLive(EarthSeasonsSimBase):
from
simulators.ursina.entities.entity_utils
import
clear_trails
clear_trails
(
b
.
planet
.
main_entity
)
UrsinaConfig
.
trail_type
=
"curve_line"
UrsinaConfig
.
trail_length
=
91
UrsinaConfig
.
trail_length
=
500
self
.
phase_num
=
3
e_posvel
=
get_body_posvel
(
self
.
earth
,
dt
)
...
...
@@ -171,7 +181,7 @@ class CenterPointMovingSimLive(EarthSeasonsSimBase):
UrsinaConfig
.
trail_type
=
"line"
# UrsinaConfig.trail_length = 91
UrsinaConfig
.
trail_type
=
"curve_line"
UrsinaConfig
.
trail_length
=
2
0
0
UrsinaConfig
.
trail_length
=
2
5
0
# UrsinaConfig.trail_length = 1000
UrsinaConfig
.
trail_thickness_factor
=
2
UrsinaConfig
.
trail_factor
=
2
...
...
@@ -215,25 +225,43 @@ class CenterPointMovingSimLive(EarthSeasonsSimBase):
self
.
set_bodies_position
(
time_data
)
self
.
show_clock
(
dt
)
print
(
"total_days:"
,
time_data
.
total_days
)
ec
=
UrsinaSimulator
.
EditorCamera
d_sun
=
distance
(
ec
.
world_position
,
self
.
sun
.
planet
.
world_position
)
print
(
"Sun distance:"
,
d_sun
)
if
self
.
phase_num
==
1
:
ec
.
world_position
+=
ec
.
up
*
2
*
UrsinaConfig
.
run_speed_factor
ec
.
world_position
+=
ec
.
back
*
1
*
UrsinaConfig
.
run_speed_factor
ec
.
world_position
+=
ec
.
up
*
2
*
UrsinaConfig
.
run_speed_factor
# 前进
ec
.
world_position
+=
ec
.
back
*
1
*
UrsinaConfig
.
run_speed_factor
# 下
elif
self
.
phase_num
==
2
:
self
.
hide_orbit_lines
()
elif
self
.
phase_num
==
3
:
pass
# ec.world_position -= ec.up * 2 * UrsinaConfig.run_speed_factor
# ec.world_position -= ec.back * 1 * UrsinaConfig.run_speed_factor
if
self
.
count_days
(
self
.
phase_num
,
time_data
,
370
):
self
.
phase_num
=
4
elif
self
.
phase_num
==
4
:
ec
.
world_position
-=
ec
.
up
*
2
*
UrsinaConfig
.
run_speed_factor
# 后退
ec
.
world_position
-=
ec
.
back
*
1.4
*
UrsinaConfig
.
run_speed_factor
# 下(快一点)
ec
.
world_position
+=
ec
.
right
*
0.8
*
UrsinaConfig
.
run_speed_factor
# 左
d_sun
=
self
.
get_distance_sun
()
print
(
"d_sun:"
,
d_sun
)
if
d_sun
>
45
:
self
.
phase_num
=
5
elif
self
.
phase_num
==
5
:
ec
.
world_position
-=
ec
.
back
*
1.4
*
UrsinaConfig
.
run_speed_factor
# 下
ec
.
world_position
+=
ec
.
right
*
0.7
*
UrsinaConfig
.
run_speed_factor
# 左
pos
=
camera
.
world_position
if
pos
[
2
]
>
2000
:
self
.
phase_num
=
6
print
(
"pos:"
,
pos
)
# if d_sun > 4500:
# ec.target_z -= 0.01
# self.camera_around()
def
get_distance_sun
(
self
):
d_sun
=
distance
(
camera
.
world_position
,
self
.
sun
.
planet
.
world_position
)
return
round
(
d_sun
/
UrsinaConfig
.
SCALE_FACTOR
/
AU
,
4
)
def
camera_around
(
self
):
ec
=
UrsinaSimulator
.
EditorCamera
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录