提交 f00033a8 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 c06c33ca
...@@ -36,6 +36,7 @@ for idx, body in enumerate(bodies): ...@@ -36,6 +36,7 @@ for idx, body in enumerate(bodies):
if idx > 0: if idx > 0:
body.init_position[0] = -body.radius * body.size_scale body.init_position[0] = -body.radius * body.size_scale
body.init_position[1] = -body.diameter * body.size_scale body.init_position[1] = -body.diameter * body.size_scale
body.rotation_speed *= 20
if len(sys.argv) > 1: if len(sys.argv) > 1:
camera_pos = sys.argv[1].replace("_", "") camera_pos = sys.argv[1].replace("_", "")
...@@ -159,7 +160,7 @@ init.body_arrived = body_arrived ...@@ -159,7 +160,7 @@ init.body_arrived = body_arrived
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后- # position = 左-右+、上+下-、前+后-
ursina_run(bodies, 100, ursina_run(bodies, 10,
position=init.camera_position, position=init.camera_position,
# show_trail=init.show_trail, # show_trail=init.show_trail,
# show_timer=True, # show_timer=True,
......
...@@ -11,6 +11,8 @@ import win32api ...@@ -11,6 +11,8 @@ import win32api
import traceback import traceback
import threading import threading
window_handle = None
def get_window_handle(window_name="宇宙模拟器(universe sim)"): def get_window_handle(window_name="宇宙模拟器(universe sim)"):
""" """
...@@ -18,7 +20,9 @@ def get_window_handle(window_name="宇宙模拟器(universe sim)"): ...@@ -18,7 +20,9 @@ def get_window_handle(window_name="宇宙模拟器(universe sim)"):
@param window_name: @param window_name:
@return: @return:
""" """
global window_handle
handle = win32gui.FindWindow(None, window_name) handle = win32gui.FindWindow(None, window_name)
window_handle = handle
return handle return handle
...@@ -195,7 +199,7 @@ def clear_frame_temp_files(): ...@@ -195,7 +199,7 @@ def clear_frame_temp_files():
shutil.rmtree("frame_temp") shutil.rmtree("frame_temp")
def create_frame_temp_files_threading(file_index, left_frames, right_frames): def create_frame_temp_files(file_index, left_frames, right_frames):
data = FrameData(left_frames, right_frames) data = FrameData(left_frames, right_frames)
if not os.path.exists("frame_temp"): if not os.path.exists("frame_temp"):
os.mkdir("frame_temp") os.mkdir("frame_temp")
...@@ -204,13 +208,13 @@ def create_frame_temp_files_threading(file_index, left_frames, right_frames): ...@@ -204,13 +208,13 @@ def create_frame_temp_files_threading(file_index, left_frames, right_frames):
data.save(file_name) data.save(file_name)
def create_frame_temp_files(file_index, left_frames, right_frames): # def create_frame_temp_files(file_index, left_frames, right_frames):
import copy # import copy
#
thread1 = threading.Thread(target=create_frame_temp_files_threading, # thread1 = threading.Thread(target=create_frame_temp_files_threading,
args=[file_index, copy.deepcopy(left_frames), # args=[file_index, copy.deepcopy(left_frames),
copy.deepcopy(right_frames)]) # copy.deepcopy(right_frames)])
thread1.start() # thread1.start()
def get_frame_temp_data(): def get_frame_temp_data():
...@@ -227,6 +231,16 @@ def get_frame_temp_data(): ...@@ -227,6 +231,16 @@ def get_frame_temp_data():
return temp_frame_data return temp_frame_data
def press_pause_key():
KEY_P = win32api.VkKeyScan('P')
win32api.PostMessage(window_handle, win32con.WM_KEYDOWN, KEY_P, 0x00190001)
# win32api.PostMessage(window_handle, win32api.VkKeyScan('P'), 0x0001 | 0x0008 | 0x0010 | 0x0020, 0)
# win32api.PostMessage(0xFFFFFFF6, win32api.VkKeyScan('P'), 0x0001 | 0x0008 | 0x0010 | 0x0020, 0)
# win32api.PostMessage(window_handle, win32con.WM_KEYDOWN, win32api.VkKeyScan('P'), 0) # 发送F9键
# win32api.PostMessage(window_handle, win32con.WM_KEYUP, win32con.VK_F9, 0)
pass
def make_3d_video(): def make_3d_video():
args = get_args() args = get_args()
# handle = get_window_handle() # handle = get_window_handle()
...@@ -256,13 +270,24 @@ def make_3d_video(): ...@@ -256,13 +270,24 @@ def make_3d_video():
_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 < last_index: if imageNum % 100 == 0:
index_base += (last_index + 1) press_pause_key()
create_frame_temp_files(index + index_base, l_frames, r_frames) create_frame_temp_files(index + index_base, l_frames, r_frames)
r_frames.clear() r_frames.clear()
l_frames.clear() l_frames.clear()
r_frames = {} r_frames = {}
l_frames = {} l_frames = {}
press_pause_key()
if index < last_index:
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册