Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
1b331a87
宇宙模拟器
项目概览
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看板
提交
1b331a87
编写于
4月 16, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
0ab2d9f7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
24 addition
and
14 deletion
+24
-14
bodies/body.py
bodies/body.py
+2
-0
bodies/earth.py
bodies/earth.py
+4
-2
sim_scenes/science/four_seasons.py
sim_scenes/science/four_seasons.py
+11
-10
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+7
-2
未找到文件。
bodies/body.py
浏览文件 @
1b331a87
...
...
@@ -21,6 +21,7 @@ class Body(metaclass=ABCMeta):
def
__init__
(
self
,
name
,
mass
,
init_position
,
init_velocity
,
rotate_angle
=
0
,
density
=
5e3
,
color
=
(
125
/
255
,
125
/
255
,
125
/
255
),
text_color
=
None
,
texture
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
None
,
parent
=
None
,
ignore_mass
=
False
,
is_fixed_star
=
False
,
trail_color
=
None
,
show_name
=
False
):
...
...
@@ -53,6 +54,7 @@ class Body(metaclass=ABCMeta):
self
.
name
=
name
self
.
__mass
=
mass
self
.
text_color
=
text_color
# 是否忽略质量(如果为True,则不计算引力)
# TODO: 注意:这里的算法是基于牛顿的万有引力(质量为0不受引力的影响在天体物理学中是不严谨)
...
...
bodies/earth.py
浏览文件 @
1b331a87
...
...
@@ -26,7 +26,8 @@ class Earth(Body):
def
__init__
(
self
,
name
=
"地球"
,
mass
=
5.97237e24
,
rotate_angle
=
23.44
,
init_position
=
[
0
,
0
,
1
*
AU
],
init_velocity
=
[
-
29.79
,
0
,
0
],
texture
=
"earth1.jpg"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
color
=
(
7
,
0
,
162
),
texture
=
"earth1.jpg"
,
text_color
=
None
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
15
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
,
parent
=
None
):
...
...
@@ -37,7 +38,8 @@ class Earth(Body):
"init_velocity"
:
init_velocity
,
"rotate_angle"
:
rotate_angle
,
"density"
:
5507.85
,
"color"
:
(
7
,
0
,
162
),
"color"
:
color
,
"text_color"
:
text_color
,
"texture"
:
texture
,
"size_scale"
:
size_scale
,
"distance_scale"
:
distance_scale
,
...
...
sim_scenes/science/four_seasons.py
浏览文件 @
1b331a87
...
...
@@ -19,13 +19,13 @@ if __name__ == '__main__':
"""
bodies
=
[
Sun
(
size_scale
=
5e1
,
texture
=
"transparent.png"
),
# 太阳透明
Earth
(
name
=
"中国春天"
,
size_scale
=
2e3
,
texture
=
"earth_hd.jpg"
,
Earth
(
name
=
"中国春天"
,
size_scale
=
6e3
,
texture
=
"earth_hd.jpg"
,
text_color
=
(
0
,
255
,
0
)
,
init_position
=
[
-
1
*
AU
,
0
,
0
],
init_velocity
=
[
0
,
0
,
-
29.79
]),
Earth
(
name
=
"中国夏天"
,
size_scale
=
2e3
,
texture
=
"earth_hd.jpg"
,
Earth
(
name
=
"中国夏天"
,
size_scale
=
6e3
,
texture
=
"earth_hd.jpg"
,
text_color
=
(
255
,
0
,
0
)
,
init_position
=
[
0
,
0
,
-
1
*
AU
],
init_velocity
=
[
29.79
,
0
,
0
]),
Earth
(
name
=
"中国秋天"
,
size_scale
=
2e3
,
texture
=
"earth_hd.jpg"
,
Earth
(
name
=
"中国秋天"
,
size_scale
=
6e3
,
texture
=
"earth_hd.jpg"
,
text_color
=
(
255
,
255
,
0
)
,
init_position
=
[
1
*
AU
,
0
,
0
],
init_velocity
=
[
0
,
0
,
29.79
]),
Earth
(
name
=
"中国冬天"
,
size_scale
=
2e3
,
texture
=
"earth_hd.jpg"
,
Earth
(
name
=
"中国冬天"
,
size_scale
=
6e3
,
texture
=
"earth_hd.jpg"
,
text_color
=
(
0
,
255
,
255
)
,
init_position
=
[
0
,
0
,
1
*
AU
],
init_velocity
=
[
-
29.79
,
0
,
0
]),
]
sun
=
bodies
[
0
]
...
...
@@ -41,13 +41,14 @@ if __name__ == '__main__':
# camera.forward = -10 * AU
# # camera.x = camera.x - AU / 100
# camera.look_at(earth.planet)
earth_1
.
planet
.
rotation_y
-=
20
5
# 春天
earth_2
.
planet
.
rotation_y
-=
0
# 夏天
earth_3
.
planet
.
rotation_y
-=
10
0
# 秋天
earth_4
.
planet
.
rotation_y
-=
1
7
5
# 冬天
earth_1
.
planet
.
rotation_y
+=
11
5
# 春天
earth_2
.
planet
.
rotation_y
+=
15
# 夏天
earth_3
.
planet
.
rotation_y
-=
8
0
# 秋天
earth_4
.
planet
.
rotation_y
-=
1
4
5
# 冬天
camera
.
parent
=
sun
.
planet
camera
.
look_at
(
earth_2
.
planet
)
# camera.parent = sun.planet
camera
.
look_at
(
earth_4
.
planet
)
camera
.
rotation_z
=
0
# camera.position=[0,0,0]
pass
...
...
simulators/ursina/entities/entity_utils.py
浏览文件 @
1b331a87
...
...
@@ -26,6 +26,7 @@ def create_name_text(parent):
@param parent:
@return:
"""
text_color
=
parent
.
body
.
text_color
b_color
=
parent
.
body_view
.
color
name_text
=
Text
(
parent
.
body_view
.
body
.
name
,
scale
=
1
,
billboard
=
True
,
parent
=
parent
,
font
=
UrsinaConfig
.
CN_FONT
,
background
=
True
,
...
...
@@ -33,8 +34,12 @@ def create_name_text(parent):
name_text
.
background
.
color
=
color
.
rgba
(
b_color
[
0
],
b_color
[
1
],
b_color
[
2
],
0.3
)
name_text
.
resolution
=
24
# self.name_text.scale = self.scale
inverse_color
=
get_inverse_color
(
b_color
)
name_text
.
color
=
color
.
rgba
(
inverse_color
[
0
],
inverse_color
[
1
],
inverse_color
[
2
],
1
)
if
text_color
is
None
:
text_color
=
get_inverse_color
(
b_color
)
else
:
text_color
=
(
text_color
[
0
]
/
255
,
text_color
[
1
]
/
255
,
text_color
[
2
]
/
255
)
name_text
.
set_light_off
()
name_text
.
color
=
color
.
rgba
(
text_color
[
0
],
text_color
[
1
],
text_color
[
2
],
1
)
parent
.
name_text
=
name_text
return
name_text
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录