LiveTimelineEyeData support

This commit is contained in:
左右看
2023-07-06 02:48:51 +08:00
parent c6641f85d1
commit 998ec9d14f
21 changed files with 573 additions and 279 deletions
@@ -1,24 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class LoadSound : ScriptableObject
{
UmaViewerMain Main => UmaViewerMain.Instance;
public struct UmaSoundInfo
{
public string acbPath;
public string awbPath;
}
public UmaSoundInfo getSoundPath(string name) {
UmaSoundInfo info;
info.acbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("acb")).FilePath;
info.awbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("awb")).FilePath;
return info;
}
}
@@ -4,6 +4,9 @@ using UnityEngine;
using Gallop;
using System.IO;
using static UmaViewerUI;
using System.Xml.Linq;
using System.Windows.Markup;
using System;
public class UmaDatabaseEntry
{
@@ -121,6 +124,32 @@ public class LiveEntry
}
}
public class PartEntry
{
public Dictionary<string, List<float>> PartSettings = new Dictionary<string, List<float>>();
public PartEntry(string data)
{
string[] lines = data.Split("\n"[0]);
string[] names = lines[0].Split(',');
foreach (var name in names)
{
PartSettings[name] = new List<float>();
}
for (int i = 1; i < lines.Length - 1; i++)
{
var values = lines[i].Split(',');
for (int j = 0; j < names.Length; j++)
{
PartSettings[names[j]].Add((float)Convert.ToDouble(values[j]));
}
}
}
}
[System.Serializable]
public class CostumeEntry
+118 -61
View File
@@ -3,83 +3,140 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static CriWare.CriAtomExCategory.ReactDuckerParameter;
public class UmaViewerAudio
{
static public void LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb)
static UmaViewerMain Main => UmaViewerMain.Instance;
public struct UmaSoundInfo
{
Debug.Log(SongAwb.Name);
public string acbPath;
public string awbPath;
}
//获取总线数
Debug.Log(CriAtomExAcf.GetNumDspSettings());
static public UmaSoundInfo getSoundPath(string name)
{
Debug.Log(name);
UmaSoundInfo info;
info.acbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("acb")).FilePath;
info.awbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("awb")).FilePath;
return info;
}
string busName = CriAtomExAcf.GetDspSettingNameByIndex(0);
var dspSetInfo = new CriAtomExAcf.AcfDspSettingInfo();
Debug.Log(CriAtomExAcf.GetDspSettingInformation(busName, out dspSetInfo));
Debug.Log(dspSetInfo.name);
Debug.Log(dspSetInfo.numExtendBuses);
Debug.Log(dspSetInfo.numBuses);
Debug.Log(dspSetInfo.numSnapshots);
Debug.Log(dspSetInfo.snapshotStartIndex);
var busInfo = new CriAtomExAcf.AcfDspBusInfo();
for (ushort i = 0; i < dspSetInfo.numExtendBuses; i++)
{
Debug.Log(i);
Debug.Log(CriAtomExAcf.GetDspBusInformation(i, out busInfo));
Debug.Log(busInfo.name);
Debug.Log(busInfo.volume);
Debug.Log(busInfo.numFxes);
Debug.Log(busInfo.numBusLinks);
}
//获取Acb文件和Awb文件的路径
string nameVar = SongAwb.Name.Split('.')[0].Split('/').Last();
//使用Live的Bgm
//nameVar = $"snd_bgm_live_{songid}_oke";
LoadSound Loader = (LoadSound)ScriptableObject.CreateInstance("LoadSound");
LoadSound.UmaSoundInfo soundInfo = Loader.getSoundPath(nameVar);
//音频组件添加路径,载入音频
CriAtom.AddCueSheet(nameVar, soundInfo.acbPath, soundInfo.awbPath);
//获得当前音频信息
CriAtomEx.CueInfo[] cueInfoList;
List<string> cueNameList = new List<string>();
cueInfoList = CriAtom.GetAcb(nameVar).GetCueInfoList();
foreach (CriAtomEx.CueInfo cueInfo in cueInfoList)
{
cueNameList.Add(cueInfo.name);
Debug.Log(cueInfo.type);
Debug.Log(cueInfo.userData);
}
static public CriAtomSource ApplyCueSheet(string cueName)
{
UmaSoundInfo soundInfo = getSoundPath(cueName);
CriAtom.AddCueSheet(cueName, soundInfo.acbPath, soundInfo.awbPath);
//´´½¨²¥·ÅÆ÷
CriAtomSource source = new GameObject("CuteAudioSource").AddComponent<CriAtomSource>();
source.transform.SetParent(GameObject.Find("AudioManager/AudioControllerBgm").transform);
source.cueSheet = nameVar;
source.cueSheet = cueName;
//播放
source.Play(cueNameList[0]);
source.use3dPositioning = false;
//source.SetBusSendLevelOffset(1, 1);
return source;
}
public enum PartForm
{
center = 0,
left = 1,
right = 2
}
/*
for (int i = 0; i < 17; i++)
static public void AlterUpdate(float _liveCurrentTime, PartEntry partInfo, List<CriAtomSource> liveVocal)
{
var timeLineData = partInfo.PartSettings["time"];
var targetIndex = 0;
for (int i = timeLineData.Count - 1; i >= 0; i--)
{
Debug.Log(source.player.GetParameterFloat32((CriAtomEx.Parameter)i));
if (_liveCurrentTime >= (double)timeLineData[i] / 1000)
{
targetIndex = i;
break;
}
}
*/
var volumeMixer = 0;
var useMixer = false;
float _999_count = 0;
for (int i = 0; i < liveVocal.Count; i++)
{
string partName = ((PartForm)i).ToString();
if (partInfo.PartSettings.ContainsKey(partName)){
var value = partInfo.PartSettings[partName][targetIndex];
if (value == 0)
{
liveVocal[i].volume = 0;
volumeMixer += 1;
}
else
{
liveVocal[i].volume = 1;
liveVocal[i].player.SetSelectorLabel("BGM_Selector", $"SelectorLabel_{value-1}");
}
float volume;
if (partInfo.PartSettings.ContainsKey(partName + "_vol"))
{
volume = partInfo.PartSettings[partName + "_vol"][targetIndex];
if(volume != 999)
{
liveVocal[i].volume *= volume;
}
else
{
_999_count += 1;
}
}
}
}
if (_999_count == liveVocal.Count)
{
useMixer = true;
}
if (useMixer)
{
switch (volumeMixer)
{
case 0:
liveVocal[0].volume = 0.7056f;
liveVocal[1].volume = 0.56f;
liveVocal[2].volume = 0.56f;
break;
case 1:
for (int i = 0; i < liveVocal.Count; i++)
{
if (liveVocal[i].volume != 0)
{
liveVocal[i].volume = 0.7031f;
}
}
break;
case 2:
for (int i = 0; i < liveVocal.Count; i++)
{
if (liveVocal[i].volume != 0)
{
liveVocal[i].volume = 0.9954f;
}
}
break;
default:
liveVocal[0].volume = 0f;
liveVocal[1].volume = 0f;
liveVocal[2].volume = 0f;
break;
}
}
}
}
+13 -12
View File
@@ -18,7 +18,7 @@ using Random = UnityEngine.Random;
public class UmaViewerBuilder : MonoBehaviour
{
public static UmaViewerBuilder Instance;
UmaViewerMain Main => UmaViewerMain.Instance;
public static UmaViewerMain Main => UmaViewerMain.Instance;
UmaViewerUI UI => UmaViewerUI.Instance;
public List<AssetBundle> Loaded;
@@ -667,10 +667,13 @@ public class UmaViewerBuilder : MonoBehaviour
GameObject Director = new GameObject("Director");
List<GameObject> transferObjs = new List<GameObject>() {
MainLive,
GameObject.Find("CriWare"),
GameObject.Find("CriWareLibraryInitializer"),
GameObject.Find("ViewerMain"),
GameObject.Find("Camera"),
GameObject.Find("Directional Light"),
GameObject.Find("AnimationCameraRoot")
GameObject.Find("AnimationCameraRoot"),
GameObject.Find("AudioManager")
};
UmaSceneController.instance.LoadScene("LiveScene",
@@ -700,7 +703,7 @@ public class UmaViewerBuilder : MonoBehaviour
delegate ()
{
Gallop.Live.Director.instance.InitializeTimeline();
Gallop.Live.Director.instance.Play(live.MusicId, characters[0].CharaEntry.Id);
Gallop.Live.Director.instance.Play(live.MusicId, characters);
}
);
}
@@ -708,7 +711,8 @@ public class UmaViewerBuilder : MonoBehaviour
//Use CriWare Library
public void LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb)
/*
public CriAtomSource LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb)
{
//清理
if (CurrentAudioSources.Count > 0)
@@ -722,6 +726,7 @@ public class UmaViewerBuilder : MonoBehaviour
Debug.Log(SongAwb.Name);
//获取总线数
Debug.Log(CriAtomExAcf.GetNumDspSettings());
string busName = CriAtomExAcf.GetDspSettingNameByIndex(0);
@@ -782,17 +787,13 @@ public class UmaViewerBuilder : MonoBehaviour
//播放
source.Play(cueNameList[0]);
return source;
//source.SetBusSendLevelOffset(1, 1);
/*
for (int i = 0; i < 17; i++)
{
Debug.Log(source.player.GetParameterFloat32((CriAtomEx.Parameter)i));
}
*/
}
*/
//Use decrypt function
public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb, bool needLyrics = true)
@@ -941,7 +942,7 @@ public class UmaViewerBuilder : MonoBehaviour
}
}
public AssetBundle LoadOrGet(UmaDatabaseEntry entry)
public static AssetBundle LoadOrGet(UmaDatabaseEntry entry)
{
if ((Main.LoadedBundles.ContainsKey(entry.Name)))
{
+1 -1
View File
@@ -723,7 +723,7 @@ public class UmaViewerUI : MonoBehaviour
HighlightChildImage(LiveCharaSoundList.content, container);
if (isCriware)
{
Builder.LoadLiveSoundCri(songid, entry);
//Builder.LoadLiveSoundCri(songid, entry);
}
else
{
@@ -373,7 +373,7 @@ namespace Gallop
{
FacialResetMouth();
MouthMorphs.ForEach(morph => ProcessMorph(morph));
ApplyRotationEye();
ApplyRotationMouth();
}
public void ClearMorph()
@@ -504,7 +504,7 @@ namespace Gallop
OverrideFace(Container.FaceOverrideData);
}
FacialReset(BaseMouthMorph.trsArray);
ApplyRotation();
ApplyRotationMouth();
}
public void FacialReset(List<TrsArray> trsArrays)
@@ -554,6 +554,19 @@ namespace Gallop
applyRotation.Invoke(BaseREyeMorph.trsArray);
}
public void ApplyRotationMouth()
{
Action<List<TrsArray>> applyRotation = delegate (List<TrsArray> trsArray)
{
foreach (TrsArray trs in trsArray)
{
if (trs.transform)
trs.transform.localRotation = RotationConvert.fromMaya(RotationRecorder[trs.transform]);
}
};
applyRotation.Invoke(BaseMouthMorph.trsArray);
}
public void ChangeMorphWeight(FacialMorph morph, float val)
{
Container.isAnimatorControl = false;
@@ -707,17 +720,17 @@ namespace Gallop
return morphs.Find(m => m.index == (int)Type);
}
private LiveTimelineKeyLipSyncData _prevKeyData;
private LiveTimelineKeyLipSyncData _lastKeyData;
private LiveTimelineKeyLipSyncData _prevLipKeyData;
private LiveTimelineKeyLipSyncData _lastLipKeyData;
public void AlterUpdateAutoLip(LiveTimelineKeyLipSyncData keyData_, float liveTime_)
{
//Debug.Log((float)keyData_.frame);
//Debug.Log(liveTime_);
if(_lastKeyData != keyData_)
if(_lastLipKeyData != keyData_)
{
_prevKeyData = _lastKeyData;
_prevLipKeyData = _lastLipKeyData;
}
float keyTime = (float)keyData_.frame / 60;
@@ -758,19 +771,19 @@ namespace Gallop
MouthMorphs.ForEach(morph => morph.weight = 0);
if (_prevKeyData != null)
if (_prevLipKeyData != null)
{
if(weightRatio != 1)
{
foreach (var part in _prevKeyData.facialPartsDataArray)
foreach (var part in _prevLipKeyData.facialPartsDataArray)
{
if (part.FacialPartsId == 0 ) { continue; }
MouthMorphs[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevKeyData.weight / 100);
MouthMorphs[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevLipKeyData.weight / 100);
}
}
else
{
foreach (var part in _prevKeyData.facialPartsDataArray)
foreach (var part in _prevLipKeyData.facialPartsDataArray)
{
if (part.FacialPartsId == 0) { continue; }
MouthMorphs[part.FacialPartsId - 1].weight = 0;
@@ -786,7 +799,124 @@ namespace Gallop
ChangeMorphMouth();
_lastKeyData = keyData_;
_lastLipKeyData = keyData_;
}
private LiveTimelineKeyFacialEyeData _prevEyesKeyData;
private LiveTimelineKeyFacialEyeData _lastEyesKeyData;
public void AlterUpdateFacialNew(ref FacialDataUpdateInfo updateInfo_, float liveTime_)
{
if(updateInfo_.eyeCur != null)
{
if (_lastEyesKeyData != updateInfo_.eyeCur)
{
_prevEyesKeyData = _lastEyesKeyData;
}
float keyTime = (float)updateInfo_.eyeCur.frame / 60;
float duringTime;
if (updateInfo_.eyeNext != null)
{
duringTime = updateInfo_.eyeNext.frame - updateInfo_.eyeCur.frame;
}
else
{
duringTime = updateInfo_.eyeCur.time;
}
float easeTime;
if (duringTime < updateInfo_.eyeCur.time)
{
easeTime = (float)duringTime / 60;
}
else
{
easeTime = (float)updateInfo_.eyeCur.time / 60;
}
float passTime = liveTime_ - keyTime;
float weightRatio = 0;
if (passTime >= easeTime)
{
weightRatio = 1;
}
else
{
float ratio = passTime / easeTime;
switch (updateInfo_.eyeCur.interpolateType)
{
case InterpolateType.Linear:
weightRatio = ratio;
break;
case InterpolateType.EaseIn:
weightRatio = Easing.EaseIn(ratio);
break;
case InterpolateType.EaseOut:
weightRatio = Easing.EaseOut(ratio);
break;
case InterpolateType.EaseInOut:
weightRatio = Easing.EaseInOut(ratio);
break;
default:
weightRatio = ratio;
break;
}
}
EyeMorphs.ForEach(morph => morph.weight = 0);
if (_prevEyesKeyData != null)
{
if (weightRatio != 1)
{
foreach (var part in _prevEyesKeyData.facialPartsDataArrayL)
{
if (part.FacialPartsId == 0) { continue; }
leftEyeMorph[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevEyesKeyData.weight / 100);
}
foreach (var part in _prevEyesKeyData.facialPartsDataArrayR)
{
if (part.FacialPartsId == 0) { continue; }
rightEyeMorph[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevEyesKeyData.weight / 100);
}
}
else
{
foreach (var part in _prevEyesKeyData.facialPartsDataArrayL)
{
if (part.FacialPartsId == 0) { continue; }
leftEyeMorph[part.FacialPartsId - 1].weight = 0;
}
foreach (var part in _prevEyesKeyData.facialPartsDataArrayR)
{
if (part.FacialPartsId == 0) { continue; }
rightEyeMorph[part.FacialPartsId - 1].weight = 0;
}
}
}
foreach (var part in updateInfo_.eyeCur.facialPartsDataArrayL)
{
if (part.FacialPartsId == 0) { continue; }
leftEyeMorph[part.FacialPartsId - 1].weight += ((float)part.WeightPer / 100 * weightRatio) * ((float)updateInfo_.eyeCur.weight / 100);
}
foreach (var part in updateInfo_.eyeCur.facialPartsDataArrayR)
{
if (part.FacialPartsId == 0) { continue; }
rightEyeMorph[part.FacialPartsId - 1].weight += ((float)part.WeightPer / 100 * weightRatio) * ((float)updateInfo_.eyeCur.weight / 100);
}
ChangeMorphEye();
_lastEyesKeyData = updateInfo_.eyeCur;
}
}
}
}
@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Gallop.Live.Cutt
{
public struct FacialDataUpdateInfo // TypeDefIndex: 29410
{
// Fields
public LiveTimelineKeyFacialFaceData faceCur; // 0x0
public LiveTimelineKeyFacialFaceData faceNext; // 0x8
public LiveTimelineKeyFacialMouthData mouth; // 0x10
public LiveTimelineKeyFacialEyeData eyeCur; // 0x18
public LiveTimelineKeyFacialEyeData eyeNext; // 0x20
public LiveTimelineKeyFacialEyebrowData eyebrow; // 0x28
public LiveTimelineKeyFacialEyeTrackData eyeTrack; // 0x30
public LiveTimelineKeyFacialEarData ear; // 0x38
public LiveTimelineKeyFacialEffectData effect; // 0x40
public int faceKeyIndex; // 0x48
public int mouthKeyIndex; // 0x4C
public int eyeKeyIndex; // 0x50
public int eyebrowKeyIndex; // 0x54
public int eyeTrackKeyIndex; // 0x58
public int earKeyIndex; // 0x5C
public int effectKeyIndex; // 0x60
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ef2081963b0a68f4e8558e38b24cc264
guid: d23729e48867d7143b85da3439885191
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -14,8 +14,10 @@ namespace Gallop.Live.Cutt
//public abstract string Description { get; set; }
//public abstract int depthCounter { get; }
LiveTimelineKey FindCurrentKey(float currentTime);
public abstract LiveTimelineKeyIndex TimeKeyIndex { get; }
LiveTimelineKeyIndex FindCurrentKey(float currentTime);
LiveTimelineKeyIndex UpdateCurrentKey(float currentTime);
}
}
@@ -27,6 +27,8 @@ namespace Gallop.Live.Cutt
public event Action<LiveTimelineKeyLipSyncData, float> OnUpdateLipSync;
public event Action<FacialDataUpdateInfo, float> OnUpdateFacial;
public void CopyValues<T>(T from, T to)
{
var json = JsonUtility.ToJson(from);
@@ -93,6 +95,7 @@ namespace Gallop.Live.Cutt
{
AlterUpdate_CharaMotionSequence(liveTime);
AlterUpdate_LipSync(liveTime);
AlterUpdate_FacialData(liveTime);
}
public void AlterUpdate_CharaMotionSequence(float liveTime)
@@ -103,23 +106,68 @@ namespace Gallop.Live.Cutt
}
}
public void AlterUpdate_FacialData(float liveTime)
{
var facialDataList = data.worksheetList[0].facial1Set;
FacialDataUpdateInfo updateInfo = default(FacialDataUpdateInfo);
if (facialDataList != null)
{
SetupFacialUpdateInfo_Eye(ref updateInfo, facialDataList.eyeKeys, liveTime);
this.OnUpdateFacial(updateInfo, liveTime);
}
}
private void SetupFacialUpdateInfo_Eye(ref FacialDataUpdateInfo updateInfo, LiveTimelineKeyFacialEyeDataList keys, float time)
{
LiveTimelineKey liveTimelineKey = null;
LiveTimelineKey liveTimelineKey2 = null;
LiveTimelineKeyIndex curKey = AlterUpdate_Key(keys, time);
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.eyeCur = liveTimelineKey as LiveTimelineKeyFacialEyeData;
updateInfo.eyeNext = liveTimelineKey2 as LiveTimelineKeyFacialEyeData;
updateInfo.eyeKeyIndex = curKey.index;
}
public void AlterUpdate_LipSync(float liveTime)
{
var lipDataList = data.worksheetList[0].ripSyncKeys;
LiveTimelineKey curKey = null;
FindTimelineKeyCurrent(out curKey, lipDataList, liveTime);
if (curKey != null)
LiveTimelineKeyIndex curKey = AlterUpdate_Key(lipDataList, liveTime);
if (curKey != null && curKey.index != -1)
{
LiveTimelineKeyLipSyncData arg = curKey as LiveTimelineKeyLipSyncData;
LiveTimelineKeyLipSyncData arg = curKey.key as LiveTimelineKeyLipSyncData;
this.OnUpdateLipSync(arg, liveTime);
}
}
public void FindTimelineKeyCurrent(out LiveTimelineKey curKey, ILiveTimelineKeyDataList keys, float curTime)
public static void FindTimelineKeyCurrent(out LiveTimelineKeyIndex curKey, ILiveTimelineKeyDataList keys, float curTime)
{
curKey = keys.FindCurrentKey(curTime);
}
public static void UpdateTimelineKeyCurrent(out LiveTimelineKeyIndex curKey, ILiveTimelineKeyDataList keys, float curTime)
{
curKey = keys.UpdateCurrentKey(curTime);
}
public static LiveTimelineKeyIndex AlterUpdate_Key(ILiveTimelineKeyDataList keys, float curTime)
{
LiveTimelineKeyIndex curKey = keys.TimeKeyIndex;
if (curKey.index == -1)
{
FindTimelineKeyCurrent(out curKey, keys, curTime);
}
else
{
UpdateTimelineKeyCurrent(out curKey, keys, curTime);
}
return curKey;
}
}
@@ -58,61 +58,20 @@ namespace Gallop.Live.Cutt
{
if (_currentKey != null && _tempAnim != null)
{
/*
var seqs = _currentKey.thisList;
LiveTimelineKeyIndex curKey = LiveTimelineControl.AlterUpdate_Key(_currentKey, currentTime);
for (int i = seqs.Count - 1; i >= 0; i--)
if (curKey != null && curKey.index != -1)
{
Debug.Log(currentTime);
if (currentTime >= (double)seqs[i].frame / 60)
{
Debug.Log("ʱ¼ä:" + ((double)seqs[i].frame / 60).ToString());
LiveTimelineKeyCharaMotionData arg = curKey.key as LiveTimelineKeyCharaMotionData;
AnimationClip anim = seqs[i].clip;
double start = (double)seqs[i].motionHeadFrame / 60;
double interval = currentTime - (double)seqs[i].frame / 60;
Debug.Log("time:" + interval.ToString());
//anim.SampleAnimation(container.gameObject, (float)(start + interval));
_tempAnim[anim.name].time = (float)(start + interval);
_tempAnim.Play(anim.name);
break;
}
}
*/
var timelineKey = GetKey(currentTime);
//if ( _prevKey != timelineKey ) Play animation all the time not affect performance maybe?
if ( true )
{
AnimationClip anim = timelineKey.clip;
double start = (double)timelineKey.motionHeadFrame / 60;
double interval = currentTime - (double)timelineKey.frame / 60;
AnimationClip anim = arg.clip;
double start = (double)arg.motionHeadFrame / 60;
double interval = currentTime - (double)arg.frame / 60;
_tempAnim[anim.name].time = (float)(start + interval);
_tempAnim.Play(anim.name);
_prevKey = timelineKey;
}
}
}
public LiveTimelineKeyCharaMotionData GetKey(float time)
{
var seqs = _currentKey.thisList;
for (int i = seqs.Count - 1; i >= 0; i--)
{
if (time >= (double)seqs[i].frame / 60)
{
return seqs[i];
}
}
return seqs[0];
}
}
}
@@ -126,7 +126,12 @@ namespace Gallop.Live.Cutt
private TimelineKeyPlayMode _playMode;
public List<T> thisList;
public LiveTimelineKeyIndex thisTimeKeyIndex = new LiveTimelineKeyIndex();
public int Count => thisList.Count;
public LiveTimelineKeyIndex TimeKeyIndex => thisTimeKeyIndex;
public LiveTimelineKey this[int index]
{
@@ -140,20 +145,61 @@ namespace Gallop.Live.Cutt
}
}
public LiveTimelineKey FindCurrentKey(float currentTime)
public LiveTimelineKeyIndex FindCurrentKey(float currentTime)
{
for (int i = thisList.Count - 1; i >= 0; i--)
{
if (currentTime >= (double)thisList[i].frame / 60)
{
return thisList[i];
thisTimeKeyIndex.index = i;
thisTimeKeyIndex.key = thisList[i];
if(i+1 != thisList.Count)
{
thisTimeKeyIndex.nextKey = thisList[i + 1];
}
else
{
thisTimeKeyIndex.nextKey = null;
}
return thisTimeKeyIndex;
}
}
return null;
}
public LiveTimelineKeyIndex UpdateCurrentKey(float currentTime)
{
if (thisTimeKeyIndex.nextKey != null)
{
if (currentTime >= (double)thisTimeKeyIndex.nextKey.frame / 60)
{
thisTimeKeyIndex.index++;
thisTimeKeyIndex.key = thisList[thisTimeKeyIndex.index];
if (thisTimeKeyIndex.index + 1 != thisList.Count)
{
thisTimeKeyIndex.nextKey = thisList[thisTimeKeyIndex.index + 1];
}
else
{
thisTimeKeyIndex.nextKey = null;
}
}
}
return thisTimeKeyIndex;
}
}
[System.Serializable]
[System.Serializable]
public class LiveTimelineKeyIndex
{
public int index = -1;
public LiveTimelineKey key = null;
public LiveTimelineKey nextKey = null;
}
[System.Serializable]
public abstract class LiveTimelineKey
{
public int frame;
+114 -53
View File
@@ -11,6 +11,7 @@ using UnityEditor.SceneManagement;
using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters;
using System.Data;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using CriWare;
namespace Gallop.Live
{
@@ -312,9 +313,10 @@ namespace Gallop.Live
public LiveEntry live;
private const string CUTT_PATH = "cutt/cutt_son{0}/cutt_son{0}";
private const string STAGE_PATH = "3d/env/live/live{0}/pfb_env_live{0}_controller000";
private const string SONG_PATH = "sound/l/{0}/snd_bgm_live_{0}_oke_01.awb";
private const string VOCAL_PATH = "sound/l/{0}/snd_bgm_live_{0}_chara_{1}_01.awb";
private const string SONG_PATH = "sound/l/{0}/snd_bgm_live_{0}_oke_01";
private const string VOCAL_PATH = "sound/l/{0}/snd_bgm_live_{0}_chara_{1}_01";
private const string RANDOM_VOCAL_PATH = "sound/l/{0}/snd_bgm_live_{0}_chara";
private const string LIVE_PART_PATH = "live/musicscores/m{0}/m{0}_part";
private UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
@@ -328,6 +330,14 @@ namespace Gallop.Live
public AudioSource liveSong;
public List<CriAtomSource> liveVocal;
public CriAtomSource liveMusic;
public PartEntry partInfo;
public bool _syncTime = false;
public bool _soloMode = true;
private void Awake()
{
if (live != null)
@@ -336,7 +346,7 @@ namespace Gallop.Live
Debug.Log(string.Format(CUTT_PATH, live.MusicId));
Debug.Log(live.BackGroundId);
Builder.LoadAssetPath(string.Format(CUTT_PATH, live.MusicId), this.gameObject.transform);
Builder.LoadAssetPath(string.Format(STAGE_PATH, live.BackGroundId), this.gameObject.transform);
//Builder.LoadAssetPath(string.Format(STAGE_PATH, live.BackGroundId), this.gameObject.transform);
//Make CharacterObject
@@ -352,13 +362,16 @@ namespace Gallop.Live
charaObjs.Add(newObj.transform);
counter++;
};
//Set Animation
//Get live parts info
UmaDatabaseEntry partAsset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Contains(string.Format(LIVE_PART_PATH, live.MusicId)));
Debug.Log(partAsset.Name);
AssetBundle bundle = UmaViewerBuilder.LoadOrGet(partAsset);
TextAsset partData = bundle.LoadAsset<TextAsset>($"m{live.MusicId}_part");
partInfo = new PartEntry(partData.text);
}
}
@@ -368,18 +381,6 @@ namespace Gallop.Live
_liveTimelineControl.OnUpdateLipSync += delegate (LiveTimelineKeyLipSyncData keyData_, float liveTime_)
{
/*
for (int k = 0; k < MemberUnitNumber; k++)
{
int num4 = k % MemberUnitNumber;
if (_characterObjects[num4].isSetting)
{
_characterObjects[num4].faceController.AlterUpdateAutoLip(liveTime_, keyData_, (LiveCharaPosition)num4);
}
}
*/
for (int k = 0; k < charaObjs.Count; k++)
{
var container = charaObjs[k].GetComponentInChildren<UmaContainer>();
@@ -388,43 +389,81 @@ namespace Gallop.Live
container.FaceDrivenKeyTarget.AlterUpdateAutoLip(keyData_, liveTime_);
}
}
/*
};
_liveTimelineControl.OnUpdateFacial += delegate (FacialDataUpdateInfo updateInfo_, float liveTime_)
{
var container = charaObjs[0].GetComponentInChildren<UmaContainer>();
if (container != null)
{
container.FaceDrivenKeyTarget.AlterUpdateAutoLip(keyData_, liveTime_);
}
*/
container.FaceDrivenKeyTarget.AlterUpdateFacialNew(ref updateInfo_, liveTime_);
};
}
public void Play(int songid, int charaid)
public void Play(int songid, List<LiveCharacterSelect> characters)
{
Debug.Log(songid);
Debug.Log(charaid);
Debug.Log(string.Format(VOCAL_PATH, songid, charaid));
var entry = UmaViewerMain.Instance.AbSounds.FirstOrDefault(a => a.Name.Contains(string.Format(VOCAL_PATH, songid, charaid)));
if (entry == null)
if (!_soloMode)
{
List<UmaDatabaseEntry> entries = new List<UmaDatabaseEntry>();
foreach (var random in UmaViewerMain.Instance.AbSounds.Where(a => (a.Name.Contains(string.Format(RANDOM_VOCAL_PATH, songid)) && a.Name.EndsWith("awb"))))
for (int i = 0; i < characters.Count; i++)
{
entries.Add(random);
}
if (entries.Count > 0)
{
entry = entries[UnityEngine.Random.Range(0, entries.Count - 1)];
}
}
if(entry != null)
{
Debug.Log(entry.Name);
}
if (characters[i].CharaEntry.Name != "" && i < 3)
{
var charaid = characters[i].CharaEntry.Id;
UmaViewerBuilder.Instance.LoadLiveSound(songid, entry, false);
liveSong = GameObject.Find("SoundController").GetComponent<AudioSource>();
var entry = UmaViewerMain.Instance.AbSounds.FirstOrDefault(a => a.Name.Contains(string.Format(VOCAL_PATH, songid, charaid)) && a.Name.EndsWith("awb"));
if (entry == null)
{
List<UmaDatabaseEntry> entries = new List<UmaDatabaseEntry>();
foreach (var random in UmaViewerMain.Instance.AbSounds.Where(a => (a.Name.Contains(string.Format(RANDOM_VOCAL_PATH, songid)) && a.Name.EndsWith("awb"))))
{
entries.Add(random);
}
if (entries.Count > 0)
{
entry = entries[UnityEngine.Random.Range(0, entries.Count - 1)];
}
}
if (entry != null)
{
Debug.Log(entry.Name);
liveVocal.Add(UmaViewerAudio.ApplyCueSheet(entry.Name.Split('.')[0]));
}
}
}
liveMusic = UmaViewerAudio.ApplyCueSheet(string.Format(SONG_PATH, songid));
foreach (var vocal in liveVocal)
{
vocal.Play(0);
}
liveMusic.Play(0);
}
else
{
var entry = UmaViewerMain.Instance.AbSounds.FirstOrDefault(a => a.Name.Contains(string.Format(VOCAL_PATH, songid, characters[0].CharaEntry.Id)) && a.Name.EndsWith("awb"));
if (entry == null)
{
List<UmaDatabaseEntry> entries = new List<UmaDatabaseEntry>();
foreach (var random in UmaViewerMain.Instance.AbSounds.Where(a => (a.Name.Contains(string.Format(RANDOM_VOCAL_PATH, songid)) && a.Name.EndsWith("awb"))))
{
entries.Add(random);
}
if (entries.Count > 0)
{
entry = entries[UnityEngine.Random.Range(0, entries.Count - 1)];
}
}
if (entry != null)
{
Debug.Log(entry.Name);
}
UmaViewerBuilder.Instance.LoadLiveSound(songid, entry, false);
liveSong = GameObject.Find("SoundController").GetComponent<AudioSource>();
}
_isLiveSetup = true;
_liveCurrentTime = 0;
@@ -433,18 +472,40 @@ namespace Gallop.Live
private void OnTimelineUpdate(float _liveCurrentTime)
{
_liveTimelineControl.AlterUpdate(_liveCurrentTime);
if (!_soloMode)
{
UmaViewerAudio.AlterUpdate(_liveCurrentTime, partInfo, liveVocal);
}
}
void Update()
{
if (_isLiveSetup)
{
_liveCurrentTime += Time.deltaTime;
OnTimelineUpdate(_liveCurrentTime);
}
else
{
_liveCurrentTime = 0;
if(_syncTime == false)
{
if (!_soloMode)
{
if(liveMusic.time > 0)
{
_liveCurrentTime = liveMusic.time / 1000;
_syncTime = true;
}
}
else
{
if(liveSong.time > 0)
{
_liveCurrentTime = liveSong.time;
_syncTime = true;
}
}
}
else
{
_liveCurrentTime += Time.deltaTime;
OnTimelineUpdate(_liveCurrentTime);
}
}
}
}