Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
0c061351
宇宙模拟器
项目概览
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看板
提交
0c061351
编写于
7月 22, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
61155d68
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
50 deletion
+69
-50
sim_scenes/fiction/transformed_mars_3d.py
sim_scenes/fiction/transformed_mars_3d.py
+4
-2
sim_scenes/fiction/transformed_planet.py
sim_scenes/fiction/transformed_planet.py
+12
-8
sim_scenes/fiction/transformed_venus_3d.py
sim_scenes/fiction/transformed_venus_3d.py
+3
-2
textures/mars.png
textures/mars.png
+0
-0
textures/mars2.png
textures/mars2.png
+0
-0
tools/sim_video_3d_cap_ext.py
tools/sim_video_3d_cap_ext.py
+50
-38
未找到文件。
sim_scenes/fiction/transformed_mars_3d.py
浏览文件 @
0c061351
...
@@ -10,7 +10,9 @@ from sim_scenes.fiction.transformed_planet import run_transformed_planet
...
@@ -10,7 +10,9 @@ from sim_scenes.fiction.transformed_planet import run_transformed_planet
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
run_transformed_planet
(
run_transformed_planet
(
"mars.jpg"
,
transformed_texture
=
"mars.jpg"
,
# texture="mars.png",
with_clouds
=
True
,
camera3d
=
True
,
camera3d
=
True
,
transparent
=
Fals
e
transparent
=
Tru
e
)
)
sim_scenes/fiction/transformed_planet.py
浏览文件 @
0c061351
...
@@ -19,14 +19,18 @@ from ursina import camera
...
@@ -19,14 +19,18 @@ from ursina import camera
import
os
import
os
def
run_transformed_planet
(
texture
,
with_clouds
=
True
,
camera3d
=
False
,
transparent
=
True
):
def
run_transformed_planet
(
transformed_texture
=
None
,
texture
=
None
,
with_clouds
=
True
,
camera3d
=
False
,
transparent
=
True
):
if
transparent
:
if
transformed_texture
is
not
None
:
texture
=
texture
.
replace
(
".jpg"
,
"_trans.png"
)
if
transparent
:
texture
=
transformed_texture
.
replace
(
".jpg"
,
"_trans.png"
)
else
:
texture
=
transformed_texture
texture
=
os
.
path
.
join
(
"transformed"
,
texture
)
# 创建带有云层的地球
# 创建带有云层的地球
earth
=
Earth
(
earth
=
Earth
(
texture
=
os
.
path
.
join
(
"transformed"
,
texture
)
,
texture
=
texture
,
rotate_angle
=
-
23.44
,
rotate_angle
=
0
,
init_position
=
[
0
,
0
,
0
],
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1
)
size_scale
=
1
)
...
@@ -34,7 +38,7 @@ def run_transformed_planet(texture, with_clouds=True, camera3d=False, transparen
...
@@ -34,7 +38,7 @@ def run_transformed_planet(texture, with_clouds=True, camera3d=False, transparen
if
with_clouds
:
if
with_clouds
:
# 创建云层(texture纹理图使用了透明云层的图片,云层的 size_scale 要稍微比地球大一点)
# 创建云层(texture纹理图使用了透明云层的图片,云层的 size_scale 要稍微比地球大一点)
clouds
=
Earth
(
name
=
"云层"
,
texture
=
"transparent_clouds.png"
,
clouds
=
Earth
(
name
=
"云层"
,
texture
=
"transparent_clouds.png"
,
rotate_angle
=
-
23.44
,
rotate_angle
=
0
,
size_scale
=
1.001
,
parent
=
earth
)
size_scale
=
1.001
,
parent
=
earth
)
bodies
.
append
(
clouds
)
bodies
.
append
(
clouds
)
...
@@ -65,6 +69,6 @@ if __name__ == '__main__':
...
@@ -65,6 +69,6 @@ if __name__ == '__main__':
"""
"""
run_transformed_planet
(
run_transformed_planet
(
"earth.jpg"
,
"earth.jpg"
,
camera3d
=
Tru
e
,
camera3d
=
Fals
e
,
transparent
=
Fals
e
transparent
=
Tru
e
)
)
sim_scenes/fiction/transformed_venus_3d.py
浏览文件 @
0c061351
...
@@ -10,7 +10,8 @@ from sim_scenes.fiction.transformed_planet import run_transformed_planet
...
@@ -10,7 +10,8 @@ from sim_scenes.fiction.transformed_planet import run_transformed_planet
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
run_transformed_planet
(
run_transformed_planet
(
"venus.jpg"
,
# transformed_texture="venus.jpg",
texture
=
"venus.jpg"
,
camera3d
=
True
,
camera3d
=
True
,
transparent
=
Fals
e
transparent
=
Tru
e
)
)
textures/mars.png
查看替换文件 @
61155d68
浏览文件 @
0c061351
319.6 KB
|
W:
|
H:
2.3 MB
|
W:
|
H:
2-up
Swipe
Onion skin
textures/mars2.png
0 → 100644
浏览文件 @
0c061351
312.4 KB
tools/sim_video_3d_cap_ext.py
浏览文件 @
0c061351
...
@@ -135,8 +135,24 @@ def video_write(video, l_frames, r_frames):
...
@@ -135,8 +135,24 @@ def video_write(video, l_frames, r_frames):
for
index
in
range
(
min_index
,
max_index
+
1
):
for
index
in
range
(
min_index
,
max_index
+
1
):
rv
=
r_frames
.
get
(
index
,
None
)
rv
=
r_frames
.
get
(
index
,
None
)
lv
=
l_frames
.
get
(
index
,
None
)
lv
=
l_frames
.
get
(
index
,
None
)
if
rv
is
None
or
lv
is
None
:
if
rv
is
None
and
lv
is
None
:
print
(
'['
+
str
(
index
)
+
"], "
,
end
=
''
)
continue
continue
if
rv
is
None
:
rv
=
r_frames
.
get
(
index
-
1
,
None
)
if
rv
is
None
:
rv
=
r_frames
.
get
(
index
+
1
,
None
)
if
rv
is
None
:
print
(
'[R:'
+
str
(
index
)
+
"], "
,
end
=
''
)
continue
if
lv
is
None
:
lv
=
l_frames
.
get
(
index
-
1
,
None
)
if
lv
is
None
:
lv
=
l_frames
.
get
(
index
+
1
,
None
)
if
lv
is
None
:
print
(
'[L:'
+
str
(
index
)
+
"], "
,
end
=
''
)
continue
print
(
str
(
index
)
+
", "
,
end
=
''
)
print
(
str
(
index
)
+
", "
,
end
=
''
)
merged_list
=
[
np
.
concatenate
((
lv
[
i
],
sublist
),
axis
=
0
)
for
i
,
sublist
in
enumerate
(
rv
)]
merged_list
=
[
np
.
concatenate
((
lv
[
i
],
sublist
),
axis
=
0
)
for
i
,
sublist
in
enumerate
(
rv
)]
try
:
try
:
...
@@ -272,40 +288,21 @@ def make_3d_video():
...
@@ -272,40 +288,21 @@ def make_3d_video():
l_frames
=
{}
l_frames
=
{}
print
(
"开始录屏"
)
print
(
"开始录屏"
)
clear_frame_temp_files
()
clear_frame_temp_files
()
while
True
:
if
imageNum
%
400
==
0
:
press_pause_key
()
create_frame_temp_files
(
completed_index
,
l_frames
,
r_frames
)
r_frames
.
clear
()
l_frames
.
clear
()
r_frames
=
{}
l_frames
=
{}
press_pause_key
()
def
record_frame
():
nonlocal
imageNum
,
last_index
,
index_base
,
completed_index
img
=
sim_window_screen_shot
()
img
=
sim_window_screen_shot
()
if
img
is
None
:
if
img
is
None
:
print
(
"
\n
模拟器窗口已关闭,退出录屏"
)
return
None
break
_3d_card
=
img
[
4
:
20
,
3
:
20
,
]
_3d_card
=
img
[
4
:
20
,
3
:
20
,
]
_3d_card_p
=
_3d_card
[
10
,
10
,]
_3d_card_p
=
_3d_card
[
10
,
10
,]
index
=
int
(
_3d_card_p
[
1
])
+
int
(
_3d_card_p
[
0
])
index
=
int
(
_3d_card_p
[
1
])
+
int
(
_3d_card_p
[
0
])
if
index
<
args
.
start_index
:
# if index in r_frames.keys() and index in l_frames.keys():
if
imageNum
%
args
.
fps
==
0
:
# return False
print
(
'X'
,
end
=
''
)
continue
if
index
<
last_index
:
if
index
<
last_index
:
index_base
+=
(
last_index
+
1
)
index_base
+=
(
last_index
+
1
)
# press_pause_key()
# create_frame_temp_files(index + index_base, l_frames, r_frames)
# r_frames.clear()
# l_frames.clear()
# r_frames = {}
# l_frames = {}
# press_pause_key()
last_index
=
index
last_index
=
index
index
=
index
+
index_base
index
=
index
+
index_base
...
@@ -315,30 +312,45 @@ def make_3d_video():
...
@@ -315,30 +312,45 @@ def make_3d_video():
_3d_card_direct
=
"right"
_3d_card_direct
=
"right"
if
index
not
in
r_frames
.
keys
():
if
index
not
in
r_frames
.
keys
():
r_frames
[
index
]
=
img
[:
864
,
:
768
,
]
r_frames
[
index
]
=
img
[:
864
,
:
768
,
]
else
:
return
False
else
:
else
:
_3d_card_color
=
"w"
_3d_card_color
=
"w"
_3d_card_direct
=
"left"
_3d_card_direct
=
"left"
if
index
not
in
l_frames
.
keys
():
if
index
not
in
l_frames
.
keys
():
l_frames
[
index
]
=
img
[:
864
,
:
768
,
]
l_frames
[
index
]
=
img
[:
864
,
:
768
,
]
else
:
# if is_blank_screen(img):
return
False
# if imageNum % args.fps == 0:
# print('x', end='')
#
# continue
if
imageNum
%
args
.
fps
==
0
:
if
imageNum
%
args
.
fps
==
0
:
print
(
'.'
,
end
=
''
)
print
(
'.'
,
end
=
''
)
# else:
# print(imageNum, end='')
imageNum
+=
1
imageNum
+=
1
return
True
while
True
:
if
imageNum
%
400
==
0
:
press_pause_key
()
for
i
in
range
(
10
):
status
=
record_frame
()
# print("status:", status, i)
if
not
status
:
break
time
.
sleep
(
0.01
)
create_frame_temp_files
(
completed_index
,
l_frames
,
r_frames
)
r_frames
.
clear
()
l_frames
.
clear
()
r_frames
=
{}
l_frames
=
{}
press_pause_key
()
# frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
status
=
record_frame
()
# if imageNum < args.fps * args.total_time:
# # img = img[:432,:768,]
# img = sim_window_screen_shot()
# # show_image(frame)
# video.write(img)
if
status
is
None
:
print
(
"
\n
模拟器窗口已关闭,退出录屏"
)
break
print
(
"3D视频处理(完成索引:%s)"
%
completed_index
)
print
(
"3D视频处理(完成索引:%s)"
%
completed_index
)
handle_3d_video
(
video
,
l_frames
,
r_frames
)
handle_3d_video
(
video
,
l_frames
,
r_frames
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录