Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
bf8772e1
太阳系三体模拟器
项目概览
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看板
提交
bf8772e1
编写于
3月 05, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
太阳系三体模拟器
上级
e152a18e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
22 deletion
+46
-22
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+34
-12
simulators/views/ursina_view.py
simulators/views/ursina_view.py
+12
-10
textures/cosmic1.jpg
textures/cosmic1.jpg
+0
-0
textures/cosmic2.jpg
textures/cosmic2.jpg
+0
-0
未找到文件。
simulators/ursina_simulator.py
浏览文件 @
bf8772e1
...
...
@@ -96,7 +96,7 @@ from simulators.simulator import Simulator
from
common.system
import
System
import
time
import
datetime
from
ursina
import
EditorCamera
from
ursina
import
EditorCamera
,
PointLight
,
SpotLight
,
AmbientLight
player
=
None
...
...
@@ -133,18 +133,35 @@ class UrsinaSimulator(Simulator):
if
self
.
check_elapsed_time
():
super
().
evolve
(
self
.
evolve_dt
)
def
cosmic_background
(
self
,
texture
=
'../textures/cosmic1.jpg'
):
texture
=
load_texture
(
texture
)
sky_dome
=
Entity
(
model
=
'sky_dome'
,
texture
=
texture
,
scale
=
300
,
color
=
color
.
white
,
position
=
(
0
,
0
,
0
),
rotation
=
(
0
,
0
,
0
))
def
run
(
self
,
dt
,
**
kwargs
):
self
.
evolve_dt
=
dt
# 设定时间间隔为1秒
self
.
interval
=
datetime
.
timedelta
(
seconds
=
0.01
)
self
.
last_time
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
seconds
=
2
)
if
"light"
in
kwargs
:
if
kwargs
[
"light"
]:
li
=
PointLight
()
# PointLight, SpotLight, AmbientLight
if
"cosmic_bg"
in
kwargs
:
cosmic_bg
=
kwargs
[
"cosmic_bg"
]
import
os
if
cosmic_bg
is
not
None
and
os
.
path
.
exists
(
cosmic_bg
):
self
.
cosmic_background
(
cosmic_bg
)
EditorCamera
()
self
.
app
.
run
()
if
__name__
==
'__main__'
:
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HALF_DAY
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HALF_DAY
"""
3个太阳、1个地球
...
...
@@ -171,17 +188,17 @@ if __name__ == '__main__':
# size_scale=4e3, texture="earth.png", distance_scale=1), # 地球放大 4000 倍,距离保持不变
# ]
bodies
=
[
Sun
(
size_scale
=
0.8e2
),
# 太阳放大 80 倍
Mercury
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 水星放大 4000 倍,距离放大 1.3 倍
Venus
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 金星放大 4000 倍,距离放大 1.3 倍
Earth
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 地球放大 4000 倍,距离放大 1.3 倍
Sun
(
size_scale
=
0.8e2
),
# 太阳放大 80 倍
Mercury
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 水星放大 4000 倍,距离放大 1.3 倍
Venus
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 金星放大 4000 倍,距离放大 1.3 倍
Earth
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 地球放大 4000 倍,距离放大 1.3 倍
Moon
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
Mars
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 火星放大 4000 倍,距离放大 1.3 倍
Mars
(
size_scale
=
4e3
,
distance_scale
=
1.3
),
# 火星放大 4000 倍,距离放大 1.3 倍
Jupiter
(
size_scale
=
0.68e3
,
distance_scale
=
0.65
),
# 木星放大 680 倍,距离缩小到真实距离的 0.65
Saturn
(
size_scale
=
0.68e3
,
distance_scale
=
0.52
),
# 土星放大 680 倍,距离缩小到真实距离的 0.52
Uranus
(
size_scale
=
0.8e3
,
distance_scale
=
0.36
),
# 天王星放大 800 倍,距离缩小到真实距离的 0.36
Neptune
(
size_scale
=
1e3
,
distance_scale
=
0.27
),
# 海王星放大 1000 倍,距离缩小到真实距离的 0.27
Pluto
(
size_scale
=
10e3
,
distance_scale
=
0.23
),
# 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除)
Saturn
(
size_scale
=
0.68e3
,
distance_scale
=
0.52
),
# 土星放大 680 倍,距离缩小到真实距离的 0.52
Uranus
(
size_scale
=
0.8e3
,
distance_scale
=
0.36
),
# 天王星放大 800 倍,距离缩小到真实距离的 0.36
Neptune
(
size_scale
=
1e3
,
distance_scale
=
0.27
),
# 海王星放大 1000 倍,距离缩小到真实距离的 0.27
Pluto
(
size_scale
=
10e3
,
distance_scale
=
0.23
),
# 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除)
]
# bodies.append(Moon(size_scale=4e3, distance_scale=1.3)) # 月球放大 10 倍,距离保持不变)
...
...
@@ -193,6 +210,8 @@ if __name__ == '__main__':
simulator
=
UrsinaSimulator
(
body_sys
)
player
=
UrsinaPlayer
((
4000000
,
800000000
,
4000000
),
simulator
.
ursina_views
)
# player = FirstPersonController()
# player = UrsinaPlayer((0, 0, 0), simulator.ursina_views)
...
...
@@ -205,4 +224,7 @@ if __name__ == '__main__':
# player._update()
simulator
.
run
(
SECONDS_PER_DAY
)
light
=
True
cosmic_bg
=
'../textures/cosmic1.jpg'
# cosmic_bg = None
simulator
.
run
(
SECONDS_PER_DAY
,
light
=
light
,
cosmic_bg
=
cosmic_bg
)
simulators/views/ursina_view.py
浏览文件 @
bf8772e1
...
...
@@ -140,8 +140,6 @@ class UrsinaPlayer(FirstPersonController):
# camera.position = avg_pos + (0, 0, 20)
# camera.rotation_x = -90
def
input
(
self
,
key
):
if
key
==
"escape"
:
if
mouse
.
locked
:
...
...
@@ -198,7 +196,8 @@ class Planet(Entity):
# self.angle = 0 # random.uniform(0.0005, 0.01)
# self.fastMode = 0
# self.rotation = (random.randint(0, 360) for i in range(3))
self
.
rotspeed
=
random
.
uniform
(
0.25
,
1.5
)
# 旋转速度和大小成反比(未使用真实数据)
self
.
rotspeed
=
30000
/
self
.
body_view
.
raduis
# random.uniform(1.0, 2.0)
self
.
rotMode
=
'x'
# random.choice(["x", "y", "z"])
self
.
name
=
body_view
.
name
...
...
@@ -210,13 +209,16 @@ class Planet(Entity):
# texture = self.__set_texture(body_view.texture)
texture
=
load_texture
(
body_view
.
texture
)
# 将贴图旋转90度
super
().
__init__
(
model
=
"sphere"
,
scale
=
scale
,
texture
=
texture
,
color
=
color
.
white
,
position
=
pos
,
rotation
=
(
0
,
0
,
0
))
# 将贴图旋转90度C:\ProgramData\Anaconda3\envs\tf_gpu\Lib\site-packages\ursina\models_compressed\diamond.ursinamesh
super
().
__init__
(
# model=TorusMesh(radius=1e20, thickness=1.25e20, radial_segments=16, tubular_segments=32),
# model="sky_dome",
model
=
"sphere"
,
scale
=
scale
,
texture
=
texture
,
color
=
color
.
white
,
position
=
pos
,
rotation
=
(
0
,
0
,
0
))
# def __set_texture(self, image_file):
# """
...
...
textures/cosmic1.jpg
0 → 100644
浏览文件 @
bf8772e1
135.1 KB
textures/cosmic2.jpg
0 → 100644
浏览文件 @
bf8772e1
620.6 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录