Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
10492b86
宇宙模拟器
项目概览
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看板
提交
10492b86
编写于
10月 26, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
36e10d8a
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
115 addition
and
23 deletion
+115
-23
bodies/body.py
bodies/body.py
+1
-1
bodies/fixed_stars/fixed_star.py
bodies/fixed_stars/fixed_star.py
+3
-1
bodies/jupiter.py
bodies/jupiter.py
+3
-1
bodies/mars.py
bodies/mars.py
+3
-1
bodies/mercury.py
bodies/mercury.py
+3
-1
bodies/neptune.py
bodies/neptune.py
+3
-1
bodies/pluto.py
bodies/pluto.py
+3
-1
bodies/saturn.py
bodies/saturn.py
+3
-1
bodies/sun.py
bodies/sun.py
+3
-1
bodies/uranus.py
bodies/uranus.py
+3
-1
bodies/venus.py
bodies/venus.py
+3
-1
sim_scenes/solar_system/halley_comet_sim.py
sim_scenes/solar_system/halley_comet_sim.py
+45
-12
simulators/ursina/ursina_mesh.py
simulators/ursina/ursina_mesh.py
+39
-0
未找到文件。
bodies/body.py
浏览文件 @
10492b86
...
@@ -26,7 +26,7 @@ class Body(metaclass=ABCMeta):
...
@@ -26,7 +26,7 @@ class Body(metaclass=ABCMeta):
text_color
=
None
,
text_color
=
None
,
texture
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
None
,
parent
=
None
,
ignore_mass
=
False
,
rotation_speed
=
None
,
parent
=
None
,
ignore_mass
=
False
,
is_fixed_star
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
is_fixed_star
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
"""
"""
天体类
天体类
@param name: 天体名称
@param name: 天体名称
...
...
bodies/fixed_stars/fixed_star.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class FixedStar(Body):
...
@@ -27,7 +27,8 @@ class FixedStar(Body):
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
color
=
(
0xFF
,
0xFF
,
0xFF
),
color
=
(
0xFF
,
0xFF
,
0xFF
),
texture
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
0.1
,
ignore_mass
=
False
,
density
=
1.408e3
,
trail_color
=
None
,
rotation_speed
=
0.1
,
ignore_mass
=
False
,
density
=
1.408e3
,
show_trail
=
True
,
trail_color
=
None
,
texture_bright
=
None
,
texture_contrast
=
None
,
show_name
=
False
):
texture_bright
=
None
,
texture_contrast
=
None
,
show_name
=
False
):
if
texture
is
None
or
texture
==
"fixed_star.png"
:
if
texture
is
None
or
texture
==
"fixed_star.png"
:
self
.
color
=
color
self
.
color
=
color
...
@@ -45,6 +46,7 @@ class FixedStar(Body):
...
@@ -45,6 +46,7 @@ class FixedStar(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/jupiter.py
浏览文件 @
10492b86
...
@@ -26,7 +26,8 @@ class Jupiter(Body):
...
@@ -26,7 +26,8 @@ class Jupiter(Body):
init_position
=
[
0
,
0
,
5.19
*
AU
],
init_position
=
[
0
,
0
,
5.19
*
AU
],
init_velocity
=
[
-
13.06
,
0
,
0
],
init_velocity
=
[
-
13.06
,
0
,
0
],
texture
=
"jupiter.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"jupiter.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
36.2537
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=
36.2537
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -39,6 +40,7 @@ class Jupiter(Body):
...
@@ -39,6 +40,7 @@ class Jupiter(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/mars.py
浏览文件 @
10492b86
...
@@ -26,7 +26,8 @@ class Mars(Body):
...
@@ -26,7 +26,8 @@ class Mars(Body):
init_position
=
[
0
,
0
,
1.52
*
AU
],
init_position
=
[
0
,
0
,
1.52
*
AU
],
init_velocity
=
[
-
24.13
,
0
,
0
],
init_velocity
=
[
-
24.13
,
0
,
0
],
texture
=
"mars.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"mars.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
14.6223
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=
14.6223
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -39,6 +40,7 @@ class Mars(Body):
...
@@ -39,6 +40,7 @@ class Mars(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/mercury.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class Mercury(Body):
...
@@ -27,7 +27,8 @@ class Mercury(Body):
init_position
=
[
0
,
0
,
0.384
*
AU
],
init_position
=
[
0
,
0
,
0.384
*
AU
],
init_velocity
=
[
-
47.87
,
0
,
0
],
init_velocity
=
[
-
47.87
,
0
,
0
],
texture
=
"mercury.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"mercury.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
0.2558
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=
0.2558
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -40,6 +41,7 @@ class Mercury(Body):
...
@@ -40,6 +41,7 @@ class Mercury(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/neptune.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class Neptune(Body):
...
@@ -27,7 +27,8 @@ class Neptune(Body):
init_position
=
[
0
,
0
,
30.7
*
AU
],
init_position
=
[
0
,
0
,
30.7
*
AU
],
init_velocity
=
[
-
5.43
,
0
,
0
],
init_velocity
=
[
-
5.43
,
0
,
0
],
texture
=
"neptune.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"neptune.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
22.3463
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=
22.3463
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -40,6 +41,7 @@ class Neptune(Body):
...
@@ -40,6 +41,7 @@ class Neptune(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/pluto.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class Pluto(Body):
...
@@ -27,7 +27,8 @@ class Pluto(Body):
init_position
=
[
0
,
0
,
39.55
*
AU
],
init_position
=
[
0
,
0
,
39.55
*
AU
],
init_velocity
=
[
-
4.7
,
0
,
0
],
init_velocity
=
[
-
4.7
,
0
,
0
],
texture
=
"pluto.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"pluto.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=-
2.3474
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=-
2.3474
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -40,6 +41,7 @@ class Pluto(Body):
...
@@ -40,6 +41,7 @@ class Pluto(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/saturn.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class Saturn(Body):
...
@@ -27,7 +27,8 @@ class Saturn(Body):
init_position
=
[
0
,
0
,
9.5
*
AU
],
init_position
=
[
0
,
0
,
9.5
*
AU
],
init_velocity
=
[
-
9.64
,
0
,
0
],
init_velocity
=
[
-
9.64
,
0
,
0
],
texture
=
"saturn.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"saturn.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
33.7711
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=
33.7711
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -40,6 +41,7 @@ class Saturn(Body):
...
@@ -40,6 +41,7 @@ class Saturn(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/sun.py
浏览文件 @
10492b86
...
@@ -23,7 +23,8 @@ class Sun(FixedStar):
...
@@ -23,7 +23,8 @@ class Sun(FixedStar):
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
color
=
(
170
,
98
,
25
),
color
=
(
170
,
98
,
25
),
texture
=
"sun2.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"sun2.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
0.6130
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=
0.6130
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -36,6 +37,7 @@ class Sun(FixedStar):
...
@@ -36,6 +37,7 @@ class Sun(FixedStar):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/uranus.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class Uranus(Body):
...
@@ -27,7 +27,8 @@ class Uranus(Body):
init_position
=
[
0
,
0
,
19.2
*
AU
],
init_position
=
[
0
,
0
,
19.2
*
AU
],
init_velocity
=
[
-
6.81
,
0
,
0
],
init_velocity
=
[
-
6.81
,
0
,
0
],
texture
=
"uranus.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"uranus.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=-
20.8816
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=-
20.8816
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -40,6 +41,7 @@ class Uranus(Body):
...
@@ -40,6 +41,7 @@ class Uranus(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
bodies/venus.py
浏览文件 @
10492b86
...
@@ -27,7 +27,8 @@ class Venus(Body):
...
@@ -27,7 +27,8 @@ class Venus(Body):
init_position
=
[
0
,
0
,
0.721
*
AU
],
init_position
=
[
0
,
0
,
0.721
*
AU
],
init_velocity
=
[
-
35
,
0
,
0
],
init_velocity
=
[
-
35
,
0
,
0
],
texture
=
"venus.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
texture
=
"venus.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=-
0.0617
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
rotation_speed
=-
0.0617
,
ignore_mass
=
False
,
show_trail
=
True
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
params
=
{
"name"
:
name
,
"name"
:
name
,
"mass"
:
mass
,
"mass"
:
mass
,
...
@@ -40,6 +41,7 @@ class Venus(Body):
...
@@ -40,6 +41,7 @@ class Venus(Body):
"distance_scale"
:
distance_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"rotation_speed"
:
rotation_speed
,
"ignore_mass"
:
ignore_mass
,
"ignore_mass"
:
ignore_mass
,
"show_trail"
:
show_trail
,
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
...
...
sim_scenes/solar_system/halley_comet_sim.py
浏览文件 @
10492b86
...
@@ -17,7 +17,9 @@ from common.func import calculate_distance
...
@@ -17,7 +17,9 @@ from common.func import calculate_distance
from
objs
import
HalleComet
,
Obj
from
objs
import
HalleComet
,
Obj
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
,
create_text_panel
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
,
create_text_panel
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_mesh
import
create_orbit_line
class
HalleyCometSim
:
class
HalleyCometSim
:
...
@@ -30,18 +32,27 @@ class HalleyCometSim:
...
@@ -30,18 +32,27 @@ class HalleyCometSim:
def
build_solar_system
(
self
):
def
build_solar_system
(
self
):
# region 构建太阳系
# region 构建太阳系
self
.
sun
=
Sun
(
size_scale
=
0.8e2
)
self
.
sun
=
Sun
(
size_scale
=
0.8e2
,
show_trail
=
False
)
self
.
earth
=
Earth
(
size_scale
=
8e3
,
distance_scale
=
1
,
rotate_angle
=
0
,
show_trail
=
False
)
self
.
mercury
=
Mercury
(
size_scale
=
4e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
venus
=
Venus
(
size_scale
=
4e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
mars
=
Mars
(
size_scale
=
4e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
jupiter
=
Jupiter
(
size_scale
=
1.68e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
saturn
=
Saturn
(
size_scale
=
1.68e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
uranus
=
Uranus
(
size_scale
=
3.5e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
neptune
=
Neptune
(
size_scale
=
3.5e3
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
pluto
=
Pluto
(
size_scale
=
1.5e5
,
distance_scale
=
1
,
show_trail
=
False
)
self
.
bodies
=
[
self
.
bodies
=
[
self
.
sun
,
# 太阳
放大 80 倍
self
.
sun
,
# 太阳
# Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍
self
.
mercury
,
# 水星
# Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍
self
.
venus
,
# 金星
Earth
(
size_scale
=
8e3
,
distance_scale
=
1
,
rotate_angle
=
0
),
# 地球放大 4000 倍,距离放大 1.3 倍
self
.
earth
,
# 地球
# Mars(size_scale=4e3, distance_scale=1.2), # 火星放大 4000 倍,距离放大 1.2 倍
self
.
mars
,
# 火星
Jupiter
(
size_scale
=
1.68e3
,
distance_scale
=
1
),
# 木星放大 680 倍,距离缩小到真实距离的 0.72
self
.
jupiter
,
# 木星
Saturn
(
size_scale
=
1.68e3
,
distance_scale
=
1
),
# 土星放大 680 倍,距离缩小到真实距离的 0.52
self
.
saturn
,
# 土星
Uranus
(
size_scale
=
3.5e3
,
distance_scale
=
1
),
# 天王星放大 1500 倍,距离缩小到真实距离的 0.36
self
.
uranus
,
# 天王星
Neptune
(
size_scale
=
3.5e3
,
distance_scale
=
1
),
# 海王星放大 1500 倍,距离缩小到真实距离的 0.27
self
.
neptune
,
# 海王星
Pluto
(
size_scale
=
1.5e5
,
distance_scale
=
1
),
# 冥王星放大 10000 倍,距离缩小到真实距离的 0.23(从太阳系的行星中排除)
self
.
pluto
,
# 冥王星
]
]
# endregion
# endregion
...
@@ -60,7 +71,7 @@ class HalleyCometSim:
...
@@ -60,7 +71,7 @@ class HalleyCometSim:
# [3.33, 0, 10.655] 68
# [3.33, 0, 10.655] 68
# [3.33, 0, 10.66] 69
# [3.33, 0, 10.66] 69
self
.
halley_comet
=
HalleComet
(
# size_scale=4e7,
self
.
halley_comet
=
HalleComet
(
# size_scale=4e7,
size_scale
=
1
e8
,
size_scale
=
0.5
e8
,
init_velocity
=
[
3.34
,
0
,
10.7
],
# [3.33, 0, 10.6] < ? <[3.34, 0, 10.7]
init_velocity
=
[
3.34
,
0
,
10.7
],
# [3.33, 0, 10.6] < ? <[3.34, 0, 10.7]
init_position
=
[
0
,
0.5
*
AU
,
-
10
*
AU
])
\
init_position
=
[
0
,
0.5
*
AU
,
-
10
*
AU
])
\
.
set_light_disable
(
True
)
.
set_light_disable
(
True
)
...
@@ -77,10 +88,23 @@ class HalleyCometSim:
...
@@ -77,10 +88,23 @@ class HalleyCometSim:
@return:
@return:
"""
"""
# 创建天空
# 创建天空
from
ursina
import
scene
UrsinaConfig
.
trail_type
=
"line"
# camera.clip_plane_near = 0.1
# camera.clip_plane_near = 0.1
camera
.
clip_plane_far
=
1000000
camera
.
clip_plane_far
=
1000000
create_sphere_sky
(
scale
=
200000
)
create_sphere_sky
(
scale
=
200000
)
application
.
time_scale
=
5
application
.
time_scale
=
5
self
.
orbit_lines
=
[]
for
body
in
self
.
bodies
[
1
:]:
if
isinstance
(
body
,
HalleComet
):
continue
print
(
"create_orbit_line"
,
body
)
orbit_line
=
create_orbit_line
(
self
.
sun
,
body
)
orbit_line
.
body
=
body
self
.
orbit_lines
.
append
(
orbit_line
)
# orbit_line.parent = scene
# self.earth_orbit = create_orbit_line(self.sun, self.earth)
# self.pluto_orbit = create_orbit_line(self.sun, self.pluto, alpha=1)
self
.
text_panel
=
create_text_panel
()
self
.
text_panel
=
create_text_panel
()
...
@@ -99,6 +123,15 @@ class HalleyCometSim:
...
@@ -99,6 +123,15 @@ class HalleyCometSim:
d
=
calculate_distance
(
self
.
halley_comet
.
position
,
self
.
sun
.
position
)
d
=
calculate_distance
(
self
.
halley_comet
.
position
,
self
.
sun
.
position
)
self
.
text_panel
.
text
=
"哈雷彗星距离太阳:%.3f AU"
%
(
d
/
AU
)
self
.
text_panel
.
text
=
"哈雷彗星距离太阳:%.3f AU"
%
(
d
/
AU
)
for
i
,
orbit_line
in
enumerate
(
self
.
orbit_lines
):
if
i
<
4
:
continue
body
=
orbit_line
.
body
distance
=
calculate_distance
(
self
.
sun
.
position
-
body
.
position
)
scale_rate
=
distance
*
UrsinaConfig
.
SCALE_FACTOR
*
0.695
/
orbit_line
.
radius
orbit_line
.
scale
=
scale_rate
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
"""
"""
...
...
simulators/ursina/ursina_mesh.py
浏览文件 @
10492b86
...
@@ -15,6 +15,7 @@ import numpy as np
...
@@ -15,6 +15,7 @@ import numpy as np
import
math
import
math
from
common.color_utils
import
conv_to_vec4_color
from
common.color_utils
import
conv_to_vec4_color
from
common.func
import
calculate_distance
from
simulators.ursina.entities.circle_line
import
CircleLine
from
simulators.ursina.entities.circle_line
import
CircleLine
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
...
@@ -127,6 +128,7 @@ def create_circle_line(parent=None, radius=1, position=None, segments=100, thick
...
@@ -127,6 +128,7 @@ def create_circle_line(parent=None, radius=1, position=None, segments=100, thick
circle_line
=
CircleLine
(
position
=
position
,
radius
=
radius
,
segments
=
segments
,
thickness
=
thickness
,
color
=
color
,
circle_line
=
CircleLine
(
position
=
position
,
radius
=
radius
,
segments
=
segments
,
thickness
=
thickness
,
color
=
color
,
alpha
=
alpha
)
alpha
=
alpha
)
circle_line
.
set_light_off
(
True
)
if
parent
is
not
None
:
if
parent
is
not
None
:
if
hasattr
(
parent
,
"planet"
):
if
hasattr
(
parent
,
"planet"
):
parent
=
parent
.
planet
parent
=
parent
.
planet
...
@@ -195,6 +197,43 @@ def get_obj_planet_position(obj):
...
@@ -195,6 +197,43 @@ def get_obj_planet_position(obj):
return
pos1
return
pos1
def
create_orbit_line
(
center_obj
,
orbiting_obj
,
thickness
=
5
,
line_color
=
None
,
alpha
=
0.6
):
if
isinstance
(
line_color
,
tuple
)
or
isinstance
(
line_color
,
list
):
line_color
=
color
.
rgba
(
line_color
[
0
]
/
255
,
line_color
[
1
]
/
255
,
line_color
[
2
]
/
255
,
alpha
)
if
line_color
is
None
:
line_color
=
orbiting_obj
.
trail_color
if
line_color
is
None
:
line_color
=
color
.
white
else
:
line_color
=
color
.
rgba
(
line_color
[
0
],
line_color
[
1
],
line_color
[
2
],
alpha
)
# line_color = adjust_brightness(line_color, 0.6)
# center_pos = get_obj_planet_position(center_obj)
# orbiting_pos = get_obj_planet_position(orbiting_obj)
distance1
=
(
center_obj
.
planet
.
position
-
orbiting_obj
.
planet
.
position
).
length
()
# distance = calculate_distance(center_obj.position - orbiting_obj.position)
# distance2 = distance * UrsinaConfig.SCALE_FACTOR * 0.695 # / center_obj.planet.scale_x # * 0.0125
orbit_line
=
create_circle_line
(
parent
=
None
,
radius
=
distance1
*
0.695
,
position
=
center_obj
.
planet
.
position
,
thickness
=
thickness
,
color
=
line_color
,
alpha
=
alpha
)
orbit_line
.
rotation_x
=
90
# orbit_line.enabled = False # 默认不显示
return
orbit_line
def
create_orbit_line2
(
center_obj
,
orbiting_obj
,
line_color
=
color
.
white
,
alpha
=
0.3
):
if
isinstance
(
line_color
,
tuple
)
or
isinstance
(
line_color
,
list
):
line_color
=
color
.
rgba
(
line_color
[
0
]
/
255
,
line_color
[
1
]
/
255
,
line_color
[
2
]
/
255
,
alpha
)
# center_pos = get_obj_planet_position(center_obj)
# orbiting_pos = get_obj_planet_position(orbiting_obj)
distance1
=
(
center_obj
.
planet
.
position
-
orbiting_obj
.
planet
.
position
).
length
()
distance
=
calculate_distance
(
center_obj
.
position
-
orbiting_obj
.
position
)
distance2
=
distance
*
UrsinaConfig
.
SCALE_FACTOR
*
0.0125
orbit_line
=
create_circle_line
(
parent
=
center_obj
,
radius
=
distance2
,
thickness
=
2
,
color
=
line_color
,
alpha
=
alpha
)
orbit_line
.
rotation_x
=
90
# orbit_line.enabled = False # 默认不显示
return
orbit_line
def
create_connecting_line
(
obj1
,
obj2
,
line_color
=
color
.
white
,
alpha
=
0.3
):
def
create_connecting_line
(
obj1
,
obj2
,
line_color
=
color
.
white
,
alpha
=
0.3
):
"""
"""
创建物体之间的连接线
创建物体之间的连接线
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录