Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
24de21fe
宇宙模拟器
项目概览
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看板
提交
24de21fe
编写于
3月 04, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
6009a01c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
44 addition
and
20 deletion
+44
-20
sim_scenes/featured/solar_system_explorer.py
sim_scenes/featured/solar_system_explorer.py
+44
-20
未找到文件。
sim_scenes/featured/solar_system_explorer.py
浏览文件 @
24de21fe
...
@@ -11,7 +11,7 @@ from ursina import camera, application, lerp, Vec3
...
@@ -11,7 +11,7 @@ from ursina import camera, application, lerp, Vec3
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
common.celestial_data_service
import
init_bodies_reality_pos_vels
,
conv_to_astropy_time
,
\
from
common.celestial_data_service
import
init_bodies_reality_pos_vels
,
conv_to_astropy_time
,
\
set_solar_system_celestial_position
,
init_bodies_pos_vels
,
get_init_pos_vels_2
set_solar_system_celestial_position
,
init_bodies_pos_vels
,
get_init_pos_vels_2
from
common.consts
import
SECONDS_PER_YEAR
,
SECONDS_PER_MINUTE
,
SECONDS_PER_HOUR
,
AU
from
common.consts
import
SECONDS_PER_YEAR
,
SECONDS_PER_MINUTE
,
SECONDS_PER_HOUR
,
AU
from
common.func
import
calculate_distance
from
common.func
import
calculate_distance
from
bodies
import
Earth
from
bodies
import
Earth
from
objs
import
QuadObj
,
CircleObj
,
Obj
,
CoreValagaClas
from
objs
import
QuadObj
,
CircleObj
,
Obj
,
CoreValagaClas
...
@@ -41,28 +41,28 @@ class SolarSystemExplorer(UniverseSimScenes):
...
@@ -41,28 +41,28 @@ class SolarSystemExplorer(UniverseSimScenes):
show_trail
=
False
show_trail
=
False
self
.
SIZE_FACTOR
=
0.01
self
.
SIZE_FACTOR
=
0.01
self
.
init_pos
=
[
2
*
AU
,
2
*
AU
,
-
10
*
AU
]
self
.
init_pos
=
[
2
*
AU
,
2
*
AU
,
-
10
*
AU
]
self
.
sun
=
Sun
(
size_scale
=
20e2
*
self
.
SIZE_FACTOR
,
show_trail
=
show_trail
,
self
.
sun
=
Sun
(
size_scale
=
20e2
*
self
.
SIZE_FACTOR
,
show_trail
=
show_trail
,
# color=(255, 250, 245),
# color=(255, 250, 245),
# texture="",
# texture="",
texture
=
"sun_light.jpg"
texture
=
"sun_light.jpg"
)
)
self
.
sun
.
glows
=
(
24
,
1.008
,
0.04
)
self
.
sun
.
glows
=
(
24
,
1.008
,
0.04
)
self
.
sun
.
set_resolution
(
200
)
self
.
sun
.
set_resolution
(
200
)
self
.
mercury
=
Mercury
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.6
,
show_trail
=
show_trail
)
self
.
mercury
=
Mercury
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.6
,
show_trail
=
show_trail
)
self
.
venus
=
Venus
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.5
,
show_trail
=
show_trail
)
self
.
venus
=
Venus
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.5
,
show_trail
=
show_trail
)
self
.
earth
=
Earth
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.5
,
rotate_angle
=
0
,
show_trail
=
show_trail
)
self
.
earth
=
Earth
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.5
,
rotate_angle
=
0
,
show_trail
=
show_trail
)
self
.
mars
=
Mars
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.4
,
show_trail
=
show_trail
)
self
.
mars
=
Mars
(
size_scale
=
2e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
1.4
,
show_trail
=
show_trail
)
self
.
jupiter
=
Jupiter
(
size_scale
=
0.3e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.7
,
show_trail
=
show_trail
)
self
.
jupiter
=
Jupiter
(
size_scale
=
0.3e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.7
,
show_trail
=
show_trail
)
self
.
saturn
=
Saturn
(
size_scale
=
0.3e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.52
,
show_trail
=
show_trail
)
self
.
saturn
=
Saturn
(
size_scale
=
0.3e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.52
,
show_trail
=
show_trail
)
self
.
uranus
=
Uranus
(
size_scale
=
0.8e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.34
,
show_trail
=
show_trail
)
self
.
uranus
=
Uranus
(
size_scale
=
0.8e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.34
,
show_trail
=
show_trail
)
self
.
neptune
=
Neptune
(
size_scale
=
0.8e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.25
,
show_trail
=
show_trail
)
self
.
neptune
=
Neptune
(
size_scale
=
0.8e3
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.25
,
show_trail
=
show_trail
)
self
.
pluto
=
Pluto
(
size_scale
=
1e4
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.23
,
show_trail
=
show_trail
)
self
.
pluto
=
Pluto
(
size_scale
=
1e4
*
self
.
SIZE_FACTOR
,
distance_scale
=
0.23
,
show_trail
=
show_trail
)
D
=
AU
/
10
D
=
AU
/
10
self
.
camera_target
=
CoreValagaClas
(
name
=
"摄像机镜头"
,
mass
=
1e30
,
color
=
(
111
,
140
,
255
),
self
.
camera_target
=
CoreValagaClas
(
name
=
"摄像机镜头"
,
mass
=
1e30
,
color
=
(
111
,
140
,
255
),
# init_position=[0, 0, 0],
# init_position=[0, 0, 0],
init_position
=
self
.
init_pos
,
init_position
=
self
.
init_pos
,
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1e3
*
self
.
SIZE_FACTOR
).
set_ignore_gravity
(
True
)
size_scale
=
1e3
*
self
.
SIZE_FACTOR
).
set_ignore_gravity
(
True
)
self
.
bodies
=
[
self
.
bodies
=
[
self
.
sun
,
# 太阳
self
.
sun
,
# 太阳
...
@@ -78,6 +78,28 @@ class SolarSystemExplorer(UniverseSimScenes):
...
@@ -78,6 +78,28 @@ class SolarSystemExplorer(UniverseSimScenes):
self
.
camera_target
self
.
camera_target
]
]
self
.
sun
.
target_offset
=
[
1
,
1
,
1.1
]
self
.
mercury
.
target_offset
=
[
1
,
1
,
1.002
]
self
.
venus
.
target_offset
=
[
1
,
1
,
1
]
self
.
earth
.
target_offset
=
[
1
,
1
,
1
]
self
.
mars
.
target_offset
=
[
1
,
1
,
1
]
self
.
jupiter
.
target_offset
=
[
1
,
1
,
1
]
self
.
saturn
.
target_offset
=
[
1
,
1
,
1
]
self
.
uranus
.
target_offset
=
[
1
,
1
,
1
]
self
.
neptune
.
target_offset
=
[
1
,
1
,
1
]
self
.
pluto
.
target_offset
=
[
1
,
1
,
1
]
self
.
sun
.
dd_factor
=
1.5
self
.
mercury
.
dd_factor
=
5
self
.
venus
.
dd_factor
=
1.5
self
.
earth
.
dd_factor
=
1.5
self
.
mars
.
dd_factor
=
1.5
self
.
jupiter
.
dd_factor
=
1.5
self
.
saturn
.
dd_factor
=
1.5
self
.
uranus
.
dd_factor
=
1.5
self
.
neptune
.
dd_factor
=
1.5
self
.
pluto
.
dd_factor
=
1.5
init_bodies_pos_vels
(
self
.
bodies
,
init_pos_vels_fun
=
self
.
get_init_pos_vels
)
init_bodies_pos_vels
(
self
.
bodies
,
init_pos_vels_fun
=
self
.
get_init_pos_vels
)
def
get_init_pos_vels
(
self
):
def
get_init_pos_vels
(
self
):
...
@@ -117,8 +139,6 @@ class SolarSystemExplorer(UniverseSimScenes):
...
@@ -117,8 +139,6 @@ class SolarSystemExplorer(UniverseSimScenes):
init_pos_vels
[
'pluto'
][
'vel'
]
=
[
-
4.699999809265137
,
0.0
,
-
0.007128323893994093
]
init_pos_vels
[
'pluto'
][
'vel'
]
=
[
-
4.699999809265137
,
0.0
,
-
0.007128323893994093
]
return
init_pos_vels
return
init_pos_vels
def
build
(
self
):
def
build
(
self
):
"""
"""
构建太阳系系统以及哈雷彗星
构建太阳系系统以及哈雷彗星
...
@@ -147,7 +167,7 @@ class SolarSystemExplorer(UniverseSimScenes):
...
@@ -147,7 +167,7 @@ class SolarSystemExplorer(UniverseSimScenes):
# camera.clip_plane_near = 0.1
# camera.clip_plane_near = 0.1
camera
.
clip_plane_far
=
51000
camera
.
clip_plane_far
=
51000
application
.
time_scale
=
0.001
application
.
time_scale
=
0.00
0
1
# camera.fov = 60
# camera.fov = 60
# self.current_stage = self.stage_01
# self.current_stage = self.stage_01
...
@@ -245,7 +265,11 @@ class SolarSystemExplorer(UniverseSimScenes):
...
@@ -245,7 +265,11 @@ class SolarSystemExplorer(UniverseSimScenes):
target
=
self
.
get_target
()
target
=
self
.
get_target
()
target_scale
=
target
.
planet
.
scale_x
target_scale
=
target
.
planet
.
scale_x
target_pos
=
target
.
planet
.
position
+
Vec3
(
0
,
target_scale
*
(
3
/
5
),
0
)
target_offset
=
target
.
target_offset
target_pos
=
target
.
planet
.
position
+
\
Vec3
(
target_scale
*
(
target_offset
[
0
]
-
1
),
target_scale
*
(
1
/
10
)
*
target_offset
[
1
],
target_scale
*
(
target_offset
[
2
]
-
1
))
self
.
camera_target
.
planet
.
look_at
(
target_pos
)
self
.
camera_target
.
planet
.
look_at
(
target_pos
)
...
@@ -253,21 +277,21 @@ class SolarSystemExplorer(UniverseSimScenes):
...
@@ -253,21 +277,21 @@ class SolarSystemExplorer(UniverseSimScenes):
if
not
hasattr
(
target
,
"distance"
):
if
not
hasattr
(
target
,
"distance"
):
target
.
distance
=
dd
target
.
distance
=
dd
self
.
camera_target
.
planet
.
position
=
lerp
(
self
.
camera_target
.
planet
.
position
,
target_pos
,
self
.
camera_target
.
planet
.
position
=
lerp
(
self
.
camera_target
.
planet
.
position
,
target_pos
,
camera
.
speed
*
time
.
dt
*
target
.
distance
)
camera
.
speed
*
time
.
dt
*
target
.
distance
)
camera_target_pos
=
self
.
camera_target
.
planet
.
position
camera_target_pos
=
self
.
camera_target
.
planet
.
position
dd2
=
distance
(
camera
.
position
,
camera_target_pos
)
dd2
=
distance
(
camera
.
position
,
camera_target_pos
)
camera
.
position
=
lerp
(
camera
.
position
,
camera_target_pos
,
camera
.
position
=
lerp
(
camera
.
position
,
camera_target_pos
,
camera
.
speed
*
0.99
*
time
.
dt
*
target
.
distance
)
camera
.
speed
*
1
*
time
.
dt
*
target
.
distance
)
if
dd
<
target_scale
*
3
and
dd2
<
target_scale
*
3
:
if
dd
<
target_scale
*
target
.
dd_factor
and
dd2
<
target_scale
*
target
.
dd_factor
:
if
target
is
not
None
:
if
target
is
not
None
:
target
.
is_arrived
=
True
target
.
is_arrived
=
True
camera_look_at
(
self
.
camera_target
,
rotation_z
=
0
)
camera_look_at
(
self
.
camera_target
,
rotation_z
=
0
)
# print(camera.position)
# print(camera.position)
print
(
target
.
name
,
target_scale
,
dd
,
self
.
camera_target
.
planet
.
position
)
print
(
target
.
name
,
target_scale
,
dd
,
self
.
camera_target
.
planet
.
position
)
# print(dd)
# print(dd)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录