Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
c5aaeb2c
宇宙模拟器
项目概览
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看板
提交
c5aaeb2c
编写于
11月 11, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
d9c2d475
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
52 deletion
+60
-52
sim_scenes/solar_system/halley_comet_sim.py
sim_scenes/solar_system/halley_comet_sim.py
+48
-46
sim_scenes/universe_sim_scenes.py
sim_scenes/universe_sim_scenes.py
+12
-6
未找到文件。
sim_scenes/solar_system/halley_comet_sim.py
浏览文件 @
c5aaeb2c
...
...
@@ -51,6 +51,7 @@ class HalleyCometSim(HalleyCometSimBase):
@return:
"""
self
.
build_solar_system
(
ignore_gravity
=
True
,
start_time
=
self
.
start_time
)
self
.
sun
.
glows
=
(
80
,
1.005
,
0.01
)
# 创建哈雷彗星创建哈雷彗星
self
.
halley_comet
=
create_halley_comet
(
self
.
params
.
init_velocity
,
self
.
params
.
init_position
)
self
.
bodies
.
append
(
self
.
halley_comet
)
...
...
@@ -72,9 +73,6 @@ class HalleyCometSim(HalleyCometSimBase):
# UrsinaConfig.trail_length = 180
UrsinaConfig
.
trail_factor
=
3
# r = 1
# self.set_window_size((int(1920 * r), int(1080 * r)), True)
# camera.clip_plane_near = 0.1
camera
.
clip_plane_far
=
1000000
...
...
@@ -83,22 +81,6 @@ class HalleyCometSim(HalleyCometSimBase):
camera_move_update
()
# camera_move_to_target_update()
def
on_ready
(
self
):
"""
事件绑定后,模拟器运行前会触发
@return:
"""
# 初始化设置
self
.
init_settings
()
# 显示网格以及坐标线
# self.show_grid_axises()
# 创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
self
.
create_orbit_lines
()
# 创建信息显示面板
self
.
text_panel
=
create_text_panel
()
def
create_orbit_lines
(
self
):
"""
创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
...
...
@@ -185,7 +167,7 @@ class HalleyCometSim(HalleyCometSimBase):
@param dt:
@return:
"""
milestones
=
[(
"1986-02-09"
,
(
0
,
2
,
0
)),
(
"2023-12-09"
,
(
0
,
-
2
,
0
)),
(
"2061-07-28"
,
(
0
,
2
,
0
))]
milestones
=
[(
"1986-02-09"
,
(
0
,
2
,
0
)),
(
"2023-12-09"
,
(
0
,
2
,
0
)),
(
"2061-07-28"
,
(
0
,
2
,
0
))]
for
milestone
,
pos
in
milestones
:
prop_name
=
f
"milestone_
{
milestone
}
"
if
not
hasattr
(
self
,
prop_name
)
and
dt
.
strftime
(
"%Y-%m-%d"
)
>=
milestone
:
...
...
@@ -230,30 +212,6 @@ class HalleyCometSim(HalleyCometSimBase):
cond_cb
=
lambda
ps
:
ps
[
"next_cond"
]
>
dt
.
year
>=
ps
[
"cond"
],
value_conv
=
self
.
s_f
)
def
on_timer_changed
(
self
,
time_data
):
"""
@param time_data:
@return:
"""
dt
=
time_data
.
get_datetime
(
self
.
start_time
)
# 摄像机看向哈雷彗星
camera_look_at
(
self
.
halley_comet
,
rotation_z
=
0
)
time_total_hours
=
time_data
.
total_hours
if
not
hasattr
(
self
,
"last_total_hours"
):
self
.
last_total_hours
=
time_total_hours
self
.
update_halley_comet_info
(
dt
)
# 每隔一段时间运行一次更新(不要太频繁更新,会导致摄像机抖动)
if
time_total_hours
-
self
.
last_total_hours
>
100
:
self
.
camera_move
(
dt
)
self
.
update_halley_comet_info
(
dt
)
self
.
update_ui
(
time_data
,
dt
)
# 记录最后更新的总耗时(小时)
self
.
last_total_hours
=
time_total_hours
def
check_create_year_label
(
self
,
last_trail
,
dt
):
"""
检测并创建年标签
...
...
@@ -370,8 +328,8 @@ class HalleyCometSim(HalleyCometSimBase):
@param dt:
@return:
"""
if
dt
.
year
>
20
58
:
UrsinaConfig
.
trail_length
=
155
if
dt
.
year
>
20
45
:
UrsinaConfig
.
trail_length
=
211
# 更新天体的位置
self
.
set_bodies_position
(
time_data
)
# 更新时钟
...
...
@@ -380,6 +338,50 @@ class HalleyCometSim(HalleyCometSimBase):
# for i, orbit_line in enumerate(self.orbit_lines):
# orbit_line.position = self.sun.planet.position
def
on_ready
(
self
):
"""
事件绑定后,模拟器运行前会触发
@return:
"""
# 初始化设置
self
.
init_settings
()
# self.set_window_size((int(1920 * r), int(1080 * r)), False)
# 最大分辨率的高度-1,保证不全屏
self
.
set_window_size
((
1920
,
1079
),
False
)
# self.set_window_size((1920 , 1080 ), False)
# 显示网格以及坐标线
# self.show_grid_axises()
# 创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
self
.
create_orbit_lines
()
# 创建信息显示面板
self
.
text_panel
=
create_text_panel
()
def
on_timer_changed
(
self
,
time_data
):
"""
@param time_data:
@return:
"""
dt
=
time_data
.
get_datetime
(
self
.
start_time
)
# 摄像机看向哈雷彗星
camera_look_at
(
self
.
halley_comet
,
rotation_z
=
0
)
time_total_hours
=
time_data
.
total_hours
if
not
hasattr
(
self
,
"last_total_hours"
):
self
.
last_total_hours
=
time_total_hours
self
.
camera_move
(
dt
)
self
.
update_halley_comet_info
(
dt
)
# 每隔一段时间运行一次更新(不要太频繁更新,会导致摄像机抖动)
if
time_total_hours
-
self
.
last_total_hours
>
100
:
self
.
update_ui
(
time_data
,
dt
)
# 记录最后更新的总耗时(小时)
self
.
last_total_hours
=
time_total_hours
if
__name__
==
'__main__'
:
"""
...
...
sim_scenes/universe_sim_scenes.py
浏览文件 @
c5aaeb2c
...
...
@@ -13,21 +13,27 @@ class UniverseSimScenes:
可以作为宇宙模拟场景的基类,但是不是必须的。
"""
@
staticmethod
def
set_window_size
(
size
=
(
1536
,
684
),
fullscreen
=
False
):
from
ursina
import
window
# window.x =-20
# window.y=-20
# window.position = (-20, -20)
if
fullscreen
:
# 设置窗口为全屏模式
window
.
fullscreen
=
True
# 设置窗口的宽度和高度
window
.
size
=
size
else
:
# 设置最大分辨率
# window.maximized = True
window
.
fullscreen
=
False
window
.
position
=
(
0
,
0
)
# 设置窗口的宽度和高度
window
.
size
=
size
# self.set_window_size((3500, 1024))
# r = 1
# self.set_window_size((1920*2, 1080*2))
# self.set_window_size((int(1920 * r), int(1080 * r)))
# self.set_window_size((2376, 1080))
# self.set_window_size((520, 540), fullscreen=False)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录