diff --git a/sim_scenes/science/speed_of_light_3d.py b/sim_scenes/science/speed_of_light_3d.py index 8198b20d73dcb8d8dc98811b69531820e8d75c67..f8fb70813a5cc554aeca218c1026bc14be6552a7 100644 --- a/sim_scenes/science/speed_of_light_3d.py +++ b/sim_scenes/science/speed_of_light_3d.py @@ -36,6 +36,7 @@ for idx, body in enumerate(bodies): if idx > 0: body.init_position[0] = -body.radius * body.size_scale body.init_position[1] = -body.diameter * body.size_scale + body.rotation_speed *= 20 if len(sys.argv) > 1: camera_pos = sys.argv[1].replace("_", "") @@ -159,7 +160,7 @@ init.body_arrived = body_arrived # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- -ursina_run(bodies, 100, +ursina_run(bodies, 10, position=init.camera_position, # show_trail=init.show_trail, # show_timer=True, diff --git a/tools/sim_video_3d_cap_ext.py b/tools/sim_video_3d_cap_ext.py index 7b6dc7332fca42159f67d3e95aa21859d554d268..78de7fb8b91b9111703ee03ed025bc7e2536be9b 100644 --- a/tools/sim_video_3d_cap_ext.py +++ b/tools/sim_video_3d_cap_ext.py @@ -11,6 +11,8 @@ import win32api import traceback import threading +window_handle = None + def get_window_handle(window_name="宇宙模拟器(universe sim)"): """ @@ -18,7 +20,9 @@ def get_window_handle(window_name="宇宙模拟器(universe sim)"): @param window_name: @return: """ + global window_handle handle = win32gui.FindWindow(None, window_name) + window_handle = handle return handle @@ -195,7 +199,7 @@ def clear_frame_temp_files(): 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) if not os.path.exists("frame_temp"): os.mkdir("frame_temp") @@ -204,13 +208,13 @@ def create_frame_temp_files_threading(file_index, left_frames, right_frames): data.save(file_name) -def create_frame_temp_files(file_index, left_frames, right_frames): - import copy - - thread1 = threading.Thread(target=create_frame_temp_files_threading, - args=[file_index, copy.deepcopy(left_frames), - copy.deepcopy(right_frames)]) - thread1.start() +# def create_frame_temp_files(file_index, left_frames, right_frames): +# import copy +# +# thread1 = threading.Thread(target=create_frame_temp_files_threading, +# args=[file_index, copy.deepcopy(left_frames), +# copy.deepcopy(right_frames)]) +# thread1.start() def get_frame_temp_data(): @@ -227,6 +231,16 @@ def get_frame_temp_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(): args = get_args() # handle = get_window_handle() @@ -256,13 +270,24 @@ def make_3d_video(): _3d_card_p = _3d_card[10, 10,] index = int(_3d_card_p[1]) + int(_3d_card_p[0]) - if index < last_index: - index_base += (last_index + 1) + if imageNum % 100 == 0: + 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() + + 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 index = index + index_base