Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
bb1ef362
宇宙模拟器
项目概览
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看板
提交
bb1ef362
编写于
10月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
55381746
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
8 deletion
+85
-8
objs/circle_obj.py
objs/circle_obj.py
+1
-1
sim_scenes/tri_bodies/two_way_foil.py
sim_scenes/tri_bodies/two_way_foil.py
+80
-7
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+4
-0
未找到文件。
objs/circle_obj.py
浏览文件 @
bb1ef362
...
@@ -22,7 +22,7 @@ class CircleObj(Obj):
...
@@ -22,7 +22,7 @@ class CircleObj(Obj):
ignore_mass
=
False
,
density
=
3.51e3
,
color
=
(
7
,
0
,
162
),
ignore_mass
=
False
,
density
=
3.51e3
,
color
=
(
7
,
0
,
162
),
trail_color
=
None
,
show_name
=
False
,
trail_color
=
None
,
show_name
=
False
,
parent
=
None
,
gravity_only_for
=
[]):
parent
=
None
,
gravity_only_for
=
[]):
from
ursina.models.procedural.
quad
import
Quad
from
ursina.models.procedural.
circle
import
Circle
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
...
sim_scenes/tri_bodies/two_way_foil.py
浏览文件 @
bb1ef362
...
@@ -45,9 +45,9 @@ if __name__ == '__main__':
...
@@ -45,9 +45,9 @@ if __name__ == '__main__':
]
]
# endregion
# endregion
two_way_foil
=
QuadObj
(
texture
=
'caustic.jpg'
,
size_scale
=
2e8
,
two_way_foil
=
QuadObj
(
texture
=
'caustic.jpg'
,
size_scale
=
4e7
,
init_velocity
=
[
-
10
,
-
10
,
0
],
init_velocity
=
[
0
,
0
,
10
0
],
init_position
=
[
0
,
0
,
39.55
*
AU
])
\
init_position
=
[
0
,
0
,
-
10
*
AU
])
\
.
set_light_disable
(
True
).
set_ignore_gravity
(
True
)
.
set_light_disable
(
True
).
set_ignore_gravity
(
True
)
three_dim_bodies
=
[]
three_dim_bodies
=
[]
...
@@ -82,17 +82,90 @@ if __name__ == '__main__':
...
@@ -82,17 +82,90 @@ if __name__ == '__main__':
@return:
@return:
"""
"""
# 创建天空
# 创建天空
create_sphere_sky
(
scale
=
8000
)
# camera.clip_plane_near = 0.1
camera
.
clip_plane_far
=
1000000
create_sphere_sky
(
scale
=
200000
)
for
body
in
two_dim_bodies
:
for
body
in
two_dim_bodies
:
body
.
planet
.
enabled
=
False
model
=
body
.
planet
.
model
if
body
.
three_dim
.
has_rings
:
if
body
.
three_dim
.
has_rings
:
rings
=
create_rings
(
body
.
planet
)
rings
=
create_rings
(
body
.
planet
)
rings
.
scale
*=
2e10
rings
.
scale
*=
2e10
current_stage
=
None
def
stage_01
():
"""
二向箔飞向太阳
@return:
"""
global
current_stage
if
two_bodies_colliding
(
two_way_foil
,
sun
):
sun
.
planet
.
enabled
=
False
sun
.
two_dim
.
planet
.
enabled
=
True
# two_way_foil.explode(sun)
two_way_foil
.
planet
.
enabled
=
False
current_stage
=
stage_02
def
blink
(
body
):
if
not
hasattr
(
body
,
"blink_d"
):
body
.
blink_d
=
1
body
.
blink_v
=
1
if
body
.
blink_d
>
0
:
body
.
blink_v
-=
0.05
body
.
planet
.
alpha
=
body
.
blink_v
if
body
.
blink_v
<=
0.7
:
body
.
blink_d
=
-
1
elif
body
.
blink_d
<
0
:
body
.
blink_v
+=
0.05
body
.
planet
.
alpha
=
body
.
blink_v
if
body
.
blink_v
>=
1
:
body
.
blink_d
=
1
def
stage_02
():
"""
@return:
"""
global
current_stage
sun
.
two_dim
.
planet
.
init_scale
+=
1.1
blink
(
sun
.
two_dim
)
for
b
in
three_dim_bodies
:
if
two_bodies_colliding
(
sun
.
two_dim
,
b
):
b
.
planet
.
enabled
=
False
b
.
two_dim
.
planet
.
enabled
=
True
if
b
.
two_dim
.
planet
.
enabled
:
b
.
two_dim
.
planet
.
init_scale
+=
1.1
blink
(
b
.
two_dim
)
current_stage
=
stage_01
def
on_timer_changed
(
time_data
):
def
on_timer_changed
(
time_data
):
two_way_foil
.
planet
.
rotation_x
+=
1
two_way_foil
.
planet
.
rotation_x
+=
1
two_way_foil
.
planet
.
rotation_y
+=
2
two_way_foil
.
planet
.
rotation_y
+=
2
for
b
in
three_dim_bodies
:
current_stage
()
b
.
planet
.
enabled
=
False
# if sun.two_dim.planet.enabled:
# sun.two_dim.planet.init_scale += 1.1
# for b in three_dim_bodies:
# if two_bodies_colliding(sun.two_dim, b):
# b.planet.enabled = False
# b.two_dim.planet.enabled = True
# if b.two_dim.planet.enabled:
# b.two_dim.planet.init_scale += 1.1
# else:
# if two_bodies_colliding(two_way_foil, sun):
# sun.planet.enabled = False
# sun.two_dim.planet.enabled = True
# for b in three_dim_bodies:
# b.planet.enabled = False
for
b
in
two_dim_bodies
:
for
b
in
two_dim_bodies
:
b
.
planet
.
rotation_x
=
90
b
.
planet
.
rotation_x
=
90
b
.
init_position
=
b
.
three_dim
.
position
b
.
init_position
=
b
.
three_dim
.
position
...
@@ -110,7 +183,7 @@ if __name__ == '__main__':
...
@@ -110,7 +183,7 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_MONTH
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
ursina_run
(
bodies
,
SECONDS_PER_MONTH
/
2
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
cosmic_bg
=
''
,
cosmic_bg
=
''
,
timer_enabled
=
True
,
timer_enabled
=
True
,
show_grid
=
False
)
show_grid
=
False
)
simulators/ursina/entities/planet.py
浏览文件 @
bb1ef362
...
@@ -106,6 +106,10 @@ class Planet(Entity):
...
@@ -106,6 +106,10 @@ class Planet(Entity):
# 当对天体大小进行缩放的时候会触发 change_body_scale
# 当对天体大小进行缩放的时候会触发 change_body_scale
UrsinaEvent
.
on_body_size_changed_subscription
(
self
.
change_body_scale
)
UrsinaEvent
.
on_body_size_changed_subscription
(
self
.
change_body_scale
)
# if model == 'circle':
# from ursina.models.procedural.circle import Circle
# model = Circle()
super
().
__init__
(
super
().
__init__
(
# model="sphere",
# model="sphere",
model
=
model
,
model
=
model
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录