improve live

This commit is contained in:
左右看
2023-07-07 05:30:20 +08:00
parent f5573496ee
commit 6a89bba5e3
15 changed files with 443 additions and 117 deletions
@@ -816,8 +816,6 @@ namespace Gallop
{
_prevLipKeyData = null;
_lastLipKeyData = null;
MouthMorphs.ForEach(morph => morph.weight = 0);
ChangeMorphMouth();
return;
}
@@ -826,42 +824,6 @@ namespace Gallop
_prevLipKeyData = _lastLipKeyData;
}
/*
float keyTime = (float)keyData_.frame / 60;
float easeTime = (float)keyData_.time/ 60;
float passTime = liveTime_ - keyTime;
float weightRatio = 0;
if (passTime >= easeTime)
{
weightRatio = 1;
}
else
{
float ratio = passTime / easeTime;
switch (keyData_.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;
}
}
*/
float weightRatio = CalcMorphWeight(liveTime_, keyData_.time, keyData_.interpolateType, keyData_, null);
MouthMorphs.ForEach(morph => morph.weight = 0);
@@ -897,6 +859,9 @@ namespace Gallop
_lastLipKeyData = keyData_;
}
private LiveTimelineKeyFacialMouthData _prevMouthKeyData;
private LiveTimelineKeyFacialMouthData _lastMouthKeyData;
private LiveTimelineKeyFacialEyeData _prevEyesKeyData;
private LiveTimelineKeyFacialEyeData _lastEyesKeyData;
@@ -908,7 +873,48 @@ namespace Gallop
public void AlterUpdateFacialNew(ref FacialDataUpdateInfo updateInfo_, float liveTime_)
{
if(updateInfo_.eyeCur != null)
if (updateInfo_.mouthCur != null)
{
if (_lastMouthKeyData != updateInfo_.mouthCur)
{
_prevMouthKeyData = _lastMouthKeyData;
}
float weightRatio = CalcMorphWeight(liveTime_, updateInfo_.mouthCur.time, updateInfo_.mouthCur.interpolateType, updateInfo_.mouthCur, updateInfo_.mouthNext);
MouthMorphs.ForEach(morph => morph.weight = 0);
if (_prevMouthKeyData != null)
{
if (weightRatio != 1)
{
foreach (var part in _prevMouthKeyData.facialPartsDataArray)
{
if (part.FacialPartsId == 0) { continue; }
MouthMorphs[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevMouthKeyData.weight / 100);
}
}
else
{
foreach (var part in _prevMouthKeyData.facialPartsDataArray)
{
if (part.FacialPartsId == 0) { continue; }
MouthMorphs[part.FacialPartsId - 1].weight = 0;
}
}
}
foreach (var part in updateInfo_.mouthCur.facialPartsDataArray)
{
if (part.FacialPartsId == 0) { continue; }
MouthMorphs[part.FacialPartsId - 1].weight += ((float)part.WeightPer / 100 * weightRatio) * ((float)updateInfo_.mouthCur.weight / 100);
}
ChangeMorphMouth();
_lastMouthKeyData = updateInfo_.mouthCur;
}
if (updateInfo_.eyeCur != null)
{
if (_lastEyesKeyData != updateInfo_.eyeCur)
{
@@ -9,7 +9,8 @@ namespace Gallop.Live.Cutt
// Fields
public LiveTimelineKeyFacialFaceData faceCur; // 0x0
public LiveTimelineKeyFacialFaceData faceNext; // 0x8
public LiveTimelineKeyFacialMouthData mouth; // 0x10
public LiveTimelineKeyFacialMouthData mouthCur; // 0x10
public LiveTimelineKeyFacialMouthData mouthNext; // 0x10
public LiveTimelineKeyFacialEyeData eyeCur; // 0x18
public LiveTimelineKeyFacialEyeData eyeNext; // 0x20
public LiveTimelineKeyFacialEyebrowData eyebrowCur; // 0x28
@@ -27,7 +27,7 @@ namespace Gallop.Live.Cutt
public event Action<LiveTimelineKeyLipSyncData, float> OnUpdateLipSync;
public event Action<FacialDataUpdateInfo, float> OnUpdateFacial;
public event Action<FacialDataUpdateInfo, float, int> OnUpdateFacial;
public void CopyValues<T>(T from, T to)
{
@@ -55,7 +55,7 @@ namespace Gallop.Live.Cutt
//}
}
public void InitCharaMotionSequence()
public void InitCharaMotionSequence(int[] motionSequence)
{
//Create Animation
foreach (var obj in Director.instance.charaObjs)
@@ -77,16 +77,17 @@ namespace Gallop.Live.Cutt
{
_keyArray[i] = data.worksheetList[0].charaMotSeqList[i].keys;
}
//Set Motion
int CharaPositionMax = characterStandPosLocators.Length;
int CharaPositionMax = Director.instance.allowCount;
_motionSequenceArray = new LiveTimelineMotionSequence[CharaPositionMax];
for (int i = 0; i < CharaPositionMax; i++)
{
_motionSequenceArray[i] = new LiveTimelineMotionSequence();
_motionSequenceArray[i].Initialize(Director.instance.charaObjs[i], i, i, this);
_motionSequenceArray[i].Initialize(Director.instance.charaObjs[i], i, motionSequence[i], this);
}
}
@@ -94,8 +95,8 @@ namespace Gallop.Live.Cutt
public void AlterUpdate(float liveTime)
{
AlterUpdate_CharaMotionSequence(liveTime);
AlterUpdate_LipSync(liveTime);
AlterUpdate_FacialData(liveTime);
AlterUpdate_LipSync(liveTime);
}
public void AlterUpdate_CharaMotionSequence(float liveTime)
@@ -112,10 +113,37 @@ namespace Gallop.Live.Cutt
FacialDataUpdateInfo updateInfo = default(FacialDataUpdateInfo);
if (facialDataList != null)
{
SetupFacialUpdateInfo_Mouth(ref updateInfo, facialDataList.mouthKeys, liveTime);
SetupFacialUpdateInfo_Eye(ref updateInfo, facialDataList.eyeKeys, liveTime);
SetupFacialUpdateInfo_Eyebrow(ref updateInfo, facialDataList.eyebrowKeys, liveTime);
SetupFacialUpdateInfo_Ear(ref updateInfo, facialDataList.earKeys, liveTime);
this.OnUpdateFacial(updateInfo, liveTime);
this.OnUpdateFacial(updateInfo, liveTime, 0);
}
var otherFacialDataList = data.worksheetList[0].other4FacialArray;
for(int i = 0; i < otherFacialDataList.Length && i < Director.instance.characterCount - 1; i++)
{
SetupFacialUpdateInfo_Mouth(ref updateInfo, otherFacialDataList[i].mouthKeys, liveTime);
SetupFacialUpdateInfo_Eye(ref updateInfo, otherFacialDataList[i].eyeKeys, liveTime);
SetupFacialUpdateInfo_Eyebrow(ref updateInfo, otherFacialDataList[i].eyebrowKeys, liveTime);
SetupFacialUpdateInfo_Ear(ref updateInfo, otherFacialDataList[i].earKeys, liveTime);
this.OnUpdateFacial(updateInfo, liveTime, i+1);
}
}
private void SetupFacialUpdateInfo_Mouth(ref FacialDataUpdateInfo updateInfo, LiveTimelineKeyFacialMouthDataList keys, float time)
{
LiveTimelineKey liveTimelineKey = null;
LiveTimelineKey liveTimelineKey2 = null;
LiveTimelineKeyIndex curKey = AlterUpdate_Key(keys, time);
if (curKey != null)
{
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.mouthCur = liveTimelineKey as LiveTimelineKeyFacialMouthData;
updateInfo.mouthNext = liveTimelineKey2 as LiveTimelineKeyFacialMouthData;
updateInfo.mouthKeyIndex = curKey.index;
}
}
@@ -125,11 +153,14 @@ namespace Gallop.Live.Cutt
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;
if (curKey != null)
{
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.eyeCur = liveTimelineKey as LiveTimelineKeyFacialEyeData;
updateInfo.eyeNext = liveTimelineKey2 as LiveTimelineKeyFacialEyeData;
updateInfo.eyeKeyIndex = curKey.index;
}
}
private void SetupFacialUpdateInfo_Eyebrow(ref FacialDataUpdateInfo updateInfo, LiveTimelineKeyFacialEyebrowDataList keys, float time)
@@ -138,11 +169,14 @@ namespace Gallop.Live.Cutt
LiveTimelineKey liveTimelineKey2 = null;
LiveTimelineKeyIndex curKey = AlterUpdate_Key(keys, time);
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.eyebrowCur = liveTimelineKey as LiveTimelineKeyFacialEyebrowData;
updateInfo.eyebrowNext = liveTimelineKey2 as LiveTimelineKeyFacialEyebrowData;
updateInfo.eyebrowKeyIndex = curKey.index;
if (curKey != null)
{
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.eyebrowCur = liveTimelineKey as LiveTimelineKeyFacialEyebrowData;
updateInfo.eyebrowNext = liveTimelineKey2 as LiveTimelineKeyFacialEyebrowData;
updateInfo.eyebrowKeyIndex = curKey.index;
}
}
private void SetupFacialUpdateInfo_Ear(ref FacialDataUpdateInfo updateInfo, LiveTimelineKeyFacialEarDataList keys, float time)
@@ -151,11 +185,14 @@ namespace Gallop.Live.Cutt
LiveTimelineKey liveTimelineKey2 = null;
LiveTimelineKeyIndex curKey = AlterUpdate_Key(keys, time);
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.earCur = liveTimelineKey as LiveTimelineKeyFacialEarData;
updateInfo.earNext = liveTimelineKey2 as LiveTimelineKeyFacialEarData;
updateInfo.earKeyIndex = curKey.index;
if (curKey != null)
{
liveTimelineKey = curKey.key;
liveTimelineKey2 = curKey.nextKey;
updateInfo.earCur = liveTimelineKey as LiveTimelineKeyFacialEarData;
updateInfo.earNext = liveTimelineKey2 as LiveTimelineKeyFacialEarData;
updateInfo.earKeyIndex = curKey.index;
}
}
public void AlterUpdate_LipSync(float liveTime)
@@ -164,7 +201,7 @@ namespace Gallop.Live.Cutt
LiveTimelineKeyIndex curKey = AlterUpdate_Key(lipDataList, liveTime);
if (curKey != null && curKey.index != -1)
if (curKey != null && curKey.index != -1 && curKey.nextKey != null)
{
LiveTimelineKeyLipSyncData arg = curKey.key as LiveTimelineKeyLipSyncData;
this.OnUpdateLipSync(arg, liveTime);
@@ -339,6 +339,9 @@ namespace Gallop.Live
public bool _syncTime = false;
public bool _soloMode = false;
public int characterCount = 0;
public int allowCount = 0;
private void Awake()
{
if (live != null)
@@ -376,9 +379,11 @@ namespace Gallop.Live
}
}
public void InitializeTimeline()
public void InitializeTimeline(int count)
{
_liveTimelineControl.InitCharaMotionSequence();
allowCount = count;
_liveTimelineControl.InitCharaMotionSequence(_liveTimelineControl.data.characterSettings.motionSequenceIndices);
_liveTimelineControl.OnUpdateLipSync += delegate (LiveTimelineKeyLipSyncData keyData_, float liveTime_)
{
@@ -391,10 +396,13 @@ namespace Gallop.Live
}
}
};
_liveTimelineControl.OnUpdateFacial += delegate (FacialDataUpdateInfo updateInfo_, float liveTime_)
_liveTimelineControl.OnUpdateFacial += delegate (FacialDataUpdateInfo updateInfo_, float liveTime_, int position)
{
var container = charaObjs[0].GetComponentInChildren<UmaContainer>();
container.FaceDrivenKeyTarget.AlterUpdateFacialNew(ref updateInfo_, liveTime_);
if( position < charaObjs.Count)
{
var container = charaObjs[position].GetComponentInChildren<UmaContainer>();
container.FaceDrivenKeyTarget.AlterUpdateFacialNew(ref updateInfo_, liveTime_);
}
};
}
@@ -402,15 +410,14 @@ namespace Gallop.Live
{
Debug.Log(songid);
var charaCount = 0;
for (int i = 0; i < characters.Count; i++)
{
if (characters[i].CharaEntry.Name != "")
{
charaCount += 1;
characterCount += 1;
}
}
if(charaCount == 1)
if(characterCount == 1)
{
_soloMode = true;
}