Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
c33a202c
宇宙模拟器
项目概览
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看板
提交
c33a202c
编写于
4月 02, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
718e9a67
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
78 addition
and
31 deletion
+78
-31
sim_scenes/featured/earth_seasons_live.py
sim_scenes/featured/earth_seasons_live.py
+68
-24
sim_scenes/featured/tri_bodies_01.py
sim_scenes/featured/tri_bodies_01.py
+3
-3
sim_scenes/func.py
sim_scenes/func.py
+3
-0
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+1
-1
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+3
-3
未找到文件。
sim_scenes/featured/earth_seasons_live.py
浏览文件 @
c33a202c
...
...
@@ -6,7 +6,7 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
ursina
import
camera
,
window
,
Text
,
color
from
ursina
import
camera
,
window
,
Text
,
color
,
Vec3
,
destroy
from
bodies
import
*
from
common.celestial_data_service
import
set_solar_system_celestial_position
,
conv_to_astropy_time
,
get_body_posvel
...
...
@@ -21,23 +21,28 @@ from simulators.ursina.ursina_config import UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina_simulator
import
UrsinaSimulator
import
numpy
as
np
import
math
class
EarthSeasonsSimLive
(
EarthSeasonsSimBase
):
def
__init__
(
self
):
super
(
EarthSeasonsSimLive
,
self
).
__init__
(
sun_transparent
=
False
,
exit_at_total_days
=
370
,
exit_at_total_days
=
370
0
,
delay_run
=
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
=
3e1
self
.
moon
=
Moon
(
name
=
"月球"
,
size_scale
=
5e3
,
self
.
earth
.
size_scale
=
2e3
self
.
earth_clouds
.
size_scale
=
self
.
earth
.
size_scale
self
.
earth_cn
.
size_scale
=
self
.
earth
.
size_scale
self
.
moon
=
Moon
(
name
=
"月球"
,
size_scale
=
2e3
,
rotation_speed
=
0.645
)
# 月球
self
.
mercury
=
Mercury
(
size_scale
=
5
e3
)
self
.
venus
=
Venus
(
name
=
"金星"
,
size_scale
=
5
e3
)
self
.
mars
=
Mars
(
size_scale
=
5
e3
)
self
.
mercury
=
Mercury
(
size_scale
=
2
e3
)
self
.
venus
=
Venus
(
name
=
"金星"
,
size_scale
=
2
e3
)
self
.
mars
=
Mars
(
size_scale
=
2
e3
)
self
.
jupiter
=
Jupiter
(
size_scale
=
1e3
)
self
.
saturn
=
Saturn
(
size_scale
=
1e3
)
self
.
uranus
=
Uranus
(
size_scale
=
4e3
)
...
...
@@ -73,9 +78,16 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
"冬至-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
)
for
body
in
self
.
bodies
:
if
body
not
in
self
.
season_earths
:
self
.
planets
.
append
(
body
)
else
:
body
.
texture
=
"transparent.png"
body
.
show_trail
=
False
def
earth_text_display
(
self
,
term_name
):
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
...
...
@@ -93,11 +105,37 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
def
on_ready
(
self
):
super
(
EarthSeasonsSimLive
,
self
).
on_ready
()
# camera_look_at(self.sun, rotation_z=0)
self
.
earth_1
.
planet
.
alpha
=
0.2
self
.
earth_2
.
planet
.
alpha
=
0.2
self
.
earth_3
.
planet
.
alpha
=
0.2
self
.
earth_4
.
planet
.
alpha
=
0.2
UrsinaConfig
.
trail_type
=
"line"
# UrsinaConfig.trail_length = 91
UrsinaConfig
.
trail_type
=
"curve_line"
UrsinaConfig
.
trail_length
=
50
# UrsinaConfig.trail_length = 1000
UrsinaConfig
.
trail_thickness_factor
=
2
for
body
in
self
.
bodies
:
body
.
planet
.
trail_scale
=
3
self
.
moon
.
planet
.
trail_scale
=
1
camera
.
clip_plane_near
=
1
# camera.clip_plane_far = sky.scale_x * 1.5
destroy
(
self
.
earth_clouds
.
planet
)
destroy
(
self
.
earth_cn
.
planet
)
# self.earth_cn.size_scale = self.earth.size_scale
for
e
in
self
.
season_earths
:
# camera_look_at(self.sun, rotation_z=0)
# e.planet.scale = 0.1
# e.planet.alpha = 0.2
e
.
name_text
.
scale
=
Vec3
(
10
,
10
,
10
)
e
.
name_text
.
font
=
self
.
font
destroy
(
e
.
name_text
.
background
)
# self.earth_2.planet.alpha = 0.2
# self.earth_3.planet.alpha = 0.2
# self.earth_4.planet.alpha = 0.2
self
.
earth
.
planet
.
name_text
.
enabled
=
False
# , self.earth_clouds, self.earth_cn
...
...
@@ -110,7 +148,7 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
self
.
moon
.
planet
.
rotation_y
=
180
self
.
show_title
()
camera
.
fov
=
140
#
camera.fov = 140
window
.
borderless
=
True
window
.
exit_button
=
False
...
...
@@ -125,9 +163,14 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
dt
=
time_data
.
get_datetime
(
self
.
start_time
)
self
.
set_bodies_position
(
time_data
)
self
.
show_clock
(
dt
)
self
.
camera_around
()
def
camera_around
(
self
):
ec
=
UrsinaSimulator
.
EditorCamera
# ec.target_z -= 0.05
# camera.position += camera.left * 0.0001
ec
.
rotation_y
-=
0.01
*
UrsinaConfig
.
run_speed_factor
# 每帧绕y轴旋转1度
# print(self.earth.planet.world_position)
# print(self.earth.planet.position)
def
set_bodies_position
(
self
,
time_data
:
TimeData
):
"""
...
...
@@ -136,37 +179,38 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
@return:
"""
dt
=
conv_to_astropy_time
(
self
.
start_time
)
center_pos
=
self
.
get_center_pos
(
dt
)
year
=
int
(
dt
.
jyear
)
t
=
dt
+
time_data
.
total_days
center_pos
=
self
.
get_center_pos
(
t
)
set_solar_system_celestial_position
(
self
.
planets
,
t
,
True
,
recalc_moon_pos_scale
=
60
,
center_pos
=
center_pos
)
year
=
int
(
t
.
jyear
)
if
self
.
last_year
!=
year
:
for
body
in
self
.
season_earths
:
jieqir
=
self
.
jieqis
.
get
(
f
"
{
body
.
name
}
-
{
year
}
"
,
None
)
if
jieqir
is
not
None
:
jieqir
=
conv_to_astropy_time
(
jieqir
)
set_solar_system_celestial_position
([
body
],
jieqir
,
False
,
center_pos
=
center_pos
)
set_solar_system_celestial_position
([
body
],
jieqir
,
False
,
center_pos
=
None
)
body
.
abs_position
=
body
.
position
self
.
last_year
=
year
t
=
dt
+
time_data
.
total_days
set_solar_system_celestial_position
(
self
.
planets
,
t
,
True
,
recalc_moon_pos_scale
=
180
,
center_pos
=
center_pos
)
for
body
in
self
.
season_earths
:
body
.
position
=
body
.
abs_position
+
self
.
sun
.
position
def
exit_handle
(
self
):
UrsinaEvent
.
on_reset
()
return
True
def
show_title
(
self
):
font
=
"fonts/DroidSansFallback.ttf"
from
common.func
import
find_file
font
=
find_file
(
f
"
{
font
}
"
,
UrsinaConfig
.
CN_FONT
)
aspect_ratio
=
window
.
aspect_ratio
position
,
origin
=
(
-
0.5
*
aspect_ratio
-
0.1
,
0.48
),
(
-
0.05
,
0.1
)
position2
,
origin2
=
(
-
0.5
*
aspect_ratio
-
0.1
,
0.40
),
(
-
0.05
,
0.1
)
# text1 = Text(text="太阳视角:观察日食月食", color=color.white, scale=2.5, position=position, # (-0.98, 0.48),
# font=font)
ext1
=
Text
(
text
=
"太阳视角:2024年重要天象"
,
color
=
color
.
white
,
scale
=
2.5
,
position
=
position
,
# (-0.98, 0.48),
font
=
font
)
font
=
self
.
font
)
text2
=
Text
(
text
=
"(地球自转放慢10倍)"
,
color
=
color
.
white
,
scale
=
1.5
,
position
=
position2
,
# (-0.98, 0.48),
font
=
font
)
font
=
self
.
font
)
# 2024年重要天象
def
show_clock
(
self
,
dt
):
...
...
sim_scenes/featured/tri_bodies_01.py
浏览文件 @
c33a202c
...
...
@@ -58,9 +58,9 @@ if __name__ == '__main__':
window
.
borderless
=
True
window
.
exit_button
=
False
# window.fullscreen = True
window
.
position
=
(
1920
,
0
)
# 设置窗口的宽度和高度
window
.
size
=
(
2340
,
1079
)
#
window.position = (1920, 0)
#
#
设置窗口的宽度和高度
#
window.size = (2340, 1079)
sky
=
create_sphere_sky
(
scale
=
80000
,
texture
=
"bg_pan_deep_blue.jpg"
)
camera
.
clip_plane_near
=
1
camera
.
clip_plane_far
=
sky
.
scale_x
*
1.5
...
...
sim_scenes/func.py
浏览文件 @
c33a202c
...
...
@@ -717,6 +717,7 @@ def speed_smooth_adjust_test():
def
create_sphere_sky
(
texture
=
"bg_pan.jpg"
,
scale
=
8000
,
rotation_x
=
None
,
rotation_y
=
None
,
rotation_z
=
None
):
from
common.image_utils
import
find_texture
from
ursina
import
camera
from
simulators.ursina.entities.sphere_sky
import
SphereSky
sky_texture
=
find_texture
(
texture
,
None
)
if
sky_texture
is
not
None
:
...
...
@@ -728,6 +729,8 @@ def create_sphere_sky(texture="bg_pan.jpg", scale=8000, rotation_x=None, rotatio
sky
.
rotation_y
=
rotation_y
if
rotation_z
is
not
None
:
sky
.
rotation_z
=
rotation_z
# camera.clip_plane_near = 1
camera
.
clip_plane_far
=
sky
.
scale_x
*
1.5
return
sky
else
:
print
(
f
'`textures`目录下没有找到图片`
{
texture
}
`,请访问如下链接下载,下载后,将图片放在`textures`目录下'
)
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
c33a202c
...
...
@@ -132,7 +132,7 @@ def create_trails(parent):
if
UrsinaConfig
.
trail_type
==
"curve_line"
:
# 如果位置比较近,就不创建拖尾了,保证拖尾间隔一定的距离
# if last_pos_distance < parent.trail_scale * trail_int_scale / 5:
if
last_pos_distance
<
10
:
if
last_pos_distance
<
parent
.
trail_scale
*
trail_int_scale
*
UrsinaConfig
.
trail_factor
:
return
else
:
# 如果位置比较近,就不创建拖尾了,保证拖尾间隔一定的距离
...
...
simulators/ursina/entities/planet.py
浏览文件 @
c33a202c
...
...
@@ -305,9 +305,9 @@ class Planet(Entity):
# self.x = -pos[1]
# self.y = pos[2]
# self.z = pos[0]
self
.
main_entity
.
x
=
pos
[
0
]
self
.
main_entity
.
y
=
pos
[
1
]
self
.
main_entity
.
z
=
pos
[
2
]
self
.
main_entity
.
world_
x
=
pos
[
0
]
self
.
main_entity
.
world_
y
=
pos
[
1
]
self
.
main_entity
.
world_
z
=
pos
[
2
]
else
:
self
.
follow_parent
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录