Remove : 패킷 녹화 기능 제거 (데이터 분석 완료)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7cbc8e64b2
commit
1621dbbe0e
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
@ -83,83 +81,6 @@ public class OptitrackSkeletonAnimator_Mingle : MonoBehaviour
|
|||||||
SetFilterStrength((FilterStrength)next);
|
SetFilterStrength((FilterStrength)next);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── 패킷 녹화 ──────────────────────────────────────────────────────────
|
|
||||||
[Header("패킷 녹화 (지터 분석용)")]
|
|
||||||
[Tooltip("활성화하면 raw 스냅샷 데이터를 CSV로 기록합니다")]
|
|
||||||
public bool enableRecording = false;
|
|
||||||
|
|
||||||
private StreamWriter m_csvWriter;
|
|
||||||
private float m_recordStartTime;
|
|
||||||
private bool m_isRecording;
|
|
||||||
private List<(string name, int id)> m_recordBoneList = new List<(string, int)>();
|
|
||||||
|
|
||||||
public void StartRecording()
|
|
||||||
{
|
|
||||||
if (m_isRecording) return;
|
|
||||||
if (m_skeletonDef == null) { Debug.LogWarning("[OptiTrack] 스켈레톤 미연결 — 녹화 불가"); return; }
|
|
||||||
|
|
||||||
// 전체 본 목록 구축
|
|
||||||
m_recordBoneList.Clear();
|
|
||||||
foreach (var bone in m_skeletonDef.Bones)
|
|
||||||
{
|
|
||||||
string optiName = bone.Name.Contains("_") ? bone.Name[(bone.Name.IndexOf('_') + 1)..] : bone.Name;
|
|
||||||
m_recordBoneList.Add((optiName, bone.Id));
|
|
||||||
}
|
|
||||||
|
|
||||||
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
|
||||||
string path = Path.Combine(Application.persistentDataPath, $"optitrack_raw_{timestamp}.csv");
|
|
||||||
|
|
||||||
m_csvWriter = new StreamWriter(path, false, Encoding.UTF8);
|
|
||||||
|
|
||||||
// 헤더: Time, NatNetDt, 본별 px,py,pz,rx,ry,rz,rw
|
|
||||||
var header = new StringBuilder("Time,NatNetDt");
|
|
||||||
foreach (var (name, _) in m_recordBoneList)
|
|
||||||
{
|
|
||||||
header.Append($",{name}_px,{name}_py,{name}_pz");
|
|
||||||
header.Append($",{name}_rx,{name}_ry,{name}_rz,{name}_rw");
|
|
||||||
}
|
|
||||||
m_csvWriter.WriteLine(header);
|
|
||||||
|
|
||||||
m_recordStartTime = Time.realtimeSinceStartup;
|
|
||||||
m_isRecording = true;
|
|
||||||
Debug.Log($"[OptiTrack] 녹화 시작 ({m_recordBoneList.Count}개 본): {path}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StopRecording()
|
|
||||||
{
|
|
||||||
if (!m_isRecording) return;
|
|
||||||
m_isRecording = false;
|
|
||||||
|
|
||||||
m_csvWriter?.Flush();
|
|
||||||
m_csvWriter?.Close();
|
|
||||||
m_csvWriter = null;
|
|
||||||
Debug.Log("[OptiTrack] 녹화 중지 — 파일 저장 완료");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RecordFrame()
|
|
||||||
{
|
|
||||||
if (!m_isRecording || m_csvWriter == null) return;
|
|
||||||
|
|
||||||
float elapsed = Time.realtimeSinceStartup - m_recordStartTime;
|
|
||||||
var line = new StringBuilder();
|
|
||||||
line.Append($"{elapsed:F6},{m_natNetDt:F6}");
|
|
||||||
|
|
||||||
foreach (var (_, boneId) in m_recordBoneList)
|
|
||||||
{
|
|
||||||
Vector3 pos = m_snapshotPositions.TryGetValue(boneId, out Vector3 p) ? p : Vector3.zero;
|
|
||||||
Quaternion rot = m_snapshotOrientations.TryGetValue(boneId, out Quaternion q) ? q : Quaternion.identity;
|
|
||||||
line.Append($",{pos.x:F6},{pos.y:F6},{pos.z:F6}");
|
|
||||||
line.Append($",{rot.x:F6},{rot.y:F6},{rot.z:F6},{rot.w:F6}");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_csvWriter.WriteLine(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
|
||||||
{
|
|
||||||
StopRecording();
|
|
||||||
}
|
|
||||||
|
|
||||||
private OptitrackSkeletonDefinition m_skeletonDef;
|
private OptitrackSkeletonDefinition m_skeletonDef;
|
||||||
private string previousSkeletonName;
|
private string previousSkeletonName;
|
||||||
|
|
||||||
@ -413,10 +334,6 @@ public class OptitrackSkeletonAnimator_Mingle : MonoBehaviour
|
|||||||
|
|
||||||
if (m_skeletonDef == null) return;
|
if (m_skeletonDef == null) return;
|
||||||
|
|
||||||
// enableRecording 토글 감지
|
|
||||||
if (enableRecording && !m_isRecording) StartRecording();
|
|
||||||
else if (!enableRecording && m_isRecording) StopRecording();
|
|
||||||
|
|
||||||
// 락 보호 하에 스냅샷 복사 + NatNet 하드웨어 타임스탬프 수신
|
// 락 보호 하에 스냅샷 복사 + NatNet 하드웨어 타임스탬프 수신
|
||||||
OptitrackHiResTimer.Timestamp frameTs;
|
OptitrackHiResTimer.Timestamp frameTs;
|
||||||
if (!StreamingClient.FillBoneSnapshot(m_skeletonDef.Id, m_snapshotPositions, m_snapshotOrientations, out frameTs))
|
if (!StreamingClient.FillBoneSnapshot(m_skeletonDef.Id, m_snapshotPositions, m_snapshotOrientations, out frameTs))
|
||||||
@ -432,9 +349,6 @@ public class OptitrackSkeletonAnimator_Mingle : MonoBehaviour
|
|||||||
m_lastFrameTimestamp = frameTs;
|
m_lastFrameTimestamp = frameTs;
|
||||||
m_hasLastFrameTimestamp = true;
|
m_hasLastFrameTimestamp = true;
|
||||||
|
|
||||||
// 패킷 녹화 (필터 적용 전 raw 데이터)
|
|
||||||
RecordFrame();
|
|
||||||
|
|
||||||
// ── Pass 1: Raw 데이터 적용 → IK 포인트 월드 위치 캡처 ──────────────────
|
// ── Pass 1: Raw 데이터 적용 → IK 포인트 월드 위치 캡처 ──────────────────
|
||||||
// 필터가 활성화되어 있을 때만 two-pass, 비활성이면 single-pass
|
// 필터가 활성화되어 있을 때만 two-pass, 비활성이면 single-pass
|
||||||
if (enableBoneFilter)
|
if (enableBoneFilter)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user