diff --git a/sim_scenes/func.py b/sim_scenes/func.py index 2064cc844a29e95b3f841a80dba2754c744ff410..df092f8a8d298d9300fb6fcdb8bfb225c5ee9f20 100644 --- a/sim_scenes/func.py +++ b/sim_scenes/func.py @@ -306,18 +306,36 @@ def create_3d_card(left=-.885, top=0.495, width=0.02, height=0.02): scale=(width, height), position=(left, top, 0) ) - + panel.color = color.rgba(0, 0, 0, 1) panel.switch_flag = 0 + panel.switch_count = [0, 0] + + def switch_count_inc(): + num1 = panel.switch_count[1] + if num1 >= 255: + panel.switch_count[1] = 0 + panel.switch_count[0] = 0 + + num0 = panel.switch_count[0] + if num0 >= 255: + panel.switch_count[1] += 1 + else: + panel.switch_count[0] += 1 + + def get_switch_index(): + return panel.switch_count[1] + panel.switch_count[0] def switch_color(): - if panel.color == color.black: - panel.color = color.white + if panel.color.r == 0: + panel.color = color.rgba(255, panel.switch_count[1], panel.switch_count[0], 255) panel.switch_flag = 1 else: - panel.color = color.black + panel.color = color.rgba(0, panel.switch_count[1], panel.switch_count[0], 255) panel.switch_flag = 0 + switch_count_inc() panel.switch_color = switch_color + panel.get_switch_index = get_switch_index return panel diff --git a/simulators/ursina_simulator.py b/simulators/ursina_simulator.py index e196871fc93357e5fda67446df1dd976ecc49067..b26c55c7edee1b9ec6bedfce0d32e1f21229aed1 100644 --- a/simulators/ursina_simulator.py +++ b/simulators/ursina_simulator.py @@ -37,7 +37,7 @@ class UrsinaSimulator(Simulator): def __init__(self, bodies_sys: System): # window.borderless = False - window.title = 'universe_sim' # '宇宙模拟器' + window.title = '宇宙模拟器(universe sim)' # 'universe_sim' # '宇宙模拟器' icon = find_file("images/icon.ico") window.icon = icon self.app = Ursina() diff --git a/tools/sim_video_3d_cap.py b/tools/sim_video_3d_cap.py index 4750e5d19256711af0480470e01129db4568c7a8..47d9c2a7aa51747c3768690a05ff5dfff31e380c 100644 --- a/tools/sim_video_3d_cap.py +++ b/tools/sim_video_3d_cap.py @@ -11,7 +11,7 @@ import win32api import traceback -def get_window_handle(window_name="universe_sim"): +def get_window_handle(window_name="宇宙模拟器(universe sim)"): """ 获取模拟器窗口句柄 @param window_name: @@ -96,13 +96,13 @@ def create_video(args, height, width): return video -# def show_image(img): -# from PIL import Image -# image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) -# image = Image.fromarray(image) -# print(type(image)) # 结果为 -# print(image.size) # 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数 -# image.show() +def show_image(img): + from PIL import Image + image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) + image = Image.fromarray(image) + print(type(image)) # 结果为 + print(image.size) # 结果为(822,694),这里注意Image输出的结果先显示列数,后显示行数 + image.show() if __name__ == '__main__': @@ -118,6 +118,8 @@ if __name__ == '__main__': # show_image(img) video = create_video(args, img.shape[0], img.shape[1]) imageNum = 0 + r_frames = [] + l_frames = [] print("开始录屏") while True: img = sim_window_screen_shot() @@ -125,6 +127,17 @@ if __name__ == '__main__': print("\n模拟器窗口已关闭,退出录屏") break + _3d_card = img[4:20, 3:20, ] + _3d_card_p = _3d_card[10, 10, ] + if _3d_card_p[2] < 100: + _3d_card_color = "b" + _3d_card_direct = "right" + r_frames.append((_3d_card_p[1]+_3d_card_p[0], img[:432, :768, ])) + else: + _3d_card_color = "w" + _3d_card_direct = "left" + l_frames.append((_3d_card_p[1]+_3d_card_p[0], img[:432, :768, ])) + # if is_blank_screen(img): # if imageNum % args.fps == 0: # print('x', end='') @@ -139,9 +152,10 @@ if __name__ == '__main__': imageNum += 1 # frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) - if imageNum < args.fps * args.total_time: - # show_image(frame) - video.write(img) + # if imageNum < args.fps * args.total_time: + # # img = img[:432,:768,] + # # show_image(frame) + # video.write(img) print("视频保存中") video.release()