improve live recording

This commit is contained in:
CroakFang
2023-08-05 22:30:16 +08:00
parent f624b6e0de
commit ee5ca42421
7 changed files with 142 additions and 18 deletions
+82 -1
View File
@@ -2831,6 +2831,85 @@ RectTransform:
m_AnchoredPosition: {x: -7.5, y: -0.5} m_AnchoredPosition: {x: -7.5, y: -0.5}
m_SizeDelta: {x: -35, y: -13} m_SizeDelta: {x: -35, y: -13}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1950769033
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1950769034}
- component: {fileID: 1950769036}
- component: {fileID: 1950769035}
m_Layer: 5
m_Name: Recording
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1950769034
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1950769033}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2146838901}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1950769035
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1950769033}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 036631af73b15ac41a9d10f75f5bbafe, type: 3}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 49
m_Alignment: 2
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\u25CF Recording...\n"
--- !u!222 &1950769036
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1950769033}
m_CullTransparentMesh: 1
--- !u!1 &1975009925 --- !u!1 &1975009925
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -2895,7 +2974,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 2146838901} m_Father: {fileID: 2146838901}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1988617878 --- !u!1 &1988617878
GameObject: GameObject:
@@ -3056,6 +3135,7 @@ MonoBehaviour:
ProgressBar: {fileID: 912298141} ProgressBar: {fileID: 912298141}
BottonUITransform: {fileID: 1107325621} BottonUITransform: {fileID: 1107325621}
FrameRateDropDown: {fileID: 499218592} FrameRateDropDown: {fileID: 499218592}
RecordingUI: {fileID: 1950769033}
--- !u!81 &2017920250 --- !u!81 &2017920250
AudioListener: AudioListener:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3394,6 +3474,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 679139655} - {fileID: 679139655}
- {fileID: 61452365} - {fileID: 61452365}
- {fileID: 1950769034}
- {fileID: 1975009928} - {fileID: 1975009928}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
@@ -69,6 +69,8 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
private UmaContainer container; private UmaContainer container;
float aposeDegress = 38.5f; float aposeDegress = 38.5f;
public bool IsLive;
public void Initialize() public void Initialize()
{ {
Time.fixedDeltaTime = FPSs; Time.fixedDeltaTime = FPSs;
@@ -172,7 +174,7 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
private void FixedUpdate() private void FixedUpdate()
{ {
if (IsRecording) if (IsRecording && !IsLive)
{ {
SaveFrame(); SaveFrame();
FrameNumber++; FrameNumber++;
@@ -315,6 +317,15 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
} }
} }
void LiveSaveFrame()
{
if (IsRecording && IsLive)
{
SaveFrame();
FrameNumber++;
}
}
void SetInitialPositionAndRotation() void SetInitialPositionAndRotation()
{ {
if (UseAbsoluteCoordinateSystem) if (UseAbsoluteCoordinateSystem)
@@ -337,10 +348,17 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
/// <summary> /// <summary>
/// レコーディングを開始または再開 /// レコーディングを開始または再開
/// </summary> /// </summary>
public void StartRecording() public void StartRecording(bool islive = false)
{ {
SetInitialPositionAndRotation(); SetInitialPositionAndRotation();
IsRecording = true; IsRecording = true;
IsLive = islive;
if (islive)
{
var director = Gallop.Live.Director.instance;
director._liveTimelineControl.RecordUma += LiveSaveFrame;
}
} }
/// <summary> /// <summary>
@@ -369,6 +387,12 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
rotationDictionary.Add(boneName, new List<Quaternion>()); rotationDictionary.Add(boneName, new List<Quaternion>());
} }
morphRecorder = new MorphRecorder(transform); morphRecorder = new MorphRecorder(transform);
if (IsLive)
{
var director = Gallop.Live.Director.instance;
director._liveTimelineControl.RecordUma -= LiveSaveFrame;
}
} }
/// <summary> /// <summary>
@@ -14,6 +14,7 @@ public class LiveViewerUI : MonoBehaviour
public Dropdown FrameRateDropDown; public Dropdown FrameRateDropDown;
public GameObject RecordingUI;
float targetHeight = 0; float targetHeight = 0;
float height; float height;
private void Awake() private void Awake()
+1
View File
@@ -704,6 +704,7 @@ public class UmaViewerBuilder : MonoBehaviour
Gallop.Live.Director.instance.InitializeTimeline(characters, UI.LiveMode); Gallop.Live.Director.instance.InitializeTimeline(characters, UI.LiveMode);
Gallop.Live.Director.instance.InitializeMusic(live.MusicId, characters); Gallop.Live.Director.instance.InitializeMusic(live.MusicId, characters);
Gallop.Live.Director.instance.Play(); Gallop.Live.Director.instance.Play();
LiveViewerUI.Instance.RecordingUI.SetActive(Gallop.Live.Director.instance.IsRecordVMD);
} }
); );
} }
@@ -101,6 +101,7 @@ namespace Gallop.Live.Cutt
public bool IsRecordVMD; public bool IsRecordVMD;
public List<LiveCameraFrame> RecordFrames = new List<LiveCameraFrame>(); public List<LiveCameraFrame> RecordFrames = new List<LiveCameraFrame>();
public List<List<LiveCameraFrame>> MultiRecordFrames = new List<List<LiveCameraFrame>>(); public List<List<LiveCameraFrame>> MultiRecordFrames = new List<List<LiveCameraFrame>>();
public event Action RecordUma;
public float currentLiveTime public float currentLiveTime
{ {
@@ -307,10 +308,10 @@ namespace Gallop.Live.Cutt
_isNowAlterUpdate = true; _isNowAlterUpdate = true;
_oldLiveTime = currentLiveTime; _oldLiveTime = currentLiveTime;
currentLiveTime = liveTime; currentLiveTime = liveTime;
_currentFrame = currentLiveTime * 60f;
_oldFrame = _oldLiveTime * 60f; _oldFrame = _oldLiveTime * 60f;
_deltaTime = currentLiveTime - _oldLiveTime; _deltaTime = currentLiveTime - _oldLiveTime;
_deltaTimeRatio = _deltaTime / 0.0166666675f; _deltaTimeRatio = _deltaTime / 0.0166666675f;
_currentFrame = currentLiveTime * 60f;
AlterUpdate_CharaMotionSequence(liveTime); AlterUpdate_CharaMotionSequence(liveTime);
AlterUpdate_FacialData(liveTime); AlterUpdate_FacialData(liveTime);
AlterUpdate_LipSync(liveTime); AlterUpdate_LipSync(liveTime);
@@ -355,6 +356,8 @@ namespace Gallop.Live.Cutt
LiveCameraFrame mulframe = new LiveCameraFrame(currentFrame, MulCamera.transform, cam.fieldOfView, lastMulframe); LiveCameraFrame mulframe = new LiveCameraFrame(currentFrame, MulCamera.transform, cam.fieldOfView, lastMulframe);
MulFrame.Add(mulframe); MulFrame.Add(mulframe);
} }
if (currentFrame % 2 == 0) RecordUma?.Invoke();
} }
} }
@@ -80,13 +80,12 @@ namespace Gallop.Live.Cutt
public void AlterUpdate(float currentTime) public void AlterUpdate(float currentTime)
{ {
if(Director.instance.liveMode == 0) var director = Director.instance;
if (Director.instance.liveMode == 0)
{ {
if (_targetAnim != null)
if(_targetAnim != null)
{ {
//_tempAnim[_targetAnim.name].time = currentTime; if (director.sliderControl.is_Touched || director.IsRecordVMD)
if (Director.instance.sliderControl.is_Touched)
{ {
_tempAnim[_targetAnim.name].time = currentTime; _tempAnim[_targetAnim.name].time = currentTime;
_tempAnim.Play(_targetAnim.name); _tempAnim.Play(_targetAnim.name);
@@ -108,7 +107,7 @@ namespace Gallop.Live.Cutt
_curIndex = curKey.index; _curIndex = curKey.index;
if ((curKey != null && _curIndex != -1 && _curIndex != _prevIndex) || Director.instance.sliderControl.is_Touched || Director.instance._syncTime == false) if ((curKey != null && _curIndex != -1 && _curIndex != _prevIndex) || Director.instance.sliderControl.is_Touched || Director.instance._syncTime == false || director.IsRecordVMD)
{ {
LiveTimelineKeyCharaMotionData arg = curKey.key as LiveTimelineKeyCharaMotionData; LiveTimelineKeyCharaMotionData arg = curKey.key as LiveTimelineKeyCharaMotionData;
@@ -623,7 +623,7 @@ namespace Gallop.Live
newRecorder.Initialize(); newRecorder.Initialize();
if (!newRecorder.IsRecording) if (!newRecorder.IsRecording)
{ {
newRecorder.StartRecording(); newRecorder.StartRecording(true);
} }
} }
} }
@@ -660,13 +660,28 @@ namespace Gallop.Live
} }
else else
{ {
if (sliderControl.is_Outed) if (IsRecordVMD)
{
_liveCurrentTime += (1/60f);
if (liveMusic != null)
{
UmaViewerAudio.Stop(liveMusic);
foreach (var vocal in liveVocal)
{
UmaViewerAudio.Stop(vocal);
}
}
UI.ProgressBar.SetValueWithoutNotify(_liveCurrentTime / totalTime);
OnTimelineUpdate(_liveCurrentTime);
_liveTimelineControl.AlterLateUpdate();
}
else if (sliderControl.is_Outed)
{ {
_liveCurrentTime = UI.ProgressBar.value * totalTime; _liveCurrentTime = UI.ProgressBar.value * totalTime;
if (liveMusic != null) if (liveMusic != null)
{ {
UmaViewerAudio.SetTime(liveMusic, _liveCurrentTime); UmaViewerAudio.SetTime(liveMusic, _liveCurrentTime);
foreach (var vocal in liveVocal) foreach (var vocal in liveVocal)
@@ -706,20 +721,20 @@ namespace Gallop.Live
else else
{ {
_liveCurrentTime += Time.deltaTime; _liveCurrentTime += Time.deltaTime;
//Debug.Log(_liveCurrentTime * 60);
UI.ProgressBar.SetValueWithoutNotify(_liveCurrentTime / totalTime); UI.ProgressBar.SetValueWithoutNotify(_liveCurrentTime / totalTime);
OnTimelineUpdate(_liveCurrentTime); OnTimelineUpdate(_liveCurrentTime);
} }
} }
UpdateMainCamera();
} }
UpdateMainCamera();
} }
private void LateUpdate() private void LateUpdate()
{ {
_liveTimelineControl.AlterLateUpdate(); if (_isLiveSetup && _syncTime && !IsRecordVMD)
{
_liveTimelineControl.AlterLateUpdate();
}
} }
DateTime ExitTime; DateTime ExitTime;