Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
a2daaea5
宇宙模拟器
项目概览
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看板
提交
a2daaea5
编写于
12月 14, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
05924941
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
456 addition
and
22 deletion
+456
-22
sim_scenes/featured/earth_seasons.py
sim_scenes/featured/earth_seasons.py
+9
-6
sim_scenes/featured/earth_seasons_1.py
sim_scenes/featured/earth_seasons_1.py
+133
-0
sim_scenes/featured/earth_seasons_2.py
sim_scenes/featured/earth_seasons_2.py
+132
-0
sim_scenes/featured/earth_seasons_3.py
sim_scenes/featured/earth_seasons_3.py
+132
-0
sim_scenes/science/earth_season_func.py
sim_scenes/science/earth_season_func.py
+20
-7
sim_scenes/universe_sim_scenes.py
sim_scenes/universe_sim_scenes.py
+5
-1
tools/sim_video_cap.py
tools/sim_video_cap.py
+25
-8
未找到文件。
sim_scenes/featured/earth_seasons.py
浏览文件 @
a2daaea5
...
@@ -62,6 +62,7 @@ class EarthSeasonsSim(UniverseSimScenes):
...
@@ -62,6 +62,7 @@ class EarthSeasonsSim(UniverseSimScenes):
self
.
sky
.
rotation_x
=
20
self
.
sky
.
rotation_x
=
20
self
.
sky
.
rotation_z
=
-
65
self
.
sky
.
rotation_z
=
-
65
if
hasattr
(
self
.
earth_clouds
,
"name_text"
):
self
.
earth_clouds
.
name_text
.
enabled
=
False
self
.
earth_clouds
.
name_text
.
enabled
=
False
def
earth_text_display
(
self
,
term_name
):
def
earth_text_display
(
self
,
term_name
):
...
@@ -71,6 +72,7 @@ class EarthSeasonsSim(UniverseSimScenes):
...
@@ -71,6 +72,7 @@ class EarthSeasonsSim(UniverseSimScenes):
@return:
@return:
"""
"""
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
if
hasattr
(
e
,
"name_text"
):
if
term_name
==
e
.
name
:
if
term_name
==
e
.
name
:
e
.
name_text
.
enabled
=
False
e
.
name_text
.
enabled
=
False
else
:
else
:
...
@@ -88,6 +90,7 @@ class EarthSeasonsSim(UniverseSimScenes):
...
@@ -88,6 +90,7 @@ class EarthSeasonsSim(UniverseSimScenes):
# 控制4个透明地球文本是否显示,防止地球文字的叠加
# 控制4个透明地球文本是否显示,防止地球文字的叠加
self
.
earth_text_display
(
term_name
)
self
.
earth_text_display
(
term_name
)
# 地球名称文字显示为相应的节气
# 地球名称文字显示为相应的节气
if
hasattr
(
self
.
earth
,
"name_text"
):
self
.
earth
.
name_text
.
text
=
term_name
self
.
earth
.
name_text
.
text
=
term_name
# if term_name == "立春": # 找到立春的位置和速度
# if term_name == "立春": # 找到立春的位置和速度
# print("position", earth.position)
# print("position", earth.position)
...
...
sim_scenes/featured/earth_seasons_1.py
0 → 100644
浏览文件 @
a2daaea5
# -*- coding:utf-8 -*-
# title :地球季节模拟(四季和24节气)
# description :地球季节模拟(四季和24节气)
# 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
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
from
sim_scenes.science.earth_season_func
import
create_important_pos_earths
,
get_solar_terms_angles
,
create_earth
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
class
EarthSeasonsSim
(
UniverseSimScenes
):
window_size
=
(
1920
/
3
,
1080
/
3
)
def
__init__
(
self
):
self
.
sun
=
Sun
(
size_scale
=
5e1
)
# 太阳使用透明纹理,不会遮挡摄像机
# 在 4 个节气的位置创建固定不动的透明地球
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
=
\
create_important_pos_earths
(
texture
=
"earth-huge.jpg"
,
size_scale
=
4.5e3
,
position_offset
=
1.0
)
# 运动的地球
self
.
earth
,
self
.
earth_clouds
=
create_earth
(
earth_texture
=
"earth-huge.jpg"
,
with_clouds
=
True
,
earth_rotation_speed
=
0.5
,
clouds_rotation_speed
=
0.6
)
# 地球立春的位置和速度
self
.
earth
.
init_position
=
[
-
9.1507536e+07
,
0.0000000e+00
,
1.1907757e+08
]
self
.
earth
.
init_velocity
=
[
-
23.550875
,
0.
,
-
18.05398
]
self
.
earth_clouds
.
init_position
=
[
-
9.1507536e+07
,
0.0000000e+00
,
1.1907757e+08
]
self
.
earth_clouds
.
init_velocity
=
[
-
23.550875
,
0.
,
-
18.05398
]
self
.
earth
.
rotate_axis_color
=
(
255
,
255
,
50
)
self
.
earth
.
rotate_axis_scale
=
0.65
self
.
bodies
=
[
self
.
sun
,
self
.
earth
,
self
.
earth_clouds
,
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
,
]
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
self
.
solar_terms_angles
=
get_solar_terms_angles
()
def
on_ready
(
self
):
# 将 4 个节气位置的地球进行旋转,让中国面对太阳
self
.
earth_1
.
planet
.
rotation_y
+=
115
# 春分
self
.
earth_2
.
planet
.
rotation_y
+=
15
# 夏至
self
.
earth_3
.
planet
.
rotation_y
-=
80
# 秋分
self
.
earth_4
.
planet
.
rotation_y
-=
145
# 冬至
self
.
earth_1
.
planet
.
alpha
=
0.3
self
.
earth_2
.
planet
.
alpha
=
0.3
self
.
earth_3
.
planet
.
alpha
=
0.3
self
.
earth_4
.
planet
.
alpha
=
0.3
# self.sky = create_sphere_sky(scale=8000)
# self.sky.rotation_y = 100
# self.sky.rotation_x = 20
# self.sky.rotation_z = -65
if
hasattr
(
self
.
earth_clouds
,
"name_text"
):
self
.
earth_clouds
.
name_text
.
enabled
=
False
# 摄像机始终看向移动的地球
camera_look_at
(
self
.
sun
,
rotation_z
=
0
)
def
earth_text_display
(
self
,
term_name
):
"""
控制4个透明地球文本是否显示,防止地球文字的叠加
@param term_name:
@return:
"""
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
if
hasattr
(
e
,
"name_text"
):
if
term_name
==
e
.
name
:
e
.
name_text
.
enabled
=
False
else
:
e
.
name_text
.
enabled
=
True
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
if
time_data
.
total_days
>
400
:
exit
(
0
)
# 根据角度范围判断,显示中国农历24节气
for
info
in
self
.
solar_terms_angles
:
if
info
[
1
]
<=
camera
.
rotation_y
<
info
[
2
]:
term_name
=
info
[
0
]
# 控制4个透明地球文本是否显示,防止地球文字的叠加
self
.
earth_text_display
(
term_name
)
# 地球名称文字显示为相应的节气
if
hasattr
(
self
.
earth
,
"name_text"
):
self
.
earth
.
name_text
.
text
=
term_name
# if term_name == "立春": # 找到立春的位置和速度
# print("position", earth.position)
# print("velocity", earth.velocity)
# print(camera.rotation_y)
def
run
(
self
):
# 订阅事件后,上面2个函数功能才会起作用
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
self
.
on_ready
)
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
# 设置计时器的最小时间单位为天
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_DAYS
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
self
.
bodies
,
SECONDS_PER_DAY
*
10
,
# position=(0, 0, 0), # 摄像机和太阳是相同位置
position
=
(
3
*
AU
,
AU
,
0
),
# 摄像机和太阳是相同位置
# show_name=True,
show_grid
=
False
,
cosmic_bg
=
''
,
# show_timer=True,
timer_enabled
=
True
)
if
__name__
==
'__main__'
:
"""
摄像机以太阳的视角看地球(四季和24节气)
"""
sim
=
EarthSeasonsSim
()
sim
.
run
()
sim_scenes/featured/earth_seasons_2.py
0 → 100644
浏览文件 @
a2daaea5
# -*- coding:utf-8 -*-
# title :地球季节模拟(四季和24节气)
# description :地球季节模拟(四季和24节气)
# 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
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
from
sim_scenes.science.earth_season_func
import
create_important_pos_earths
,
get_solar_terms_angles
,
create_earth
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
class
EarthSeasonsSim
(
UniverseSimScenes
):
window_size
=
(
1920
/
3
,
1080
/
3
)
def
__init__
(
self
):
self
.
sun
=
Sun
(
size_scale
=
5e1
)
# 太阳使用透明纹理,不会遮挡摄像机
# 在 4 个节气的位置创建固定不动的透明地球
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
=
\
create_important_pos_earths
(
texture
=
"earth-huge.jpg"
,
size_scale
=
4.5e3
,
position_offset
=
1.0
)
# 运动的地球
self
.
earth
,
self
.
earth_clouds
=
create_earth
(
earth_texture
=
"earth-huge.jpg"
,
with_clouds
=
True
,
earth_rotation_speed
=
0.5
,
clouds_rotation_speed
=
0.6
)
# 地球立春的位置和速度
self
.
earth
.
init_position
=
[
-
9.1507536e+07
,
0.0000000e+00
,
1.1907757e+08
]
self
.
earth
.
init_velocity
=
[
-
23.550875
,
0.
,
-
18.05398
]
self
.
earth_clouds
.
init_position
=
[
-
9.1507536e+07
,
0.0000000e+00
,
1.1907757e+08
]
self
.
earth_clouds
.
init_velocity
=
[
-
23.550875
,
0.
,
-
18.05398
]
self
.
earth
.
rotate_axis_color
=
(
255
,
255
,
50
)
self
.
earth
.
rotate_axis_scale
=
0.65
self
.
bodies
=
[
self
.
sun
,
self
.
earth
,
self
.
earth_clouds
,
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
,
]
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
self
.
solar_terms_angles
=
get_solar_terms_angles
()
def
on_ready
(
self
):
# 将 4 个节气位置的地球进行旋转,让中国面对太阳
self
.
earth_1
.
planet
.
rotation_y
+=
115
# 春分
self
.
earth_2
.
planet
.
rotation_y
+=
15
# 夏至
self
.
earth_3
.
planet
.
rotation_y
-=
80
# 秋分
self
.
earth_4
.
planet
.
rotation_y
-=
145
# 冬至
self
.
earth_1
.
planet
.
alpha
=
0.3
self
.
earth_2
.
planet
.
alpha
=
0.3
self
.
earth_3
.
planet
.
alpha
=
0.3
self
.
earth_4
.
planet
.
alpha
=
0.3
# self.sky = create_sphere_sky(scale=8000)
# self.sky.rotation_y = 100
# self.sky.rotation_x = 20
# self.sky.rotation_z = -65
if
hasattr
(
self
.
earth_clouds
,
"name_text"
):
self
.
earth_clouds
.
name_text
.
enabled
=
False
# 摄像机始终看向移动的地球
camera_look_at
(
self
.
sun
,
rotation_z
=
0
)
def
earth_text_display
(
self
,
term_name
):
"""
控制4个透明地球文本是否显示,防止地球文字的叠加
@param term_name:
@return:
"""
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
if
hasattr
(
e
,
"name_text"
):
if
term_name
==
e
.
name
:
e
.
name_text
.
enabled
=
False
else
:
e
.
name_text
.
enabled
=
True
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
if
time_data
.
total_days
>
400
:
exit
(
0
)
# 根据角度范围判断,显示中国农历24节气
for
info
in
self
.
solar_terms_angles
:
if
info
[
1
]
<=
camera
.
rotation_y
<
info
[
2
]:
term_name
=
info
[
0
]
# 控制4个透明地球文本是否显示,防止地球文字的叠加
self
.
earth_text_display
(
term_name
)
# 地球名称文字显示为相应的节气
if
hasattr
(
self
.
earth
,
"name_text"
):
self
.
earth
.
name_text
.
text
=
term_name
# if term_name == "立春": # 找到立春的位置和速度
# print("position", earth.position)
# print("velocity", earth.velocity)
# print(camera.rotation_y)
def
run
(
self
):
# 订阅事件后,上面2个函数功能才会起作用
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
self
.
on_ready
)
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
# 设置计时器的最小时间单位为天
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_DAYS
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
self
.
bodies
,
SECONDS_PER_DAY
*
10
,
# position=(0, 0, 0), # 摄像机和太阳是相同位置
position
=
(
0
,
AU
,
-
3
*
AU
),
# 摄像机和太阳是相同位置
# show_name=True,
show_grid
=
False
,
cosmic_bg
=
''
,
# show_timer=True,
timer_enabled
=
True
)
if
__name__
==
'__main__'
:
"""
摄像机以太阳的视角看地球(四季和24节气)
"""
sim
=
EarthSeasonsSim
()
sim
.
run
()
sim_scenes/featured/earth_seasons_3.py
0 → 100644
浏览文件 @
a2daaea5
# -*- coding:utf-8 -*-
# title :地球季节模拟(四季和24节气)
# description :地球季节模拟(四季和24节气)
# 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
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
from
sim_scenes.science.earth_season_func
import
create_important_pos_earths
,
get_solar_terms_angles
,
create_earth
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
class
EarthSeasonsSim
(
UniverseSimScenes
):
window_size
=
(
1920
/
3
,
1080
/
3
)
def
__init__
(
self
):
self
.
sun
=
Sun
(
size_scale
=
5e1
)
# 太阳使用透明纹理,不会遮挡摄像机
# 在 4 个节气的位置创建固定不动的透明地球
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
=
\
create_important_pos_earths
(
texture
=
"earth-huge.jpg"
,
size_scale
=
4.5e3
,
position_offset
=
1.0
)
# 运动的地球
self
.
earth
,
self
.
earth_clouds
=
create_earth
(
earth_texture
=
"earth-huge.jpg"
,
with_clouds
=
True
,
earth_rotation_speed
=
0.5
,
clouds_rotation_speed
=
0.6
)
# 地球立春的位置和速度
self
.
earth
.
init_position
=
[
-
9.1507536e+07
,
0.0000000e+00
,
1.1907757e+08
]
self
.
earth
.
init_velocity
=
[
-
23.550875
,
0.
,
-
18.05398
]
self
.
earth_clouds
.
init_position
=
[
-
9.1507536e+07
,
0.0000000e+00
,
1.1907757e+08
]
self
.
earth_clouds
.
init_velocity
=
[
-
23.550875
,
0.
,
-
18.05398
]
self
.
earth
.
rotate_axis_color
=
(
255
,
255
,
50
)
self
.
earth
.
rotate_axis_scale
=
0.65
self
.
bodies
=
[
self
.
sun
,
self
.
earth
,
self
.
earth_clouds
,
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
,
]
# 中国农历24节气表,数据为 节气名称 和 camera.rotation_y 的角度范围值
self
.
solar_terms_angles
=
get_solar_terms_angles
()
def
on_ready
(
self
):
# 将 4 个节气位置的地球进行旋转,让中国面对太阳
self
.
earth_1
.
planet
.
rotation_y
+=
115
# 春分
self
.
earth_2
.
planet
.
rotation_y
+=
15
# 夏至
self
.
earth_3
.
planet
.
rotation_y
-=
80
# 秋分
self
.
earth_4
.
planet
.
rotation_y
-=
145
# 冬至
self
.
earth_1
.
planet
.
alpha
=
0.3
self
.
earth_2
.
planet
.
alpha
=
0.3
self
.
earth_3
.
planet
.
alpha
=
0.3
self
.
earth_4
.
planet
.
alpha
=
0.3
# self.sky = create_sphere_sky(scale=8000)
# self.sky.rotation_y = 100
# self.sky.rotation_x = 20
# self.sky.rotation_z = -65
if
hasattr
(
self
.
earth_clouds
,
"name_text"
):
self
.
earth_clouds
.
name_text
.
enabled
=
False
# 摄像机始终看向移动的地球
camera_look_at
(
self
.
sun
,
rotation_z
=
0
)
def
earth_text_display
(
self
,
term_name
):
"""
控制4个透明地球文本是否显示,防止地球文字的叠加
@param term_name:
@return:
"""
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
if
hasattr
(
e
,
"name_text"
):
if
term_name
==
e
.
name
:
e
.
name_text
.
enabled
=
False
else
:
e
.
name_text
.
enabled
=
True
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
if
time_data
.
total_days
>
400
:
exit
(
0
)
# 根据角度范围判断,显示中国农历24节气
for
info
in
self
.
solar_terms_angles
:
if
info
[
1
]
<=
camera
.
rotation_y
<
info
[
2
]:
term_name
=
info
[
0
]
# 控制4个透明地球文本是否显示,防止地球文字的叠加
self
.
earth_text_display
(
term_name
)
# 地球名称文字显示为相应的节气
if
hasattr
(
self
.
earth
,
"name_text"
):
self
.
earth
.
name_text
.
text
=
term_name
# if term_name == "立春": # 找到立春的位置和速度
# print("position", earth.position)
# print("velocity", earth.velocity)
# print(camera.rotation_y)
def
run
(
self
):
# 订阅事件后,上面2个函数功能才会起作用
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
self
.
on_ready
)
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
# 设置计时器的最小时间单位为天
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_DAYS
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
self
.
bodies
,
SECONDS_PER_DAY
*
10
,
# position=(0, 0, 0), # 摄像机和太阳是相同位置
position
=
(
0
,
4
*
AU
,
0
),
# 摄像机和太阳是相同位置
# show_name=True,
show_grid
=
False
,
cosmic_bg
=
''
,
# show_timer=True,
timer_enabled
=
True
)
if
__name__
==
'__main__'
:
"""
摄像机以太阳的视角看地球(四季和24节气)
"""
sim
=
EarthSeasonsSim
()
sim
.
run
()
sim_scenes/science/earth_season_func.py
浏览文件 @
a2daaea5
...
@@ -12,7 +12,7 @@ from bodies import Sun, Earth
...
@@ -12,7 +12,7 @@ from bodies import Sun, Earth
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
common.consts
import
SECONDS_PER_DAY
,
AU
def
create_trans_earth
(
name
,
text_color
,
position
,
texture
=
"earth_transparent.png"
):
def
create_trans_earth
(
name
,
text_color
,
position
,
texture
=
"earth_transparent.png"
,
size_scale
=
5e3
):
"""
"""
创建透明的地球
创建透明的地球
@param name: 名称
@param name: 名称
...
@@ -21,21 +21,34 @@ def create_trans_earth(name, text_color, position, texture="earth_transparent.pn
...
@@ -21,21 +21,34 @@ def create_trans_earth(name, text_color, position, texture="earth_transparent.pn
@param texture: 透明地球的纹理图片
@param texture: 透明地球的纹理图片
@return:
@return:
"""
"""
return
Earth
(
name
=
name
,
size_scale
=
5e3
,
texture
=
texture
,
# 明的地球纹理
return
Earth
(
name
=
name
,
size_scale
=
size_scale
,
texture
=
texture
,
# 明的地球纹理
text_color
=
text_color
,
rotation_speed
=
0
,
text_color
=
text_color
,
rotation_speed
=
0
,
init_position
=
position
,
init_velocity
=
[
0
,
0
,
0
]).
set_ignore_gravity
(
True
)
# 忽略重力
init_position
=
position
,
init_velocity
=
[
0
,
0
,
0
]).
set_ignore_gravity
(
True
)
# 忽略重力
def
create_important_pos_earths
(
texture
=
"earth_transparent.png"
):
def
create_important_pos_earths
(
texture
=
"earth_transparent.png"
,
size_scale
=
5e3
,
position_offset
=
1.05
):
"""
"""
创建24节气中4个重要位置的透明地球
创建24节气中4个重要位置的透明地球
@param texture: 透明地球的纹理图片
@param texture: 透明地球的纹理图片
@param size_scale:
@param position_offset:
@return:
@return:
"""
"""
earth_1
=
create_trans_earth
(
name
=
"春分"
,
text_color
=
(
0
,
255
,
0
),
position
=
[
-
1.05
*
AU
,
0
,
0
],
texture
=
texture
)
earth_1
=
create_trans_earth
(
name
=
"春分"
,
text_color
=
(
0
,
255
,
0
),
position
=
[
-
position_offset
*
AU
,
0
,
0
],
earth_2
=
create_trans_earth
(
name
=
"夏至"
,
text_color
=
(
255
,
0
,
0
),
position
=
[
0
,
0
,
-
1.05
*
AU
],
texture
=
texture
)
texture
=
texture
,
size_scale
=
size_scale
)
earth_3
=
create_trans_earth
(
name
=
"秋分"
,
text_color
=
(
255
,
255
,
0
),
position
=
[
1.05
*
AU
,
0
,
0
],
texture
=
texture
)
earth_2
=
create_trans_earth
(
name
=
"夏至"
,
text_color
=
(
255
,
0
,
0
),
position
=
[
0
,
0
,
-
position_offset
*
AU
],
earth_4
=
create_trans_earth
(
name
=
"冬至"
,
text_color
=
(
0
,
255
,
255
),
position
=
[
0
,
0
,
1.05
*
AU
],
texture
=
texture
)
texture
=
texture
,
size_scale
=
size_scale
)
earth_3
=
create_trans_earth
(
name
=
"秋分"
,
text_color
=
(
255
,
255
,
0
),
position
=
[
position_offset
*
AU
,
0
,
0
],
texture
=
texture
,
size_scale
=
size_scale
)
earth_4
=
create_trans_earth
(
name
=
"冬至"
,
text_color
=
(
0
,
255
,
255
),
position
=
[
0
,
0
,
position_offset
*
AU
],
texture
=
texture
,
size_scale
=
size_scale
)
earth_1
.
set_light_disable
(
True
)
earth_2
.
set_light_disable
(
True
)
earth_3
.
set_light_disable
(
True
)
earth_4
.
set_light_disable
(
True
)
return
earth_1
,
earth_2
,
earth_3
,
earth_4
return
earth_1
,
earth_2
,
earth_3
,
earth_4
...
...
sim_scenes/universe_sim_scenes.py
浏览文件 @
a2daaea5
...
@@ -22,7 +22,11 @@ class UniverseSimScenes:
...
@@ -22,7 +22,11 @@ class UniverseSimScenes:
def
__new__
(
cls
,
*
args
,
**
kwargs
):
def
__new__
(
cls
,
*
args
,
**
kwargs
):
print
(
"参数个数"
,
len
(
sys
.
argv
))
print
(
"参数个数"
,
len
(
sys
.
argv
))
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
UniverseSimScenes
.
set_window_size
((
1920
,
1079
),
False
)
if
hasattr
(
cls
,
"window_size"
):
window_size
=
cls
.
window_size
else
:
window_size
=
(
1920
,
1079
)
UniverseSimScenes
.
set_window_size
(
window_size
,
False
)
cls
.
record_rate
=
2
cls
.
record_rate
=
2
UniverseSimScenes
.
screen_record
=
True
UniverseSimScenes
.
screen_record
=
True
application
.
time_scale
=
0.00001
application
.
time_scale
=
0.00001
...
...
tools/sim_video_cap.py
浏览文件 @
a2daaea5
...
@@ -39,9 +39,20 @@ def get_args():
...
@@ -39,9 +39,20 @@ def get_args():
return
args
return
args
def
screen_shot
(
window_img_dc
):
def
get_window_size
(
hwnd
):
width
,
height
=
win32api
.
GetSystemMetrics
(
win32con
.
SM_CXVIRTUALSCREEN
),
\
rect
=
win32gui
.
GetWindowRect
(
hwnd
)
width
=
rect
[
2
]
-
rect
[
0
]
height
=
rect
[
3
]
-
rect
[
1
]
return
width
,
height
def
screen_shot
(
window_img_dc
,
width
=
None
,
height
=
None
):
screen_width
,
screen_height
=
win32api
.
GetSystemMetrics
(
win32con
.
SM_CXVIRTUALSCREEN
),
\
win32api
.
GetSystemMetrics
(
win32con
.
SM_CYVIRTUALSCREEN
)
win32api
.
GetSystemMetrics
(
win32con
.
SM_CYVIRTUALSCREEN
)
if
width
is
None
or
width
==
screen_width
or
height
==
screen_height
:
width
,
height
=
screen_width
,
screen_height
# 创建一个内存设备描述表
# 创建一个内存设备描述表
mem_dc
=
window_img_dc
.
CreateCompatibleDC
()
mem_dc
=
window_img_dc
.
CreateCompatibleDC
()
# 创建位图对象
# 创建位图对象
...
@@ -91,9 +102,10 @@ def sim_window_screen_shot(wait_ses=-1, retry_times=3):
...
@@ -91,9 +102,10 @@ def sim_window_screen_shot(wait_ses=-1, retry_times=3):
handle
=
get_window_handle
()
handle
=
get_window_handle
()
if
handle
>
0
:
if
handle
>
0
:
desktop_dc
=
win32gui
.
GetWindowDC
(
handle
)
desktop_dc
=
win32gui
.
GetWindowDC
(
handle
)
width
,
height
=
get_window_size
(
handle
)
img_dc
=
win32ui
.
CreateDCFromHandle
(
desktop_dc
)
img_dc
=
win32ui
.
CreateDCFromHandle
(
desktop_dc
)
try
:
try
:
img
=
screen_shot
(
img_dc
)
img
=
screen_shot
(
img_dc
,
width
,
height
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
"ERROR:"
,
str
(
e
))
print
(
"ERROR:"
,
str
(
e
))
print
(
"handle"
,
handle
)
print
(
"handle"
,
handle
)
...
@@ -136,7 +148,11 @@ def get_current_time():
...
@@ -136,7 +148,11 @@ def get_current_time():
def
check_img
(
img
):
def
check_img
(
img
):
if
img
[
400
:
500
,
400
:
500
].
sum
()
==
0
:
if
img
is
None
:
return
False
w
,
h
,
p
=
img
.
shape
if
img
[
int
(
w
*
3
/
5
):
int
(
w
*
4
/
5
),
int
(
h
*
3
/
5
):
int
(
h
*
4
/
5
)].
sum
()
==
0
and
\
img
[
int
(
w
*
3
/
8
):
int
(
w
*
5
/
8
),
int
(
h
*
3
/
8
):
int
(
h
*
5
/
8
)].
sum
()
==
0
:
return
False
return
False
return
True
return
True
...
@@ -172,6 +188,10 @@ if __name__ == '__main__':
...
@@ -172,6 +188,10 @@ if __name__ == '__main__':
print
(
"开始录屏时间:"
,
get_current_time
())
print
(
"开始录屏时间:"
,
get_current_time
())
while
True
:
while
True
:
if
imageNum
<
args
.
fps
*
args
.
total_time
:
# show_image(frame)
video
.
write
(
img
)
img
=
sim_window_screen_shot
()
img
=
sim_window_screen_shot
()
if
img
is
None
:
if
img
is
None
:
print
(
"
\n
模拟器窗口已关闭,退出录屏时间:"
,
get_current_time
())
print
(
"
\n
模拟器窗口已关闭,退出录屏时间:"
,
get_current_time
())
...
@@ -191,9 +211,6 @@ if __name__ == '__main__':
...
@@ -191,9 +211,6 @@ if __name__ == '__main__':
imageNum
+=
1
imageNum
+=
1
# frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
# frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
if
imageNum
<
args
.
fps
*
args
.
total_time
:
# show_image(frame)
video
.
write
(
img
)
print
(
"视频保存中"
)
print
(
"视频保存中"
)
video
.
release
()
video
.
release
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录