Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
029fba4d
宇宙模拟器
项目概览
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看板
提交
029fba4d
编写于
10月 23, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
ecda749a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
56 addition
and
38 deletion
+56
-38
sim_scenes/science/earth_season_func.py
sim_scenes/science/earth_season_func.py
+49
-0
sim_scenes/science/earth_seasons.py
sim_scenes/science/earth_seasons.py
+3
-26
sim_scenes/science/earth_seasons_2.py
sim_scenes/science/earth_seasons_2.py
+4
-12
未找到文件。
sim_scenes/science/earth_season_func.py
0 → 100644
浏览文件 @
029fba4d
# -*- coding:utf-8 -*-
# title :地球季节(四季和24节气)函数功能
# description :
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
ursina
import
camera
from
bodies
import
Sun
,
Earth
from
common.consts
import
SECONDS_PER_DAY
,
AU
def
create_trans_earth
(
name
,
text_color
,
position
):
"""
创建透明的地球
@param name: 名称
@param text_color: 文字颜色
@param position: 地球的位置
@return:
"""
return
Earth
(
name
=
name
,
size_scale
=
5e3
,
texture
=
"earth_transparent.png"
,
# 明的地球纹理
text_color
=
text_color
,
rotation_speed
=
0
,
init_position
=
position
,
init_velocity
=
[
0
,
0
,
0
]).
set_ignore_gravity
(
True
)
# 忽略重力
def
create_important_pos_earths
():
earth_1
=
create_trans_earth
(
name
=
"春分"
,
text_color
=
(
0
,
255
,
0
),
position
=
[
-
1.05
*
AU
,
0
,
0
])
earth_2
=
create_trans_earth
(
name
=
"夏至"
,
text_color
=
(
255
,
0
,
0
),
position
=
[
0
,
0
,
-
1.05
*
AU
])
earth_3
=
create_trans_earth
(
name
=
"秋分"
,
text_color
=
(
255
,
255
,
0
),
position
=
[
1.05
*
AU
,
0
,
0
])
earth_4
=
create_trans_earth
(
name
=
"冬至"
,
text_color
=
(
0
,
255
,
255
),
position
=
[
0
,
0
,
1.05
*
AU
])
return
earth_1
,
earth_2
,
earth_3
,
earth_4
def
get_solar_terms_angles
():
"""
中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
@return:
"""
solar_terms_angles
=
[
(
"小寒"
,
-
22.5
,
-
7.5
),
(
"大寒"
,
-
37.5
,
-
22.5
),
(
"立春"
,
-
52.5
,
-
37.5
),
(
"雨水"
,
-
67.5
,
-
52.5
),
(
"惊蛰"
,
-
82.5
,
-
67.5
),
(
"春分"
,
-
97.5
,
-
82.5
),
(
"清明"
,
-
112.5
,
-
97.5
),
(
"谷雨"
,
-
127.5
,
-
112.5
),
(
"立夏"
,
-
142.5
,
-
127.5
),
(
"小满"
,
-
157.5
,
-
142.5
),
(
"芒种"
,
-
172.5
,
-
157.5
),
(
"夏至"
,
-
180
,
-
172.5
),
(
"夏至"
,
172.5
,
180
),
(
"小暑"
,
157.5
,
172.5
),
(
"大暑"
,
142.5
,
157.5
),
(
"立秋"
,
127.5
,
142.5
),
(
"处暑"
,
112.5
,
127.5
),
(
"白露"
,
97.5
,
112.5
),
(
"秋分"
,
82.5
,
97.5
),
(
"寒露"
,
67.5
,
82.5
),
(
"霜降"
,
52.5
,
67.5
),
(
"立冬"
,
37.5
,
52.5
),
(
"小雪"
,
22.5
,
37.5
),
(
"大雪"
,
7.5
,
22.5
),
(
"冬至"
,
-
7.5
,
7.5
)]
return
solar_terms_angles
\ No newline at end of file
sim_scenes/science/earth_seasons.py
浏览文件 @
029fba4d
...
@@ -11,33 +11,17 @@ from ursina import camera
...
@@ -11,33 +11,17 @@ from ursina import camera
from
bodies
import
Sun
,
Earth
from
bodies
import
Sun
,
Earth
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
sim_scenes.science.earth_season_func
import
create_important_pos_earths
,
get_solar_terms_angles
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
def
create_earth
(
name
,
text_color
,
position
):
"""
创建透明的地球
@param name: 名称
@param text_color: 文字颜色
@param position: 地球的位置
@return:
"""
return
Earth
(
name
=
name
,
size_scale
=
5e3
,
texture
=
"earth_transparent.png"
,
# 明的地球纹理
text_color
=
text_color
,
rotation_speed
=
0
,
init_position
=
position
,
init_velocity
=
[
0
,
0
,
0
]).
set_ignore_gravity
(
True
)
# 忽略重力
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
"""
"""
摄像机以太阳的视角看地球(四季和24节气)
摄像机以太阳的视角看地球(四季和24节气)
"""
"""
sun
=
Sun
(
size_scale
=
5e1
,
texture
=
"transparent.png"
)
# 太阳使用透明纹理,不会遮挡摄像机
sun
=
Sun
(
size_scale
=
5e1
,
texture
=
"transparent.png"
)
# 太阳使用透明纹理,不会遮挡摄像机
# 在 4 个节气的位置创建固定不动的透明地球
# 在 4 个节气的位置创建固定不动的透明地球
earth_1
=
create_earth
(
name
=
"春分"
,
text_color
=
(
0
,
255
,
0
),
position
=
[
-
1.05
*
AU
,
0
,
0
])
earth_1
,
earth_2
,
earth_3
,
earth_4
=
create_important_pos_earths
()
earth_2
=
create_earth
(
name
=
"夏至"
,
text_color
=
(
255
,
0
,
0
),
position
=
[
0
,
0
,
-
1.05
*
AU
])
earth_3
=
create_earth
(
name
=
"秋分"
,
text_color
=
(
255
,
255
,
0
),
position
=
[
1.05
*
AU
,
0
,
0
])
earth_4
=
create_earth
(
name
=
"冬至"
,
text_color
=
(
0
,
255
,
255
),
position
=
[
0
,
0
,
1.05
*
AU
])
# 运动的地球
# 运动的地球
earth
=
Earth
(
size_scale
=
5e3
,
texture
=
"earth_hd.jpg"
,
earth
=
Earth
(
size_scale
=
5e3
,
texture
=
"earth_hd.jpg"
,
text_color
=
[
255
,
255
,
255
],
rotation_speed
=
0.5
,
# 为演示效果,自转角速度取0.5度/小时,实际为15度/小时
text_color
=
[
255
,
255
,
255
],
rotation_speed
=
0.5
,
# 为演示效果,自转角速度取0.5度/小时,实际为15度/小时
...
@@ -56,14 +40,7 @@ if __name__ == '__main__':
...
@@ -56,14 +40,7 @@ if __name__ == '__main__':
]
]
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
solar_terms_angles
=
[
solar_terms_angles
=
get_solar_terms_angles
()
(
"小寒"
,
-
22.5
,
-
7.5
),
(
"大寒"
,
-
37.5
,
-
22.5
),
(
"立春"
,
-
52.5
,
-
37.5
),
(
"雨水"
,
-
67.5
,
-
52.5
),
(
"惊蛰"
,
-
82.5
,
-
67.5
),
(
"春分"
,
-
97.5
,
-
82.5
),
(
"清明"
,
-
112.5
,
-
97.5
),
(
"谷雨"
,
-
127.5
,
-
112.5
),
(
"立夏"
,
-
142.5
,
-
127.5
),
(
"小满"
,
-
157.5
,
-
142.5
),
(
"芒种"
,
-
172.5
,
-
157.5
),
(
"夏至"
,
-
180
,
-
172.5
),
(
"夏至"
,
172.5
,
180
),
(
"小暑"
,
157.5
,
172.5
),
(
"大暑"
,
142.5
,
157.5
),
(
"立秋"
,
127.5
,
142.5
),
(
"处暑"
,
112.5
,
127.5
),
(
"白露"
,
97.5
,
112.5
),
(
"秋分"
,
82.5
,
97.5
),
(
"寒露"
,
67.5
,
82.5
),
(
"霜降"
,
52.5
,
67.5
),
(
"立冬"
,
37.5
,
52.5
),
(
"小雪"
,
22.5
,
37.5
),
(
"大雪"
,
7.5
,
22.5
),
(
"冬至"
,
-
7.5
,
7.5
)]
def
on_ready
():
def
on_ready
():
...
...
sim_scenes/science/earth_seasons_2.py
浏览文件 @
029fba4d
...
@@ -11,6 +11,7 @@ from ursina import camera
...
@@ -11,6 +11,7 @@ from ursina import camera
from
bodies
import
Sun
,
Earth
from
bodies
import
Sun
,
Earth
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
from
sim_scenes.science.earth_season_func
import
get_solar_terms_angles
,
create_important_pos_earths
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
...
@@ -36,10 +37,8 @@ if __name__ == '__main__':
...
@@ -36,10 +37,8 @@ if __name__ == '__main__':
"""
"""
sun
=
Sun
(
size_scale
=
5e1
,
texture
=
"transparent.png"
)
# 太阳使用透明纹理,不会遮挡摄像机
sun
=
Sun
(
size_scale
=
5e1
,
texture
=
"transparent.png"
)
# 太阳使用透明纹理,不会遮挡摄像机
# 在 4 个节气的位置创建固定不动的透明地球
# 在 4 个节气的位置创建固定不动的透明地球
earth_1
=
create_earth
(
name
=
"春分"
,
text_color
=
(
0
,
255
,
0
),
position
=
[
-
1.05
*
AU
,
0
,
0
])
earth_1
,
earth_2
,
earth_3
,
earth_4
=
create_important_pos_earths
()
earth_2
=
create_earth
(
name
=
"夏至"
,
text_color
=
(
255
,
0
,
0
),
position
=
[
0
,
0
,
-
1.05
*
AU
])
earth_3
=
create_earth
(
name
=
"秋分"
,
text_color
=
(
255
,
255
,
0
),
position
=
[
1.05
*
AU
,
0
,
0
])
earth_4
=
create_earth
(
name
=
"冬至"
,
text_color
=
(
0
,
255
,
255
),
position
=
[
0
,
0
,
1.05
*
AU
])
# 运动的地球
# 运动的地球
earth
=
Earth
(
size_scale
=
5e3
,
texture
=
"earth-huge.jpg"
,
earth
=
Earth
(
size_scale
=
5e3
,
texture
=
"earth-huge.jpg"
,
text_color
=
[
255
,
255
,
255
],
rotation_speed
=
0.5
,
# 为演示效果,自转角速度取0.5度/小时,实际为15度/小时
text_color
=
[
255
,
255
,
255
],
rotation_speed
=
0.5
,
# 为演示效果,自转角速度取0.5度/小时,实际为15度/小时
...
@@ -63,14 +62,7 @@ if __name__ == '__main__':
...
@@ -63,14 +62,7 @@ if __name__ == '__main__':
]
]
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
solar_terms_angles
=
[
solar_terms_angles
=
get_solar_terms_angles
()
(
"小寒"
,
-
22.5
,
-
7.5
),
(
"大寒"
,
-
37.5
,
-
22.5
),
(
"立春"
,
-
52.5
,
-
37.5
),
(
"雨水"
,
-
67.5
,
-
52.5
),
(
"惊蛰"
,
-
82.5
,
-
67.5
),
(
"春分"
,
-
97.5
,
-
82.5
),
(
"清明"
,
-
112.5
,
-
97.5
),
(
"谷雨"
,
-
127.5
,
-
112.5
),
(
"立夏"
,
-
142.5
,
-
127.5
),
(
"小满"
,
-
157.5
,
-
142.5
),
(
"芒种"
,
-
172.5
,
-
157.5
),
(
"夏至"
,
-
180
,
-
172.5
),
(
"夏至"
,
172.5
,
180
),
(
"小暑"
,
157.5
,
172.5
),
(
"大暑"
,
142.5
,
157.5
),
(
"立秋"
,
127.5
,
142.5
),
(
"处暑"
,
112.5
,
127.5
),
(
"白露"
,
97.5
,
112.5
),
(
"秋分"
,
82.5
,
97.5
),
(
"寒露"
,
67.5
,
82.5
),
(
"霜降"
,
52.5
,
67.5
),
(
"立冬"
,
37.5
,
52.5
),
(
"小雪"
,
22.5
,
37.5
),
(
"大雪"
,
7.5
,
22.5
),
(
"冬至"
,
-
7.5
,
7.5
)]
def
on_ready
():
def
on_ready
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录