Skip to content

Commit

Permalink
リップシンク機能の追加
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-akira committed Jul 14, 2018
1 parent 0ed61f3 commit c9d9b20
Show file tree
Hide file tree
Showing 11 changed files with 952 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Assets/ExternalPlugins/SteamVR*
Assets/ExternalPlugins/VRM*
Assets/ExternalPlugins/VRM.Samples*
Assets/ExternalPlugins/StreamingAssets*
Assets/ExternalPlugins/OVRLipSync*
ControlWindowSeparateThreadBackup*
Assembly*.csproj
OVR*.sln
Expand Down
2 changes: 1 addition & 1 deletion Assets/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Plugins/ControlWindow.dll
Binary file not shown.
163 changes: 160 additions & 3 deletions Assets/Scenes/VirtualMotionCapture.unity
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,162 @@ Transform:
m_Father: {fileID: 1128534204}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &144144636
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 144144642}
- component: {fileID: 144144641}
- component: {fileID: 144144639}
- component: {fileID: 144144637}
m_Layer: 0
m_Name: OVRLipSync
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &144144637
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 144144636}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 56d1ab24c7c08cf468bd0cd65a063018, type: 3}
m_Name:
m_EditorClassIdentifier:
audioSource: {fileID: 144144639}
provider: 0
SmoothAmount: 100
EnableLipSync: 0
Gain: 1
AudioMute: 1
DelayCompensate: 0
selectedDevice:
--- !u!82 &144144639
AudioSource:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 144144636}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1.1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &144144641
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 144144636}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 82aa5cb7a870de440baadff9083be41c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &144144642
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 144144636}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -149.63986, y: -201.5098, z: -1171.8685}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &170076733
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -267,7 +423,7 @@ AudioListener:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 0
m_Enabled: 1
--- !u!20 &282840813
Camera:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -356,7 +512,7 @@ AudioListener:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 462948916}
m_Enabled: 0
m_Enabled: 1
--- !u!124 &462948919
Behaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1318,7 +1474,7 @@ AudioListener:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1404284878}
m_Enabled: 0
m_Enabled: 1
--- !u!124 &1404284881
Behaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1420,6 +1576,7 @@ MonoBehaviour:
CalibrationCamera: {fileID: 1312323656}
BackgroundRenderer: {fileID: 892957809}
GridCanvas: {fileID: 814726118}
LipSync: {fileID: 144144637}
FreeCamera: {fileID: 282840813}
FrontCamera: {fileID: 1404284882}
BackCamera: {fileID: 462948920}
Expand Down
84 changes: 84 additions & 0 deletions Assets/Scripts/ControlWinFormsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class ControlWinFormsWindow : MonoBehaviour

public GameObject GridCanvas;

public DynamicOVRLipSync LipSync;

private GameObject CurrentModel = null;

private VRIK vrik = null;
Expand Down Expand Up @@ -150,6 +152,14 @@ void Start()
win.Calibrate = Calibrate;
win.EndCalibrate = EndCalibrate;

win.SetLipSyncEnable = SetLipSyncEnable;
win.GetLipSyncDevices = GetLipSyncDevices;
win.SetLipSyncDevice = SetLipSyncDevice;
win.SetLipSyncGain = SetLipSyncGain;
win.SetLipSyncMaxWeightEnable = SetLipSyncMaxWeightEnable;
win.SetLipSyncWeightThreashold = SetLipSyncWeightThreashold;
win.SetLipSyncMaxWeightEmphasis = SetLipSyncMaxWeightEmphasis;

win.ChangeBackgroundColor = ChangeBackgroundColor;
win.SetBackgroundTransparent = SetBackgroundTransparent;
win.SetWindowBorder = SetWindowBorder;
Expand Down Expand Up @@ -246,6 +256,9 @@ private async void ImportVRM(string path, bool ImportForCalibration)
// ParseしたJSONをシーンオブジェクトに変換していく
CurrentModel = await VRMImporter.LoadVrmAsync(context);

//LipSync
LipSync.ImportVRMmodel(CurrentModel);

CurrentModel.transform.SetParent(transform, false);

SetVRIK(CurrentModel);
Expand Down Expand Up @@ -347,6 +360,53 @@ private void EndCalibrate()

#endregion

#region LipSync

private void SetLipSyncEnable(bool enable)
{
LipSync.EnableLipSync = enable;
CurrentSettings.LipSyncEnable = enable;
}

private string[] GetLipSyncDevices()
{
return LipSync.GetMicrophoneDevices();
}

private void SetLipSyncDevice(string device)
{
LipSync.SetMicrophoneDevice(device);
CurrentSettings.LipSyncDevice = device;
}

private void SetLipSyncGain(float gain)
{
if (gain < 1.0f) gain = 1.0f;
if (gain > 256.0f) gain = 256.0f;
LipSync.Gain = gain;
CurrentSettings.LipSyncGain = gain;
}

private void SetLipSyncMaxWeightEnable(bool enable)
{
LipSync.MaxWeightEnable = enable;
CurrentSettings.LipSyncMaxWeightEnable = enable;
}

private void SetLipSyncWeightThreashold(float threashold)
{
LipSync.WeightThreashold = threashold;
CurrentSettings.LipSyncWeightThreashold = threashold;
}

private void SetLipSyncMaxWeightEmphasis(bool enable)
{
LipSync.MaxWeightEmphasis = enable;
CurrentSettings.LipSyncMaxWeightEmphasis = enable;
}

#endregion

#region Color

private void ChangeBackgroundColor(float r, float g, float b, bool isCustom)
Expand Down Expand Up @@ -673,6 +733,18 @@ private class Settings
public bool ShowCameraGrid = false;
[OptionalField]
public bool WindowClickThrough;
[OptionalField]
public bool LipSyncEnable;
[OptionalField]
public string LipSyncDevice;
[OptionalField]
public float LipSyncGain;
[OptionalField]
public bool LipSyncMaxWeightEnable;
[OptionalField]
public float LipSyncWeightThreashold;
[OptionalField]
public bool LipSyncMaxWeightEmphasis;
}

private Settings CurrentSettings = new Settings();
Expand Down Expand Up @@ -738,6 +810,18 @@ private void LoadSettings()
WindowLoader.Instance.LoadShowCameraGrid?.Invoke(CurrentSettings.ShowCameraGrid);
SetWindowClickThrough(CurrentSettings.WindowClickThrough);
WindowLoader.Instance.LoadSetWindowClickThrough?.Invoke(CurrentSettings.WindowClickThrough);
SetLipSyncEnable(CurrentSettings.LipSyncEnable);
WindowLoader.Instance.LoadLipSyncEnable?.Invoke(CurrentSettings.LipSyncEnable);
SetLipSyncDevice(CurrentSettings.LipSyncDevice);
WindowLoader.Instance.LoadLipSyncDevice?.Invoke(CurrentSettings.LipSyncDevice);
SetLipSyncGain(CurrentSettings.LipSyncGain);
WindowLoader.Instance.LoadLipSyncGain(CurrentSettings.LipSyncGain);
SetLipSyncMaxWeightEnable(CurrentSettings.LipSyncMaxWeightEnable);
WindowLoader.Instance.LoadLipSyncMaxWeightEnable?.Invoke(CurrentSettings.LipSyncMaxWeightEnable);
SetLipSyncWeightThreashold(CurrentSettings.LipSyncWeightThreashold);
WindowLoader.Instance.LoadLipSyncWeightThreashold?.Invoke(CurrentSettings.LipSyncWeightThreashold);
SetLipSyncMaxWeightEmphasis(CurrentSettings.LipSyncMaxWeightEmphasis);
WindowLoader.Instance.LoadLipSyncMaxWeightEmphasis?.Invoke(CurrentSettings.LipSyncMaxWeightEmphasis);
}
}

Expand Down
Loading

0 comments on commit c9d9b20

Please sign in to comment.