Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
55381746
宇宙模拟器
项目概览
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看板
提交
55381746
编写于
10月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
fc8c8bda
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
90 addition
and
16 deletion
+90
-16
objs/__init__.py
objs/__init__.py
+1
-0
objs/circle_obj.py
objs/circle_obj.py
+48
-0
sim_scenes/tri_bodies/two_way_foil.py
sim_scenes/tri_bodies/two_way_foil.py
+40
-16
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+1
-0
未找到文件。
objs/__init__.py
浏览文件 @
55381746
from
objs.obj
import
Obj
from
objs.diamond
import
Diamond
from
objs.quad_obj
import
QuadObj
from
objs.circle_obj
import
CircleObj
from
objs.football
import
Football
from
objs.satellite
import
Satellite
,
Satellite2
from
objs.space_ship
import
SpaceShip
...
...
objs/circle_obj.py
0 → 100644
浏览文件 @
55381746
# -*- coding:utf-8 -*-
# title :圆形
# description :圆形
# author :Python超人
# date :2023-10-17
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# ==============================================================================
from
objs.obj
import
Obj
class
CircleObj
(
Obj
):
"""
圆形
密度:3.51g/cm³
"""
def
__init__
(
self
,
name
=
"圆形"
,
mass
=
5.97237e24
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
texture
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
ignore_mass
=
False
,
density
=
3.51e3
,
color
=
(
7
,
0
,
162
),
trail_color
=
None
,
show_name
=
False
,
parent
=
None
,
gravity_only_for
=
[]):
from
ursina.models.procedural.quad
import
Quad
params
=
{
"name"
:
name
,
"mass"
:
mass
,
"init_position"
:
init_position
,
"init_velocity"
:
init_velocity
,
"density"
:
density
,
"color"
:
color
,
"texture"
:
texture
,
"size_scale"
:
size_scale
,
"distance_scale"
:
distance_scale
,
"ignore_mass"
:
ignore_mass
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
,
"parent"
:
parent
,
"gravity_only_for"
:
gravity_only_for
,
"model"
:
"circle"
,
}
super
().
__init__
(
**
params
)
if
__name__
==
'__main__'
:
circle
=
CircleObj
()
print
(
circle
)
sim_scenes/tri_bodies/two_way_foil.py
浏览文件 @
55381746
...
...
@@ -9,34 +9,24 @@
from
bodies
import
Sun
,
Earth
,
Moon
from
objs
import
CoreValagaClas
,
SciFiBomber
,
WaterDrop
,
QuadObj
from
objs
import
CoreValagaClas
,
SciFiBomber
,
WaterDrop
,
QuadObj
,
CircleObj
from
common.consts
import
AU
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_main_entity
,
two_bodies_colliding
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.entities.entity_utils
import
create_directional_light
,
create_rings
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
ursina
import
camera
if
__name__
==
'__main__'
:
"""
三体二向箔场景模拟
"""
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Asteroids
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_MONTH
,
SECONDS_PER_YEAR
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
create_sphere_sky
from
simulators.ursina.ursina_event
import
UrsinaEvent
if
__name__
==
'__main__'
:
# 八大行星:木星(♃)、土星(♄)、天王星(♅)、海王星(♆)、地球(⊕)、金星(♀)、火星(♂)、水星(☿)
# 排列顺序
# 1、体积:(以地球为1)木星 :土星 :天王星 :海王星 :地球 :金星 :火星 :水星 = 1330:745:65:60:1:0.86:0.15:0.056
# 2、质量:(以地球为1)木星 :土星 :天王星 :海王星 :地球 :金星 :火星 :水星 = 318:95:14.53:17.15:1:0.8:0.11:0.0553
# 3、离太阳从近到远的顺序:水星、金星、地球、火星、木星、土星、天王星、海王星
# =====================================================================
# 以下展示的效果非太阳系真实的距离和大小
# 1、由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大
# 2、为了达到最佳的显示效果,对每个行星天体的距离进行了缩放
"""
三体二向箔场景模拟
"""
# region 构建太阳系
sun
=
Sun
(
size_scale
=
0.8e2
)
...
...
@@ -60,7 +50,30 @@ if __name__ == '__main__':
init_position
=
[
0
,
0
,
39.55
*
AU
])
\
.
set_light_disable
(
True
).
set_ignore_gravity
(
True
)
three_dim_bodies
=
[]
two_dim_bodies
=
[]
def
create_two_dim
(
body
):
body_2
=
CircleObj
(
texture
=
body
.
texture
,
size_scale
=
body
.
diameter
*
body
.
size_scale
,
distance_scale
=
body
.
distance_scale
,
init_position
=
body
.
position
)
\
.
set_light_disable
(
True
).
set_ignore_gravity
(
True
)
body
.
two_dim
=
body_2
body_2
.
three_dim
=
body
return
body_2
for
body
in
bodies
:
two_dim_body
=
create_two_dim
(
body
)
three_dim_bodies
.
append
(
body
)
two_dim_bodies
.
append
(
two_dim_body
)
bodies
.
append
(
two_way_foil
)
for
body
in
two_dim_bodies
:
bodies
.
append
(
body
)
def
on_ready
():
...
...
@@ -70,11 +83,22 @@ if __name__ == '__main__':
"""
# 创建天空
create_sphere_sky
(
scale
=
8000
)
for
body
in
two_dim_bodies
:
if
body
.
three_dim
.
has_rings
:
rings
=
create_rings
(
body
.
planet
)
rings
.
scale
*=
2e10
def
on_timer_changed
(
time_data
):
two_way_foil
.
planet
.
rotation_x
+=
1
two_way_foil
.
planet
.
rotation_y
+=
2
for
b
in
three_dim_bodies
:
b
.
planet
.
enabled
=
False
for
b
in
two_dim_bodies
:
b
.
planet
.
rotation_x
=
90
b
.
init_position
=
b
.
three_dim
.
position
print
(
b
.
planet
.
position
,
b
.
three_dim
.
planet
.
position
)
pass
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
55381746
...
...
@@ -270,6 +270,7 @@ def create_rings(parent):
# 设置行星环不受灯光影响,否则看不清行星环
parent
.
ring
.
set_light_off
()
return
parent
.
ring
def
clear_trails
(
parent
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录