diff --git a/src-python/model.py b/src-python/model.py index f865c2d8..23621e92 100644 --- a/src-python/model.py +++ b/src-python/model.py @@ -82,11 +82,13 @@ class Model: self.previous_receive_message = "" self.translator = Translator() self.keyword_processor = KeywordProcessor() + overlay_small_log_settings = copy.deepcopy(config.OVERLAY_SMALL_LOG_SETTINGS) + overlay_large_log_settings = copy.deepcopy(config.OVERLAY_LARGE_LOG_SETTINGS) + overlay_large_log_settings["ui_scaling"] = overlay_large_log_settings["ui_scaling"] * 0.25 overlay_settings = { - "small": config.OVERLAY_SMALL_LOG_SETTINGS, - "large": config.OVERLAY_LARGE_LOG_SETTINGS, + "small": overlay_small_log_settings, + "large": overlay_large_log_settings, } - overlay_settings["large"]["ui_scaling"] = copy.copy(config.OVERLAY_LARGE_LOG_SETTINGS["ui_scaling"]*0.25) self.overlay = Overlay(overlay_settings) self.overlay_image = OverlayImage() self.mic_audio_queue = None @@ -747,7 +749,7 @@ class Model: self.overlay.updateDisplayDuration(config.OVERLAY_LARGE_LOG_SETTINGS["display_duration"], size) self.overlay.updateFadeoutDuration(config.OVERLAY_LARGE_LOG_SETTINGS["fadeout_duration"], size) self.overlay.updateOpacity(config.OVERLAY_LARGE_LOG_SETTINGS["opacity"], size, True) - self.overlay.updateUiScaling(config.OVERLAY_LARGE_LOG_SETTINGS["ui_scaling"]*0.25, size) + self.overlay.updateUiScaling(config.OVERLAY_LARGE_LOG_SETTINGS["ui_scaling"] * 0.25, size) def startOverlay(self): self.overlay.startOverlay() diff --git a/src-python/models/overlay/overlay.py b/src-python/models/overlay/overlay.py index b486c77a..8f7bbe6f 100644 --- a/src-python/models/overlay/overlay.py +++ b/src-python/models/overlay/overlay.py @@ -47,22 +47,22 @@ def getHMDBaseMatrix(): return arr def getLeftHandBaseMatrix(): - x_pos = 0.0 - y_pos = -0.06 - z_pos = -0.14 - x_rotation = -62.0 - y_rotation = 154.0 - z_rotation = 71.0 + x_pos = 0.3 + y_pos = 0.1 + z_pos = -0.31 + x_rotation = -65.0 + y_rotation = 165.0 + z_rotation = 115.0 arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation) return arr def getRightHandBaseMatrix(): - x_pos = 0.0 - y_pos = -0.06 - z_pos = -0.14 - x_rotation = -62.0 - y_rotation = -154.0 - z_rotation = -71.0 + x_pos = -0.3 + y_pos = 0.1 + z_pos = -0.31 + x_rotation = -65.0 + y_rotation = -165.0 + z_rotation = -115.0 arr = getBaseMatrix(x_pos, y_pos, z_pos, x_rotation, y_rotation, z_rotation) return arr @@ -286,6 +286,9 @@ class Overlay: if __name__ == "__main__": from overlay_image import OverlayImage + import logging + + logging.basicConfig(level=logging.DEBUG) small_settings = { "x_pos": 0.0, @@ -294,10 +297,10 @@ if __name__ == "__main__": "x_rotation": 0.0, "y_rotation": 0.0, "z_rotation": 0.0, - "display_duration": 5, - "fadeout_duration": 2, + "display_duration": 0, + "fadeout_duration": 100, "opacity": 1.0, - "ui_scaling": 0.5, + "ui_scaling": 1.0, "tracker": "HMD", } @@ -308,11 +311,11 @@ if __name__ == "__main__": "x_rotation": 0.0, "y_rotation": 0.0, "z_rotation": 0.0, - "display_duration": 5, - "fadeout_duration": 0, + "display_duration": 0, + "fadeout_duration": 100, "opacity": 1.0, - "ui_scaling": 0.5, - "tracker": "LeftHand", + "ui_scaling": 1.0, + "tracker": "RightHand", } settings_dict = { @@ -320,6 +323,9 @@ if __name__ == "__main__": "large": large_settings } + # オーバーレイの初期化設定を確認 + logging.debug(f"Settings Dict: {settings_dict}") + overlay_image = OverlayImage() overlay = Overlay(settings_dict) overlay.startOverlay() @@ -328,19 +334,31 @@ if __name__ == "__main__": time.sleep(1) # Example usage - img = overlay_image.createOverlayImageLargeLog("send", "こんにちは、世界!さようなら", "Japanese", "Hello,World!Goodbye", "Japanese") - overlay.updateImage(img, "large") - for i in range(100): - print(i) - # Example usage - img = overlay_image.createOverlayImageSmallLog(f"こんにちは、世界!さようなら_{i}", "Japanese", "Hello,World!Goodbye", "Japanese") - overlay.updateImage(img, "small") - time.sleep(5) + try: + img = overlay_image.createOverlayImageLargeLog("send", f"こんにちは、世界!さようなら {i}", "Japanese", "Hello,World!Goodbye", "Japanese") + logging.debug(f"Generated Image: {img}") + overlay.updateImage(img, "large") + img = overlay_image.createOverlayImageSmallLog(f"こんにちは、世界!さようなら_{i}", "Japanese", "Hello,World!Goodbye", "Japanese") + overlay.updateImage(img, "small") + time.sleep(1) + except openvr.error_code.OverlayError_InvalidParameter as e: + logging.error(f"OverlayError_InvalidParameter: {e}") + break + except Exception as e: + logging.error(f"Unexpected error: {e}") + break - if i%2 == 0: - overlay.updatePosition(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "HMD", "small") - else: - overlay.updatePosition(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "RightHand", "small") + # for i in range(100): + # print(i) + # # Example usage + # img = overlay_image.createOverlayImageSmallLog(f"こんにちは、世界!さようなら_{i}", "Japanese", "Hello,World!Goodbye", "Japanese") + # overlay.updateImage(img, "small") + # time.sleep(5) + + # if i%2 == 0: + # overlay.updatePosition(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "HMD", "small") + # else: + # overlay.updatePosition(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, "RightHand", "small") overlay.shutdownOverlay() \ No newline at end of file diff --git a/src-python/models/overlay/overlay_image.py b/src-python/models/overlay/overlay_image.py index 5f9b0e6f..11a1c07e 100644 --- a/src-python/models/overlay/overlay_image.py +++ b/src-python/models/overlay/overlay_image.py @@ -96,13 +96,13 @@ class OverlayImage: @staticmethod def getUiSizeLargeLog() -> dict: return { - "width": 960*4, - "font_size_large": 30*4, - "font_size_small": 20*4, - "margin": 25*4, - "radius": 25*4, - "padding": 10*4, - "clause_margin": 20*4, + "width": 960, + "font_size_large": 30, + "font_size_small": 20, + "margin": 25, + "radius": 25, + "padding": 10, + "clause_margin": 20, } @staticmethod @@ -211,8 +211,8 @@ class OverlayImage: "datetime": datetime.now().strftime("%H:%M") }) - if len(self.message_log) > 10: - self.message_log = self.message_log[-10:] + if len(self.message_log) > 5: + self.message_log = self.message_log[-5:] imgs = [ self.createTextboxLargeLog(