Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
6aa88f03
宇宙模拟器
项目概览
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看板
提交
6aa88f03
编写于
11月 24, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
f6bd676d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
5 deletion
+48
-5
sim_lab/wormhole_sim.py
sim_lab/wormhole_sim.py
+29
-4
tools/sim_video_cap.bat
tools/sim_video_cap.bat
+2
-1
tools/sim_video_cap.py
tools/sim_video_cap.py
+17
-0
未找到文件。
sim_lab/wormhole_sim.py
浏览文件 @
6aa88f03
...
@@ -6,7 +6,9 @@
...
@@ -6,7 +6,9 @@
# link :https://gitcode.net/pythoncr/
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# python_version :3.9
# ==============================================================================
# ==============================================================================
from
bodies
import
Sun
,
Earth
import
random
from
bodies
import
Sun
,
Earth
,
FixedStar
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.entity_utils
import
create_ambient_light
from
simulators.ursina.entities.entity_utils
import
create_ambient_light
from
bodies.universe_body
import
create_universe_body
from
bodies.universe_body
import
create_universe_body
...
@@ -64,10 +66,12 @@ class WormholeSim(UniverseSimScenes):
...
@@ -64,10 +66,12 @@ class WormholeSim(UniverseSimScenes):
self
.
current_universe
=
None
self
.
current_universe
=
None
self
.
target_universe
=
None
self
.
target_universe
=
None
self
.
universes
=
[]
self
.
universes
=
[]
self
.
fixed_stars
=
[]
self
.
wormhole_infos
=
{}
self
.
wormhole_infos
=
{}
self
.
create_universes
()
self
.
create_universes
()
self
.
bodies
=
[
self
.
camera_target
]
+
self
.
universes
self
.
create_fixed_stars
()
self
.
bodies
=
[
self
.
camera_target
]
+
self
.
universes
+
self
.
fixed_stars
def
create_universe
(
self
,
name
,
idx
,
position
):
def
create_universe
(
self
,
name
,
idx
,
position
):
if
name
is
None
:
if
name
is
None
:
...
@@ -77,9 +81,29 @@ class WormholeSim(UniverseSimScenes):
...
@@ -77,9 +81,29 @@ class WormholeSim(UniverseSimScenes):
init_position
=
position
,
init_position
=
position
,
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
)
)
universe_body
.
set_light_disable
(
True
)
return
universe_body
return
universe_body
def
fixed_stars_D
(
self
):
r
=
random
.
random
()
D
=
self
.
D
*
(
2
+
r
)
return
D
def
create_fixed_stars
(
self
):
D
=
self
.
fixed_stars_D
positions
=
[[
D
(),
D
(),
D
()],
[
D
(),
D
(),
-
D
()],
[
D
(),
-
D
(),
D
()],
[
D
(),
-
D
(),
-
D
()],
[
-
D
(),
D
(),
D
()],
[
-
D
(),
D
(),
-
D
()],
[
-
D
(),
-
D
(),
D
()],
[
-
D
(),
-
D
(),
-
D
()]]
# positions = [[D, D, D], [D, D, -D], [D, -D, D], [D, 0, D], [D, 0, - D], [D, 0, D],
# [D, -D, -D], [-D, D, D], [-D, D, -D], [0, -D, -D], [0, D, D], [0, D, -D],
# [-D, -D, D], [-D, -D, -D], [-D, -D, 0], [-D, -D, 0]]
for
position
in
positions
:
fixed_star
=
FixedStar
(
color
=
(
200
,
200
,
200
),
size_scale
=
0.5
,
init_position
=
position
)
fixed_star
.
glows
=
(
0
,
1.1
,
1.08
)
self
.
fixed_stars
.
append
(
fixed_star
)
def
create_universes
(
self
):
def
create_universes
(
self
):
D
=
self
.
D
D
=
self
.
D
# camera_target_init_speed: int = 100
# camera_target_init_speed: int = 100
...
@@ -155,7 +179,7 @@ class WormholeSim(UniverseSimScenes):
...
@@ -155,7 +179,7 @@ class WormholeSim(UniverseSimScenes):
# camera.scale = 1000
# camera.scale = 1000
# camera.parent = camera_target.planet
# camera.parent = camera_target.planet
# camera.rotation_x = 90
# camera.rotation_x = 90
camera
.
fov
=
1
0
0
camera
.
fov
=
1
2
0
for
universe
in
self
.
universes
:
for
universe
in
self
.
universes
:
universe
.
planet
.
collider
=
"sphere"
universe
.
planet
.
collider
=
"sphere"
...
@@ -458,6 +482,7 @@ class WormholeSim(UniverseSimScenes):
...
@@ -458,6 +482,7 @@ class WormholeSim(UniverseSimScenes):
gravity_works
=
False
,
gravity_works
=
False
,
# bg_music='sounds/no_glory.mp3',
# bg_music='sounds/no_glory.mp3',
timer_enabled
=
True
,
timer_enabled
=
True
,
video_recoder
=
True
,
show_exit_button
=
False
,
show_exit_button
=
False
,
show_grid
=
False
,
show_grid
=
False
,
show_camera_info
=
False
,
show_camera_info
=
False
,
...
...
tools/sim_video_cap.bat
浏览文件 @
6aa88f03
...
@@ -8,6 +8,7 @@ SET SimDir=%DISK%/works/gitcode/universe_sim
...
@@ -8,6 +8,7 @@ SET SimDir=%DISK%/works/gitcode/universe_sim
SET
SimFileDir
=
%
1
SET
SimFileDir
=
%
1
SET
SimFileName
=
%
2
SET
SimFileName
=
%
2
SET
param3
=
%
3
SET
param3
=
%
3
SET
param4
=
%
4
SET
PYTHONPATH
=
%SimDir%
;
SET
PYTHONPATH
=
%SimDir%
;
SET
SimFilePath
=
%SimDir%
/sim
_scenes/
%SimFileDir%
/
SET
SimFilePath
=
%SimDir%
/sim
_scenes/
%SimFileDir%
/
...
@@ -20,6 +21,6 @@ cd %SimFilePath%
...
@@ -20,6 +21,6 @@ cd %SimFilePath%
start
python
-m
%SimFileName%
%
3
start
python
-m
%SimFileName%
%
3
cd
%SimDir%
\tools
cd
%SimDir%
\tools
python
-m
sim_video_cap
--save
_name
=
%param3
%
python
-m
sim_video_cap
--save
_name
=
%param3
%
--wait
=
%param4
%
tools/sim_video_cap.py
浏览文件 @
6aa88f03
...
@@ -26,11 +26,14 @@ def get_args():
...
@@ -26,11 +26,14 @@ def get_args():
parser
.
add_argument
(
'--fps'
,
type
=
int
,
default
=
30
,
help
=
'frame per second'
)
parser
.
add_argument
(
'--fps'
,
type
=
int
,
default
=
30
,
help
=
'frame per second'
)
parser
.
add_argument
(
'--total_time'
,
type
=
int
,
default
=
10000000
,
help
=
'video total time'
)
parser
.
add_argument
(
'--total_time'
,
type
=
int
,
default
=
10000000
,
help
=
'video total time'
)
parser
.
add_argument
(
'--save_name'
,
type
=
str
,
default
=
'video.mp4'
,
help
=
'save file name'
)
parser
.
add_argument
(
'--save_name'
,
type
=
str
,
default
=
'video.mp4'
,
help
=
'save file name'
)
parser
.
add_argument
(
'--wait'
,
type
=
int
,
default
=
0
,
help
=
'wait for recoding'
)
# parser.add_argument('--screen_type', default=0, type=int, choices=[0, 1], help='1: full screen, 0: region screen')
# parser.add_argument('--screen_type', default=0, type=int, choices=[0, 1], help='1: full screen, 0: region screen')
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print
(
"total_time:"
,
args
.
total_time
)
print
(
"total_time:"
,
args
.
total_time
)
print
(
"fps:"
,
args
.
fps
)
print
(
"fps:"
,
args
.
fps
)
print
(
"save_name:"
,
args
.
save_name
)
print
(
"save_name:"
,
args
.
save_name
)
print
(
"wait:"
,
args
.
wait
)
return
args
return
args
...
@@ -67,6 +70,17 @@ def screen_shot(window_img_dc):
...
@@ -67,6 +70,17 @@ def screen_shot(window_img_dc):
# return True
# return True
# return False
# return False
def
wait_sec
(
sec
=
0
):
print
(
"等待 %s 秒"
%
sec
)
times
=
sec
*
100
while
True
:
if
sec
<
0
:
return
time
.
sleep
(
0.01
)
times
-=
1
if
times
<=
0
:
return
def
sim_window_screen_shot
(
wait_ses
=-
1
):
def
sim_window_screen_shot
(
wait_ses
=-
1
):
times
=
wait_ses
*
100
times
=
wait_ses
*
100
...
@@ -115,6 +129,9 @@ if __name__ == '__main__':
...
@@ -115,6 +129,9 @@ if __name__ == '__main__':
print
(
"没有找到模拟器窗口,录屏失败!"
)
print
(
"没有找到模拟器窗口,录屏失败!"
)
exit
(
1
)
exit
(
1
)
if
args
.
wait
>
0
:
wait_sec
(
args
.
wait
)
# show_image(img)
# show_image(img)
video
=
create_video
(
args
,
img
.
shape
[
0
],
img
.
shape
[
1
])
video
=
create_video
(
args
,
img
.
shape
[
0
],
img
.
shape
[
1
])
imageNum
=
0
imageNum
=
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录