Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
406b7343
宇宙模拟器
项目概览
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看板
提交
406b7343
编写于
11月 11, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
bf539743
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
19 deletion
+56
-19
sim_scenes/fiction/earth_orbit_stopped.py
sim_scenes/fiction/earth_orbit_stopped.py
+3
-2
sim_scenes/solar_system/halley_comet_lib.py
sim_scenes/solar_system/halley_comet_lib.py
+16
-15
sim_scenes/universe_sim_scenes.py
sim_scenes/universe_sim_scenes.py
+31
-0
simulators/ursina/entities/timer.py
simulators/ursina/entities/timer.py
+6
-2
未找到文件。
sim_scenes/fiction/earth_orbit_stopped.py
浏览文件 @
406b7343
...
...
@@ -12,6 +12,7 @@ from common.func import calculate_distance, get_acceleration_info
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
set_camera_parent
,
\
create_text_panel
from
bodies.body
import
AU
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.body_timer
import
BodyTimer
,
TimeData
from
simulators.ursina.entities.entity_utils
import
get_value_direction_vectors
from
simulators.ursina.ui.control_ui
import
ControlUI
...
...
@@ -23,7 +24,7 @@ from simulators.ursina.ursina_mesh import create_circle_line, create_orbit_line
from
ursina
import
color
class
EarthOrbitStoppedSim
:
class
EarthOrbitStoppedSim
(
UniverseSimScenes
)
:
"""
地球停止公转模拟类
"""
...
...
@@ -236,7 +237,7 @@ if __name__ == '__main__':
# 订阅事件后,上面的函数功能才会起作用
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
sim
.
on_timer_changed
)
UniverseSimScenes
.
set_window_size
((
1400
,
700
))
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
...
...
sim_scenes/solar_system/halley_comet_lib.py
浏览文件 @
406b7343
...
...
@@ -15,6 +15,7 @@ from common.celestial_data_service import get_reality_orbit_points, init_bodies_
from
common.color_utils
import
trail_color_brightest
from
common.consts
import
AU
from
objs
import
HalleComet
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ursina_mesh
import
create_orbit_by_points
...
...
@@ -53,7 +54,7 @@ def create_orbit_line(center_body, body, start_time):
return
orbit_line
class
HalleyCometSimBase
:
class
HalleyCometSimBase
(
UniverseSimScenes
)
:
def
__init__
(
self
):
self
.
mercury
=
None
...
...
@@ -68,20 +69,20 @@ class HalleyCometSimBase:
self
.
pluto
=
None
self
.
bodies
=
[]
def
set_window_size
(
self
,
size
=
(
1536
,
684
),
fullscreen
=
False
):
from
ursina
import
window
if
fullscreen
:
# 设置窗口为全屏模式
window
.
fullscreen
=
True
# 设置窗口的宽度和高度
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)
#
def set_window_size(self, size=(1536, 684), fullscreen=False):
#
from ursina import window
#
if fullscreen:
#
# 设置窗口为全屏模式
#
window.fullscreen = True
#
#
# 设置窗口的宽度和高度
#
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)
def
build_solar_system
(
self
,
ignore_gravity
=
False
,
start_time
=
None
):
# region 构建太阳系
...
...
sim_scenes/universe_sim_scenes.py
0 → 100644
浏览文件 @
406b7343
# -*- coding:utf-8 -*-
# title :宇宙模拟场景的基类
# description :可以作为宇宙模拟场景的基类,但是不是必须的
# author :Python超人
# date :2023-11-11
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# ==============================================================================
class
UniverseSimScenes
:
"""
可以作为宇宙模拟场景的基类,但是不是必须的。
"""
@
staticmethod
def
set_window_size
(
size
=
(
1536
,
684
),
fullscreen
=
False
):
from
ursina
import
window
if
fullscreen
:
# 设置窗口为全屏模式
window
.
fullscreen
=
True
# 设置窗口的宽度和高度
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)
simulators/ursina/entities/timer.py
浏览文件 @
406b7343
...
...
@@ -18,8 +18,12 @@ class Timer(Text):
def
__init__
(
self
,
show
=
True
):
# 创建一个文本对象来显示计时器的时间
super
().
__init__
(
text
=
' '
,
position
=
(
0.70
,
-
0.465
),
origin
=
(
-
0.5
,
0.5
),
from
ursina
import
window
aspect_ratio
=
window
.
aspect_ratio
position
,
origin
=
(
0.5
*
aspect_ratio
-
0.18
,
-
0.465
),
(
-
0.5
,
0.5
),
super
().
__init__
(
text
=
' '
,
position
=
position
,
#(0.70, -0.465),
origin
=
origin
,
font
=
UrsinaConfig
.
CN_FONT
,
background
=
True
)
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
if
not
show
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录