Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
faa5674c
宇宙模拟器
项目概览
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看板
提交
faa5674c
编写于
4月 22, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
0d1da2e1
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
25 addition
and
4 deletion
+25
-4
objs/rock.py
objs/rock.py
+1
-1
sim_scenes/README.md
sim_scenes/README.md
+3
-0
sim_scenes/solar_system/earth_moon.py
sim_scenes/solar_system/earth_moon.py
+9
-1
sim_scenes/wonders/__init__.py
sim_scenes/wonders/__init__.py
+0
-0
sim_scenes/wonders/comets_jupiter.py
sim_scenes/wonders/comets_jupiter.py
+1
-1
sim_scenes/wonders/sun_earth_moon.py
sim_scenes/wonders/sun_earth_moon.py
+0
-0
sim_scenes/wonders/transit_of_venus_mercury.py
sim_scenes/wonders/transit_of_venus_mercury.py
+1
-1
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+9
-0
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+1
-0
未找到文件。
objs/rock.py
浏览文件 @
faa5674c
...
@@ -45,7 +45,7 @@ class Rock(Obj):
...
@@ -45,7 +45,7 @@ class Rock(Obj):
# 对岩石进行缩放,保证 create_rock 保证创建的岩石大小差异不会过大
# 对岩石进行缩放,保证 create_rock 保证创建的岩石大小差异不会过大
ROCK_SIZE_SCALE_FACTOR
=
{
ROCK_SIZE_SCALE_FACTOR
=
{
6
:
1e-2
,
6
:
0.5
,
7
:
1e-2
7
:
1e-2
}
}
...
...
sim_scenes/README.md
浏览文件 @
faa5674c
...
@@ -24,3 +24,6 @@
...
@@ -24,3 +24,6 @@
### 三体的场景模拟
### 三体的场景模拟
**sim_scenes/tri_bodies**
**sim_scenes/tri_bodies**
### 天文奇观模拟
**sim_scenes/wonders**
sim_scenes/solar_system/earth_moon.py
浏览文件 @
faa5674c
...
@@ -10,6 +10,7 @@ from bodies import Sun, Earth, Moon
...
@@ -10,6 +10,7 @@ from bodies import Sun, Earth, Moon
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
bodies.body
import
AU
from
bodies.body
import
AU
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
@@ -28,9 +29,16 @@ if __name__ == '__main__':
...
@@ -28,9 +29,16 @@ if __name__ == '__main__':
def
on_ready
():
def
on_ready
():
# 运行前触发
# 运行开始前,将摄像机指向地球
# 运行开始前,将摄像机指向地球
earth
=
bodies
[
0
]
earth
=
bodies
[
0
]
moon
=
bodies
[
1
]
# 摄像机看向地球
camera_look_at
(
earth
)
camera_look_at
(
earth
)
# 创建太阳光
shadows_shader
=
create_directional_light
(
position
=
(
200
,
0
,
-
300
),
target
=
earth
,
shadows
=
True
)
earth
.
planet
.
shadows
=
shadows_shader
moon
.
planet
.
shadows
=
shadows_shader
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
...
@@ -38,7 +46,7 @@ if __name__ == '__main__':
...
@@ -38,7 +46,7 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_
MONTH
,
ursina_run
(
bodies
,
SECONDS_PER_
DAY
,
position
=
(
-
300000
,
1500000
,
-
1000
),
position
=
(
-
300000
,
1500000
,
-
1000
),
show_timer
=
True
,
show_timer
=
True
,
show_trail
=
True
)
show_trail
=
True
)
sim_scenes/wonders/__init__.py
0 → 100644
浏览文件 @
faa5674c
sim_scenes/
science
/comets_jupiter.py
→
sim_scenes/
wonders
/comets_jupiter.py
浏览文件 @
faa5674c
...
@@ -57,7 +57,7 @@ if __name__ == '__main__':
...
@@ -57,7 +57,7 @@ if __name__ == '__main__':
comets
=
[]
comets
=
[]
r
=
jupiter
.
raduis
r
=
jupiter
.
raduis
for
i
in
range
(
3
0
):
for
i
in
range
(
2
0
):
# 随机生成石头
# 随机生成石头
comet
=
create_comet
(
i
,
gravity_only_for
=
jupiter
)
comet
=
create_comet
(
i
,
gravity_only_for
=
jupiter
)
bodies
.
append
(
comet
)
bodies
.
append
(
comet
)
...
...
sim_scenes/
solar_system
/sun_earth_moon.py
→
sim_scenes/
wonders
/sun_earth_moon.py
浏览文件 @
faa5674c
文件已移动
sim_scenes/
solar_system
/transit_of_venus_mercury.py
→
sim_scenes/
wonders
/transit_of_venus_mercury.py
浏览文件 @
faa5674c
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
# title :水星、金星凌日
# title :水星、金星凌日
# description :水星、金星凌日
# description :
天象奇观:
水星、金星凌日
# author :Python超人
# author :Python超人
# date :2023-02-11
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# link :https://gitcode.net/pythoncr/
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
faa5674c
...
@@ -176,6 +176,10 @@ def create_directional_light(position, target=None, shadows=False, light_color=N
...
@@ -176,6 +176,10 @@ def create_directional_light(position, target=None, shadows=False, light_color=N
else
:
else
:
light_color
=
color
.
rgba
(
light_color
[
0
]
/
255
,
light_color
[
1
]
/
255
,
light_color
[
2
]
/
255
,
1
)
light_color
=
color
.
rgba
(
light_color
[
0
]
/
255
,
light_color
[
1
]
/
255
,
light_color
[
2
]
/
255
,
1
)
light
=
DirectionalLight
(
position
=
position
,
intensity
=
10
,
range
=
10
,
color
=
light_color
)
light
=
DirectionalLight
(
position
=
position
,
intensity
=
10
,
range
=
10
,
color
=
light_color
)
if
shadows
:
light
.
shadows
=
lit_with_shadows_shader
if
target
is
not
None
:
if
target
is
not
None
:
if
hasattr
(
target
,
"planet"
):
if
hasattr
(
target
,
"planet"
):
if
hasattr
(
target
.
planet
,
"main_entity"
):
if
hasattr
(
target
.
planet
,
"main_entity"
):
...
@@ -185,6 +189,11 @@ def create_directional_light(position, target=None, shadows=False, light_color=N
...
@@ -185,6 +189,11 @@ def create_directional_light(position, target=None, shadows=False, light_color=N
else
:
else
:
light
.
look_at
(
target
)
light
.
look_at
(
target
)
if
shadows
:
return
lit_with_shadows_shader
else
:
return
None
def
create_trail_line
(
parent
,
pos
):
def
create_trail_line
(
parent
,
pos
):
"""
"""
...
...
simulators/ursina_simulator.py
浏览文件 @
faa5674c
...
@@ -101,6 +101,7 @@ class UrsinaSimulator(Simulator):
...
@@ -101,6 +101,7 @@ class UrsinaSimulator(Simulator):
volume_scale
=
pow
(
body
.
planet
.
model
.
get_bounds
().
volume
,
1
/
3
)
volume_scale
=
pow
(
body
.
planet
.
model
.
get_bounds
().
volume
,
1
/
3
)
# 根据体积、大小缩放判断爆炸的量
# 根据体积、大小缩放判断爆炸的量
scale
=
3
*
volume_scale
*
body
.
size_scale
*
UrsinaConfig
.
SCALE_FACTOR
scale
=
3
*
volume_scale
*
body
.
size_scale
*
UrsinaConfig
.
SCALE_FACTOR
print
(
scale
,
body
)
explode_ani
=
Animation
(
explosion_file
,
explode_ani
=
Animation
(
explosion_file
,
position
=
body
.
planet
.
position
,
position
=
body
.
planet
.
position
,
scale
=
scale
,
fps
=
6
,
scale
=
scale
,
fps
=
6
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录