Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
1ab087ee
宇宙模拟器
项目概览
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看板
提交
1ab087ee
编写于
3月 26, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
f1f315c8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
36 addition
and
18 deletion
+36
-18
bodies/moon.py
bodies/moon.py
+2
-1
objs/rock.py
objs/rock.py
+1
-1
sim_scenes/featured/jupiter_moon_protects_earth.py
sim_scenes/featured/jupiter_moon_protects_earth.py
+23
-13
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+10
-3
未找到文件。
bodies/moon.py
浏览文件 @
1ab087ee
...
...
@@ -27,7 +27,7 @@ class Moon(Body):
init_velocity
=
[
-
(
29.79
+
1.03
),
0
,
0
],
texture
=
"moon.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
0.25
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
,
trail_color
=
None
,
show_name
=
False
,
show_trail
=
True
,
gravity_only_for_earth
=
False
):
"""
@param name: 月球名称
...
...
@@ -57,6 +57,7 @@ class Moon(Body):
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"trail_color"
:
trail_color
,
"show_trail"
:
show_trail
,
"show_name"
:
show_name
}
super
().
__init__
(
**
params
)
...
...
objs/rock.py
浏览文件 @
1ab087ee
...
...
@@ -46,7 +46,7 @@ class Rock(Obj):
# 对岩石进行缩放,保证 create_rock 保证创建的岩石大小差异不会过大
ROCK_SIZE_SCALE_FACTOR
=
{
6
:
0.5
,
7
:
1e-2
7
:
3e-1
}
...
...
sim_scenes/featured/jupiter_moon_protects_earth.py
浏览文件 @
1ab087ee
...
...
@@ -35,14 +35,14 @@ class JupiterMoonProtectsEarthSim(UniverseSimScenes):
self
.
sun_jupiter_d
=
520000000
# 分别保存太阳碰撞次数、木星碰撞次数、地球碰撞次数、月球碰撞次数、木星保护次数、月球保护次数
self
.
colliding_count
=
[
0
,
0
,
0
,
0
,
0
,
0
]
self
.
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
0.85e2
)
# 太阳放大 80 倍,距离保持不变
self
.
jupiter
=
Jupiter
(
name
=
"木星"
,
size_scale
=
0.45e3
,
ignore_mass
=
True
)
# 木星放大 600 倍,距离保持不变
self
.
earth
=
Earth
(
name
=
"地球"
,
size_scale
=
2.5e3
,
ignore_mass
=
True
,
)
# 地球放大 2000 倍,距离保持不变
self
.
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
0.85e2
,
show_trail
=
False
)
# 太阳放大 80 倍,距离保持不变
self
.
jupiter
=
Jupiter
(
name
=
"木星"
,
size_scale
=
0.45e3
,
ignore_mass
=
True
,
show_trail
=
False
)
# 木星放大 600 倍,距离保持不变
self
.
earth
=
Earth
(
name
=
"地球"
,
size_scale
=
2.5e3
,
ignore_mass
=
True
,
show_trail
=
False
)
# 地球放大 2000 倍,距离保持不变
self
.
moon
=
Moon
(
name
=
"月球"
,
size_scale
=
3.5e3
,
# 月球球放大 3000 倍,为了较好的效果,地月距离要比实际大
init_position
=
[
self
.
earth_moon_d
,
0
,
AU
],
init_velocity
=
[
0
,
0
,
0
],
ignore_mass
=
True
,
rotation_speed
=
0.4065
,
rotation_speed
=
0.4065
,
show_trail
=
False
,
# gravity_only_for_earth=True
)
# .set_light_disable(True)
...
...
@@ -99,7 +99,7 @@ class JupiterMoonProtectsEarthSim(UniverseSimScenes):
# vel = [0, 0, 0]
# 石头随机大小
size_scale
=
random
.
randint
(
3
00
,
600
)
*
1.5e4
size_scale
=
random
.
randint
(
5
00
,
600
)
*
1.5e4
# 随机创建石头
rock
=
create_rock
(
no
=
index
%
7
+
1
,
name
=
f
'岩石
{
index
+
1
}
'
,
mass
=
size_scale
/
1000
,
...
...
@@ -191,10 +191,14 @@ class JupiterMoonProtectsEarthSim(UniverseSimScenes):
if
collided
:
# 如果碰撞了,则该石头重复再利用,这样才保证有无限个石头可用
pos
,
vel
=
self
.
random_pos_vel
()
comet
.
planet
.
on_reset
()
comet
.
planet
.
trails
.
clear
()
if
hasattr
(
comet
.
planet
,
"trail_last_pos"
):
delattr
(
comet
.
planet
,
"trail_last_pos"
)
# comet.planet.trails.clear()
# if hasattr(comet.planet, "trail_last_pos"):
# delattr(comet.planet, "trail_last_pos")
# if hasattr(comet.planet, "last_trail"):
# del comet.planet.last_trail
# delattr(comet.planet, "last_trail")
comet
.
init_position
=
pos
comet
.
init_velocity
=
vel
comet
.
set_visible
(
True
)
...
...
@@ -205,10 +209,12 @@ class JupiterMoonProtectsEarthSim(UniverseSimScenes):
if
hasattr
(
comet
,
"moon_collided"
):
delattr
(
comet
,
"moon_collided"
)
print
(
"Sun:%s Jupiter:%s Earth:%s Moon:%s"
%
(
self
.
colliding_count
[
0
],
self
.
colliding_count
[
1
],
self
.
colliding_count
[
2
],
self
.
colliding_count
[
3
]))
comet
.
planet
.
on_reset
()
# print("Sun:%s Jupiter:%s Earth:%s Moon:%s" % (self.colliding_count[0],
# self.colliding_count[1],
# self.colliding_count[2],
# self.colliding_count[3]))
sun_cnt
,
jupiter_cnt
,
earth_cnt
,
moon_cnt
,
j_protected_cnt
,
m_protected_cnt
=
self
.
colliding_count
total_cnt
=
sun_cnt
+
jupiter_cnt
+
earth_cnt
+
moon_cnt
if
total_cnt
==
0
:
...
...
@@ -272,6 +278,10 @@ class JupiterMoonProtectsEarthSim(UniverseSimScenes):
# UrsinaConfig.trail_length = 1000
UrsinaConfig
.
trail_thickness_factor
=
2
for
b
in
self
.
bodies
:
if
isinstance
(
b
,
Rock
):
print
(
"岩石大小"
,
b
.
name
,
b
.
planet
.
scale_x
)
if
__name__
==
'__main__'
:
"""
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
1ab087ee
...
...
@@ -147,7 +147,8 @@ def create_trails(parent):
else
:
trail
=
create_trail_sphere
(
parent
,
pos
)
# 拖尾为球体
if
trail
is
not
None
:
if
trail
is
None
:
return
create_trail_info
(
parent
.
body
,
trail
)
# 创建拖尾球体,并作为字典的key,存放拖尾球体的位置
...
...
@@ -287,7 +288,10 @@ def create_trail_curve_line(parent, pos):
trail
=
None
if
hasattr
(
parent
,
"trail_last_pos"
):
trail_last_pos
=
parent
.
trail_last_pos
if
distance
(
pos
,
trail_last_pos
)
>
0
:
d
=
distance
(
pos
,
trail_last_pos
)
# if d > 200:
# print(parent.body.name, d)
if
d
>
0
:
trail
=
Entity
(
model
=
Mesh
(
vertices
=
((
pos
[
0
],
pos
[
1
],
pos
[
2
]),
(
trail_last_pos
[
0
],
trail_last_pos
[
1
],
trail_last_pos
[
2
])),
mode
=
'line'
,
...
...
@@ -344,6 +348,9 @@ def clear_trails(parent):
parent
.
trails
.
clear
()
if
hasattr
(
parent
,
"trail_last_pos"
):
delattr
(
parent
,
"trail_last_pos"
)
if
hasattr
(
parent
,
"last_trail"
):
destroy
(
parent
.
last_trail
)
delattr
(
parent
,
"last_trail"
)
def
create_fixed_star_lights
(
fixed_star
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录