Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
c10acbec
宇宙模拟器
项目概览
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看板
提交
c10acbec
编写于
10月 06, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
a4bdd56e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
74 addition
and
5 deletion
+74
-5
bodies/asteroid.py
bodies/asteroid.py
+4
-0
common/win_pos.py
common/win_pos.py
+12
-0
sim_scenes/func.py
sim_scenes/func.py
+8
-0
sim_scenes/solar_system/solar_system_2.py
sim_scenes/solar_system/solar_system_2.py
+14
-2
sim_scenes/solar_system/solar_system_4.py
sim_scenes/solar_system/solar_system_4.py
+15
-1
sim_scenes/wonders/sun_earth_moon.py
sim_scenes/wonders/sun_earth_moon.py
+21
-2
未找到文件。
bodies/asteroid.py
浏览文件 @
c10acbec
...
...
@@ -47,6 +47,10 @@ class Asteroid(Body):
def
show_trail
(
self
):
return
False
@
show_trail
.
setter
def
show_trail
(
self
,
value
):
self
.
__show_trail
=
value
def
ignore_gravity_with
(
self
,
body
):
"""
是否忽略指定天体的引力
...
...
common/win_pos.py
浏览文件 @
c10acbec
...
...
@@ -84,10 +84,22 @@ Area.rect.y : {y}
print
(
"Pycharm 窗口"
,
rect
)
def
set_universe_win_pos
():
rect
=
(
183
,
70
,
1536
,
863
)
r
=
1.25
rect
=
(
int
(
rect
[
0
]
/
r
),
int
(
rect
[
1
]
/
r
),
int
((
rect
[
2
]
+
rect
[
0
])
/
r
),
int
((
rect
[
3
]
+
rect
[
1
])
/
r
))
# Area.rect.h: 863
# Area.rect.w: 1536
# Area.rect.x: 183
# Area.rect.y: 70
set_win_pos
(
'宇宙模拟器(universe sim)'
,
rect
)
if
__name__
==
'__main__'
:
# 使用方法:
# 1、运行 win_pos.py,找到 EV录屏 区域 -> EV录屏 (183, 70, 1536, 863)
set_pycharm_win_pos
()
# set_universe_win_pos()
# 2、打开 C:\Users\Administrator\AppData\Local\EVCapture\conf\Admin.conf
# 修改:
# Area.rect.h : 863
...
...
sim_scenes/func.py
浏览文件 @
c10acbec
...
...
@@ -663,6 +663,14 @@ def speed_smooth_adjust_test():
plt
.
show
()
def
create_sphere_sky
(
texture
=
"bg_pan.jpg"
,
scale
=
8000
):
from
common.image_utils
import
find_texture
from
simulators.ursina.entities.sphere_sky
import
SphereSky
sky_texture
=
find_texture
(
texture
,
None
)
if
sky_texture
is
not
None
:
SphereSky
(
texture
=
sky_texture
).
scale
=
scale
if
__name__
==
'__main__'
:
# from bodies import Sun, Earth
#
...
...
sim_scenes/solar_system/solar_system_2.py
浏览文件 @
c10acbec
...
...
@@ -8,7 +8,8 @@
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Asteroids
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_MONTH
,
SECONDS_PER_YEAR
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
create_sphere_sky
from
simulators.ursina.ursina_event
import
UrsinaEvent
if
__name__
==
'__main__'
:
# 八大行星:木星(♃)、土星(♄)、天王星(♅)、海王星(♆)、地球(⊕)、金星(♀)、火星(♂)、水星(☿)
...
...
@@ -37,8 +38,19 @@ if __name__ == '__main__':
Pluto
(
size_scale
=
10e3
,
distance_scale
=
0.23
),
# 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除)
]
# endregion
def
on_ready
():
"""
事件绑定后,模拟器运行前会触发
@return:
"""
# 创建天空
create_sphere_sky
(
scale
=
8000
)
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
show_grid
=
False
)
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
cosmic_bg
=
''
,
show_grid
=
False
)
sim_scenes/solar_system/solar_system_4.py
浏览文件 @
c10acbec
...
...
@@ -8,9 +8,10 @@
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
,
Asteroids
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_YEAR
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
create_sphere_sky
import
math
from
common.consts
import
G
from
simulators.ursina.ursina_event
import
UrsinaEvent
def
get_velocity
(
mass
,
distance
,
velocity
,
target_distance
):
...
...
@@ -86,9 +87,22 @@ if __name__ == '__main__':
body
.
init_velocity
=
init_velocity
body_index
+=
1
# def on_ready():
# """
# 事件绑定后,模拟器运行前会触发
# @return:
# """
# # 创建天空
# create_sphere_sky(scale=8000)
#
# # 运行前会触发 on_ready
# UrsinaEvent.on_ready_subscription(on_ready)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
show_trail
=
True
,
# 运行轨迹拖尾效果(通过快捷键 I 控制开关)
show_grid
=
False
,
# cosmic_bg='',
bg_music
=
"sounds/interstellar.mp3"
)
sim_scenes/wonders/sun_earth_moon.py
浏览文件 @
c10acbec
...
...
@@ -8,7 +8,7 @@
# ==============================================================================
from
bodies
import
Sun
,
Earth
,
Moon
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
,
create_sphere_sky
from
bodies.body
import
AU
from
simulators.ursina.ursina_event
import
UrsinaEvent
...
...
@@ -32,6 +32,7 @@ if __name__ == '__main__':
# moon_pos, moon_vel = [-384400, 0, 0], [EARTH_INIT_VELOCITY, 0, -1.03]
moon
=
Moon
(
init_position
=
moon_pos
,
# 距地距离约: 363104 至 405696 km
init_velocity
=
moon_vel
,
rotation_speed
=
0.40
,
size_scale
=
2e1
)
# 月球放大 20 倍,距离保持不变
bodies
=
[
sun
,
...
...
@@ -42,6 +43,18 @@ if __name__ == '__main__':
]
def
on_ready
():
"""
事件绑定后,模拟器运行前会触发
@return:
"""
# 运行前触发
# 创建天空
create_sphere_sky
(
scale
=
8000
)
moon
.
planet
.
rotation_y
=
90
def
on_timer_changed
(
time_data
):
camera_look_at
(
moon
,
rotation_z
=
0
)
...
...
@@ -49,9 +62,15 @@ if __name__ == '__main__':
# 订阅事件后,上面的函数功能才会起作用
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position=(0, 0, 0) 的位置是站在地球视角,可以观看月相变化的过程
ursina_run
(
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
0
,
0
),
show_timer
=
True
)
ursina_run
(
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
0
,
0
),
show_grid
=
False
,
cosmic_bg
=
''
,
show_timer
=
True
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录