diff --git a/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs b/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs index c6eb325e..8f590a85 100644 --- a/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs +++ b/Assets/Scripts/KindRetargeting/CustomRetargetingScript.cs @@ -134,6 +134,19 @@ namespace KindRetargeting public List rotationOffsetCache; public float initialHipsHeight; public float avatarScale; + + // LimbWeightController 설정들 + public float maxDistance; + public float minDistance; + public float weightSmoothSpeed; + public float hipsMinDistance; + public float hipsMaxDistance; + public bool useFixedChairGap; + public float chairHipsFixedGap; + public float groundHipsMinHeight; + public float groundHipsMaxHeight; + public float footHeightMinThreshold; + public float footHeightMaxThreshold; } // 각 손가락 관절별로 필터 버퍼를 관리하는 Dictionary 추가 @@ -340,6 +353,9 @@ namespace KindRetargeting offsetCache.Add(new RotationOffsetData((int)kvp.Key, kvp.Value)); } + // LimbWeightController 컴포넌트 가져오기 + var limbWeightController = GetComponent(); + var settings = new RetargetingSettings { hipsWeight = hipsWeight, @@ -356,6 +372,19 @@ namespace KindRetargeting rotationOffsetCache = offsetCache, initialHipsHeight = initialHipsHeight, avatarScale = avatarScale, + + // LimbWeightController 설정들 저장 + maxDistance = limbWeightController?.maxDistance ?? 0.5f, + minDistance = limbWeightController?.minDistance ?? 0.1f, + weightSmoothSpeed = limbWeightController?.weightSmoothSpeed ?? 10f, + hipsMinDistance = limbWeightController?.hipsMinDistance ?? 0.2f, + hipsMaxDistance = limbWeightController?.hipsMaxDistance ?? 0.6f, + useFixedChairGap = limbWeightController?.useFixedChairGap ?? true, + chairHipsFixedGap = limbWeightController?.chairHipsFixedGap ?? 0.1f, + groundHipsMinHeight = limbWeightController?.groundHipsMinHeight ?? 0f, + groundHipsMaxHeight = limbWeightController?.groundHipsMaxHeight ?? 0.5f, + footHeightMinThreshold = limbWeightController?.footHeightMinThreshold ?? 0.2f, + footHeightMaxThreshold = limbWeightController?.footHeightMaxThreshold ?? 0.5f, }; string json = JsonUtility.ToJson(settings, true); @@ -412,6 +441,23 @@ namespace KindRetargeting initialHipsHeight = settings.initialHipsHeight; avatarScale = settings.avatarScale; previousScale = avatarScale; + + // LimbWeightController 설정들 로드 + var limbWeightController = GetComponent(); + if (limbWeightController != null) + { + limbWeightController.maxDistance = settings.maxDistance; + limbWeightController.minDistance = settings.minDistance; + limbWeightController.weightSmoothSpeed = settings.weightSmoothSpeed; + limbWeightController.hipsMinDistance = settings.hipsMinDistance; + limbWeightController.hipsMaxDistance = settings.hipsMaxDistance; + limbWeightController.useFixedChairGap = settings.useFixedChairGap; + limbWeightController.chairHipsFixedGap = settings.chairHipsFixedGap; + limbWeightController.groundHipsMinHeight = settings.groundHipsMinHeight; + limbWeightController.groundHipsMaxHeight = settings.groundHipsMaxHeight; + limbWeightController.footHeightMinThreshold = settings.footHeightMinThreshold; + limbWeightController.footHeightMaxThreshold = settings.footHeightMaxThreshold; + } diff --git a/Assets/Scripts/KindRetargeting/Editor/RetargetingControlWindow.cs b/Assets/Scripts/KindRetargeting/Editor/RetargetingControlWindow.cs index 0e7a8306..0626ef1a 100644 --- a/Assets/Scripts/KindRetargeting/Editor/RetargetingControlWindow.cs +++ b/Assets/Scripts/KindRetargeting/Editor/RetargetingControlWindow.cs @@ -448,6 +448,7 @@ public class RetargetingControlWindow : EditorWindow limb.weightSmoothSpeed = 10f; limb.groundHipsMinHeight = 0.3f; limb.groundHipsMaxHeight = 0.7f; + limb.chairHipsFixedGap = 0.1f; EditorUtility.SetDirty(limb); } @@ -491,6 +492,8 @@ public class RetargetingControlWindow : EditorWindow preset.limbMinDistance = limb.minDistance; preset.footHeightMinThreshold = limb.footHeightMinThreshold; preset.footHeightMaxThreshold = limb.footHeightMaxThreshold; + preset.useFixedChairGap = limb.useFixedChairGap; + preset.chairHipsFixedGap = limb.chairHipsFixedGap; } presets[currentPresetName] = preset; @@ -519,6 +522,8 @@ public class RetargetingControlWindow : EditorWindow limb.minDistance = preset.limbMinDistance; limb.footHeightMinThreshold = preset.footHeightMinThreshold; limb.footHeightMaxThreshold = preset.footHeightMaxThreshold; + limb.useFixedChairGap = preset.useFixedChairGap; + limb.chairHipsFixedGap = preset.chairHipsFixedGap; } EditorUtility.SetDirty(script); @@ -919,7 +924,7 @@ public class RetargetingControlWindow : EditorWindow EditorGUILayout.PropertyField(useFixedChairGap, new GUIContent("의자 고정 간격 사용")); if (useFixedChairGap.boolValue) { - EditorGUILayout.PropertyField(chairHipsFixedGap, new GUIContent("의자-허리 고정 간격")); + EditorGUILayout.Slider(chairHipsFixedGap, 0f, 0.3f, new GUIContent("의자-허리 고정 간격")); } EditorGUILayout.Space(5); @@ -1197,5 +1202,7 @@ public class RetargetingPreset public float limbMinDistance; public float footHeightMinThreshold; public float footHeightMaxThreshold; + public bool useFixedChairGap; + public float chairHipsFixedGap; // ... 기타 필요한 설정들 } \ No newline at end of file diff --git a/Assets/Scripts/KindRetargeting/LimbWeightController.cs b/Assets/Scripts/KindRetargeting/LimbWeightController.cs index de577dd7..35a568ee 100644 --- a/Assets/Scripts/KindRetargeting/LimbWeightController.cs +++ b/Assets/Scripts/KindRetargeting/LimbWeightController.cs @@ -22,7 +22,7 @@ namespace KindRetargeting [Header("의자 거리 기반 허리 높이 설정")] [SerializeField] public bool useFixedChairGap = true; // 고정 간격 사용 여부 - [SerializeField, Range(0.1f, 1f)] public float chairHipsFixedGap = 0.2f; // 의자와 허리 간 고정 간격 + [SerializeField, Range(0f, 0.3f)] public float chairHipsFixedGap = 0.1f; // 의자와 허리 간 고정 간격 [Header("바닥 기준 히프 보정")] [SerializeField, Range(0.3f, 1f)] public float groundHipsMinHeight = 0f; // 최소 높이 (가중치 0)