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
@@ -69,6 +69,8 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
private UmaContainer container;
float aposeDegress = 38.5f;
public bool IsLive;
public void Initialize()
{
Time.fixedDeltaTime = FPSs;
@@ -172,7 +174,7 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
private void FixedUpdate()
{
if (IsRecording)
if (IsRecording && !IsLive)
{
SaveFrame();
FrameNumber++;
@@ -315,6 +317,15 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
}
}
void LiveSaveFrame()
{
if (IsRecording && IsLive)
{
SaveFrame();
FrameNumber++;
}
}
void SetInitialPositionAndRotation()
{
if (UseAbsoluteCoordinateSystem)
@@ -337,10 +348,17 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
/// <summary>
/// レコーディングを開始または再開
/// </summary>
public void StartRecording()
public void StartRecording(bool islive = false)
{
SetInitialPositionAndRotation();
IsRecording = true;
IsLive = islive;
if (islive)
{
var director = Gallop.Live.Director.instance;
director._liveTimelineControl.RecordUma += LiveSaveFrame;
}
}
/// <summary>
@@ -369,6 +387,12 @@ public class UnityHumanoidVMDRecorder : MonoBehaviour
rotationDictionary.Add(boneName, new List<Quaternion>());
}
morphRecorder = new MorphRecorder(transform);
if (IsLive)
{
var director = Gallop.Live.Director.instance;
director._liveTimelineControl.RecordUma -= LiveSaveFrame;
}
}
/// <summary>
@@ -14,6 +14,7 @@ public class LiveViewerUI : MonoBehaviour
public Dropdown FrameRateDropDown;
public GameObject RecordingUI;
float targetHeight = 0;
float height;
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.InitializeMusic(live.MusicId, characters);
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 List<LiveCameraFrame> RecordFrames = new List<LiveCameraFrame>();
public List<List<LiveCameraFrame>> MultiRecordFrames = new List<List<LiveCameraFrame>>();
public event Action RecordUma;
public float currentLiveTime
{
@@ -307,10 +308,10 @@ namespace Gallop.Live.Cutt
_isNowAlterUpdate = true;
_oldLiveTime = currentLiveTime;
currentLiveTime = liveTime;
_currentFrame = currentLiveTime * 60f;
_oldFrame = _oldLiveTime * 60f;
_deltaTime = currentLiveTime - _oldLiveTime;
_deltaTimeRatio = _deltaTime / 0.0166666675f;
_currentFrame = currentLiveTime * 60f;
AlterUpdate_CharaMotionSequence(liveTime);
AlterUpdate_FacialData(liveTime);
AlterUpdate_LipSync(liveTime);
@@ -355,6 +356,8 @@ namespace Gallop.Live.Cutt
LiveCameraFrame mulframe = new LiveCameraFrame(currentFrame, MulCamera.transform, cam.fieldOfView, lastMulframe);
MulFrame.Add(mulframe);
}
if (currentFrame % 2 == 0) RecordUma?.Invoke();
}
}
@@ -80,13 +80,12 @@ namespace Gallop.Live.Cutt
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.instance.sliderControl.is_Touched)
if (director.sliderControl.is_Touched || director.IsRecordVMD)
{
_tempAnim[_targetAnim.name].time = currentTime;
_tempAnim.Play(_targetAnim.name);
@@ -108,7 +107,7 @@ namespace Gallop.Live.Cutt
_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;
@@ -623,7 +623,7 @@ namespace Gallop.Live
newRecorder.Initialize();
if (!newRecorder.IsRecording)
{
newRecorder.StartRecording();
newRecorder.StartRecording(true);
}
}
}
@@ -660,13 +660,28 @@ namespace Gallop.Live
}
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;
if (liveMusic != null)
{
UmaViewerAudio.SetTime(liveMusic, _liveCurrentTime);
foreach (var vocal in liveVocal)
@@ -706,20 +721,20 @@ namespace Gallop.Live
else
{
_liveCurrentTime += Time.deltaTime;
//Debug.Log(_liveCurrentTime * 60);
UI.ProgressBar.SetValueWithoutNotify(_liveCurrentTime / totalTime);
OnTimelineUpdate(_liveCurrentTime);
}
}
UpdateMainCamera();
}
UpdateMainCamera();
}
private void LateUpdate()
{
_liveTimelineControl.AlterLateUpdate();
if (_isLiveSetup && _syncTime && !IsRecordVMD)
{
_liveTimelineControl.AlterLateUpdate();
}
}
DateTime ExitTime;