Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
c1bf0019
宇宙模拟器
项目概览
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看板
提交
c1bf0019
编写于
12月 04, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
3fcc15dc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
16 deletion
+37
-16
sim_scenes/solar_system/solar_system_reality_2.py
sim_scenes/solar_system/solar_system_reality_2.py
+37
-16
未找到文件。
sim_scenes/solar_system/solar_system_reality_2.py
浏览文件 @
c1bf0019
...
@@ -14,6 +14,8 @@ from common.celestial_data_service import get_body_posvel, recalc_moon_position,
...
@@ -14,6 +14,8 @@ from common.celestial_data_service import get_body_posvel, recalc_moon_position,
set_solar_system_celestial_position
,
set_earth_rotation
,
get_reality_orbit_points
set_solar_system_celestial_position
,
set_earth_rotation
,
get_reality_orbit_points
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HOUR
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HOUR
,
AU
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.func
import
ext_fun_for_method
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
...
@@ -23,7 +25,7 @@ from ursina import camera, application
...
@@ -23,7 +25,7 @@ from ursina import camera, application
from
simulators.ursina.ursina_mesh
import
create_orbit_line
,
create_orbit_by_points
from
simulators.ursina.ursina_mesh
import
create_orbit_line
,
create_orbit_by_points
class
SolarSystemRealitySim
:
class
SolarSystemRealitySim
(
UniverseSimScenes
)
:
def
__init__
(
self
):
def
__init__
(
self
):
"""
"""
...
@@ -43,10 +45,10 @@ class SolarSystemRealitySim:
...
@@ -43,10 +45,10 @@ class SolarSystemRealitySim:
# 由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大
# 由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大
# 太阳 60倍、
# 太阳 60倍、
SUN_SIZE_SCALE
=
6
0
SUN_SIZE_SCALE
=
5
0
SIZE_SCALE_1
=
2000
SIZE_SCALE_1
=
2000
SIZE_SCALE_2
=
5
e2
SIZE_SCALE_2
=
5
00
SIZE_SCALE_3
=
15
e2
SIZE_SCALE_3
=
15
00
# 太阳缩放比例
# 太阳缩放比例
self
.
sun_size_scale
=
0.04e2
if
self
.
debug_mode
else
SUN_SIZE_SCALE
self
.
sun_size_scale
=
0.04e2
if
self
.
debug_mode
else
SUN_SIZE_SCALE
...
@@ -136,6 +138,7 @@ class SolarSystemRealitySim:
...
@@ -136,6 +138,7 @@ class SolarSystemRealitySim:
@return:
@return:
"""
"""
# 运行前触发
# 运行前触发
self
.
set_window_size
((
1920
,
1079
),
False
)
self
.
sky
=
create_sphere_sky
(
scale
=
80000
)
self
.
sky
=
create_sphere_sky
(
scale
=
80000
)
...
@@ -187,7 +190,7 @@ class SolarSystemRealitySim:
...
@@ -187,7 +190,7 @@ class SolarSystemRealitySim:
segments
=
100
)
segments
=
100
)
# print(points)
# print(points)
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
,
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
,
alpha
=
alpha
)
alpha
=
alpha
,
thickness
=
1
)
return
orbit_line
return
orbit_line
def
create_orbit_lines
(
self
):
def
create_orbit_lines
(
self
):
...
@@ -197,7 +200,7 @@ class SolarSystemRealitySim:
...
@@ -197,7 +200,7 @@ class SolarSystemRealitySim:
"""
"""
self
.
orbit_lines
=
[]
self
.
orbit_lines
=
[]
for
body
in
self
.
bodies
[
1
:]:
for
body
in
self
.
bodies
[
1
:]:
alpha
=
0.5
alpha
=
1
orbit_line
=
self
.
create_orbit_line
(
self
.
sun
,
body
,
self
.
start_time
,
alpha
=
alpha
)
orbit_line
=
self
.
create_orbit_line
(
self
.
sun
,
body
,
self
.
start_time
,
alpha
=
alpha
)
if
orbit_line
is
not
None
:
if
orbit_line
is
not
None
:
self
.
orbit_lines
.
append
(
orbit_line
)
self
.
orbit_lines
.
append
(
orbit_line
)
...
@@ -270,9 +273,9 @@ class SolarSystemRealitySim:
...
@@ -270,9 +273,9 @@ class SolarSystemRealitySim:
def
init_steps
(
self
):
def
init_steps
(
self
):
self
.
step_index
=
0
self
.
step_index
=
0
self
.
steps
=
[
self
.
steps
=
[
self
.
set_body_as_real_scale
,
self
.
set_bodies_as_real_scale
,
lambda
:
self
.
recover_body_scale
(
self
.
sun
),
lambda
:
self
.
enabled_orbit_lines
(),
lambda
:
self
.
enabled_orbit_lines
(),
lambda
:
self
.
recover_body_scale
(
self
.
sun
),
lambda
:
self
.
recover_body_scale
([
self
.
earth
,
self
.
mercury
,
self
.
venus
,
self
.
mars
,
self
.
earth_clouds
]),
lambda
:
self
.
recover_body_scale
([
self
.
earth
,
self
.
mercury
,
self
.
venus
,
self
.
mars
,
self
.
earth_clouds
]),
lambda
:
self
.
recover_body_scale
([
self
.
jupiter
,
self
.
saturn
]),
lambda
:
self
.
recover_body_scale
([
self
.
jupiter
,
self
.
saturn
]),
lambda
:
self
.
recover_body_scale
([
self
.
uranus
,
self
.
neptune
]),
lambda
:
self
.
recover_body_scale
([
self
.
uranus
,
self
.
neptune
]),
...
@@ -284,6 +287,7 @@ class SolarSystemRealitySim:
...
@@ -284,6 +287,7 @@ class SolarSystemRealitySim:
from
ursina
import
Vec4
from
ursina
import
Vec4
orbit_line
.
alpha
=
0
orbit_line
.
alpha
=
0
orbit_line
.
color
*=
Vec4
(
1
,
1
,
1
,
0
)
orbit_line
.
color
*=
Vec4
(
1
,
1
,
1
,
0
)
# orbit_line.origin_color = orbit_line.color
# orbit_line.origin_color = orbit_line.color
def
orbit_line_update
():
def
orbit_line_update
():
...
@@ -312,18 +316,20 @@ class SolarSystemRealitySim:
...
@@ -312,18 +316,20 @@ class SolarSystemRealitySim:
scale_inc
=
(
scale_x
-
body
.
planet
.
scale_x
)
/
200.0
scale_inc
=
(
scale_x
-
body
.
planet
.
scale_x
)
/
200.0
def
update_scale
():
def
update_scale
():
# body.planet.origin_update()
planet_scale_x
=
body
.
planet
.
scale_x
planet_scale_x
=
body
.
planet
.
scale_x
planet_scale_x
+=
scale_inc
planet_scale_x
+=
scale_inc
if
planet_scale_x
>
scale_x
:
if
planet_scale_x
>
scale_x
:
planet_scale_x
=
scale_x
planet_scale_x
=
scale_x
body
.
planet
.
update
=
lambda
:
Non
e
body
.
planet
.
update
=
body
.
planet
.
origin_updat
e
body
.
planet
.
scale
=
planet_scale_x
body
.
planet
.
scale
=
planet_scale_x
body
.
planet
.
update
=
update_scale
body
.
planet
.
update
=
update_scale
def
recover_run
(
self
):
def
recover_run
(
self
):
for
body
in
self
.
bodies
:
pass
body
.
planet
.
update
=
body
.
planet
.
origin_update
# for body in self.bodies:
# body.planet.update = body.planet.origin_update
def
recover_sky
(
self
):
def
recover_sky
(
self
):
def
update_sky
():
def
update_sky
():
...
@@ -343,15 +349,30 @@ class SolarSystemRealitySim:
...
@@ -343,15 +349,30 @@ class SolarSystemRealitySim:
bodies
=
body_or_bodies
bodies
=
body_or_bodies
for
body
in
bodies
:
for
body
in
bodies
:
self
.
scale_animation
(
body
)
self
.
scale_animation
(
body
)
from
ursina
import
invoke
def
set_body_as_real_scale
(
self
):
def
recover_run_speed
():
self
.
save_body_scale
()
UrsinaConfig
.
run_speed_factor
=
1
for
body
in
self
.
bodies
:
body
.
planet
.
origin_update
=
body
.
planet
.
update
invoke
(
function
=
recover_run_speed
,
delay
=
3.0
)
body
.
planet
.
update
=
lambda
:
None
def
set_body_as_real_scale
(
self
,
body
):
UrsinaConfig
.
run_speed_factor
=
0.01
body
.
planet
.
origin_update
=
body
.
planet
.
update
# body.planet.update = lambda: None
def
update_scale
():
size_scale
,
scale_x
=
self
.
body_scale_dict
[
body
]
size_scale
,
scale_x
=
self
.
body_scale_dict
[
body
]
body
.
planet
.
scale
=
scale_x
/
size_scale
body
.
planet
.
scale
=
scale_x
/
size_scale
ext_fun_for_method
(
body
.
planet
,
after_run_fun
=
update_scale
)
def
set_bodies_as_real_scale
(
self
):
self
.
save_body_scale
()
for
body
in
self
.
bodies
:
self
.
set_body_as_real_scale
(
body
)
for
orbit_line
in
self
.
orbit_lines
:
for
orbit_line
in
self
.
orbit_lines
:
orbit_line
.
origin_alpha
=
orbit_line
.
alpha
orbit_line
.
origin_alpha
=
orbit_line
.
alpha
# orbit_line.alpha = 0
# orbit_line.alpha = 0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录