Skip to content

Commit

Permalink
Merge pull request #5 from kirurobo/develop
Browse files Browse the repository at this point in the history
Update VRM viewer
  • Loading branch information
kirurobo authored Sep 9, 2018
2 parents d2b44af + a73e6c2 commit cd7927e
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Assets/StreamingAssets/default_vrm.Textures.meta

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

Binary file modified Assets/StreamingAssets/default_vrm.Textures/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/default_vrm.Textures/icon.png.meta

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

Binary file modified Assets/StreamingAssets/default_vrm.vrm
Binary file not shown.
4 changes: 2 additions & 2 deletions Assets/StreamingAssets/default_vrm.vrm.meta

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

54 changes: 52 additions & 2 deletions Assets/UniWinApi/Examples/99_VrmViewerSample/VrmSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class VrmSample : MonoBehaviour {

private CameraController.WheelMode originalWheelMode;

public AudioSource audioSource;


// Use this for initialization
void Start () {
Expand All @@ -43,6 +45,11 @@ void Start () {
}
}

if (!audioSource)
{
audioSource = FindObjectOfType<AudioSource>();
}

// Load the initial motion.
LoadMotion(Application.streamingAssetsPath + "/default_bvh.txt");

Expand Down Expand Up @@ -119,14 +126,24 @@ private void Window_OnFilesDropped(string[] files)
if (ext == ".vrm")
{
LoadModel(path);
break;
continue;
}

// Open the motion file if its extension is ".bvh" or ".txt".
if (ext == ".bvh" || ext == ".txt")
{
LoadMotion(path);
break;
continue;
}

// Open the audio file.
// mp3はライセンスの関係でWindowsスタンドアローンでは読み込めないよう。
// 参考 https://docs.unity3d.com/jp/460/ScriptReference/WWW.GetAudioClip.html
// 参考 https://answers.unity.com/questions/433428/load-mp3-from-harddrive-on-pc-again.html
if (ext == ".ogg" || ext == ".wav")
{
LoadAudio(path);
continue;
}
}
}
Expand Down Expand Up @@ -213,4 +230,37 @@ private void LoadModel(string path)
}
}
}

/// <summary>
/// Load the audio clip
/// Reference: http://fantom1x.blog130.fc2.com/blog-entry-299.html
/// </summary>
/// <param name="path"></param>
private void LoadAudio(string path)
{
StartCoroutine(LoadAudioCoroutine(path));
}

private System.Collections.IEnumerator LoadAudioCoroutine(string path)
{
if (!File.Exists(path)) yield break;

using (WWW www = new WWW("file://" + path))
{
while (!www.isDone) {
yield return null;
}

AudioClip audioClip = www.GetAudioClip(false, false);
if (audioClip.loadState != AudioDataLoadState.Loaded)
{
Debug.Log("Failed to load audio: " + path);
yield break;
}

audioSource.clip = audioClip;
audioSource.Play();
Debug.Log("Audio: " + path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 13bcdf69fdb73ac4388722569c356a3f, type: 3}
m_Name:
m_EditorClassIdentifier:
_isTransparent: 0
_isTransparent: 1
_isTopmost: 1
_isMaximized: 0
_isMinimized: 0
Expand Down Expand Up @@ -1824,6 +1824,7 @@ GameObject:
- component: {fileID: 1787938563}
- component: {fileID: 1787938568}
- component: {fileID: 1787938567}
- component: {fileID: 1787938569}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
Expand Down Expand Up @@ -1942,6 +1943,87 @@ MonoBehaviour:
uiController: {fileID: 0}
cameraController: {fileID: 0}
cameraTransform: {fileID: 0}
audioSource: {fileID: 0}
--- !u!82 &1787938569
AudioSource:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787938562}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
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: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- serializedVersion: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
--- !u!1 &1898265829
GameObject:
m_ObjectHideFlags: 0
Expand Down
9 changes: 5 additions & 4 deletions Assets/UniWinApi/Examples/99_VrmViewerSample/readme_jp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

## 使い方

解像度を選んで起動後、[End]キーを押してみてください
ウィンドウが透過されれば正常に動作しています。
解像度を選んで起動後、ウィンドウが透過されれば正常に動作しています


### ファイルの読み込み

* VRMファイルをドロップするとモデルを差し替えます。
* BVHファイル(拡張子は .txt でも可)をドロップするとモーションを差し替えます。
* BVHファイル(拡張子は .bvh または .txt で受付)をドロップするとモーションを差し替えます。
* .ogg または .wav のファイルをドロップすると音声を再生します。ただしモーションと同期はしていません。


### ウィンドウ操作
Expand All @@ -33,7 +34,7 @@

### 照明操作

* [Shift]を押しながらマウスの右ボタンドラッグでカメラが回転します
* [Shift]を押しながらマウスの右ボタンドラッグでライトが回転します


## ソースおよび配布元
Expand Down

0 comments on commit cd7927e

Please sign in to comment.