- capture_screenshot → RGB24 PNG (알파 정보 자동 제거, 일반 사진) - capture_alpha_screenshot → RGBA32 PNG (배경 투명, OBS/합성 소스용) - HDR/Linear RT → sRGB RT 로 Blit 한 후 ReadPixels — Spout(OBS) 결과와 동일 톤 - 코루틴 기반 임시 고해상도 캡처(captureWidth/Height) 제거 — 카메라 해상도 그대로 → Spout 송신 한 프레임 깜빡임 부작용 사라짐 - screenshot.Initialize() 시그니처 host 인자 제거(코루틴 불필요) - UXML 인스펙터: captureWidth/Height 필드 제거 + 안내 갱신 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
196 lines
6.6 KiB
C#
196 lines
6.6 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
/// <summary>
|
|
/// StreamDeck 단일 기능 버튼들을 통합 관리하는 시스템 컨트롤러
|
|
/// 각 기능은 서브매니저로 분리되어 있으며, 명령어 디스패치 파사드 역할
|
|
/// </summary>
|
|
public class SystemController : MonoBehaviour
|
|
{
|
|
[Header("OptiTrack")]
|
|
public OptiTrackManager optiTrack = new OptiTrackManager();
|
|
|
|
[Header("Facial Motion Capture")]
|
|
public FacialMotionManager facialMotion = new FacialMotionManager();
|
|
|
|
[Header("Motion Recording")]
|
|
public MotionRecordingManager motionRecording = new MotionRecordingManager();
|
|
|
|
[Header("Screenshot")]
|
|
public ScreenshotManager screenshot = new ScreenshotManager();
|
|
|
|
[Header("Cloth Simulation")]
|
|
public ClothSimulationManager clothSimulation = new ClothSimulationManager();
|
|
|
|
[Header("Avatar Head")]
|
|
public AvatarHeadManager avatarHead = new AvatarHeadManager();
|
|
|
|
[Header("Retargeting Remote")]
|
|
public RetargetingRemoteManager retargetingRemote = new RetargetingRemoteManager();
|
|
|
|
[Header("Runtime Control Panel")]
|
|
public RuntimeControlPanelManager runtimeControlPanel = new RuntimeControlPanelManager();
|
|
|
|
[Header("Debug")]
|
|
public bool enableDebugLog = true;
|
|
|
|
// 싱글톤 패턴
|
|
public static SystemController Instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
optiTrack.Initialize(Log, LogError);
|
|
facialMotion.Initialize(Log, LogError);
|
|
motionRecording.Initialize(optiTrack, Log, LogError);
|
|
screenshot.Initialize(Log, LogError);
|
|
clothSimulation.Initialize(Log, LogError);
|
|
avatarHead.Initialize(Log, LogError);
|
|
retargetingRemote.Initialize(Log, LogError);
|
|
runtimeControlPanel.Initialize(transform, Log, LogError);
|
|
|
|
Log("SystemController 초기화 완료");
|
|
Log($"OptiTrack 클라이언트: {(optiTrack.optitrackClient != null ? "설정됨" : "없음")}");
|
|
Log($"Motion Recorder 개수: {motionRecording.motionRecorders.Count}");
|
|
Log($"Facial Motion 클라이언트 개수: {facialMotion.facialMotionClients.Count}");
|
|
Log($"Screenshot 카메라: {(screenshot.screenshotCamera != null ? "설정됨" : "없음")}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 명령어 실행 - WebSocket에서 받은 명령을 적절한 매니저로 디스패치
|
|
/// </summary>
|
|
public void ExecuteCommand(string command, Dictionary<string, object> parameters)
|
|
{
|
|
Log($"명령어 실행: {command}");
|
|
|
|
switch (command)
|
|
{
|
|
// OptiTrack 마커
|
|
case "toggle_optitrack_markers":
|
|
optiTrack.ToggleOptitrackMarkers();
|
|
break;
|
|
case "show_optitrack_markers":
|
|
optiTrack.ShowOptitrackMarkers();
|
|
break;
|
|
case "hide_optitrack_markers":
|
|
optiTrack.HideOptitrackMarkers();
|
|
break;
|
|
case "reconnect_optitrack":
|
|
optiTrack.ReconnectOptitrack();
|
|
break;
|
|
case "spawn_optitrack_client":
|
|
optiTrack.SpawnOptitrackClientFromPrefab();
|
|
break;
|
|
|
|
// Facial Motion
|
|
case "reconnect_facial_motion":
|
|
facialMotion.ReconnectFacialMotion();
|
|
break;
|
|
case "refresh_facial_motion_clients":
|
|
facialMotion.RefreshFacialMotionClients();
|
|
break;
|
|
|
|
// Motion Recording
|
|
case "start_motion_recording":
|
|
motionRecording.StartMotionRecording();
|
|
break;
|
|
case "stop_motion_recording":
|
|
motionRecording.StopMotionRecording();
|
|
break;
|
|
case "toggle_motion_recording":
|
|
motionRecording.ToggleMotionRecording();
|
|
break;
|
|
case "refresh_motion_recorders":
|
|
motionRecording.RefreshMotionRecorders();
|
|
break;
|
|
|
|
// Screenshot
|
|
case "capture_screenshot":
|
|
screenshot.CaptureScreenshot();
|
|
break;
|
|
case "capture_alpha_screenshot":
|
|
screenshot.CaptureAlphaScreenshot();
|
|
break;
|
|
case "open_screenshot_folder":
|
|
screenshot.OpenScreenshotFolder();
|
|
break;
|
|
|
|
// Avatar Head
|
|
case "refresh_avatar_head_colliders":
|
|
avatarHead.RefreshAvatarHeadColliders();
|
|
break;
|
|
|
|
// MagicaCloth
|
|
case "refresh_magica_cloth":
|
|
case "reset_magica_cloth":
|
|
clothSimulation.ResetAllMagicaCloth();
|
|
break;
|
|
case "reset_magica_cloth_keep_pose":
|
|
clothSimulation.ResetAllMagicaClothKeepPose();
|
|
break;
|
|
|
|
// Retargeting Remote
|
|
case "start_retargeting_remote":
|
|
retargetingRemote.StartRetargetingRemote();
|
|
break;
|
|
case "stop_retargeting_remote":
|
|
retargetingRemote.StopRetargetingRemote();
|
|
break;
|
|
case "toggle_retargeting_remote":
|
|
retargetingRemote.ToggleRetargetingRemote();
|
|
break;
|
|
case "refresh_retargeting_characters":
|
|
retargetingRemote.AutoRegisterRetargetingCharacters();
|
|
break;
|
|
|
|
default:
|
|
LogError($"알 수 없는 명령어: {command}");
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
runtimeControlPanel.Tick();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
screenshot.Cleanup();
|
|
runtimeControlPanel.Cleanup();
|
|
}
|
|
|
|
// --- 하위 호환 프로퍼티 (StreamDeckServerManager 등 외부 참조용) ---
|
|
|
|
public OptitrackStreamingClient optitrackClient => optiTrack.optitrackClient;
|
|
public bool IsRecording() => motionRecording.IsRecording();
|
|
public List<Transform> GetAvatarHeadTargets() => avatarHead.GetAvatarHeadTargets();
|
|
public void RefreshAvatarHeadColliders() => avatarHead.RefreshAvatarHeadColliders();
|
|
public bool IsRetargetingRemoteRunning() => retargetingRemote.IsRetargetingRemoteRunning();
|
|
public string GetRetargetingRemoteUrl() => retargetingRemote.GetRetargetingRemoteUrl();
|
|
|
|
private void Log(string message)
|
|
{
|
|
if (enableDebugLog)
|
|
{
|
|
Debug.Log($"[SystemController] {message}");
|
|
}
|
|
}
|
|
|
|
private void LogError(string message)
|
|
{
|
|
Debug.LogError($"[SystemController] {message}");
|
|
}
|
|
}
|