Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
13ced94f
太阳系三体模拟器
项目概览
Python_超人
/
太阳系三体模拟器
通知
1074
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看板
提交
13ced94f
编写于
3月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
太阳系三体模拟器
上级
571f216c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
12 deletion
+41
-12
simulators/ursina/ursina_config.py
simulators/ursina/ursina_config.py
+2
-0
simulators/ursina/ursina_ui.py
simulators/ursina/ursina_ui.py
+31
-9
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+6
-1
simulators/views/ursina_view.py
simulators/views/ursina_view.py
+2
-2
未找到文件。
simulators/ursina/ursina_config.py
浏览文件 @
13ced94f
...
...
@@ -35,6 +35,8 @@ class UrsinaConfig:
show_trail
=
False
# 拖尾球体的数量
trail_length
=
200
# 默认秒数(0表示默认)
seconds_per
=
0
__body_size_factor
=
1.0
...
...
simulators/ursina/ursina_ui.py
浏览文件 @
13ced94f
...
...
@@ -9,7 +9,8 @@
from
ursina
import
Ursina
,
window
,
Entity
,
Grid
,
Mesh
,
camera
,
Text
,
application
,
color
,
mouse
,
Vec2
,
Vec3
,
\
load_texture
,
held_keys
,
Button
,
ButtonList
,
destroy
,
scene
,
distance
,
Sequence
,
Wait
,
Func
from
ursina.prefabs.first_person_controller
import
FirstPersonController
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
\
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
,
SECONDS_PER_YEAR
from
common.consts
import
AU
from
simulators.ursina.ui_component
import
UiSlider
,
SwithButton
,
UiButton
from
simulators.ursina.ursina_config
import
UrsinaConfig
...
...
@@ -50,6 +51,7 @@ class UrsinaUI:
tooltips
=
(
"系统默认"
,
"每秒相当于1天"
,
"每秒相当于1周"
,
"每秒相当于1个月"
,
"每秒相当于1年"
,
"每秒相当于十年"
,
"每秒相当于1百年"
))
self
.
sec_per_time_switch
.
on_value_changed
=
self
.
sec_per_time_switch_changed
self
.
on_off_trail
=
SwithButton
((
self
.
no_trail_button_text
,
self
.
trail_button_text
),
default
=
self
.
no_trail_button_text
,
...
...
@@ -95,9 +97,9 @@ class UrsinaUI:
),
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
)
# , popup=True
)
self
.
sec_per_time_switch
.
x
=
-
0.
5
self
.
on_off_switch
.
x
=
-
0.2
self
.
on_off_trail
.
x
=
-
0.
2
self
.
sec_per_time_switch
.
x
=
-
0.
4
self
.
on_off_switch
.
x
=
0.2
self
.
on_off_trail
.
x
=
-
0.
4
wp
.
y
=
0.5
# wp.panel.scale_y / 2 * wp.scale_y # center the window panel
wp
.
x
=
0.6
# wp.scale_x + 0.1
# wp.x = 0#wp.panel.scale_x / 2 * wp.scale_x
...
...
@@ -136,13 +138,30 @@ class UrsinaUI:
destroy
(
message_box
)
s
=
Sequence
(
Wait
(
3
),
Wait
(
close_time
),
Func
(
close_message
)
)
s
.
start
()
# # 使用 time 模块来实现定时关闭
# invoke(close_message, delay=close_time)
def
sec_per_time_switch_changed
(
self
):
# ("默认", "天", "周", "月", "年", "十年", "百年")
if
self
.
sec_per_time_switch
.
value
==
"天"
:
UrsinaConfig
.
seconds_per
=
SECONDS_PER_DAY
elif
self
.
sec_per_time_switch
.
value
==
"周"
:
UrsinaConfig
.
seconds_per
=
SECONDS_PER_WEEK
elif
self
.
sec_per_time_switch
.
value
==
"月"
:
UrsinaConfig
.
seconds_per
=
SECONDS_PER_MONTH
elif
self
.
sec_per_time_switch
.
value
==
"年"
:
UrsinaConfig
.
seconds_per
=
SECONDS_PER_YEAR
elif
self
.
sec_per_time_switch
.
value
==
"十年"
:
UrsinaConfig
.
seconds_per
=
SECONDS_PER_YEAR
*
10
elif
self
.
sec_per_time_switch
.
value
==
"百年"
:
UrsinaConfig
.
seconds_per
=
SECONDS_PER_YEAR
*
100
else
:
UrsinaConfig
.
seconds_per
=
0
def
on_off_trail_changed
(
self
):
if
self
.
on_off_trail
.
value
==
self
.
trail_button_text
:
UrsinaConfig
.
show_trail
=
True
...
...
@@ -164,10 +183,10 @@ class UrsinaUI:
# 返回摄像机移动后的坐标
return
camera_pos
+
move_vector
def
move_camera_to_entity
(
self
,
entity
,
d
):
def
move_camera_to_entity
(
self
,
entity
,
d
):
import
math
# print("before",camera.position, entity.position)
camera
.
position
=
entity
.
position
#
- Vec3(0, 0, d) # 设置摄像机位置
camera
.
position
=
entity
.
position
#
- Vec3(0, 0, d) # 设置摄像机位置
camera
.
world_position
=
entity
.
position
# camera.rotation = (0, 0, 0) # 重置摄像机旋转角度
...
...
@@ -190,8 +209,11 @@ class UrsinaUI:
# UrsinaConfig.SCALE_FACTOR
# import copy
# camera_rotation = copy.deepcopy(camera.rotation)
d
=
item
.
planet
.
scale_x
*
20
self
.
move_camera_to_entity
(
item
.
planet
,
d
)
try
:
d
=
item
.
planet
.
scale_x
*
20
self
.
move_camera_to_entity
(
item
.
planet
,
d
)
except
Exception
as
e
:
self
.
show_message
(
f
"
{
item
}
飞不见了"
)
# d = distance(camera.position, item.planet.position)
# camera.look_at(item.planet)
# if d > 1.5 * x:
...
...
simulators/ursina_simulator.py
浏览文件 @
13ced94f
...
...
@@ -79,7 +79,12 @@ class UrsinaSimulator(Simulator):
def
check_and_evolve
(
self
):
if
self
.
check_elapsed_time
():
run_speed_factor
=
UrsinaConfig
.
run_speed_factor
super
().
evolve
(
self
.
evolve_dt
*
run_speed_factor
)
if
UrsinaConfig
.
seconds_per
==
0
:
evolve_dt
=
self
.
evolve_dt
*
run_speed_factor
else
:
evolve_dt
=
UrsinaConfig
.
seconds_per
*
run_speed_factor
super
().
evolve
(
evolve_dt
)
def
cosmic_background
(
self
,
texture
=
'../textures/cosmic2.jpg'
):
"""
...
...
simulators/views/ursina_view.py
浏览文件 @
13ced94f
...
...
@@ -111,8 +111,8 @@ class Planet(Entity):
texture
=
texture
,
color
=
color
.
white
,
position
=
pos
,
rotation
=
rotation
,
double_sided
=
True
)
rotation
=
rotation
# ,double_sided=True
)
if
hasattr
(
self
.
body_view
.
body
,
"torus_stars"
):
# 星环小天体群(主要模拟小行星群,非一个天体)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录