Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
e2a28818
太阳系三体模拟器
项目概览
Python_超人
/
太阳系三体模拟器
通知
1075
Star
131
Fork
128
代码
文件
提交
分支
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看板
提交
e2a28818
编写于
3月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
太阳系三体模拟器
上级
bfb30361
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
29 addition
and
12 deletion
+29
-12
simulators/ursina/ui_component.py
simulators/ursina/ui_component.py
+3
-4
simulators/ursina/ursina_config.py
simulators/ursina/ursina_config.py
+5
-3
simulators/ursina/ursina_ui.py
simulators/ursina/ursina_ui.py
+3
-3
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+18
-2
未找到文件。
simulators/ursina/ui_component.py
浏览文件 @
e2a28818
...
...
@@ -16,12 +16,12 @@ from simulators.ursina.ursina_config import UrsinaConfig
class
UiSlider
(
Slider
):
def
__init__
(
self
,
text
,
min
=
0.01
,
max
=
3
,
default
=
1
):
def
__init__
(
self
,
text
,
min
=
0.01
,
max
=
3
,
step
=
.
01
,
default
=
1
):
# Text.default_font = 'msyhl.ttc' # 'simsun.ttc'
super
().
__init__
(
text
=
text
,
height
=
Text
.
size
,
y
=-
.
6
,
step
=
.
01
,
step
=
step
,
min
=
min
,
max
=
max
,
default
=
default
,
...
...
@@ -35,10 +35,9 @@ class UiSlider(Slider):
# self.height *= 8/10
class
SwithButton
(
ButtonGroup
):
def
__init__
(
self
,
options
,
default
,
tooltips
=
None
):
super
().
__init__
(
options
,
min_selection
=
1
,
default
=
default
,
super
().
__init__
(
options
,
min_selection
=
1
,
default
=
default
,
selected_color
=
color
.
rgba
(
0.1
,
0.6
,
0.1
,
1.0
),
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
))
# self.label.scale = 0.8
...
...
simulators/ursina/ursina_config.py
浏览文件 @
e2a28818
...
...
@@ -11,15 +11,15 @@
class
UrsinaConfig
:
# 常量定义
# 天体缩放的因子(不能太大,否则无法容得下大数量级的天体)
SCALE_FACTOR
=
5e-
10
# 天体缩放的因子(不能太大,否则无法容得下大数量级的天体)
调整 5e-7 最佳
SCALE_FACTOR
=
5e-
7
# 旋转因子为1,则为正常的转速
ROTATION_SPEED_FACTOR
=
1.0
# ROTATION_SPEED_FACTOR = 0.01
# 中文字体(微软雅黑)
CN_FONT
=
"msyhl.ttc"
# 'simsun.ttc' 仿宋体
CN_FONT
=
'simsun.ttc'
# 仿宋体
#
CN_FONT = 'simsun.ttc' # 仿宋体
# 速度的倍数
__run_speed_factor
=
1.0
...
...
@@ -37,6 +37,8 @@ class UrsinaConfig:
trail_length
=
200
# 默认秒数(0表示默认)
seconds_per
=
0
# # 控制摄像机动作速度(天体越大,速度越快,天体越小,速度越慢)
# control_camera_speed = 1
__body_size_factor
=
1.0
...
...
simulators/ursina/ursina_ui.py
浏览文件 @
e2a28818
...
...
@@ -27,12 +27,12 @@ class UrsinaUI:
self
.
no_trail_button_text
=
"○ "
self
.
trail_button_text
=
"○--"
application
.
time_scale
=
0.5
#
application.time_scale = 0.5
self
.
slider_body_spin_factor
=
UiSlider
(
text
=
'自转速度'
,
min
=
0.01
,
max
=
30
,
default
=
1
)
self
.
slider_body_size_factor
=
UiSlider
(
text
=
'天体缩放'
,
min
=
0.1
,
max
=
100
,
default
=
1
)
self
.
slider_run_speed_factor
=
UiSlider
(
text
=
"运行速度"
,
min
=
0.01
,
max
=
80
,
default
=
1
)
self
.
slider_control_speed_factor
=
UiSlider
(
text
=
"控制速度"
,
min
=
0.01
,
max
=
3
0
,
default
=
application
.
time_scale
)
self
.
slider_trail_length
=
UiSlider
(
text
=
"拖尾长度"
,
min
=
30
,
max
=
500
,
default
=
UrsinaConfig
.
trail_length
)
self
.
slider_control_speed_factor
=
UiSlider
(
text
=
"控制速度"
,
min
=
0.01
,
max
=
5
0
,
default
=
application
.
time_scale
)
self
.
slider_trail_length
=
UiSlider
(
text
=
"拖尾长度"
,
min
=
30
,
max
=
500
,
step
=
10
,
default
=
UrsinaConfig
.
trail_length
)
self
.
slider_body_size_factor
.
on_value_changed
=
self
.
on_slider_body_size_changed
self
.
slider_body_spin_factor
.
on_value_changed
=
self
.
on_slider_body_spin_changed
...
...
simulators/ursina_simulator.py
浏览文件 @
e2a28818
...
...
@@ -8,7 +8,7 @@
# ==============================================================================
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina
from
ursina
import
Ursina
,
window
,
Entity
,
Grid
,
Mesh
,
camera
,
Text
,
application
,
color
,
mouse
,
Vec2
,
Vec3
,
\
load_texture
,
held_keys
load_texture
,
held_keys
,
distance
from
ursina.prefabs.first_person_controller
import
FirstPersonController
from
simulators.ursina.ursina_event
import
UrsinaEvent
...
...
@@ -57,9 +57,25 @@ class UrsinaSimulator(Simulator):
self
.
ursina_views
.
append
(
view
)
# planets.append(newPlanet)
# x += cp[i] * 10
self
.
adj_application_time_scale
()
UrsinaEvent
.
on_searching_bodies_subscription
(
type
(
self
).
__name__
,
self
.
on_searching_bodies
)
def
adj_application_time_scale
(
self
):
max_distance
=
0
for
b1
in
self
.
body_views
:
for
b2
in
self
.
body_views
:
if
b1
is
b2
:
continue
d
=
distance
(
b1
.
planet
,
b2
.
planet
)
if
d
>
max_distance
:
max_distance
=
d
# UrsinaConfig.control_camera_speed = round(max_distance * 10, 2)
time_scale
=
round
(
pow
(
max_distance
,
1
/
3
),
2
)
if
time_scale
<
0.01
:
time_scale
=
0.01
application
.
time_scale
=
time_scale
def
on_searching_bodies
(
self
,
**
kwargs
):
views
=
[]
for
view
in
self
.
body_views
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录