├── README.md
├── MMD2UnityTool
├── 使用方法
│ ├── 1.jpg
│ ├── 2.jpg
│ └── 3.jpg
├── .vsconfig
├── Assets
│ ├── MMD2UnityTool
│ │ ├── 3rd
│ │ │ ├── mmd-for-unity-master
│ │ │ │ ├── logo.png
│ │ │ │ ├── README.md
│ │ │ │ ├── readme.html
│ │ │ │ ├── Resources
│ │ │ │ │ ├── toon
│ │ │ │ │ │ ├── toon00.bmp
│ │ │ │ │ │ ├── toon01.bmp
│ │ │ │ │ │ ├── toon02.bmp
│ │ │ │ │ │ ├── toon03.bmp
│ │ │ │ │ │ ├── toon04.bmp
│ │ │ │ │ │ ├── toon05.bmp
│ │ │ │ │ │ ├── toon06.bmp
│ │ │ │ │ │ ├── toon07.bmp
│ │ │ │ │ │ ├── toon08.bmp
│ │ │ │ │ │ ├── toon09.bmp
│ │ │ │ │ │ └── toon10.bmp
│ │ │ │ │ ├── HalfLambert.shader
│ │ │ │ │ ├── PMDMaterial
│ │ │ │ │ │ ├── Toons
│ │ │ │ │ │ │ └── toon.png
│ │ │ │ │ │ ├── README.md
│ │ │ │ │ │ ├── Shaders
│ │ │ │ │ │ │ ├── MeshPmdMaterialShadowVertFrag.cginc
│ │ │ │ │ │ │ ├── MeshPmdMaterial.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-CullBack.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-CullBack-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialVertFrag.cginc
│ │ │ │ │ │ │ ├── MeshPmdMaterialDummy.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-Trans-CullBack-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-CullBack.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-CullBack-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-Trans-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-Trans-CullBack-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-Trans-CullBack.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-Trans-NoCastShadow.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterial-Trans.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-Trans-CullBack.shader
│ │ │ │ │ │ │ ├── MeshPmdMaterialOutline-Trans.shader
│ │ │ │ │ │ │ └── MeshPmdMaterialSurface.cginc
│ │ │ │ │ │ ├── PMD Material.mat
│ │ │ │ │ │ ├── PMD Material Transparent.mat
│ │ │ │ │ │ ├── PMD Material with Outline Transparent.mat
│ │ │ │ │ │ └── PMD Material with Outline.mat
│ │ │ │ │ ├── Morph
│ │ │ │ │ │ ├── MorphBase.cs
│ │ │ │ │ │ ├── GroupMorph.cs
│ │ │ │ │ │ ├── UvMorph.cs
│ │ │ │ │ │ ├── VertexMorph.cs
│ │ │ │ │ │ └── BoneMorph.cs
│ │ │ │ │ ├── PhysicsManager.cs
│ │ │ │ │ ├── MMDSkinsScript.cs
│ │ │ │ │ ├── ExpressionManagerScript.cs
│ │ │ │ │ ├── IK
│ │ │ │ │ │ ├── BoneController.cs
│ │ │ │ │ │ └── CCDIKSolver.cs
│ │ │ │ │ └── MMDEngine.cs
│ │ │ │ ├── .gitignore
│ │ │ │ ├── Editor
│ │ │ │ │ ├── Inspector
│ │ │ │ │ │ ├── PMDScriptableObject.cs
│ │ │ │ │ │ ├── VMDScriptableObject.cs
│ │ │ │ │ │ ├── ScriptableObjectBase.cs
│ │ │ │ │ │ ├── InspectorBase.cs
│ │ │ │ │ │ ├── VMDInspector.cs
│ │ │ │ │ │ └── PMDInspector.cs
│ │ │ │ │ ├── Config
│ │ │ │ │ │ └── ConfigWindow.cs
│ │ │ │ │ ├── MMDLoader
│ │ │ │ │ │ ├── Private
│ │ │ │ │ │ │ ├── ComputeSkin.cs
│ │ │ │ │ │ │ ├── AlphaReadableTextureDirectoryImporter.cs
│ │ │ │ │ │ │ ├── MotionAgent.cs
│ │ │ │ │ │ │ └── MMDMathf.cs
│ │ │ │ │ │ ├── LoadedWindow.cs
│ │ │ │ │ │ ├── VMDLoaderWindow.cs
│ │ │ │ │ │ └── PMDLoaderWindow.cs
│ │ │ │ │ ├── XFileImporter
│ │ │ │ │ │ ├── XFileImporterWindow.cs
│ │ │ │ │ │ └── Private
│ │ │ │ │ │ │ └── XFileImporter.cs
│ │ │ │ │ ├── PhysicsManagerEditor.cs
│ │ │ │ │ ├── ExpressionManagerEditor.cs
│ │ │ │ │ └── MorphManagerEditor.cs
│ │ │ │ ├── .MMDIKBaker
│ │ │ │ │ ├── MMDIKBaker
│ │ │ │ │ │ ├── miku.pmd
│ │ │ │ │ │ ├── IK_Test.vmd
│ │ │ │ │ │ ├── TrueMyHeart.vmd
│ │ │ │ │ │ ├── Program.cs
│ │ │ │ │ │ └── Properties
│ │ │ │ │ │ │ └── AssemblyInfo.cs
│ │ │ │ │ ├── MMDIKBakerGUI
│ │ │ │ │ │ ├── bin
│ │ │ │ │ │ │ └── Debug
│ │ │ │ │ │ │ │ ├── MMDIKBakerGUI.exe
│ │ │ │ │ │ │ │ ├── MMDModelLibrary.dll
│ │ │ │ │ │ │ │ ├── MMDMotionLibrary.dll
│ │ │ │ │ │ │ │ ├── MMDBoneBakerLibrary.dll
│ │ │ │ │ │ │ │ └── MMDIKBakerGUI.vshost.exe
│ │ │ │ │ │ ├── Properties
│ │ │ │ │ │ │ ├── Settings.settings
│ │ │ │ │ │ │ ├── Settings.Designer.cs
│ │ │ │ │ │ │ ├── AssemblyInfo.cs
│ │ │ │ │ │ │ └── Resources.Designer.cs
│ │ │ │ │ │ ├── Program.cs
│ │ │ │ │ │ └── Form1.cs
│ │ │ │ │ ├── MMDIKBakerLibrary
│ │ │ │ │ │ ├── Misc
│ │ │ │ │ │ │ ├── Vector2.cs
│ │ │ │ │ │ │ ├── IIKSolver.cs
│ │ │ │ │ │ │ ├── IIKLimitter.cs
│ │ │ │ │ │ │ └── BezireCurve.cs
│ │ │ │ │ │ ├── Motion
│ │ │ │ │ │ │ ├── MMDMotion.cs
│ │ │ │ │ │ │ ├── MMDFaceKeyFrame.cs
│ │ │ │ │ │ │ ├── AnimationPlayer.cs
│ │ │ │ │ │ │ ├── MMDBoneKeyFrame.cs
│ │ │ │ │ │ │ └── MMDMotionTrack.cs
│ │ │ │ │ │ ├── Properties
│ │ │ │ │ │ │ └── AssemblyInfo.cs
│ │ │ │ │ │ ├── Model
│ │ │ │ │ │ │ ├── MMDIK.cs
│ │ │ │ │ │ │ ├── MMDBone.cs
│ │ │ │ │ │ │ └── ModelConverter.cs
│ │ │ │ │ │ └── IKBaker.cs
│ │ │ │ │ ├── TraceAndTestImpact.testsettings
│ │ │ │ │ ├── Local.testsettings
│ │ │ │ │ ├── MMDIKBaker.vsmdi
│ │ │ │ │ ├── MMDModelLibrary
│ │ │ │ │ │ ├── CoordinateType.cs
│ │ │ │ │ │ ├── Ver1
│ │ │ │ │ │ │ ├── ModelBoneDisp.cs
│ │ │ │ │ │ │ ├── ModelBoneDispName.cs
│ │ │ │ │ │ │ ├── ModelHeader.cs
│ │ │ │ │ │ │ ├── ModelIK.cs
│ │ │ │ │ │ │ ├── ModelBone.cs
│ │ │ │ │ │ │ └── ModelVertex.cs
│ │ │ │ │ │ ├── Properties
│ │ │ │ │ │ │ └── AssemblyInfo.cs
│ │ │ │ │ │ └── MMDModel.cs
│ │ │ │ │ ├── MMDMotionLibrary
│ │ │ │ │ │ ├── CoordinateType.cs
│ │ │ │ │ │ ├── Motion2
│ │ │ │ │ │ │ ├── FaceMotionData.cs
│ │ │ │ │ │ │ ├── LightMotionData.cs
│ │ │ │ │ │ │ ├── MotionData.cs
│ │ │ │ │ │ │ └── CameraMotionData.cs
│ │ │ │ │ │ ├── Properties
│ │ │ │ │ │ │ └── AssemblyInfo.cs
│ │ │ │ │ │ ├── MMDMotion.cs
│ │ │ │ │ │ └── MotionManager.cs
│ │ │ │ │ └── MMDIKBakerTest
│ │ │ │ │ │ ├── Properties
│ │ │ │ │ │ └── AssemblyInfo.cs
│ │ │ │ │ │ └── Vector3Test.cs
│ │ │ │ ├── LICENSE
│ │ │ │ ├── CHANGE-LOG
│ │ │ │ └── tutorial.md
│ │ │ └── mmd-for-unity-master.meta
│ │ ├── 3rd.meta
│ │ ├── Editor.meta
│ │ └── Editor
│ │ │ ├── Private.meta
│ │ │ ├── MMD2UnityToolMenu.cs.meta
│ │ │ ├── Private
│ │ │ ├── CameraVmdAgent.cs.meta
│ │ │ ├── FbxConverterTool.cs.meta
│ │ │ ├── VMDCameraConverter.cs.meta
│ │ │ ├── FbxConverterTool.cs
│ │ │ └── CameraVmdAgent.cs
│ │ │ └── MMD2UnityToolMenu.cs
│ └── MMD2UnityTool.meta
└── Packages
│ └── manifest.json
└── .gitignore
/README.md:
--------------------------------------------------------------------------------
1 | # MMD2UnityTool
2 | MMD导出到Unity 一些辅助工具
3 | 测试
--------------------------------------------------------------------------------
/MMD2UnityTool/使用方法/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/使用方法/1.jpg
--------------------------------------------------------------------------------
/MMD2UnityTool/使用方法/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/使用方法/2.jpg
--------------------------------------------------------------------------------
/MMD2UnityTool/使用方法/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/使用方法/3.jpg
--------------------------------------------------------------------------------
/MMD2UnityTool/.vsconfig:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0",
3 | "components": [
4 | "Microsoft.VisualStudio.Workload.ManagedGame"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/logo.png
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/README.md:
--------------------------------------------------------------------------------
1 | mmd-for-unity
2 | =============
3 |
4 |
5 | [MikuMikuDance for Unity 公式ページ](http://mmd-for-unity-proj.github.io/mmd-for-unity/)
6 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/readme.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/readme.html
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon00.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon00.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon01.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon01.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon02.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon02.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon03.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon03.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon04.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon04.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon05.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon05.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon06.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon06.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon07.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon07.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon08.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon08.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon09.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon09.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon10.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/toon/toon10.bmp
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.gitignore:
--------------------------------------------------------------------------------
1 | [Ll]ibrary/
2 | [Tt]emp/
3 | [Oo]bj/
4 |
5 | # Autogenerated VS/MD solution and project files
6 | *.csproj
7 | *.unityproj
8 | *.sln
9 | *.asset
10 | *.meta
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Inspector/PMDScriptableObject.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | public class PMDScriptableObject : ScriptableObjectBase
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Inspector/VMDScriptableObject.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | public class VMDScriptableObject : ScriptableObjectBase
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/HalfLambert.shader:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/HalfLambert.shader
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02947eeb1b73847848661814aa7db321
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/miku.pmd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/miku.pmd
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b48153ffb94284f07b4402360a8d6294
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/IK_Test.vmd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/IK_Test.vmd
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Toons/toon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Toons/toon.png
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 933c14437a47644f59d857bae047394e
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/TrueMyHeart.vmd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/TrueMyHeart.vmd
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/Private.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0a46a49821585407b924d826eb4f1fe3
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ca2e40c29b72148aca866896cf8e5b3e
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDIKBakerGUI.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDIKBakerGUI.exe
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDModelLibrary.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDModelLibrary.dll
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDMotionLibrary.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDMotionLibrary.dll
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDBoneBakerLibrary.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDBoneBakerLibrary.dll
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDIKBakerGUI.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MorphoDiana/MMD2UnityTool/HEAD/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/bin/Debug/MMDIKBakerGUI.vshost.exe
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Inspector/ScriptableObjectBase.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | public class ScriptableObjectBase
5 | #if !(UNITY_3_5 || UNITY_3_4 || UNITY_3_3)
6 | : ScriptableObject
7 | #endif
8 | {
9 | public string assetPath;
10 | }
11 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/MMD2UnityToolMenu.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a8e5eaa97dd4747388e0e19686ce50ff
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/Private/CameraVmdAgent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 378d93e894cfb4722b77ca45677e13bf
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/Private/FbxConverterTool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 68bd6b02f80a7470980b8a4a2e7a10ff
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/Private/VMDCameraConverter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d442fd3ddd0a34461a4543f3a0f2bc09
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Misc/Vector2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MMDIKBakerLibrary.Misc
6 | {
7 | struct Vector2
8 | {
9 | public float X;
10 | public float Y;
11 | public Vector2(float x, float y)
12 | {
13 | X = x;
14 | Y = y;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/Morph/MorphBase.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | public class MorphBase : MonoBehaviour
6 | {
7 | public float group_weight = 0.0f;
8 |
9 | ///
10 | /// ウェイト計算
11 | ///
12 | public float GetWeight(Transform transform)
13 | {
14 | return transform.localPosition.z + group_weight;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/TraceAndTestImpact.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | これらは、トレースおよびテストの影響のテスト設定です。
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/Local.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | これらはローカル テスト実行用の既定のテスト設定です。
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker.vsmdi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/CoordinateType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace MikuMikuDance.Model
3 | {
4 | ///
5 | /// 座標系を表す列挙体
6 | ///
7 | public enum CoordinateType
8 | {
9 | ///
10 | /// 左手座標系
11 | ///
12 | /// MMDの標準座標系
13 | LeftHandedCoordinate = 1,
14 | ///
15 | /// 右手座標系
16 | ///
17 | /// XNAの標準座標系
18 | RightHandedCoordinate = -1,
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/CoordinateType.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace MikuMikuDance.Motion
3 | {
4 | ///
5 | /// 座標系を表す列挙体
6 | ///
7 | public enum CoordinateType
8 | {
9 | ///
10 | /// 左手座標系
11 | ///
12 | /// MMDの標準座標系
13 | LeftHandedCoordinate = 1,
14 | ///
15 | /// 右手座標系
16 | ///
17 | /// XNAの標準座標系
18 | RightHandedCoordinate = -1,
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Misc/IIKSolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Model;
5 |
6 | namespace MMDIKBakerLibrary.Misc
7 | {
8 | interface IIKSolver
9 | {
10 | ///
11 | /// IKのソルブ
12 | ///
13 | /// 対象IK
14 | /// ボーンマネージャ
15 | /// 呼び出し側でUpdateGlobalをもう一度呼ぶ場合はtrue
16 | bool Solve(MMDIK ik, MMDBoneManager BoneManager);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace MMDIKBakerGUI
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// アプリケーションのメイン エントリ ポイントです。
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new Form1());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Motion/MMDMotion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MMDIKBakerLibrary.Motion
6 | {
7 | class MMDMotion
8 | {
9 | ///
10 | /// ボーンモーションデータ
11 | ///
12 | /// ボーンごとに時系列順
13 | public Dictionary> BoneFrames;
14 | ///
15 | /// フェイスモーションデータ
16 | ///
17 | /// 表情ごとに時系列順
18 | public Dictionary> FaceFrames;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Misc/IIKLimitter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Model;
5 |
6 | namespace MMDIKBakerLibrary.Misc
7 | {
8 | interface IIKLimitter
9 | {
10 | ///
11 | /// 制限の適用
12 | ///
13 | /// 対象となるボーン
14 | void Adjust(MMDBone bone);
15 |
16 | ///
17 | /// 回転軸制限の適用
18 | ///
19 | /// 対象となるボーン名
20 | /// 回転軸
21 | void Adjust(string boneName, ref Vector3 rotationAxis);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PhysicsManager.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | ///
5 | /// 物理演算管理(基本的にInspector拡張用に付加するだけで、このクラス自体は何もしない)
6 | ///
7 | public class PhysicsManager : MonoBehaviour {
8 |
9 | ///
10 | /// 初回更新前処理
11 | ///
12 | public void Start()
13 | {
14 | //再生時には不要なので、ビルド版では削除
15 | connect_bone_list = null;
16 | }
17 |
18 | ///
19 | /// Physicsに移動する前のGameObject
20 | ///
21 | [System.Serializable]
22 | public class ConnectBone {
23 | public GameObject joint;
24 | public GameObject parent;
25 |
26 | public ConnectBone(GameObject j = null, GameObject p = null) {joint = j; parent = p;}
27 | }
28 |
29 | public ConnectBone[] connect_bone_list = null; // Physicsに移動する前のGameObjectリスト
30 | }
31 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Config/ConfigWindow.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 |
4 | namespace MMD
5 | {
6 | public class ConfigWindow : EditorWindow
7 | {
8 | private Config config;
9 |
10 | [MenuItem("MMD for Unity/Config")]
11 | public static void Init()
12 | {
13 | GetWindow("MFU Config");
14 | }
15 |
16 | // Windowが有効化されたとき
17 | // フォーカスが外れて戻ってきたときや再度開かれたときなど
18 | void OnEnable()
19 | {
20 | if (config == null)
21 | {
22 | // 読み込む
23 | config = MMD.Config.LoadAndCreate();
24 | }
25 | }
26 |
27 | // ウィンドウの描画処理
28 | void OnGUI()
29 | {
30 | // あとは任せる
31 | config.OnGUI();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/Private/ComputeSkin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UnityEngine;
6 | //using Mono.Simd;
7 |
8 | namespace MMD
9 | {
10 | namespace Skin
11 | {
12 | ///
13 | /// スキンの計算を行う
14 | ///
15 | public class ComputeMorph
16 | {
17 | ///
18 | /// モーフベクトルをweight値から計算する
19 | ///
20 | /// モーフベクトル
21 | /// ウェイト
22 | /// 表情の移動ベクトル
23 | public static void Compute(ref Vector3[] resultVector, Vector3[] morphVector, float weight)
24 | {
25 | // モーフベクトルを伸び縮みさせたものを結果として返す
26 | for (int i = 0; i < morphVector.Length; i++)
27 | resultVector[i] = morphVector[i] * weight;
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /[Ll]ibrary/
2 | /[Tt]emp/
3 | /[Oo]bj/
4 | /[Bb]uild/
5 | /[Bb]uilds/
6 | /Assets/AssetStoreTools*
7 |
8 | # Autogenerated VS/MD/Consulo solution and project files
9 | ExportedObj/
10 | .consulo/
11 | *.csproj
12 | *.unityproj
13 | *.sln
14 | *.suo
15 | *.tmp
16 | *.user
17 | *.userprefs
18 | *.pidb
19 | *.booproj
20 | *.svd
21 | *.vscode
22 | *.vs
23 | *.objs
24 | *.history
25 |
26 |
27 | # Unity3D generated meta files
28 | *.pidb.meta
29 |
30 | # Unity3D Generated File On Crash Reports
31 | sysinfo.txt
32 |
33 | # Builds
34 | *.apk
35 | *.unitypackage
36 |
37 | # Unity3D Ignore
38 | MMD2UnityTool/Library
39 | MMD2UnityTool/Logs
40 | MMD2UnityTool/Temp
41 | MMD2UnityTool/ProjectSettings
42 | MMD2UnityTool/UserSettings
43 | MMD2UnityTool/obj
44 | MMD2UnityTool/.history
45 | MMD2UnityTool/.vs
46 |
47 | MMD2UnityTool/Assets/Z_Test
48 | MMD2UnityTool/Assets/Z_Test.meta
49 |
50 | ProjectVersion.txt
51 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/Private/AlphaReadableTextureDirectoryImporter.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections.Generic;
4 |
5 | public class AlphaReadableTextureDirectoryImporter : AssetPostprocessor {
6 |
7 | ///
8 | /// テクスチャプリプロセッサ
9 | ///
10 | void OnPreprocessTexture() {
11 | if (-1 != assetPath.IndexOf(AlphaReadableTexture.directory_name)) {
12 | //MmdForUnityの解析用ディレクトリなら
13 | TextureImporter importer = (TextureImporter)assetImporter;
14 | importer.isReadable = true; //読み込み可能とする
15 | //importer.textureFormat = TextureImporterFormat.Alpha8; //アルファのみ
16 | importer.mipmapEnabled = false; //mipmapを作成しない
17 | if (importer.DoesSourceTextureHaveAlpha()) {
18 | //アルファが有れば
19 | //透過フラグを立てる
20 | importer.alphaIsTransparency = true;
21 | } else {
22 | //アルファが無ければ
23 | //解像度を最小化
24 | importer.maxTextureSize = 1;
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/XFileImporter/XFileImporterWindow.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections;
4 |
5 | public class XFileImporterWindow : EditorWindow {
6 | Object xFile = null;
7 |
8 | [MenuItem ("MMD for Unity/XFile Importer")]
9 | static void Init() {
10 | var window = (XFileImporterWindow)EditorWindow.GetWindow(true, "XFile Importer");
11 | window.Show();
12 | }
13 |
14 | void OnGUI() {
15 | const int height = 20;
16 |
17 | xFile = EditorGUI.ObjectField(
18 | new Rect(0, 0, position.width-16, height), "XFile" ,xFile, typeof(Object), true);
19 |
20 | if (xFile != null) {
21 | if (GUI.Button(new Rect(0, height+2, position.width/2, height), "Convert")) {
22 | XFileImporter.Import(xFile);
23 | xFile = null; // 読み終わったので空にする
24 | }
25 | } else {
26 | EditorGUI.LabelField(new Rect(0, height+2, position.width, height), "Missing", "Select XFile");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Ver1/ModelBoneDisp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using WORD = System.UInt16;
4 |
5 | namespace MikuMikuDance.Model.Ver1
6 | {
7 | ///
8 | /// ボーン枠用表示データ
9 | ///
10 | public class ModelBoneDisp
11 | {
12 | ///
13 | /// 枠用ボーン番号
14 | ///
15 | public WORD BoneIndex { get; set; } // 枠用ボーン番号
16 | ///
17 | /// 表示枠用番号
18 | ///
19 | public byte BoneDispFrameIndex { get; set; } // 表示枠番号
20 |
21 | internal void Read(BinaryReader reader)
22 | {
23 | BoneIndex = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
24 | BoneDispFrameIndex = reader.ReadByte();
25 | }
26 |
27 | internal void Write(BinaryWriter writer)
28 | {
29 | writer.Write(BoneIndex);
30 | writer.Write(BoneDispFrameIndex);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/LoadedWindow.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections;
4 |
5 | public class LoadedWindow : EditorWindow
6 | {
7 | ///
8 | /// メッセージ用テキスト
9 | ///
10 | public string Text { get; set; }
11 |
12 | const int width = 400;
13 |
14 | const int height = 300;
15 |
16 | ///
17 | /// 初期化
18 | ///
19 | /// ウィンドウ
20 | public static LoadedWindow Init()
21 | {
22 | var window = EditorWindow.GetWindow("PMD file loaded!") as LoadedWindow;
23 | var pos = window.position;
24 | pos.height = LoadedWindow.height;
25 | pos.width = LoadedWindow.width;
26 | window.position = pos;
27 | return window;
28 | }
29 |
30 | void OnGUI()
31 | {
32 | EditorGUI.TextArea(new Rect(0, 0, LoadedWindow.width, LoadedWindow.height - 30), this.Text);
33 |
34 | if (GUI.Button(new Rect(0, height - 30, LoadedWindow.width, 30), "OK"))
35 | Close();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/XFileImporter/Private/XFileImporter.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | /*
5 | * 1. Google Sketchupのプラグインをインストール
6 | * http://www.3drad.com/Google-SketchUp-To-DirectX-XNA-Exporter-Plug-in.htm
7 | * (プラグインはSketchupをインストールしたフォルダのPluginsフォルダにスクリプトを入れればOK)
8 | *
9 | * 2. Xファイルの出力
10 | * 適当にフォルダを指定して出力
11 | *
12 | * 3. Projectへの読み込み
13 | * 出力したフォルダごとProjectに投げればOK
14 | *
15 | * 4. スクリプトの適用
16 | * 適当なGameObjectにこのスクリプトを適用させる
17 | * xFile変数にロードしたXファイルをD&Dして実行すれば出来上がり
18 | *
19 | * 諸注意
20 | * Xファイルは方言が多いので、現在は1.のプラグインで出力したファイルのみ対応
21 | */
22 |
23 | public class XFileImporter {
24 |
25 | // Use this for initialization
26 | public static void Import(Object xFile) {
27 | xfile.XFileConverter cnv = new xfile.XFileConverter(xFile);
28 |
29 | Object prefab = cnv.CreatePrefab();
30 | Material[] material = cnv.CreateMaterials();
31 | Mesh mesh = cnv.CreateMesh();
32 | cnv.ReplacePrefab(prefab, mesh, material);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MikuMikuDance.Model.Ver1;
5 | using MikuMikuDance.Model;
6 | using MikuMikuDance.Motion.Motion2;
7 | using MikuMikuDance.Motion;
8 | using MMDIKBakerLibrary;
9 |
10 | namespace MMDIKBaker
11 | {
12 | class Program
13 | {
14 | static void Main(string[] args)
15 | {
16 | //コンソールアプリ作りたいわけじゃないのでハードコーディングしとく
17 | string InputPMD = "miku.pmd";
18 | string InputVMD = "TrueMyHeart.vmd";
19 | string OutputVMD = "tmh_bake.vmd";
20 | MMDModel1 model = (MMDModel1)ModelManager.Read(InputPMD, MikuMikuDance.Model.CoordinateType.RightHandedCoordinate);
21 | MMDMotion2 motion = (MMDMotion2)MotionManager.Read(InputVMD, MikuMikuDance.Motion.CoordinateType.RightHandedCoordinate);
22 | motion = IKBaker.bake(motion, model);
23 | MotionManager.Write(OutputVMD, motion);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/Morph/GroupMorph.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | public class GroupMorph : MorphBase
6 | {
7 | public MorphManager.PanelType panel;
8 | public int[] indices;
9 | public float[] values;
10 |
11 | private float prev_weight_ = 0.0f;
12 | private float[] values_cache_ = null;
13 |
14 | ///
15 | /// モーフ処理
16 | ///
17 | /// 更新したか(true:更新した、false:未更新)
18 | /// モーフ値
19 | public bool Compute(float[] composite)
20 | {
21 | bool result = false;
22 | //キャッシュ設定
23 | float weight = base.GetWeight(transform);
24 | if ((prev_weight_ != weight) || (null == values_cache_)) {
25 | values_cache_ = values.Select(x=>x * weight).ToArray();
26 | prev_weight_ = weight;
27 | result = true;
28 | }
29 |
30 | //反映
31 | for (int i = 0, i_max = values_cache_.Length; i < i_max; ++i) {
32 | composite[indices[i]] += values_cache_[i];
33 | }
34 | return result;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/Morph/UvMorph.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | public class UvMorph : MorphBase
6 | {
7 | public MorphManager.PanelType panel;
8 | public int[] indices;
9 | public Vector2[] values;
10 |
11 | private float prev_weight_ = 0.0f;
12 | private Vector2[] values_cache_ = null;
13 |
14 | ///
15 | /// モーフ処理
16 | ///
17 | /// 更新したか(true:更新した、false:未更新)
18 | /// モーフ値
19 | public bool Compute(Vector2[] composite)
20 | {
21 | bool result = false;
22 | //キャッシュ設定
23 | float weight = base.GetWeight(transform);
24 | if ((prev_weight_ != weight) || (null == values_cache_)) {
25 | values_cache_ = values.Select(x=>x * weight).ToArray();
26 | prev_weight_ = weight;
27 | result = true;
28 | }
29 |
30 | //反映
31 | for (int i = 0, i_max = values_cache_.Length; i < i_max; ++i) {
32 | composite[indices[i]] += values_cache_[i];
33 | }
34 | return result;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Motion/MMDFaceKeyFrame.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Misc;
5 |
6 | namespace MMDIKBakerLibrary.Motion
7 | {
8 | class MMDFaceKeyFrame
9 | {
10 | ///
11 | /// 表情名
12 | ///
13 | public string FaceName;
14 | ///
15 | /// フレーム番号
16 | ///
17 | public uint FrameNo;
18 | ///
19 | /// 表情適応割合
20 | ///
21 | public float Rate;
22 | ///
23 | /// 表情の補完
24 | ///
25 | /// フレーム1
26 | /// フレーム2
27 | /// 進行度合い
28 | /// 表情適用量
29 | public static float Lerp(MMDFaceKeyFrame frame1, MMDFaceKeyFrame frame2, float progress)
30 | {
31 | return MathHelper.Lerp(frame1.Rate, frame2.Rate, progress);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/Morph/VertexMorph.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | public class VertexMorph : MorphBase
6 | {
7 | public MorphManager.PanelType panel;
8 | public int[] indices;
9 | public Vector3[] values;
10 |
11 | private float prev_weight_ = 0.0f;
12 | private Vector3[] values_cache_ = null;
13 |
14 | ///
15 | /// モーフ処理
16 | ///
17 | /// 更新したか(true:更新した、false:未更新)
18 | /// モーフ値
19 | public bool Compute(Vector3[] composite)
20 | {
21 | bool result = false;
22 | //キャッシュ設定
23 | float weight = base.GetWeight(transform);
24 | if ((prev_weight_ != weight) || (null == values_cache_)) {
25 | values_cache_ = values.Select(x=>x * weight).ToArray();
26 | prev_weight_ = weight;
27 | result = true;
28 | }
29 |
30 | //反映
31 | for (int i = 0, i_max = values_cache_.Length; i < i_max; ++i) {
32 | composite[indices[i]] += values_cache_[i];
33 | }
34 | return result;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/README.md:
--------------------------------------------------------------------------------
1 | MMD Shader for Unity
2 | ========
3 |
4 | ### Preview ###
5 |
6 |
7 |
8 | Presented by [3DCGArts](http://www.3dcg-arts.net/)
9 |
10 | ### Download ###
11 |
12 | [Version 1.2](https://github.com/3dcgarts/MMD-Shader-for-Unity/zipball/v1.2)
13 |
14 | ### 使い方 ###
15 |
16 | Unityパッケージである
17 |
18 | ```
19 | PMDMaterials.unitypackage
20 | ```
21 |
22 | を、Unityのメニューの
23 |
24 | ```
25 | Assets->Import Package->Custom Package...
26 | ```
27 |
28 | からインポートしてください。
29 |
30 | シェーダは以下の4つが用意されています。
31 |
32 | ```
33 | MMD/PMDMaterial
34 | MMD/PMDMaterial-with-Outline
35 | MMD/Transparent/PMDMaterial
36 | MMD/Transparent/PMDMaterial-with-Outline
37 | ```
38 |
39 | Transparent とついているものは、透明な材質に使ってください。
40 |
41 | Outline とついているものは、輪郭線を表示する材質に使ってください。
42 |
43 | ### その他 ###
44 |
45 | シェーダに割り当てられているプロパティは、PMDEditor の値に準拠しています。
46 |
47 | Directional Light (Color: White, Intensity: 0.5) の光源を受けている時に正しく表示されるように設計されています。
48 |
49 | 「Lat式ミク」のような特殊なメッシュ構造を持ったモデルも正しく表示することができます。
50 |
51 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.269
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MMDIKBakerGUI.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Ver1/ModelBoneDispName.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace MikuMikuDance.Model.Ver1
4 | {
5 | ///
6 | /// ボーン枠用の枠名
7 | ///
8 | public class ModelBoneDispName
9 | {
10 | ///
11 | /// ボーン枠用の枠名
12 | ///
13 | public string BoneDispName { get; set; }//ボーン枠用枠名
14 | ///
15 | /// ボーン枠用の枠名(英語、拡張)
16 | ///
17 | public string BoneDispNameEnglish { get; set; }//ボーン枠用枠名(英語、拡張)
18 | internal void Read(BinaryReader reader)
19 | {
20 | BoneDispName = MMDModel1.GetString(reader.ReadBytes(50));
21 | BoneDispNameEnglish = null;
22 | }
23 | internal void ReadExpantion(BinaryReader reader)
24 | {
25 | BoneDispNameEnglish = MMDModel1.GetString(reader.ReadBytes(50));
26 | }
27 |
28 | internal void Write(BinaryWriter writer)
29 | {
30 | writer.Write(MMDModel1.GetBytes(BoneDispName, 50));
31 | }
32 |
33 | internal void WriteExpantion(BinaryWriter writer)
34 | {
35 | writer.Write(MMDModel1.GetBytes(BoneDispNameEnglish, 50));
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットを通して制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MMDIKBakerTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MMDIKBakerTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照できなくなります。このアセンブリ内で COM から型にアクセスする必要がある場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。
23 | [assembly: Guid("fb3f53b4-55bc-473b-8bb1-c40e079dd827")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、以下のように '*' を使用してビルド番号とリビジョン番号を
33 | // 既定値にすることができます:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBaker/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MMDBoneBaker")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MMDBoneBaker")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("49201036-3934-4006-b21b-04eb8fb6aeee")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MMDIKBakerGUI")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MMDIKBakerGUI")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("0339f748-b7cb-4486-bae7-b330d0ac3512")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/Motion2/FaceMotionData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using DWORD = System.UInt32;
4 |
5 | namespace MikuMikuDance.Motion.Motion2
6 | {
7 | ///
8 | /// フェイスモーションデータ
9 | ///
10 | public class FaceMotionData
11 | {
12 | ///
13 | /// 表情適応割合
14 | ///
15 | public float Rate { get; set; }
16 | ///
17 | /// 表情名
18 | ///
19 | public string FaceName { get; set; }//[15];
20 | ///
21 | /// フレームナンバー
22 | ///
23 | public DWORD FrameNo { get; set; }
24 | internal void Read(BinaryReader reader)
25 | {
26 | FaceName = MMDMotion2.GetString(reader.ReadBytes(15));
27 | FrameNo = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
28 | //Wait = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
29 | Rate = BitConverter.ToSingle(reader.ReadBytes(4), 0);
30 | }
31 |
32 | internal void Write(BinaryWriter writer)
33 | {
34 | writer.Write(MMDMotion2.GetBytes(FaceName, 15));
35 | writer.Write((DWORD)FrameNo);
36 | writer.Write((Single)Rate);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MMDModelLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MMDModelLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2011 Wilfrem")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("cff3de6f-3e61-4425-869b-3080f2bc37e5")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.0.0.0")]
36 | [assembly: AssemblyFileVersion("2.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MMDMotionLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MMDMotionLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2011 Wilfrem")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("0584ce0b-5284-42b4-9c40-1afe2917ccbd")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.0.0.0")]
36 | [assembly: AssemblyFileVersion("2.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/MMD2UnityToolMenu.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEditor;
4 | using UnityEngine;
5 |
6 | public static class MMD2UnityToolMenu
7 | {
8 | [MenuItem("Assets/MMD2UnityTool/Export Vmd To Fbx")]
9 | public static void SpliteMMDFbxMotionToHumainMotionFbx()
10 | {
11 | var selected = Selection.activeObject;
12 | string selectPath = AssetDatabase.GetAssetPath(selected);
13 | if (!string.IsNullOrEmpty(selectPath))
14 | {
15 | FbxConverterTool.SpliteFbxMotion2Anim(selectPath);
16 | }
17 | else
18 | {
19 | Debug.LogError("没有选中文件或文件夹");
20 | }
21 | }
22 |
23 | [MenuItem("Assets/MMD2UnityTool/Export Camera Vmd To Anim")]
24 | public static void ExportCameraVmdToAnim()
25 | {
26 | var selected = Selection.activeObject;
27 | string selectPath = AssetDatabase.GetAssetPath(selected);
28 | if (!string.IsNullOrEmpty(selectPath))
29 | {
30 | CameraVmdAgent camera_agent = new CameraVmdAgent(selectPath);
31 | camera_agent.CreateAnimationClip();
32 | Debug.LogFormat("[{0}]:Export Camera Vmd Success!", System.DateTime.Now);
33 | }
34 | else
35 | {
36 | Debug.LogError("没有选中文件或文件夹");
37 | }
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/MMDMotion.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace MikuMikuDance.Motion
4 | {
5 | ///
6 | /// MMDモーションを表すインターフェイス
7 | ///
8 | public interface MMDMotion
9 | {
10 | ///
11 | /// MMDモーションバージョン番号
12 | ///
13 | int Version { get; }
14 | ///
15 | /// Read関数
16 | ///
17 | /// この関数はModelManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が読まれた状態で渡される
18 | /// マジック文字とバージョン番号読み込み済みのBinaryReader
19 | /// 変換先座標系
20 | /// スケーリング値
21 | void Read(BinaryReader reader, CoordinateType coordinate, float scale);
22 | ///
23 | /// 保持しているデータの座標系
24 | ///
25 | CoordinateType Coordinate { get; }
26 | #if false
27 | ///
28 | /// スケーリング
29 | ///
30 | /// 拡大倍率
31 | void Scale(float ScaleFactor);
32 | #endif
33 | ///
34 | /// モーションの書き出し
35 | ///
36 | /// 書き出し
37 | /// スケーリング値
38 | void Write(BinaryWriter writer, float scale);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialShadowVertFrag.cginc:
--------------------------------------------------------------------------------
1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
2 |
3 | /*
4 | * MMD Shader for Unity
5 | *
6 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | float _Opacity;
21 | sampler2D _MainTex;
22 | float4 _MainTex_ST;
23 |
24 | struct v2f
25 | {
26 | float4 pos : SV_POSITION;
27 | float2 uv : TEXCOORD0;
28 | };
29 |
30 | v2f shadow_vert( appdata_img v )
31 | {
32 | v2f o;
33 | o.pos = UnityObjectToClipPos(v.vertex);
34 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
35 | return o;
36 | }
37 |
38 | half4 shadow_frag( v2f i ) : COLOR
39 | {
40 | float4 tex_color = tex2D(_MainTex, i.uv);
41 | return half4(0, 0, 0, tex_color.a * _Opacity);
42 | }
43 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("MMDBoneBakerLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MMDBoneBakerLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
23 | [assembly: Guid("912f8a3c-d5c2-421d-8d85-7be2978d4dcf")]
24 |
25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
38 | [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MMDIKBakerTest")]
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/MMDSkinsScript.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | public class MMDSkinsScript : MonoBehaviour
6 | {
7 | // 表情の種類
8 | public enum SkinType
9 | {
10 | Base,
11 | EyeBrow,
12 | Eye,
13 | Lip,
14 | Other,
15 | }
16 |
17 | // 全ての頂点データからターゲットとなる頂点インデックス
18 | public int[] targetIndices;
19 |
20 | // モーフ先へのベクトル
21 | public Vector3[] morphTarget;
22 |
23 | // 表情の種類
24 | public SkinType skinType;
25 |
26 | // 前フレームのウェイト値
27 | float prev_weight = 0;
28 |
29 | // ウェイト付きモーフ結果
30 | public Vector3[] current_morph=null;
31 |
32 | // Use this for initialization
33 | void Start ()
34 | {
35 |
36 | }
37 |
38 | // モーフの計算
39 | public bool Compute(Vector3[] composite)
40 | {
41 | bool computed_morph = false; // 計算したかどうか
42 |
43 | float weight = transform.localPosition.z;
44 |
45 | if(current_morph==null || targetIndices.Length!=current_morph.Length)
46 | current_morph=new Vector3[targetIndices.Length];
47 |
48 | if (weight != prev_weight)
49 | {
50 | computed_morph = true;
51 | for (int i = 0; i < targetIndices.Length; i++)
52 | current_morph[i]=morphTarget[i] * weight;
53 | }
54 | for (int i = 0; i < targetIndices.Length; i++)
55 | {
56 | if(targetIndices[i] 0)
14 | {
15 | string targetPath = Application.dataPath + "/AnimationClip"; //目录AnimationClip
16 | if (!Directory.Exists(targetPath))
17 | {
18 | Directory.CreateDirectory(targetPath); //如果目录不存在就创建一个
19 | }
20 |
21 | foreach (Object obj in objects) //遍历选择的物体
22 | {
23 | AnimationClip fbxClip = obj as AnimationClip;
24 | if (fbxClip != null)
25 | {
26 | AnimationClip clip = new AnimationClip(); //new一个AnimationClip存放生成的AnimationClip
27 | EditorUtility.CopySerialized(fbxClip, clip); //复制
28 | AssetDatabase.CreateAsset(clip, "Assets/AnimationClip/" + fbxClip.name + ".anim"); //生成文件
29 | }
30 | else
31 | {
32 | Debug.Log("当前选择的文件不是带有AnimationClip的FBX文件");
33 | }
34 | }
35 |
36 | }
37 |
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _MainTex("テクスチャ", 2D) = "white" {}
27 | _ToonTex("トゥーン", 2D) = "white" {}
28 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
29 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
30 | }
31 |
32 | SubShader
33 | {
34 | // First Pass
35 | Pass
36 | {
37 | Cull Off
38 | }
39 |
40 | // Surface Shader
41 | CGPROGRAM
42 | #pragma surface surf MMD
43 | #include "MeshPmdMaterialSurface.cginc"
44 | ENDCG
45 | }
46 |
47 | // Other Environment
48 | Fallback "Diffuse"
49 | }
50 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/PMD Material.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: PMD Material
10 | m_Shader: {fileID: 4800000, guid: 0cb22e333ded91341b3f5eba1c6bb950, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _MainTex:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _SphereAddTex:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _SphereMulTex:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _ToonTex:
34 | m_Texture: {fileID: 2800000, guid: df2482a76bd514960b85b7ba12b9ea17, type: 3}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | m_Floats:
38 | - _Shininess: 0
39 | m_Colors:
40 | - _AmbColor: {r: 0, g: 0, b: 0, a: 1}
41 | - _Color: {r: 0.14534715, g: 0.848968, b: 0.52422005, a: 1}
42 | - _SpecularColor: {r: 0, g: 0, b: 0, a: 1}
43 | --- !u!1002 &2100001
44 | EditorExtensionImpl:
45 | serializedVersion: 6
46 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-CullBack.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-CullBack"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _MainTex("テクスチャ", 2D) = "white" {}
27 | _ToonTex("トゥーン", 2D) = "white" {}
28 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
29 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
30 | }
31 |
32 | SubShader
33 | {
34 | // First Pass
35 | Pass
36 | {
37 | Cull Back
38 | }
39 |
40 | // Surface Shader
41 | CGPROGRAM
42 | #pragma surface surf MMD
43 | #include "MeshPmdMaterialSurface.cginc"
44 | ENDCG
45 | }
46 |
47 | // Other Environment
48 | Fallback "Diffuse"
49 | }
50 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/PMD Material Transparent.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: PMD Material Transparent
10 | m_Shader: {fileID: 4800000, guid: d9a28a4fb26b1bf4aa2074b1b9e5a000, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _MainTex:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _SphereAddTex:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _SphereMulTex:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _ToonTex:
34 | m_Texture: {fileID: 2800000, guid: df2482a76bd514960b85b7ba12b9ea17, type: 3}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | m_Floats:
38 | - _Opacity: 0.8
39 | - _Shininess: 0
40 | m_Colors:
41 | - _AmbColor: {r: 0, g: 0, b: 0, a: 1}
42 | - _Color: {r: 0.84393066, g: 0.8589086, b: 0.113923594, a: 1}
43 | - _SpecularColor: {r: 0, g: 0, b: 0, a: 1}
44 | --- !u!1002 &2100001
45 | EditorExtensionImpl:
46 | serializedVersion: 6
47 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011, Eiichi Takebuchi, Takahiro Inoue, Shota Ozaki, goopymoon, Masamitsu Ishikawa, Kazuki Yasufuku, Fumiya Hirano.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 |
8 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 |
10 | Neither the name of the MikuMikuDance for Unity nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11 |
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _MainTex("テクスチャ", 2D) = "white" {}
27 | _ToonTex("トゥーン", 2D) = "white" {}
28 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
29 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
30 | }
31 |
32 | SubShader
33 | {
34 | // Settings
35 | Tags
36 | {
37 | "ForceNoShadowCasting" = "True"
38 | }
39 |
40 | // First Pass
41 | Pass
42 | {
43 | Cull Off
44 | }
45 |
46 | // Surface Shader
47 | CGPROGRAM
48 | #pragma surface surf MMD
49 | #include "MeshPmdMaterialSurface.cginc"
50 | ENDCG
51 | }
52 |
53 | // Other Environment
54 | Fallback "Diffuse"
55 | }
56 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/VMDLoaderWindow.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using UnityEditor;
4 |
5 | public class VMDLoaderWindow : EditorWindow {
6 | Object vmdFile;
7 | GameObject pmdPrefab;
8 | MMD.VMDImportConfig vmd_config;
9 |
10 | [MenuItem ("MMD for Unity/VMD Loader")]
11 | static void Init() {
12 | var window = (VMDLoaderWindow)EditorWindow.GetWindow(true, "VMDLoader");
13 | window.Show();
14 | }
15 |
16 | void OnEnable()
17 | {
18 | // デフォルトコンフィグ
19 | vmdFile = null;
20 | pmdPrefab = null;
21 | vmd_config = MMD.Config.LoadAndCreate().vmd_config.Clone();
22 | }
23 |
24 | void OnGUI() {
25 | // GUIの有効化
26 | GUI.enabled = !EditorApplication.isPlaying;
27 |
28 | // GUI描画
29 | pmdPrefab = (GameObject)EditorGUILayout.ObjectField("PMD Prefab", pmdPrefab, typeof(GameObject), false);
30 | vmdFile = EditorGUILayout.ObjectField("VMD File", vmdFile, typeof(Object), false);
31 | vmd_config.OnGUIFunction();
32 |
33 | {
34 | bool gui_enabled_old = GUI.enabled;
35 | GUI.enabled = !EditorApplication.isPlaying && (pmdPrefab != null) && (vmdFile != null);
36 | if (GUILayout.Button("Convert")) {
37 | LoadMotion();
38 | vmdFile = null;
39 | }
40 | GUI.enabled = gui_enabled_old;
41 | }
42 | }
43 |
44 | void LoadMotion() {
45 | string file_path = AssetDatabase.GetAssetPath(vmdFile);
46 | MMD.MotionAgent motion_agent = new MMD.MotionAgent(file_path);
47 | motion_agent.CreateAnimationClip(pmdPrefab
48 | , vmd_config.createAnimationFile
49 | , vmd_config.interpolationQuality
50 | );
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-CullBack-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-CullBack-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _MainTex("テクスチャ", 2D) = "white" {}
27 | _ToonTex("トゥーン", 2D) = "white" {}
28 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
29 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
30 | }
31 |
32 | SubShader
33 | {
34 | // Settings
35 | Tags
36 | {
37 | "ForceNoShadowCasting" = "True"
38 | }
39 |
40 | // First Pass
41 | Pass
42 | {
43 | Cull Back
44 | }
45 |
46 | // Surface Shader
47 | CGPROGRAM
48 | #pragma surface surf MMD
49 | #include "MeshPmdMaterialSurface.cginc"
50 | ENDCG
51 | }
52 |
53 | // Other Environment
54 | Fallback "Diffuse"
55 | }
56 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/MMDModel.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace MikuMikuDance.Model
4 | {
5 | ///
6 | /// MMDモデルを表すインターフェイス
7 | ///
8 | ///
9 | /// このクラスを継承し、オリジナルのオブジェクトを作成する場合は引数なしコンストラクタを用意すること
10 | /// また、Read,Write関数をオーバーライドすること。
11 | ///
12 | public interface MMDModel
13 | {
14 | ///
15 | /// MMDモデルバージョン番号
16 | ///
17 | float Version { get; }
18 | ///
19 | /// Read関数
20 | ///
21 | /// この関数はModelManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が読まれた状態で渡される
22 | /// マジック文字とバージョン番号読み込み済みのBinaryReader
23 | /// 座標系変換指定
24 | /// スケール
25 | void Read(BinaryReader reader, CoordinateType coordinate, float scale);
26 | ///
27 | /// Write関数
28 | ///
29 | /// この関数はModelManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が書かれた状態で渡される
30 | /// マジック文字とバージョン番号書き込み済みのBinaryWriter
31 | /// スケール
32 | void Write(BinaryWriter writer, float scale);
33 | ///
34 | /// 保持しているデータの座標系
35 | ///
36 | CoordinateType Coordinate { get; }
37 |
38 | #if false
39 | ///
40 | /// スケーリング
41 | ///
42 | /// 拡大倍率
43 | void Scale(float ScaleFactor);
44 | #endif
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialVertFrag.cginc:
--------------------------------------------------------------------------------
1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
2 |
3 | /*
4 | * MMD Shader for Unity
5 | *
6 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | float4 _Color;
21 | float _Opacity;
22 | float4 _OutlineColor;
23 | float _OutlineWidth;
24 |
25 | struct v2f
26 | {
27 | float4 pos : SV_POSITION;
28 | float2 uv : TEXCOORD0;
29 | };
30 |
31 | v2f vert( appdata_base v )
32 | {
33 | v2f o;
34 | float4 pos = UnityObjectToClipPos(v.vertex);
35 | float4 normal = UnityObjectToClipPos(float4(v.normal, 0.0));
36 | float width = _OutlineWidth / 1024.0; //目コピ調整値(算術根拠無し)
37 | float depth_offset = pos.z / 4194304.0; //僅かに奥に移動(floatの仮数部は23bitなので(1<<21)程度で割った値は丸めに入らないが非常に小さな値の筈)
38 | o.pos = pos + normal * float4(width, width, 0.0, 0.0) + float4(0.0, 0.0, depth_offset, 0.0);
39 |
40 | return o;
41 | }
42 | half4 frag( v2f i ) : COLOR
43 | {
44 | return half4( _OutlineColor.rgb, _OutlineColor.a * _Opacity );
45 | }
46 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/Motion2/LightMotionData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using DWORD = System.UInt32;
4 |
5 | namespace MikuMikuDance.Motion.Motion2
6 | {
7 | ///
8 | /// ライトモーションデータ
9 | ///
10 | public class LightMotionData
11 | {
12 | ///
13 | /// フレームナンバー
14 | ///
15 | public DWORD FrameNo { get; set; }
16 | ///
17 | /// ライトの色
18 | ///
19 | public float[] Color { get; protected set; }
20 | ///
21 | /// ライトの位置
22 | ///
23 | public float[] Location { get; protected set; }
24 | internal void Read(BinaryReader reader, float CoordZ)
25 | {
26 | FrameNo = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
27 | Color = new float[3];
28 | Location = new float[3];
29 | for (int i = 0; i < 3; i++)
30 | Color[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
31 | for (int i = 0; i < 3; i++)
32 | Location[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
33 | Location[2] *= CoordZ;
34 | }
35 |
36 | internal void Write(BinaryWriter writer, float CoordZ)
37 | {
38 | writer.Write((DWORD)FrameNo);
39 | for (int i = 0; i < 3; i++)
40 | writer.Write((Single)Color[i]);
41 | writer.Write((Single)Location[0]);
42 | writer.Write((Single)Location[1]);
43 | writer.Write((Single)Location[2] * CoordZ);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/CHANGE-LOG:
--------------------------------------------------------------------------------
1 | -----ここからGitHUBでの開発-----
2 | 【2.0b】
3 | GitHUBで開発された分をリリース.
4 |
5 | 【2.0.14b】
6 | Configがうまくロードされない場合があるので対処
7 | マイナー以降のナンバリングはGitHUBのPullRequestに準拠
8 |
9 | -----ここまでSorceForge.jpのSVNで開発-----
10 |
11 | 【r240】
12 | ここまでで対応したこと
13 | ・PMXConverter
14 | 頂点モーフ,UVモーフ,材質モーフ等
15 | ・透過不透明,エッシ有無,影放ち有無,背面カリング有無の16種類のシェーダを使い分ける様に対応
16 | 不透明度0.99の時に両面描画
17 | 不透明度0.98の時にセルフシャドウを受けないマテリアル
18 | エッジが無ければ影を放たない
19 | ・物理演算のグローバル座標化等々
20 | ・詳しい対応については以下のURL参照
21 | http://sourceforge.jp/projects/mmd-for-unity/scm/svn/listCommit?skip=0
22 |
23 | 【r121】
24 | ・[readme.html] 使い方を追記
25 | UnityでMMDを動かす会 として使い方を用意したほうがよさそうな.
26 | SourceForgeのwikiとかバグ管理とか活用したいところ
27 | ・[AvatarSettingScript.cs]Animator.MatchTargetの引数にWeightMaskが必要らしいので追加
28 | 但し、これで正しいのかわからない。要検証
29 | ・CCDIK周りの整理
30 | 余計なコメント・ファイルの削除など
31 |
32 | 既知の問題
33 | ・Mechanim(Animator?)を使うのに必要なAvatorが生成されないため、Mechanimが使えない
34 | -> http://forum.unity3d.com/threads/156951-Create-Mechanim-Avatar-in-editor-script
35 | "in 4.0 we can only create Avatars in the ModelImporter" とのこと。
36 | ばーじょんあっぷ待ち。
37 |
38 |
39 | 【r120】
40 | MMDIKBakerのGUI版を追加。
41 | コンソール+VisualStudio必須だったものをそうでもない具合に。
42 |
43 |
44 | 【r119】
45 | 読み込み部分、移動の抽出を変更。ズレがなくなった模様
46 |
47 |
48 | 【r117】
49 | 改善したこと
50 | ・IKの実装
51 | ・VMD読み込み時の座標修正
52 | ・Unity側に表示されるWarningの改善
53 |
54 | 既知のバグ
55 | ・VMD読み込み時にズレがでている(気がする
56 | ・VMDの補間がUnity側に反映されていない
57 |
58 |
59 | 【1.1a-r109】
60 | 61回もマイナーバージョンアップしているわけではないので表記を変更
61 |
62 | 改善したこと
63 | ・トゥーンシェーダーに対応
64 | ・表情を実装
65 | ・剛体にも対応
66 | ・一部、バグっているモデルについても対応
67 |
68 | 既知のバグ
69 | ・Lat式ミクの読み込みが不完全
70 | ・複数の表情を動かせない
71 | ・同じ複数のモデルを一つのシーンに入れて表情を動かすと全部同じ顔になる
72 |
73 | 【1.61a】
74 | ひとまず動いている版
75 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/PMD Material with Outline Transparent.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: PMD Material with Outline Transparent
10 | m_Shader: {fileID: 4800000, guid: 200ec679e5d921b4fbbfca0acb268f60, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _MainTex:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _SphereAddTex:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _SphereMulTex:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _ToonTex:
34 | m_Texture: {fileID: 2800000, guid: df2482a76bd514960b85b7ba12b9ea17, type: 3}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | m_Floats:
38 | - _Opacity: 0.5
39 | - _OutlineWidth: 0.06858341
40 | - _Shininess: 0
41 | m_Colors:
42 | - _AmbColor: {r: 0.21939135, g: 0.21939135, b: 0.21939135, a: 1}
43 | - _Color: {r: 0.7620103, g: 0.21136099, b: 0.21136099, a: 1}
44 | - _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
45 | - _SpecularColor: {r: 0, g: 0, b: 0, a: 1}
46 | --- !u!1002 &2100001
47 | EditorExtensionImpl:
48 | serializedVersion: 6
49 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/PMD Material with Outline.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: PMD Material with Outline
10 | m_Shader: {fileID: 4800000, guid: 1caff3dbcad030e45946b79da5247af8, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _MainTex:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _SphereAddTex:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _SphereMulTex:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _ToonTex:
34 | m_Texture: {fileID: 2800000, guid: df2482a76bd514960b85b7ba12b9ea17, type: 3}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | m_Floats:
38 | - _Opacity: 1
39 | - _OutlineWidth: 0.070219226
40 | - _Shininess: 0
41 | m_Colors:
42 | - _AmbColor: {r: 0.23463738, g: 0.23463738, b: 0.23463738, a: 1}
43 | - _Color: {r: 0.11564884, g: 0.3061467, b: 0.6743529, a: 1}
44 | - _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
45 | - _SpecularColor: {r: 0.16904736, g: 0.16904736, b: 0.16904736, a: 1}
46 | --- !u!1002 &2100001
47 | EditorExtensionImpl:
48 | serializedVersion: 6
49 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Inspector/InspectorBase.cs:
--------------------------------------------------------------------------------
1 | // Inspectorからインポートなどができるようになります
2 | // 他スクリプトと競合してしまう時はコメントアウトしてください
3 |
4 | #define USE_INSPECTOR
5 |
6 | //----------
7 |
8 | #if USE_INSPECTOR
9 | using System.IO;
10 | using System.Linq;
11 | using UnityEditor;
12 | using UnityEditor.Callbacks;
13 | using UnityEngine;
14 |
15 | namespace MMD
16 | {
17 | [InitializeOnLoad]
18 | public class InspectorBase : Editor
19 | {
20 | static InspectorBase()
21 | {
22 | EntryEditorApplicationUpdate();
23 | }
24 |
25 | [DidReloadScripts]
26 | static void OnDidReloadScripts()
27 | {
28 | EntryEditorApplicationUpdate();
29 | }
30 |
31 | static void EntryEditorApplicationUpdate()
32 | {
33 | EditorApplication.update += Update;
34 | }
35 |
36 | static void Update()
37 | {
38 | if (Selection.objects.Length != 0)
39 | {
40 | string path = AssetDatabase.GetAssetPath(Selection.activeObject);
41 | string extension = Path.GetExtension(path).ToLower();
42 |
43 | if (extension == ".pmd" || extension == ".pmx")
44 | {
45 | //SetupScriptableObject(path);
46 | }
47 | else if (extension == ".vmd")
48 | {
49 | //SetupScriptableObject(path);
50 | }
51 | }
52 | }
53 |
54 | static void SetupScriptableObject(string path) where T : ScriptableObjectBase
55 | {
56 | int count = Selection.objects.OfType().Count();
57 | if (count != 0) return;
58 | T scriptableObject = ScriptableObject.CreateInstance();
59 | scriptableObject.assetPath = path;
60 | Selection.activeObject = scriptableObject;
61 | EditorUtility.UnloadUnusedAssetsImmediate();
62 | }
63 | }
64 | }
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialDummy.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Dummy"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
28 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
29 | _MainTex("テクスチャ", 2D) = "white" {}
30 | _ToonTex("トゥーン", 2D) = "white" {}
31 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
32 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
33 |
34 | _DummyColor("ダミー色", Color) = (1,0,1,1)
35 | _DummyOriginalShaderType("オリジナルシェーダータイプ", Float) = 0
36 | }
37 |
38 | SubShader
39 | {
40 | // First Pass
41 | Pass
42 | {
43 | Color[_DummyColor]
44 | Lighting Off
45 | Cull Off
46 | ZWrite On
47 | ZTest LEqual
48 | Offset 0, 0
49 | AlphaTest Greater 0.0
50 | }
51 | }
52 |
53 | // Other Environment
54 | Fallback "Diffuse"
55 | }
56 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-Trans-CullBack-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-CullBack-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _MainTex("テクスチャ", 2D) = "white" {}
28 | _ToonTex("トゥーン", 2D) = "white" {}
29 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
30 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
31 | }
32 |
33 | SubShader
34 | {
35 | // Settings
36 | Tags
37 | {
38 | "Queue" = "Transparent"
39 | "RenderType" = "Transparent"
40 | }
41 |
42 | // Surface Shader
43 | Cull Back
44 | ZWrite On
45 | Blend SrcAlpha OneMinusSrcAlpha
46 | AlphaTest Greater 0.0
47 | CGPROGRAM
48 | #pragma surface surf MMD
49 | #include "MeshPmdMaterialSurface.cginc"
50 | ENDCG
51 |
52 | }
53 |
54 | // Other Environment
55 | Fallback "Transparent/Diffuse"
56 | }
57 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Model/MMDIK.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MMDIKBakerLibrary.Model
6 | {
7 | class MMDIK
8 | {
9 | ///
10 | /// 目標位置となるボーン
11 | ///
12 | public MMDBone IKBone { get; internal set; }
13 | ///
14 | /// エフェクタとなるボーン
15 | ///
16 | public MMDBone IKTargetBone { get; internal set; }
17 | ///
18 | /// 再帰演算回数
19 | ///
20 | public readonly UInt16 Iteration;
21 | ///
22 | /// IKの影響度
23 | ///
24 | public readonly float ControlWeight;
25 | ///
26 | /// IK影響下のボーン
27 | ///
28 | public List IKChildBones { get; internal set; }
29 |
30 | internal int IKBoneIndex;
31 | internal int IKTargetBoneIndex;
32 | internal List ikChildBoneIndex;
33 | ///
34 | /// コンストラクタ
35 | ///
36 | /// IKボーンとなるボーン
37 | /// エフェクタとなるボーン
38 | /// 再帰演算回数
39 | /// IKの影響度
40 | /// IK影響下のボーン
41 | public MMDIK(int ikBoneIndex, int iktargetindex, UInt16 iteration, float controlWeight, List ikChildBones)
42 | {
43 | IKBoneIndex = ikBoneIndex;
44 | IKTargetBoneIndex = iktargetindex;
45 | Iteration = iteration;
46 | ControlWeight = controlWeight;
47 | ikChildBoneIndex = ikChildBones;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/PMDLoaderWindow.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using UnityEditor;
4 |
5 | public class PMDLoaderWindow : EditorWindow {
6 | Object pmdFile;
7 | MMD.PMDImportConfig pmd_config;
8 |
9 | [MenuItem("MMD for Unity/PMD Loader")]
10 | static void Init() {
11 | var window = (PMDLoaderWindow)EditorWindow.GetWindow(true, "PMDLoader");
12 | window.Show();
13 | }
14 |
15 | void OnEnable()
16 | {
17 | // デフォルトコンフィグ
18 | pmdFile = null;
19 | pmd_config = MMD.Config.LoadAndCreate().pmd_config.Clone();
20 | }
21 |
22 | void OnGUI() {
23 | // GUIの有効化
24 | GUI.enabled = !EditorApplication.isPlaying;
25 |
26 | // GUI描画
27 | pmdFile = EditorGUILayout.ObjectField("PMD File" , pmdFile, typeof(Object), false);
28 | pmd_config.OnGUIFunction();
29 |
30 | {
31 | bool gui_enabled_old = GUI.enabled;
32 | GUI.enabled = !EditorApplication.isPlaying && (pmdFile != null);
33 | if (GUILayout.Button("Convert")) {
34 | LoadModel();
35 | pmdFile = null; // 読み終わったので空にする
36 | }
37 | GUI.enabled = gui_enabled_old;
38 | }
39 | }
40 |
41 | void LoadModel() {
42 | string file_path = AssetDatabase.GetAssetPath(pmdFile);
43 | MMD.ModelAgent model_agent = new MMD.ModelAgent(file_path);
44 | model_agent.CreatePrefab(pmd_config.shader_type
45 | , pmd_config.rigidFlag
46 | , pmd_config.animation_type
47 | , pmd_config.use_ik
48 | , pmd_config.scale
49 | , pmd_config.is_pmx_base_import
50 | );
51 |
52 | // 読み込み完了メッセージ
53 | var window = LoadedWindow.Init();
54 | window.Text = string.Format(
55 | "----- model name -----\n{0}\n\n----- comment -----\n{1}",
56 | model_agent.name,
57 | model_agent.comment
58 | );
59 | window.Show();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-with-Outline"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
27 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
28 | _MainTex("テクスチャ", 2D) = "white" {}
29 | _ToonTex("トゥーン", 2D) = "white" {}
30 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
31 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
32 | }
33 |
34 | SubShader
35 | {
36 | // Surface Shader
37 | Cull Off
38 | CGPROGRAM
39 | #pragma surface surf MMD
40 | #include "MeshPmdMaterialSurface.cginc"
41 | ENDCG
42 |
43 | // Outline Pass
44 | Pass
45 | {
46 | Cull Front
47 | Lighting Off
48 |
49 | CGPROGRAM
50 | #pragma vertex vert
51 | #pragma fragment frag
52 | #include "UnityCG.cginc"
53 | #include "MeshPmdMaterialVertFrag.cginc"
54 | ENDCG
55 | }
56 | }
57 |
58 | // Other Environment
59 | Fallback "Diffuse"
60 | }
61 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-CullBack.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-with-Outline-CullBack"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
27 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
28 | _MainTex("テクスチャ", 2D) = "white" {}
29 | _ToonTex("トゥーン", 2D) = "white" {}
30 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
31 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
32 | }
33 |
34 | SubShader
35 | {
36 | // Surface Shader
37 | Cull Back
38 | CGPROGRAM
39 | #pragma surface surf MMD
40 | #include "MeshPmdMaterialSurface.cginc"
41 | ENDCG
42 |
43 | // Outline Pass
44 | Pass
45 | {
46 | Cull Front
47 | Lighting Off
48 |
49 | CGPROGRAM
50 | #pragma vertex vert
51 | #pragma fragment frag
52 | #include "UnityCG.cginc"
53 | #include "MeshPmdMaterialVertFrag.cginc"
54 | ENDCG
55 | }
56 | }
57 |
58 | // Other Environment
59 | Fallback "Diffuse"
60 | }
61 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Motion/AnimationPlayer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Model;
5 | using MMDIKBakerLibrary.Misc;
6 |
7 | namespace MMDIKBakerLibrary.Motion
8 | {
9 | class AnimationPlayer
10 | {
11 | private MMDBoneManager boneManager;
12 | private MMDMotionTrack motionTrack;
13 | private Dictionary resultPoses = new Dictionary();
14 | private List underIKBones = new List();
15 | Dictionary BindPoses;
16 | public AnimationPlayer(MMDBoneManager boneManager)
17 | {
18 | this.boneManager = boneManager;
19 | BindPoses = new Dictionary();
20 | for (int i = 0; i < boneManager.Count; ++i)
21 | {
22 | BindPoses.Add(boneManager[i].Name, boneManager[i].BindPose);
23 | }
24 | }
25 |
26 | public void SetMotion(MMDMotion motionData)
27 | {
28 | this.motionTrack = new MMDMotionTrack(motionData);
29 | }
30 |
31 | public bool Update()
32 | {
33 | resultPoses.Clear();
34 | bool result = motionTrack.Update();
35 | foreach (KeyValuePair subpose in motionTrack.SubPoses)
36 | {
37 | resultPoses[subpose.Key] = subpose.Value;
38 | SQTTransform bindPose, sub = subpose.Value, local;
39 | if (BindPoses.TryGetValue(subpose.Key, out bindPose))
40 | {
41 | SQTTransform.Multiply(ref sub, ref bindPose, out local);
42 | boneManager[subpose.Key].LocalTransform = local;
43 | }
44 | }
45 | return result;
46 | }
47 |
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-with-Outline-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
27 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
28 | _MainTex("テクスチャ", 2D) = "white" {}
29 | _ToonTex("トゥーン", 2D) = "white" {}
30 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
31 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
32 | }
33 |
34 | SubShader
35 | {
36 | // Settings
37 | Tags
38 | {
39 | "ForceNoShadowCasting" = "True"
40 | }
41 |
42 | // Surface Shader
43 | Cull Off
44 | CGPROGRAM
45 | #pragma surface surf MMD
46 | #include "MeshPmdMaterialSurface.cginc"
47 | ENDCG
48 |
49 | // Outline Pass
50 | Pass
51 | {
52 | Cull Front
53 | Lighting Off
54 |
55 | CGPROGRAM
56 | #pragma vertex vert
57 | #pragma fragment frag
58 | #include "UnityCG.cginc"
59 | #include "MeshPmdMaterialVertFrag.cginc"
60 | ENDCG
61 | }
62 | }
63 |
64 | // Other Environment
65 | Fallback "Diffuse"
66 | }
67 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Packages/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "com.unity.collab-proxy": "1.3.9",
4 | "com.unity.formats.fbx": "4.1.2",
5 | "com.unity.ide.rider": "2.0.7",
6 | "com.unity.ide.visualstudio": "2.0.5",
7 | "com.unity.ide.vscode": "1.2.3",
8 | "com.unity.recorder": "2.5.7",
9 | "com.unity.test-framework": "1.1.22",
10 | "com.unity.textmeshpro": "3.0.1",
11 | "com.unity.timeline": "1.4.6",
12 | "com.unity.ugui": "1.0.0",
13 | "com.unity.modules.ai": "1.0.0",
14 | "com.unity.modules.androidjni": "1.0.0",
15 | "com.unity.modules.animation": "1.0.0",
16 | "com.unity.modules.assetbundle": "1.0.0",
17 | "com.unity.modules.audio": "1.0.0",
18 | "com.unity.modules.cloth": "1.0.0",
19 | "com.unity.modules.director": "1.0.0",
20 | "com.unity.modules.imageconversion": "1.0.0",
21 | "com.unity.modules.imgui": "1.0.0",
22 | "com.unity.modules.jsonserialize": "1.0.0",
23 | "com.unity.modules.particlesystem": "1.0.0",
24 | "com.unity.modules.physics": "1.0.0",
25 | "com.unity.modules.physics2d": "1.0.0",
26 | "com.unity.modules.screencapture": "1.0.0",
27 | "com.unity.modules.terrain": "1.0.0",
28 | "com.unity.modules.terrainphysics": "1.0.0",
29 | "com.unity.modules.tilemap": "1.0.0",
30 | "com.unity.modules.ui": "1.0.0",
31 | "com.unity.modules.uielements": "1.0.0",
32 | "com.unity.modules.umbra": "1.0.0",
33 | "com.unity.modules.unityanalytics": "1.0.0",
34 | "com.unity.modules.unitywebrequest": "1.0.0",
35 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
36 | "com.unity.modules.unitywebrequestaudio": "1.0.0",
37 | "com.unity.modules.unitywebrequesttexture": "1.0.0",
38 | "com.unity.modules.unitywebrequestwww": "1.0.0",
39 | "com.unity.modules.vehicles": "1.0.0",
40 | "com.unity.modules.video": "1.0.0",
41 | "com.unity.modules.vr": "1.0.0",
42 | "com.unity.modules.wind": "1.0.0",
43 | "com.unity.modules.xr": "1.0.0"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-CullBack-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/PMDMaterial-with-Outline-CullBack-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _SpecularColor("反射色", Color) = (1,1,1)
24 | _AmbColor("環境色", Color) = (1,1,1)
25 | _Shininess("反射強度", Float) = 0
26 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
27 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
28 | _MainTex("テクスチャ", 2D) = "white" {}
29 | _ToonTex("トゥーン", 2D) = "white" {}
30 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
31 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
32 | }
33 |
34 | SubShader
35 | {
36 | // Settings
37 | Tags
38 | {
39 | "ForceNoShadowCasting" = "True"
40 | }
41 |
42 | // Surface Shader
43 | Cull Back
44 | CGPROGRAM
45 | #pragma surface surf MMD
46 | #include "MeshPmdMaterialSurface.cginc"
47 | ENDCG
48 |
49 | // Outline Pass
50 | Pass
51 | {
52 | Cull Front
53 | Lighting Off
54 |
55 | CGPROGRAM
56 | #pragma vertex vert
57 | #pragma fragment frag
58 | #include "UnityCG.cginc"
59 | #include "MeshPmdMaterialVertFrag.cginc"
60 | ENDCG
61 | }
62 | }
63 |
64 | // Other Environment
65 | Fallback "Diffuse"
66 | }
67 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-Trans-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _MainTex("テクスチャ", 2D) = "white" {}
28 | _ToonTex("トゥーン", 2D) = "white" {}
29 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
30 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
31 | }
32 |
33 | SubShader
34 | {
35 | // Settings
36 | Tags
37 | {
38 | "Queue" = "Transparent"
39 | "RenderType" = "Transparent"
40 | }
41 |
42 | // Surface Shader
43 | Cull Front
44 | ZWrite Off
45 | Blend SrcAlpha OneMinusSrcAlpha
46 | AlphaTest Greater 0.0
47 | CGPROGRAM
48 | #pragma surface surf MMD
49 | #include "MeshPmdMaterialSurface.cginc"
50 | ENDCG
51 |
52 | // Surface Shader
53 | Cull Back
54 | ZWrite On
55 | Blend SrcAlpha OneMinusSrcAlpha
56 | AlphaTest Greater 0.0
57 | CGPROGRAM
58 | #pragma surface surf MMD
59 | #include "MeshPmdMaterialSurface.cginc"
60 | ENDCG
61 |
62 | }
63 |
64 | // Other Environment
65 | Fallback "Transparent/Diffuse"
66 | }
67 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Model/MMDBone.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Misc;
5 |
6 | namespace MMDIKBakerLibrary.Model
7 | {
8 | class MMDBone
9 | {
10 | ///
11 | /// ボーンの名前
12 | ///
13 | public readonly string Name;
14 |
15 | ///
16 | /// ボーンのバインドポーズ行列
17 | ///
18 | public readonly SQTTransform BindPose;
19 | ///
20 | /// ボーンのバインドポーズ逆行列
21 | ///
22 | /// 変更しないこと……
23 | public Matrix InverseBindPose;
24 | ///
25 | /// ボーンの親のボーンのインデックス情報
26 | ///
27 | /// 親が無い場合は-1
28 | public readonly int SkeletonHierarchy;
29 |
30 | ///
31 | /// ボーンのローカル変換行列
32 | ///
33 | /// アニメーション再生時にはアニメーションにより上書きされる
34 | public SQTTransform LocalTransform;
35 |
36 | ///
37 | /// ボーンのグローバル変換行列
38 | ///
39 | /// 毎フレームごとにLocalTransformから計算され、上書きされる
40 | public Matrix GlobalTransform;
41 | ///
42 | /// コンストラクタ
43 | ///
44 | /// 名前
45 | /// バインドポーズ
46 | /// 逆バインドポーズ
47 | /// 親ボーン番号
48 | public MMDBone(string name, SQTTransform bindPose, Matrix inverseBindPose, int skeletonHierarchy)
49 | {
50 | Name = name;
51 | BindPose = bindPose;
52 | InverseBindPose = inverseBindPose;
53 | SkeletonHierarchy = skeletonHierarchy;
54 | LocalTransform = bindPose;
55 | GlobalTransform = Matrix.Identity;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Ver1/ModelHeader.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace MikuMikuDance.Model.Ver1
4 | {
5 | ///
6 | /// モデルヘッダ情報を表すクラス
7 | ///
8 | public class ModelHeader
9 | {
10 | ///
11 | /// モデル名
12 | ///
13 | public string ModelName { get; set; }
14 | ///
15 | /// モデルコメント
16 | ///
17 | public string Comment { get; set; }
18 | ///
19 | /// モデル名(英語、拡張)
20 | ///
21 | public string ModelNameEnglish { get; set; }
22 | ///
23 | /// モデルコメント(英語、拡張)
24 | ///
25 | public string CommentEnglish { get; set; }
26 | ///
27 | /// 既定のコンストラクタ
28 | ///
29 | public ModelHeader()
30 | {
31 | ModelName = "";
32 | Comment = "";
33 | ModelNameEnglish = null;
34 | CommentEnglish = null;
35 | }
36 | internal void Read(BinaryReader reader)
37 | {
38 | //モデル名
39 | ModelName = MMDModel1.GetString(reader.ReadBytes(20));
40 | //コメント
41 | Comment = MMDModel1.GetString(reader.ReadBytes(256));
42 | }
43 |
44 | internal void ReadExpantion(BinaryReader reader)
45 | {
46 | ModelNameEnglish = MMDModel1.GetString(reader.ReadBytes(20));
47 | CommentEnglish = MMDModel1.GetString(reader.ReadBytes(256));
48 | }
49 |
50 | internal void Write(BinaryWriter writer)
51 | {
52 | writer.Write(MMDModel1.GetBytes(ModelName, 20));
53 | writer.Write(MMDModel1.GetBytes(Comment, 256));
54 | }
55 |
56 | internal void WriteExpantion(BinaryWriter writer)
57 | {
58 | writer.Write(MMDModel1.GetBytes(ModelNameEnglish, 20));
59 | writer.Write(MMDModel1.GetBytes(CommentEnglish, 256));
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-Trans-CullBack-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-with-Outline-CullBack-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
28 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
29 | _MainTex("テクスチャ", 2D) = "white" {}
30 | _ToonTex("トゥーン", 2D) = "white" {}
31 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
32 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
33 | }
34 |
35 | SubShader
36 | {
37 | // Settings
38 | Tags
39 | {
40 | "Queue" = "Transparent"
41 | "RenderType" = "Transparent"
42 | }
43 |
44 | // Surface Shader Pass
45 | Cull Back
46 | ZWrite On
47 | Blend SrcAlpha OneMinusSrcAlpha
48 | AlphaTest Greater 0.0
49 | CGPROGRAM
50 | #pragma surface surf MMD
51 | #include "MeshPmdMaterialSurface.cginc"
52 | ENDCG
53 |
54 | // Outline Pass
55 | Pass
56 | {
57 | Cull Front
58 | Lighting Off
59 | CGPROGRAM
60 | #pragma vertex vert
61 | #pragma fragment frag
62 | #include "UnityCG.cginc"
63 | #include "MeshPmdMaterialVertFrag.cginc"
64 | ENDCG
65 | }
66 |
67 | }
68 |
69 | // Other Environment
70 | Fallback "Transparent/Diffuse"
71 | }
72 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Misc/BezireCurve.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MMDIKBakerLibrary.Misc
6 | {
7 | struct BezierCurve
8 | {
9 | internal const float Epsilon = 1.0e-3f;
10 |
11 | ///
12 | /// ベジェ曲線に用いる点1
13 | ///
14 | public Vector2 v1;
15 | ///
16 | /// ベジェ曲線に用いる点2
17 | ///
18 | public Vector2 v2;
19 |
20 |
21 | ///
22 | /// 進行度合から移行度合を取得
23 | ///
24 | /// 進行度合
25 | /// 移行度合
26 | public float Evaluate(float Progress)
27 | {
28 | //ニュートン法による近似
29 | float t = MathHelper.Clamp(Progress, 0f, 1f);
30 | float dt;
31 | do
32 | {
33 | dt = -(fx(t) - Progress) / dfx(t);
34 |
35 | if (float.IsNaN(dt))
36 | break;
37 | t += MathHelper.Clamp(dt, -1f, 1f);//大幅に移動して別の解に到達するのを防止する用
38 | } while (Math.Abs(dt) > Epsilon);
39 | return MathHelper.Clamp(fy(t), 0f, 1f);//念のため、0-1の間に収まるようにした
40 | }
41 | //fy(t)を計算する関数
42 | private float fy(float t)
43 | {
44 | //fy(t)=(1-t)^3*0+3*(1-t)^2*t*v1.y+3*(1-t)*t^2*v2.y+t^3*1
45 | return 3 * (1 - t) * (1 - t) * t * v1.Y + 3 * (1 - t) * t * t * v2.Y + t * t * t;
46 | }
47 | //fx(t)を計算する関数
48 | float fx(float t)
49 | {
50 | //fx(t)=(1-t)^3*0+3*(1-t)^2*t*v1.x+3*(1-t)*t^2*v2.x+t^3*1
51 | return 3 * (1 - t) * (1 - t) * t * v1.X + 3 * (1 - t) * t * t * v2.X + t * t * t;
52 | }
53 | //dfx/dtを計算する関数
54 | float dfx(float t)
55 | {
56 | //dfx(t)/dt=-6(1-t)*t*v1.x+3(1-t)^2*v1.x-3t^2*v2.x+6(1-t)*t*v2.x+3t^2
57 | return -6 * (1 - t) * t * v1.X + 3 * (1 - t) * (1 - t) * v1.X
58 | - 3 * t * t * v2.X + 6 * (1 - t) * t * v2.X + 3 * t * t;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-Trans-CullBack.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-CullBack"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _MainTex("テクスチャ", 2D) = "white" {}
28 | _ToonTex("トゥーン", 2D) = "white" {}
29 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
30 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
31 | }
32 |
33 | SubShader
34 | {
35 | // Settings
36 | Tags
37 | {
38 | "Queue" = "Transparent"
39 | "RenderType" = "Transparent"
40 | }
41 |
42 | // Surface Shader
43 | Cull Back
44 | ZWrite On
45 | Blend SrcAlpha OneMinusSrcAlpha
46 | AlphaTest Greater 0.0
47 | CGPROGRAM
48 | #pragma surface surf MMD
49 | #include "MeshPmdMaterialSurface.cginc"
50 | ENDCG
51 |
52 | // ShadowCast Pass
53 | Pass
54 | {
55 | Tags
56 | {
57 | "LightMode" = "ShadowCaster"
58 | }
59 | Cull Off
60 | Lighting Off
61 | //Offset [_ShadowBias], [_ShadowBiasSlope] //使えない様なのでコメントアウト
62 | AlphaTest Greater 0.25
63 |
64 | CGPROGRAM
65 | #pragma vertex shadow_vert
66 | #pragma fragment shadow_frag
67 | #include "UnityCG.cginc"
68 | #include "MeshPmdMaterialShadowVertFrag.cginc"
69 | ENDCG
70 | }
71 |
72 | }
73 |
74 | // Other Environment
75 | Fallback "Transparent/Diffuse"
76 | }
77 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/Editor/Private/CameraVmdAgent.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using UnityEditor;
5 | using UnityEditor.Animations;
6 | using UnityEngine;
7 |
8 | public class CameraVmdAgent
9 | {
10 | string _vmdFile;
11 | MMD.VMD.VMDFormat format_;
12 |
13 | public CameraVmdAgent(string filePath)
14 | {
15 | _vmdFile = filePath;
16 |
17 | }
18 |
19 | public void CreateAnimationClip()
20 | {
21 | if (null == format_)
22 | {
23 | format_ = VMDLoaderScript.Import(_vmdFile);
24 | }
25 |
26 | AnimationClip animation_clip = VMDCameraConverter.CreateAnimationClip(format_);
27 | if (animation_clip == null)
28 | {
29 | throw new System.Exception("Cannot create AnimationClip");
30 | }
31 |
32 | string vmd_folder = Path.GetDirectoryName(_vmdFile);
33 | string anima_file = Path.Combine(vmd_folder, animation_clip.name + ".anim");
34 |
35 | if (File.Exists(anima_file))
36 | AssetDatabase.DeleteAsset(anima_file);
37 |
38 | AssetDatabase.CreateAsset(animation_clip, anima_file);
39 |
40 | AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(animation_clip));
41 |
42 |
43 |
44 | GameObject mmdCamera = new GameObject("MMDCamera");
45 |
46 | Animator animator = mmdCamera.AddComponent();
47 | AnimationClip clip = AssetDatabase.LoadAssetAtPath(anima_file);
48 | AnimatorController controller = AnimatorController.CreateAnimatorControllerAtPath(Path.Combine(vmd_folder, animation_clip.name + ".controller"));
49 | AnimatorState state = controller.AddMotion(clip);
50 | animator.runtimeAnimatorController = controller;
51 |
52 | GameObject distance = new GameObject("Distance");
53 | distance.transform.parent = mmdCamera.transform;
54 |
55 | GameObject camera = new GameObject("Camera");
56 | camera.transform.parent = distance.transform;
57 | camera.AddComponent();
58 |
59 | camera.transform.rotation = Quaternion.Euler(0, 180, 0);
60 |
61 | string prefabPath = Path.Combine(vmd_folder,"MMDCamera.prefab");
62 | PrefabUtility.SaveAsPrefabAsset(mmdCamera, prefabPath);
63 |
64 | GameObject.DestroyImmediate(mmdCamera);
65 |
66 | //AssetDatabase.Refresh();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-Trans-NoCastShadow.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-with-Outline-NoCastShadow"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
28 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
29 | _MainTex("テクスチャ", 2D) = "white" {}
30 | _ToonTex("トゥーン", 2D) = "white" {}
31 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
32 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
33 | }
34 |
35 | SubShader
36 | {
37 | // Settings
38 | Tags
39 | {
40 | "Queue" = "Transparent"
41 | "RenderType" = "Transparent"
42 | }
43 |
44 | // Surface Shader Pass ( Back )
45 | Cull Front
46 | ZWrite On
47 | Blend SrcAlpha OneMinusSrcAlpha
48 | AlphaTest Greater 0.0
49 | CGPROGRAM
50 | #pragma surface surf MMD
51 | #include "MeshPmdMaterialSurface.cginc"
52 | ENDCG
53 |
54 | // Surface Shader Pass
55 | Cull Back
56 | ZWrite On
57 | Blend SrcAlpha OneMinusSrcAlpha
58 | AlphaTest Greater 0.0
59 | CGPROGRAM
60 | #pragma surface surf MMD
61 | #include "MeshPmdMaterialSurface.cginc"
62 | ENDCG
63 |
64 | // Outline Pass
65 | Pass
66 | {
67 | Cull Front
68 | Lighting Off
69 | CGPROGRAM
70 | #pragma vertex vert
71 | #pragma fragment frag
72 | #include "UnityCG.cginc"
73 | #include "MeshPmdMaterialVertFrag.cginc"
74 | ENDCG
75 | }
76 |
77 | }
78 |
79 | // Other Environment
80 | Fallback "Transparent/Diffuse"
81 | }
82 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Ver1/ModelIK.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using WORD = System.UInt16;
4 |
5 | namespace MikuMikuDance.Model.Ver1
6 | {
7 | ///
8 | /// IKボーン
9 | ///
10 | public class ModelIK
11 | {
12 | ///
13 | /// IKボーン番号
14 | ///
15 | public WORD IKBoneIndex { get; set; } // IKボーン番号
16 | ///
17 | /// IKターゲットボーン番号
18 | ///
19 | /// IKボーンが最初に接続するボーン
20 | public WORD IKTargetBoneIndex { get; set; } // IKターゲットボーン番号 // IKボーンが最初に接続するボーン
21 | //byte ik_chain_length;//読み込んでるが、ik_child_bone_indexで参照可のため、メンバにしない
22 | ///
23 | /// 再帰演算回数
24 | ///
25 | /// IK値1
26 | public WORD Iterations { get; set; } // 再帰演算回数 // IK値1
27 | ///
28 | /// 一回のIK計算での角度制限
29 | ///
30 | /// IK値2
31 | public float AngleLimit { get; set; } // IKの影響度 // IK値2
32 | ///
33 | /// IK影響下のボーン番号リスト
34 | ///
35 | public WORD[] IKChildBoneIndex { get; set; } // IK影響下のボーン番号-サイズはik_chain_length
36 |
37 | internal void Read(BinaryReader reader)
38 | {
39 | IKBoneIndex = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
40 | IKTargetBoneIndex = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
41 | byte ik_chain_length = reader.ReadByte();
42 | Iterations = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
43 | AngleLimit = BitConverter.ToSingle(reader.ReadBytes(4), 0);
44 | IKChildBoneIndex = new WORD[ik_chain_length];
45 | for (int i = 0; i < ik_chain_length; i++)
46 | IKChildBoneIndex[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
47 | }
48 |
49 | internal void Write(BinaryWriter writer)
50 | {
51 | writer.Write(IKBoneIndex);
52 | writer.Write(IKTargetBoneIndex);
53 | writer.Write((byte)IKChildBoneIndex.Length);
54 | writer.Write(Iterations);
55 | writer.Write(AngleLimit);
56 | for (int i = 0; i < IKChildBoneIndex.Length; i++)
57 | writer.Write(IKChildBoneIndex[i]);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterial-Trans.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _MainTex("テクスチャ", 2D) = "white" {}
28 | _ToonTex("トゥーン", 2D) = "white" {}
29 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
30 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
31 | }
32 |
33 | SubShader
34 | {
35 | // Settings
36 | Tags
37 | {
38 | "Queue" = "Transparent"
39 | "RenderType" = "Transparent"
40 | }
41 |
42 | // Surface Shader
43 | Cull Front
44 | ZWrite Off
45 | Blend SrcAlpha OneMinusSrcAlpha
46 | AlphaTest Greater 0.0
47 | CGPROGRAM
48 | #pragma surface surf MMD
49 | #include "MeshPmdMaterialSurface.cginc"
50 | ENDCG
51 |
52 | // Surface Shader
53 | Cull Back
54 | ZWrite On
55 | Blend SrcAlpha OneMinusSrcAlpha
56 | AlphaTest Greater 0.0
57 | CGPROGRAM
58 | #pragma surface surf MMD
59 | #include "MeshPmdMaterialSurface.cginc"
60 | ENDCG
61 |
62 | // ShadowCast Pass
63 | Pass
64 | {
65 | Tags
66 | {
67 | "LightMode" = "ShadowCaster"
68 | }
69 | Cull Off
70 | Lighting Off
71 | //Offset [_ShadowBias], [_ShadowBiasSlope] //使えない様なのでコメントアウト
72 | AlphaTest Greater 0.25
73 |
74 | CGPROGRAM
75 | #pragma vertex shadow_vert
76 | #pragma fragment shadow_frag
77 | #include "UnityCG.cginc"
78 | #include "MeshPmdMaterialShadowVertFrag.cginc"
79 | ENDCG
80 | }
81 |
82 | }
83 |
84 | // Other Environment
85 | Fallback "Transparent/Diffuse"
86 | }
87 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/IKBaker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Model;
5 | using MMDIKBakerLibrary.Motion;
6 | using MMDMotion2 = MikuMikuDance.Motion.Motion2.MMDMotion2;
7 | using MMDModel1 = MikuMikuDance.Model.Ver1.MMDModel1;
8 | namespace MMDIKBakerLibrary
9 | {
10 | public class IKBaker
11 | {
12 | public static MMDMotion2 bake(MMDMotion2 motion, MMDModel1 model)
13 | {
14 | //ボーン取得
15 | MMDBoneManager boneManager = ModelConverter.BuildBoneManager(model);
16 | //ベイク前のモーションとベイク後のモーションを準備
17 | MMDMotion beforeMotion = MotionConverter.Convert(motion);
18 | MMDMotion afterMotion = CreateAfterMotionPrototype(beforeMotion, boneManager);
19 | //アニメーションプレイヤーを作成
20 | AnimationPlayer player = new AnimationPlayer(boneManager);
21 | player.SetMotion(beforeMotion);
22 | //ベイクしていく
23 | uint frameNo = 0;
24 | bool ExitFlag = false;
25 | while (!ExitFlag)
26 | {
27 | ExitFlag = !player.Update();
28 | //ボーンのグローバル行列更新
29 | boneManager.CalcGlobalTransform();
30 | //IK更新
31 | boneManager.CalcIK();
32 | //ベイク
33 | boneManager.bake(frameNo, afterMotion);
34 | ++frameNo;
35 | }
36 | //元のMMDMotion2に直して返却
37 | return MotionConverter.Convert(afterMotion, motion.ModelName);
38 | }
39 |
40 | private static MMDMotion CreateAfterMotionPrototype(MMDMotion beforeMotion, MMDBoneManager boneManager)
41 | {
42 | //ベイク対象外の情報をコピー
43 | MMDMotion result = new MMDMotion();
44 | //表情は参照をコピーしておく
45 | result.FaceFrames = beforeMotion.FaceFrames;
46 | //ボーンは必要分だけ参照をコピー
47 | result.BoneFrames = new Dictionary>();
48 | foreach (KeyValuePair> boneSet in beforeMotion.BoneFrames)
49 | {
50 | if (!boneManager.IsUnderIK(boneSet.Key))
51 | {
52 | result.BoneFrames.Add(boneSet.Key, boneSet.Value);
53 | }
54 | else
55 | {
56 | result.BoneFrames.Add(boneSet.Key, new List());
57 | }
58 | }
59 | return result;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-Trans-CullBack.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-with-Outline-CullBack"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
28 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
29 | _MainTex("テクスチャ", 2D) = "white" {}
30 | _ToonTex("トゥーン", 2D) = "white" {}
31 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
32 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
33 | }
34 |
35 | SubShader
36 | {
37 | // Settings
38 | Tags
39 | {
40 | "Queue" = "Transparent"
41 | "RenderType" = "Transparent"
42 | }
43 |
44 | // Surface Shader Pass
45 | Cull Back
46 | ZWrite On
47 | Blend SrcAlpha OneMinusSrcAlpha
48 | AlphaTest Greater 0.0
49 | CGPROGRAM
50 | #pragma surface surf MMD
51 | #include "MeshPmdMaterialSurface.cginc"
52 | ENDCG
53 |
54 | // Outline Pass
55 | Pass
56 | {
57 | Cull Front
58 | Lighting Off
59 | CGPROGRAM
60 | #pragma vertex vert
61 | #pragma fragment frag
62 | #include "UnityCG.cginc"
63 | #include "MeshPmdMaterialVertFrag.cginc"
64 | ENDCG
65 | }
66 |
67 | // ShadowCast Pass
68 | Pass
69 | {
70 | Tags
71 | {
72 | "LightMode" = "ShadowCaster"
73 | }
74 | Cull Off
75 | Lighting Off
76 | //Offset [_ShadowBias], [_ShadowBiasSlope] //使えない様なのでコメントアウト
77 | AlphaTest Greater 0.25
78 |
79 | CGPROGRAM
80 | #pragma vertex shadow_vert
81 | #pragma fragment shadow_frag
82 | #include "UnityCG.cginc"
83 | #include "MeshPmdMaterialShadowVertFrag.cginc"
84 | ENDCG
85 | }
86 |
87 | }
88 |
89 | // Other Environment
90 | Fallback "Transparent/Diffuse"
91 | }
92 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/ExpressionManagerScript.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UnityEngine;
6 |
7 | ///
8 | /// 表情の管理クラス
9 | ///
10 | public class ExpressionManagerScript : MonoBehaviour
11 | {
12 | public int[] indices;
13 |
14 | public Vector3[] source; // 元頂点, source_position
15 |
16 | public Vector3[] composite;
17 |
18 | public Mesh mesh; // メッシュ
19 | private Mesh renderer_shared_mesh; // レンダー共有メッシュ
20 |
21 | public MMDSkinsScript[] skin_script; // 子供の表情のスクリプト配列
22 |
23 | //int lip_count = 0;
24 | //int eye_count = 0;
25 | //int eye_brow_count = 0;
26 | //int other_count = 0;
27 |
28 | void Init()
29 | {
30 | // meshの取得
31 | if (!mesh) {
32 | //後方互換用コード(新コンバータでは mesh は必ず設定される)
33 | //メッシュが設定されていなければ SkinnedMeshRenderer から取得する
34 | mesh = transform.parent.gameObject.GetComponent().sharedMesh;
35 | }
36 | renderer_shared_mesh = (Mesh)Instantiate(mesh); //複製して、書き換えはそちらで行う
37 | renderer_shared_mesh.name = "ExpressionManagerScript/" + mesh.name;
38 | transform.parent.gameObject.GetComponent().sharedMesh = renderer_shared_mesh;
39 |
40 | // 頂点インデックス取得
41 | indices = transform.Find("base").GetComponent().targetIndices;
42 |
43 | skin_script = GetSkinScripts(); // 表情に付いているスクリプトを取得
44 |
45 | // 元頂点配列に入れていく
46 | source = new Vector3[indices.Length];
47 | for (int i = 0; i < indices.Length; i++)
48 | source[i] = mesh.vertices[indices[i]];
49 |
50 | // 合成するベクトル配列
51 | composite = new Vector3[indices.Length];
52 | for (int i = 0; i < indices.Length; i++)
53 | composite[i] = Vector3.zero;
54 | }
55 |
56 | void Start()
57 | {
58 | Init();
59 | }
60 |
61 | // SkinScriptの配列を子供の表情から探して拾ってくる
62 | MMDSkinsScript[] GetSkinScripts()
63 | {
64 | // 表情のスクリプトを拾ってくる
65 | var scripts = new MMDSkinsScript[transform.childCount];
66 | for (int i = 0; i < scripts.Length; i++)
67 | scripts[i] = transform.GetChild(i).GetComponent();
68 |
69 | return scripts;
70 | }
71 |
72 | void LateUpdate()
73 | {
74 | Renderer renderer=transform.parent.GetComponent();
75 | if(!renderer.enabled)
76 | return;
77 | var vtxs = renderer_shared_mesh.vertices; // 配列を受け入れ
78 |
79 | //各表情の合成ベクトルを初期化しておく
80 | for (int i = 0; i < indices.Length; i++)
81 | composite[i] = Vector3.zero;
82 | // 表情ごとに計算する
83 | foreach (var s in this.skin_script)
84 | {
85 | s.Compute(composite);
86 | }
87 |
88 | // ここで計算結果を入れていく
89 | for (int i = 0; i < indices.Length; i++)
90 | {
91 | vtxs[indices[i]] = source[i] + composite[i];
92 | }
93 |
94 | renderer_shared_mesh.vertices = vtxs; // ここで反映
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Motion/MMDBoneKeyFrame.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using DWORD = System.UInt32;
5 | using MMDIKBakerLibrary.Misc;
6 |
7 | namespace MMDIKBakerLibrary.Motion
8 | {
9 | class MMDBoneKeyFrame
10 | {
11 | ///
12 | /// ボーン名
13 | ///
14 | public string BoneName;//[15];
15 | ///
16 | /// フレーム番号
17 | ///
18 | public DWORD FrameNo;
19 | ///
20 | /// スケールベクトル
21 | ///
22 | public Vector3 Scales;
23 | ///
24 | /// 位置ベクトル
25 | ///
26 | public Vector3 Location;
27 | ///
28 | /// クォータニオン
29 | ///
30 | public Quaternion Quatanion;
31 |
32 | ///
33 | /// 補完用曲線
34 | ///
35 | /// 順にX,Y,Z,回転
36 | public BezierCurve[] Curve;
37 |
38 | ///
39 | /// 補完
40 | ///
41 | /// フレーム1
42 | /// フレーム2
43 | /// 進行度合い
44 | /// 補完結果
45 | public static void Lerp(MMDBoneKeyFrame frame1, MMDBoneKeyFrame frame2, decimal Progress, out SQTTransform result)
46 | {
47 | decimal ProgX, ProgY, ProgZ, ProgR;
48 | ProgX = (decimal)frame2.Curve[0].Evaluate((float)Progress);
49 | ProgY = (decimal)frame2.Curve[1].Evaluate((float)Progress);
50 | ProgZ = (decimal)frame2.Curve[2].Evaluate((float)Progress);
51 | ProgR = (decimal)frame2.Curve[3].Evaluate((float)Progress);
52 | decimal x, y, z;
53 | Quaternion q;
54 | Vector3 scales;
55 | x = MathHelper.Lerp(frame1.Location.X, frame2.Location.X, ProgX);
56 | y = MathHelper.Lerp(frame1.Location.Y, frame2.Location.Y, ProgY);
57 | z = MathHelper.Lerp(frame1.Location.Z, frame2.Location.Z, ProgZ);
58 | Quaternion.Slerp(ref frame1.Quatanion, ref frame2.Quatanion, ProgR, out q);
59 | //MMDはスケールのアニメーションを含まないので、スケールのベジェ曲線計算は行わない
60 | Vector3.Lerp(ref frame1.Scales, ref frame2.Scales, Progress, out scales);
61 | Vector3 t = new Vector3(x, y, z);
62 | SQTTransform.Create(ref scales, ref q, ref t, out result);
63 | }
64 | ///
65 | /// このフレームのSQTトランスフォームを取得
66 | ///
67 | /// SQLトランスフォーム
68 | public void GetSQTTransform(out SQTTransform result)
69 | {
70 | SQTTransform.Create(ref Scales, ref Quatanion, ref Location, out result);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/PhysicsManagerEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | ///
7 | /// 物理演算用Inspector拡張
8 | ///
9 | [CustomEditor(typeof(PhysicsManager))]
10 | public sealed class PhysicsManagerEditor : Editor
11 | {
12 | ///
13 | /// 初回処理
14 | ///
15 | public void Awake()
16 | {
17 | PhysicsManager self = (PhysicsManager)target;
18 | if (null != self.connect_bone_list) {
19 | joint_list_ = self.connect_bone_list.Where(x=>(null != x.joint))
20 | .Select(x=>x.joint.GetComponent())
21 | .ToArray();
22 | } else {
23 | joint_list_ = null;
24 | }
25 | }
26 |
27 | ///
28 | /// Inspector描画
29 | ///
30 | public override void OnInspectorGUI()
31 | {
32 | if (null != joint_list_) {
33 | //再生時は書き換え不可
34 | bool old_gui_enabled = GUI.enabled;
35 | bool crnt_gui_enabled = !Application.isPlaying;
36 | GUI.enabled = crnt_gui_enabled;
37 |
38 | foreach(var joint in joint_list_) {
39 | GameObject parent_object = GetOriginalParent(joint);
40 | if (null == parent_object) {
41 | //Physicsに移動する前のGameObjectが無いなら
42 | //ラベルのみ
43 | GUI.enabled = false;
44 | EditorGUILayout.LabelField(joint.name);
45 | GUI.enabled = crnt_gui_enabled;
46 | } else if (joint.GetComponent().isKinematic) {
47 | //ボーン追従(isKinematic)オブジェクト付属のジョイントなら
48 | //移動不可
49 | GUI.enabled = false;
50 | EditorGUILayout.Toggle(joint.name, false);
51 | GUI.enabled = crnt_gui_enabled;
52 | } else if (Selection.activeTransform == joint.transform.parent) {
53 | //Physicsに属しているなら
54 | //移動可
55 | if (true != EditorGUILayout.Toggle(joint.name, true)) {
56 | //変更なら
57 | //ジョイントツリーに移動
58 | joint.transform.parent = parent_object.transform;
59 | }
60 | } else if (parent_object.transform == joint.transform.parent) {
61 | //ジョイントツリーに属している
62 | //移動可
63 | if (false != EditorGUILayout.Toggle(joint.name, false)) {
64 | //変更なら
65 | //Physicsに移動
66 | joint.transform.parent = Selection.activeTransform;
67 | }
68 | } else {
69 | //手動で移動したと思われる
70 | //ラベルのみ
71 | GUI.enabled = false;
72 | EditorGUILayout.LabelField(joint.name);
73 | GUI.enabled = crnt_gui_enabled;
74 | }
75 | }
76 |
77 | GUI.enabled = old_gui_enabled;
78 | }
79 | }
80 |
81 | ///
82 | /// Physicsに移動する前のGameObjectを取得する
83 | ///
84 | private GameObject GetOriginalParent(ConfigurableJoint joint)
85 | {
86 | PhysicsManager self = (PhysicsManager)target;
87 | return self.connect_bone_list.Where(x=>(joint.gameObject == x.joint))
88 | .Select(x=>x.parent)
89 | .FirstOrDefault();
90 | }
91 |
92 | private ConfigurableJoint[] joint_list_; //移動対象リスト
93 | }
94 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/Private/MotionAgent.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections.Generic;
4 | using System.IO;
5 |
6 | namespace MMD {
7 |
8 | public class MotionAgent {
9 |
10 | ///
11 | /// コンストラクタ
12 | ///
13 | /// 読み込むファイルパス
14 | public MotionAgent(string file_path) {
15 | if (string.IsNullOrEmpty(file_path)) {
16 | throw new System.ArgumentException();
17 | }
18 | file_path_ = file_path;
19 | header_ = VMDLoaderScript.GetHeader(file_path_); //VMD読み込み
20 | format_ = null;
21 | }
22 |
23 | ///
24 | /// アニメーションクリップを作成する
25 | ///
26 | /// 使用するPMDのGameObject
27 | /// Prefab外に作成するか(true:Prefab外に作成, false:Prefab内蔵)
28 | /// 補完曲線品質
29 | public void CreateAnimationClip(GameObject assign_pmd, bool create_asset, int interpolationQuality) {
30 | //VMDファイルのインポート
31 | if (null == format_) {
32 | //まだ読み込んでいないなら読むこむ
33 | format_ = VMDLoaderScript.Import(file_path_); //VMD読み込み
34 | header_ = format_.header;
35 | }
36 |
37 | //アニメーションクリップの作成
38 | AnimationClip animation_clip = VMDConverter.CreateAnimationClip(format_, assign_pmd, interpolationQuality);
39 | if (animation_clip == null)
40 | {
41 | throw new System.Exception("Cannot create AnimationClip");
42 | }
43 |
44 | // ここで登録
45 | //anim.AddClip(animation_clip, animation_clip.name);
46 |
47 | if (create_asset) {
48 | // フォルダを生成してアニメーションのファイルを書き出す
49 | string prefab_folder = AssetDatabase.GetAssetPath(assign_pmd);
50 | prefab_folder = Path.GetDirectoryName(prefab_folder);
51 |
52 | if (!Directory.Exists(prefab_folder + "/Animation"))
53 | AssetDatabase.CreateFolder(prefab_folder, "Animation");
54 |
55 | AssetDatabase.CreateAsset(animation_clip, prefab_folder + "/Animation/" + animation_clip.name + ".anim");
56 | }
57 | else
58 | {
59 | // こちらはPrefabの中に入れるタイプ
60 | AssetDatabase.AddObjectToAsset(animation_clip, AssetDatabase.GetAssetPath(assign_pmd));
61 | }
62 |
63 | AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(animation_clip));
64 | }
65 |
66 | ///
67 | /// アニメーション名取得
68 | ///
69 | /// アニメーション名
70 | public string name {get{
71 | string result = null;
72 | if (null != format_) {
73 | result = format_.name;
74 | }
75 | return result;
76 | }}
77 |
78 | ///
79 | /// アニメーション名取得
80 | ///
81 | /// アニメーション名
82 | public string model_name {get{
83 | string result = null;
84 | if (null != header_) {
85 | result = header_.vmd_model_name;
86 | }
87 | return result;
88 | }}
89 | string file_path_;
90 | VMD.VMDFormat.Header header_;
91 | VMD.VMDFormat format_;
92 | }
93 | }
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialOutline-Trans.shader:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | Shader "MMD/Transparent/PMDMaterial-with-Outline"
19 | {
20 | Properties
21 | {
22 | _Color("拡散色", Color) = (1,1,1,1)
23 | _Opacity("不透明度", Float) = 1.0
24 | _SpecularColor("反射色", Color) = (1,1,1)
25 | _AmbColor("環境色", Color) = (1,1,1)
26 | _Shininess("反射強度", Float) = 0
27 | _OutlineColor("エッジ色", Color) = (0,0,0,1)
28 | _OutlineWidth("エッジ幅", Range(0,1)) = 0.2
29 | _MainTex("テクスチャ", 2D) = "white" {}
30 | _ToonTex("トゥーン", 2D) = "white" {}
31 | _SphereAddTex("スフィア(加算)", 2D) = "black" {}
32 | _SphereMulTex("スフィア(乗算)", 2D) = "white" {}
33 | }
34 |
35 | SubShader
36 | {
37 | // Settings
38 | Tags
39 | {
40 | "Queue" = "Transparent"
41 | "RenderType" = "Transparent"
42 | }
43 |
44 | // Surface Shader Pass ( Back )
45 | Cull Front
46 | ZWrite On
47 | Blend SrcAlpha OneMinusSrcAlpha
48 | AlphaTest Greater 0.0
49 | CGPROGRAM
50 | #pragma surface surf MMD
51 | #include "MeshPmdMaterialSurface.cginc"
52 | ENDCG
53 |
54 | // Surface Shader Pass
55 | Cull Back
56 | ZWrite On
57 | Blend SrcAlpha OneMinusSrcAlpha
58 | AlphaTest Greater 0.0
59 | CGPROGRAM
60 | #pragma surface surf MMD
61 | #include "MeshPmdMaterialSurface.cginc"
62 | ENDCG
63 |
64 | // Outline Pass
65 | Pass
66 | {
67 | Cull Front
68 | Lighting Off
69 | CGPROGRAM
70 | #pragma vertex vert
71 | #pragma fragment frag
72 | #include "UnityCG.cginc"
73 | #include "MeshPmdMaterialVertFrag.cginc"
74 | ENDCG
75 | }
76 |
77 | // ShadowCast Pass
78 | Pass
79 | {
80 | Tags
81 | {
82 | "LightMode" = "ShadowCaster"
83 | }
84 | Cull Off
85 | Lighting Off
86 | //Offset [_ShadowBias], [_ShadowBiasSlope] //使えない様なのでコメントアウト
87 | AlphaTest Greater 0.25
88 |
89 | CGPROGRAM
90 | #pragma vertex shadow_vert
91 | #pragma fragment shadow_frag
92 | #include "UnityCG.cginc"
93 | #include "MeshPmdMaterialShadowVertFrag.cginc"
94 | ENDCG
95 | }
96 |
97 | }
98 |
99 | // Other Environment
100 | Fallback "Transparent/Diffuse"
101 | }
102 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // このコードはツールによって生成されました。
4 | // ランタイム バージョン:4.0.30319.269
5 | //
6 | // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7 | // コードが再生成されるときに損失したりします
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MMDIKBakerGUI.Properties
12 | {
13 |
14 |
15 | ///
16 | /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
17 | ///
18 | // このクラスは StronglyTypedResourceBuilder クラスが ResGen
19 | // または Visual Studio のようなツールを使用して自動生成されました。
20 | // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
21 | // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// このクラスに使用される、キャッシュされた ResourceManager のインスタンスを返します。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MMDIKBakerGUI.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、
56 | /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Inspector/VMDInspector.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections;
4 | using MMD.PMD;
5 | using System.IO;
6 |
7 | namespace MMD
8 | {
9 | [CustomEditor(typeof(VMDScriptableObject))]
10 | public class VMDInspector : Editor
11 | {
12 | // VMD Load option
13 | public GameObject pmdPrefab;
14 | VMDImportConfig vmd_config;
15 |
16 | // last selected item
17 | private MotionAgent motion_agent;
18 | private string message = "";
19 |
20 | ///
21 | /// 有効化処理
22 | ///
23 | void OnEnable()
24 | {
25 | // デフォルトコンフィグ
26 | var config = MMD.Config.LoadAndCreate();
27 | vmd_config = config.vmd_config.Clone();
28 |
29 | // モデル情報
30 | if (config.inspector_config.use_vmd_preload)
31 | {
32 | var obj = (VMDScriptableObject)target;
33 | motion_agent = new MotionAgent(obj.assetPath);
34 | }
35 | else
36 | {
37 | motion_agent = null;
38 | }
39 | }
40 |
41 | ///
42 | /// Inspector上のGUI描画処理を行います
43 | ///
44 | public override void OnInspectorGUI()
45 | {
46 | // GUIの有効化
47 | GUI.enabled = !EditorApplication.isPlaying;
48 |
49 | pmdPrefab = (GameObject)EditorGUILayout.ObjectField("PMD Prefab", pmdPrefab, typeof(Object), false);
50 | vmd_config.OnGUIFunction();
51 |
52 | // Convertボタン
53 | EditorGUILayout.Space();
54 | if (message.Length != 0)
55 | {
56 | GUILayout.Label(message);
57 | }
58 | else
59 | {
60 | bool gui_enabled_old = GUI.enabled;
61 | GUI.enabled = (null != pmdPrefab);
62 | if (GUILayout.Button("Convert"))
63 | {
64 | if (null == motion_agent) {
65 | var obj = (VMDScriptableObject)target;
66 | motion_agent = new MotionAgent(obj.assetPath);
67 | }
68 | motion_agent.CreateAnimationClip(pmdPrefab
69 | , vmd_config.createAnimationFile
70 | , vmd_config.interpolationQuality
71 | );
72 | message = "Loading done.";
73 | }
74 | GUI.enabled = gui_enabled_old;
75 | }
76 | GUILayout.Space(40);
77 |
78 | // モデル情報
79 | if (motion_agent == null) return;
80 | EditorGUILayout.LabelField("Model Name");
81 | EditorGUILayout.LabelField(motion_agent.model_name, EditorStyles.textField);
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/PMDMaterial/Shaders/MeshPmdMaterialSurface.cginc:
--------------------------------------------------------------------------------
1 | /*
2 | * MMD Shader for Unity
3 | *
4 | * Copyright 2012 Masataka SUMI, Takahiro INOUE
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | float4 _Color;
19 | float _Opacity;
20 | float4 _AmbColor;
21 | float4 _SpecularColor;
22 | float _Shininess;
23 | sampler2D _MainTex;
24 | sampler2D _ToonTex;
25 | sampler2D _SphereAddTex;
26 | sampler2D _SphereMulTex;
27 |
28 | struct EditorSurfaceOutput
29 | {
30 | half3 Albedo;
31 | half3 Normal;
32 | half3 Emission;
33 | half3 Gloss;
34 | half Specular;
35 | half Alpha;
36 | half4 Custom;
37 | };
38 |
39 | inline half4 LightingMMD (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
40 | {
41 | // LightColor revison
42 | float4 lightColor = _LightColor0 * 1.2 * atten;
43 |
44 | // Specular
45 | float specularStrength = s.Specular;
46 | float dirDotNormalHalf = max(0, dot(s.Normal, normalize(lightDir + viewDir)));
47 | float dirSpecularWeight = pow( dirDotNormalHalf, _Shininess );
48 | float4 dirSpecular = _SpecularColor * lightColor * dirSpecularWeight;
49 | // ToonMap
50 | float lightStrength = dot(lightDir, s.Normal) * 0.5 + 0.5;
51 | float4 toon = tex2D( _ToonTex, float2( specularStrength, lightStrength ) );
52 | // Output
53 | float4 color = saturate( _AmbColor + ( _Color * lightColor ) );
54 | color *= s.Custom;
55 | color += saturate(dirSpecular);
56 | color *= toon;
57 | color.a = s.Alpha;
58 | return color;
59 | }
60 |
61 | struct Input
62 | {
63 | float2 uv_MainTex;
64 | };
65 |
66 | void surf (Input IN, inout EditorSurfaceOutput o)
67 | {
68 | // Defaults
69 | o.Albedo = 0.0;
70 | o.Emission = 0.0;
71 | o.Gloss = 0.0;
72 | o.Specular = 0.0;
73 |
74 | // Diffuse Map
75 | float2 uv_coord = float2( IN.uv_MainTex.x, IN.uv_MainTex.y );
76 | float4 tex_color = tex2D( _MainTex, uv_coord );
77 | // Sphere Map
78 | float3 viewNormal = normalize( mul( UNITY_MATRIX_MV, float4(normalize(o.Normal), 0.0) ).xyz );
79 | float2 sphereUv = viewNormal.xy * 0.5 + 0.5;
80 | float4 sphereAdd = tex2D( _SphereAddTex, sphereUv );
81 | float4 sphereMul = tex2D( _SphereMulTex, sphereUv );
82 |
83 | // Output
84 | o.Custom = tex_color; // DiffuseTex Default:White
85 | o.Custom += sphereAdd; // SphereAddTex Default:Black
86 | o.Custom *= sphereMul; // SphereMulTex Default:White
87 | o.Custom.a = 1.0;
88 | o.Alpha = _Opacity * tex_color.a;
89 | }
90 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/Inspector/PMDInspector.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections;
4 | using MMD.PMD;
5 | using System.IO;
6 |
7 | namespace MMD
8 | {
9 | [CustomEditor(typeof(PMDScriptableObject))]
10 | public class PMDInspector : Editor
11 | {
12 | PMDImportConfig pmd_config;
13 |
14 | // last selected item
15 | private ModelAgent model_agent;
16 | private string message = "";
17 |
18 | ///
19 | /// 有効化処理
20 | ///
21 | private void OnEnable()
22 | {
23 | // デフォルトコンフィグ
24 | var config = MMD.Config.LoadAndCreate();
25 | pmd_config = config.pmd_config.Clone();
26 |
27 | // モデル情報
28 | if (config.inspector_config.use_pmd_preload)
29 | {
30 | var obj = (PMDScriptableObject)target;
31 | model_agent = new ModelAgent(obj.assetPath);
32 | }
33 | else
34 | {
35 | model_agent = null;
36 | }
37 | }
38 |
39 | ///
40 | /// Inspector上のGUI描画処理を行います
41 | ///
42 | public override void OnInspectorGUI()
43 | {
44 | // GUIの有効化
45 | GUI.enabled = !EditorApplication.isPlaying;
46 |
47 | // GUI描画
48 | pmd_config.OnGUIFunction();
49 |
50 | // Convertボタン
51 | EditorGUILayout.Space();
52 | if (message.Length != 0)
53 | {
54 | GUILayout.Label(message);
55 | }
56 | else
57 | {
58 | if (GUILayout.Button("Convert to Prefab"))
59 | {
60 | if (null == model_agent) {
61 | var obj = (PMDScriptableObject)target;
62 | model_agent = new ModelAgent(obj.assetPath);
63 | }
64 | model_agent.CreatePrefab(pmd_config.shader_type
65 | , pmd_config.rigidFlag
66 | , pmd_config.animation_type
67 | , pmd_config.use_ik
68 | , pmd_config.scale
69 | , pmd_config.is_pmx_base_import
70 | );
71 | message = "Loading done.";
72 | }
73 | }
74 | GUILayout.Space(40);
75 |
76 | // モデル情報
77 | if (model_agent == null) return;
78 | EditorGUILayout.LabelField("Model Name");
79 | EditorGUILayout.LabelField(model_agent.name, EditorStyles.textField);
80 |
81 | EditorGUILayout.Space();
82 |
83 | EditorGUILayout.LabelField("Comment");
84 | EditorGUILayout.LabelField(model_agent.comment, EditorStyles.textField, GUILayout.Height(300));
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/Motion2/MotionData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using DWORD = System.UInt32;
4 |
5 | namespace MikuMikuDance.Motion.Motion2
6 | {
7 | ///
8 | /// ボーンモーションデータ
9 | ///
10 | public class MotionData
11 | {
12 | ///
13 | /// ボーン名
14 | ///
15 | public string BoneName { get; set; }//[15];
16 | ///
17 | /// フレーム番号
18 | ///
19 | public DWORD FrameNo { get; set; }
20 | ///
21 | /// 位置ベクトル
22 | ///
23 | public float[] Location { get; protected set; }
24 | ///
25 | /// クォータニオン
26 | ///
27 | public float[] Quatanion { get; protected set; }
28 | ///
29 | /// 補完データ
30 | ///
31 | public byte[][][] Interpolation { get; protected set; }
32 | ///
33 | /// 既定のコンストラクタ
34 | ///
35 | public MotionData()
36 | {
37 | Location = new float[3];
38 | Quatanion = new float[4];
39 | Interpolation = new byte[4][][];
40 | for (int i = 0; i < 4; i++)
41 | {
42 | Interpolation[i] = new byte[4][];
43 | for (int j = 0; j < 4; j++)
44 | Interpolation[i][j] = new byte[4];
45 | }
46 | }
47 | internal void Read(BinaryReader reader, float CoordZ, float scale)
48 | {
49 | BoneName = MMDMotion2.GetString(reader.ReadBytes(15));
50 | FrameNo = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
51 | for (int i = 0; i < 3; i++)
52 | Location[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0) * scale;
53 | for (int i = 0; i < 4; i++)
54 | Quatanion[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
55 | for (int i = 0; i < 4; i++)
56 | for (int j = 0; j < 4; j++)
57 | for (int k = 0; k < 4; k++)
58 | Interpolation[i][j][k] = reader.ReadByte();
59 | Location[2] *= CoordZ;
60 | Quatanion[0] *= CoordZ;
61 | Quatanion[1] *= CoordZ;
62 | }
63 |
64 | internal void Write(BinaryWriter writer, float CoordZ, float scale)
65 | {
66 | writer.Write(MMDMotion2.GetBytes(BoneName, 15));
67 | writer.Write((DWORD)FrameNo);
68 | writer.Write((Single)Location[0]*scale);
69 | writer.Write((Single)Location[1]*scale);
70 | writer.Write((Single)Location[2] * CoordZ*scale);
71 | writer.Write((Single)Quatanion[0] * CoordZ);
72 | writer.Write((Single)Quatanion[1] * CoordZ);
73 | writer.Write((Single)Quatanion[2]);
74 | writer.Write((Single)Quatanion[3]);
75 | for (int i = 0; i < 4; i++)
76 | for (int j = 0; j < 4; j++)
77 | for (int k = 0; k < 4; k++)
78 | writer.Write((byte)Interpolation[i][j][k]);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Model/ModelConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Misc;
5 |
6 | namespace MMDIKBakerLibrary.Model
7 | {
8 | static class ModelConverter
9 | {
10 | public static MMDBoneManager BuildBoneManager(MikuMikuDance.Model.Ver1.MMDModel1 model)
11 | {
12 | List bones;
13 | List iks;
14 | bones = new List();
15 | iks = new List();
16 | Matrix[] absPoses = new Matrix[model.Bones.LongLength];
17 | //各ボーンの絶対座標を計算
18 | for (long i = 0; i < model.Bones.LongLength; ++i)
19 | {
20 | Matrix.CreateTranslation((decimal)model.Bones[i].BoneHeadPos[0],
21 | (decimal)model.Bones[i].BoneHeadPos[1],
22 | (decimal)model.Bones[i].BoneHeadPos[2],
23 | out absPoses[i]);
24 | }
25 | for (long i = 0; i < model.Bones.LongLength; ++i)
26 | {
27 | Matrix localMatrix;
28 | if (model.Bones[i].ParentBoneIndex != 0xffff)
29 | {
30 | Matrix parentInv;
31 | Matrix.Invert(ref absPoses[model.Bones[i].ParentBoneIndex], out parentInv);
32 | Matrix.Multiply(ref parentInv, ref absPoses[i], out localMatrix);
33 | }
34 | else
35 | {
36 | localMatrix = absPoses[i];
37 | }
38 | SQTTransform bindPose = SQTTransform.FromMatrix(localMatrix);
39 | Matrix inverseBindPose;
40 | Matrix.Invert(ref absPoses[i], out inverseBindPose);
41 | bones.Add(new MMDBone(model.Bones[i].BoneName, bindPose, inverseBindPose, model.Bones[i].ParentBoneIndex));
42 | }
43 | for (long i = 0; i < model.IKs.LongLength; ++i)
44 | {
45 | List ikChildBones = new List();
46 | foreach (var ikc in model.IKs[i].IKChildBoneIndex)
47 | ikChildBones.Add(ikc);
48 | iks.Add(new MMDIK(model.IKs[i].IKBoneIndex, model.IKs[i].IKTargetBoneIndex, model.IKs[i].Iterations, model.IKs[i].AngleLimit, ikChildBones));
49 | }
50 | //ボーンインデックス→ボーンオブジェクト化
51 | IKSetup(iks, bones);
52 | return new MMDBoneManager(bones, iks);
53 | }
54 | ///
55 | /// ボーンインデックス→ボーンオブジェクト化
56 | ///
57 | public static void IKSetup(List iks, List bones)
58 | {
59 | foreach (var ik in iks)
60 | {
61 | ik.IKBone = bones[ik.IKBoneIndex];
62 | ik.IKTargetBone = bones[ik.IKTargetBoneIndex];
63 | List ikchilds = new List();
64 | foreach (var ikci in ik.ikChildBoneIndex)
65 | ikchilds.Add(bones[ikci]);
66 | ik.IKChildBones = new List(ikchilds);
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/ExpressionManagerEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | ///
7 | /// 表情用Inspector拡張
8 | ///
9 | [CustomEditor(typeof(ExpressionManagerScript))]
10 | public sealed class ExpressionManagerEditor : Editor
11 | {
12 | ///
13 | /// スタティックコンストラクタ
14 | ///
15 | static ExpressionManagerEditor()
16 | {
17 | skin_displays_ = new bool[Enum.GetValues(typeof(MMDSkinsScript.SkinType)).Length];
18 | for (int i = 0, i_max = skin_displays_.Length; i < i_max; ++i) {
19 | skin_displays_[i] = true;
20 | }
21 | }
22 |
23 | ///
24 | /// 初回処理
25 | ///
26 | public void Awake()
27 | {
28 | children_ = new List[Enum.GetValues(typeof(MMDSkinsScript.SkinType)).Length];
29 | for (int i = 0, i_max = children_.Length; i < i_max; ++i) {
30 | children_[i] = new List();
31 | }
32 | //子登録
33 | foreach (Transform child in Selection.activeTransform) {
34 | MMDSkinsScript skins = child.GetComponent();
35 | children_[(int)skins.skinType].Add(child);
36 | }
37 | }
38 |
39 | ///
40 | /// Inspector描画
41 | ///
42 | public override void OnInspectorGUI()
43 | {
44 | ExpressionManagerScript self = (ExpressionManagerScript)target;
45 | bool is_dirty = false;
46 |
47 | //mesh
48 | self.mesh = (Mesh)EditorGUILayout.ObjectField("Mesh", self.mesh, typeof(Mesh), false);
49 |
50 | //skin_script
51 | for (int i = 0, i_max = children_.Length; i < i_max; ++i) {
52 | if (MMDSkinsScript.SkinType.Base == (MMDSkinsScript.SkinType)i) {
53 | //Baseだったらスキップ
54 | continue;
55 | }
56 |
57 | //スキンツリータイトル
58 | string skin_name = ((MMDSkinsScript.SkinType)i).ToString();
59 | skin_displays_[i] = EditorGUILayout.Foldout(skin_displays_[i], skin_name);
60 | //スキンツリー内部
61 | if (skin_displays_[i]) {
62 | //このスキンを表示するなら
63 | GUIStyle style = new GUIStyle();
64 | style.margin.left = 10;
65 | EditorGUILayout.BeginVertical(style);
66 | {
67 | //モーフオブジェクト走査
68 | foreach (Transform child in children_[i]) {
69 | float value = child.localPosition.z;
70 | value = EditorGUILayout.Slider(child.name, value, 0.0f, 1.0f);
71 | if (child.localPosition.z != value) {
72 | //変更が掛かったなら
73 | //Undo登録
74 | #if !UNITY_4_2 //4.3以降
75 | Undo.RecordObject(child, "Expression Change");
76 | #else
77 | Undo.RegisterUndo(child, "Expression Change");
78 | #endif
79 | //Z位置更新
80 | Vector3 position = child.localPosition;
81 | position.z = value;
82 | child.localPosition = position;
83 | //改変モーフオブジェクトのInspector更新
84 | EditorUtility.SetDirty(child.transform);
85 |
86 | is_dirty = true;
87 | }
88 | }
89 | }
90 | EditorGUILayout.EndVertical();
91 | }
92 |
93 | }
94 |
95 | if (is_dirty) {
96 | //更新が有ったなら
97 | //Inspector更新
98 | EditorUtility.SetDirty(target);
99 | }
100 | }
101 |
102 | private static bool[] skin_displays_; //スキンの表示
103 | private List[] children_; //スキン別子モーフオブジェクト
104 | }
105 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MMDLoader/Private/MMDMathf.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | public class MMDMathf
5 | {
6 | public static Matrix4x4 CreateRotationXMatrix(float rad)
7 | {
8 | Matrix4x4 m = Matrix4x4.identity;
9 | float cos = Mathf.Cos(rad), sin = Mathf.Sin(rad);
10 | m.m11 = cos; m.m12 = -sin;
11 | m.m21 = sin; m.m22 = cos;
12 | return m;
13 | }
14 |
15 | public static Matrix4x4 CreateRotationYMatrix(float rad)
16 | {
17 | Matrix4x4 m = Matrix4x4.identity;
18 | float cos = Mathf.Cos(rad), sin = Mathf.Sin(rad);
19 | m.m00 = cos; m.m02 = sin;
20 | m.m20 = -sin; m.m22 = cos;
21 | return m;
22 | }
23 |
24 | public static Matrix4x4 CreateRotationZMatrix(float rad)
25 | {
26 | Matrix4x4 m = Matrix4x4.identity;
27 | float cos = Mathf.Cos(rad), sin = Mathf.Sin(rad);
28 | m.m01 = cos; m.m02 = -sin;
29 | m.m11 = sin; m.m12 = cos;
30 | return m;
31 | }
32 |
33 | public static Matrix4x4 CreateRotationMatrixFromRollPitchYaw(float r, float p, float y)
34 | {
35 | Matrix4x4 m = Matrix4x4.identity;
36 | float rc = Mathf.Cos(r), rs = Mathf.Sin(r); // Z
37 | float pc = Mathf.Cos(p), ps = Mathf.Sin(p); // Y
38 | float yc = Mathf.Cos(y), ys = Mathf.Sin(y);; // X
39 | m.m00 = rc*pc; m.m01 = rc*ps*ys-rs*yc; m.m02 = rc*ps*yc+rs*ys;
40 | m.m10 = rs*pc; m.m11 = rs*ps*ys+rc*yc; m.m12 = rs*ps*yc-rc*ys;
41 | m.m20 = -ps; m.m21 = pc*ys; m.m22 = pc*yc;
42 | return m;
43 | }
44 |
45 | public static Vector3 CreatePositionFromMatrix(Matrix4x4 m)
46 | {
47 | return new Vector3(m.m30, m.m31, m.m33);
48 | }
49 |
50 | public static Quaternion CreateQuaternionFromRotationMatrix(Matrix4x4 m)
51 | {
52 | Quaternion q;
53 | const float quad = 1.0f / 4.0f;
54 | q.x = ( m.m00 + m.m11 + m.m22 + 1.0f) * quad;
55 | q.y = ( m.m00 - m.m11 - m.m22 + 1.0f) * quad;
56 | q.z = (-m.m00 + m.m11 - m.m22 + 1.0f) * quad;
57 | q.w = (-m.m00 - m.m11 + m.m22 + 1.0f) * quad;
58 | if (q.x < 0.0f) q.x = 0.0f;
59 | if (q.y < 0.0f) q.y = 0.0f;
60 | if (q.z < 0.0f) q.z = 0.0f;
61 | if (q.w < 0.0f) q.w = 0.0f;
62 | q.x = Mathf.Sqrt(q.x);
63 | q.y = Mathf.Sqrt(q.y);
64 | q.z = Mathf.Sqrt(q.z);
65 | q.w = Mathf.Sqrt(q.w);
66 | if (q.x >= q.y && q.x >= q.z && q.x >= q.w)
67 | {
68 | q.x *= 1.0f;
69 | q.y *= Sign(m.m22 - m.m13);
70 | q.z *= Sign(m.m03 - m.m21);
71 | q.w *= Sign(m.m11 - m.m02);
72 | }
73 | else if (q.y >= q.x && q.y >= q.z && q.y >= q.w)
74 | {
75 | q.x *= Sign(m.m22 - m.m13);
76 | q.y *= 1.0f;
77 | q.z *= Sign(m.m11 + m.m02);
78 | q.w *= Sign(m.m03 + m.m21);
79 | }
80 | else if(q.z >= q.x && q.z >= q.y && q.z >= q.w) {
81 | q.x *= Sign(m.m03 - m.m21);
82 | q.y *= Sign(m.m11 + m.m02);
83 | q.z *= +1.0f;
84 | q.w *= Sign(m.m22 + m.m13);
85 | } else if(q.w >= q.x && q.w >= q.y && q.w >= q.z) {
86 | q.x *= Sign(m.m11 - m.m02);
87 | q.y *= Sign(m.m21 + m.m03);
88 | q.z *= Sign(m.m22 + m.m13);
89 | q.w *= +1.0f;
90 | }
91 | float r = 1.0f / Norm(q.x, q.y, q.z, q.w);
92 | q.x *= r;
93 | q.y *= r;
94 | q.z *= r;
95 | q.w *= r;
96 | return q;
97 | }
98 |
99 | private static float Sign(float x)
100 | {
101 | return (x >= 0.0f) ? 1.0f : -1.0f;
102 | }
103 |
104 | private static float Norm(float a, float b, float c, float d)
105 | {
106 | return Mathf.Sqrt(a*a+b*b+c*c+d*d);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/IK/BoneController.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | public class BoneController : MonoBehaviour
6 | {
7 | public BoneController additive_parent;
8 | public float additive_rate;
9 | public CCDIKSolver ik_solver;
10 | public BoneController[] ik_solver_targets;
11 |
12 | public bool add_local;
13 | public bool add_move;
14 | public bool add_rotate;
15 |
16 | ///
17 | /// 簡略化トランスフォーム
18 | ///
19 | [System.Serializable]
20 | public class LiteTransform {
21 | public Vector3 position; // 位置
22 | public Quaternion rotation; // 回転
23 |
24 | public LiteTransform(Vector3 p, Quaternion r) {position = p; rotation = r;}
25 | }
26 | private LiteTransform prev_global_;
27 | private LiteTransform prev_local_;
28 |
29 | ///
30 | /// 初回更新前処理
31 | ///
32 | void Start()
33 | {
34 | if (null != ik_solver) {
35 | ik_solver = transform.GetComponent();
36 | if (0 == ik_solver_targets.Length) {
37 | ik_solver_targets = Enumerable.Repeat(ik_solver.target, 1)
38 | .Concat(ik_solver.chains)
39 | .Select(x=>x.GetComponent())
40 | .ToArray();
41 | }
42 | }
43 | UpdatePrevTransform();
44 | }
45 |
46 | ///
47 | /// ボーン変形
48 | ///
49 | public void Process()
50 | {
51 | if (null != additive_parent) {
52 | //付与親有りなら
53 | LiteTransform additive_parent_transform = additive_parent.GetDeltaTransform(add_local);
54 | if (add_move) {
55 | //付与移動有りなら
56 | transform.localPosition += additive_parent_transform.position * additive_rate;
57 | }
58 | if (add_rotate) {
59 | //付与回転有りなら
60 | Quaternion delta_rotate_rate;
61 | if (0.0f <= additive_rate) {
62 | //正回転
63 | delta_rotate_rate = Quaternion.Slerp(Quaternion.identity, additive_parent_transform.rotation, additive_rate);
64 | }
65 | else
66 | {
67 | //逆回転
68 | Quaternion additive_parent_delta_rotate_reverse = Quaternion.Inverse(additive_parent_transform.rotation);
69 | delta_rotate_rate = Quaternion.Slerp(Quaternion.identity, additive_parent_delta_rotate_reverse, -additive_rate);
70 | }
71 | transform.localRotation *= delta_rotate_rate;
72 | }
73 | }
74 | }
75 |
76 | ///
77 | /// 差分トランスフォーム取得
78 | ///
79 | /// 差分トランスフォーム
80 | /// ローカル付与か(true:ローカル付与, false:通常付与)
81 | public LiteTransform GetDeltaTransform(bool is_add_local) {
82 | LiteTransform result;
83 | if (is_add_local) {
84 | //ローカル付与(親も含めた変形量算出)
85 | result = new LiteTransform(transform.position - prev_global_.position
86 | , Quaternion.Inverse(prev_global_.rotation) * transform.rotation
87 | );
88 | } else {
89 | //通常付与(このボーン単体での変形量算出)
90 | result = new LiteTransform(transform.localPosition - prev_local_.position
91 | , Quaternion.Inverse(prev_local_.rotation) * transform.localRotation
92 | );
93 | }
94 | return result;
95 | }
96 |
97 | ///
98 | /// 差分基点トランスフォーム更新
99 | ///
100 | public void UpdatePrevTransform() {
101 | prev_global_ = new LiteTransform(transform.position, transform.rotation);
102 | prev_local_ = new LiteTransform(transform.localPosition, transform.localRotation);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/Motion2/CameraMotionData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using DWORD = System.UInt32;
4 | using WORD = System.UInt16;
5 |
6 | namespace MikuMikuDance.Motion.Motion2
7 | {
8 | ///
9 | /// カメラモーションデータ
10 | ///
11 | public class CameraMotionData
12 | {
13 | ///
14 | /// フレーム番号
15 | ///
16 | public DWORD FrameNo { get; set; }
17 | ///
18 | /// 長さ
19 | ///
20 | public float Length { get; set; }
21 | ///
22 | /// 位置
23 | ///
24 | public float[] Location { get; protected set; }
25 | ///
26 | /// 回転
27 | ///
28 | public float[] Rotate { get; protected set; }
29 | ///
30 | /// 補完データ
31 | ///
32 | public byte[][] Interpolation { get; protected set; }
33 | ///
34 | /// 視野角
35 | ///
36 | public WORD ViewingAngle { get; protected set; }
37 | ///
38 | /// 不明データ
39 | ///
40 | /// だれか教えてくれ(´・ω・`)
41 | public byte[] Unknown { get; protected set; }
42 | ///
43 | /// 既定のコンストラクタ
44 | ///
45 | public CameraMotionData()
46 | {
47 | Location = new float[3];
48 | Rotate = new float[3];
49 | Interpolation = new byte[6][];
50 | for (int i = 0; i < 6; i++)
51 | Interpolation[i] = new byte[4];
52 | Unknown = new byte[3];
53 | }
54 |
55 | internal void Read(BinaryReader reader, float CoordZ)
56 | {
57 | FrameNo = BitConverter.ToUInt32(reader.ReadBytes(4), 0);
58 | Length = BitConverter.ToSingle(reader.ReadBytes(4), 0);
59 | for (int i = 0; i < 3; i++)
60 | Location[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
61 | for (int i = 0; i < 3; i++)
62 | Rotate[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
63 | for (int i = 0; i < 6; i++)
64 | for (int j = 0; j < 4; j++)
65 | Interpolation[i][j] = reader.ReadByte();
66 | ViewingAngle = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
67 | for (int i = 0; i < 3; i++)
68 | Unknown[i] = reader.ReadByte();
69 | Location[2] *= CoordZ;
70 | Rotate[2] *= CoordZ;
71 | /*Rotate[0] *= CoordZ;
72 | Rotate[1] *= CoordZ;*/
73 | }
74 |
75 | internal void Write(BinaryWriter writer, float CoordZ)
76 | {
77 | writer.Write((DWORD)FrameNo);
78 | writer.Write((Single)Length);
79 | writer.Write((Single)Location[0]);
80 | writer.Write((Single)Location[1]);
81 | writer.Write((Single)Location[2] * CoordZ);
82 | writer.Write((Single)Rotate[0]);
83 | writer.Write((Single)Rotate[1]);
84 | writer.Write((Single)Rotate[2] * CoordZ);
85 | for (int i = 0; i < 6; i++)
86 | for (int j = 0; j < 4; j++)
87 | writer.Write((byte)Interpolation[i][j]);
88 | writer.Write((WORD)ViewingAngle);
89 | for (int i = 0; i < 3; i++)
90 | writer.Write((byte)Unknown[i]);
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Ver1/ModelBone.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using WORD = System.UInt16;
4 |
5 | namespace MikuMikuDance.Model.Ver1
6 | {
7 | ///
8 | /// ボーン
9 | ///
10 | public class ModelBone
11 | {
12 | ///
13 | /// ボーン名
14 | ///
15 | public string BoneName { get; set; } //20byte分char ボーン名
16 | ///
17 | /// 親ボーン番号
18 | ///
19 | /// 無い場合は0xFFFFを代入
20 | public WORD ParentBoneIndex { get; set; } // 親ボーン番号(ない場合は0xFFFF)
21 | ///
22 | /// tail位置のボーン番号
23 | ///
24 | /// チェーン末端の場合は0xFFFF。 親:子は1:多なので、主に位置決め用
25 | public WORD TailPosBoneIndex { get; set; } // tail位置のボーン番号(チェーン末端の場合は0xFFFF) // 親:子は1:多なので、主に位置決め用
26 | ///
27 | /// ボーンの種類
28 | ///
29 | /// 0:回転 1:回転と移動 2:IK 3:不明 4:IK影響下 5:回転影響下 6:IK接続先 7:非表示 8:捻り 9:回転運動
30 | public byte BoneType { get; set; } // ボーンの種類
31 | ///
32 | /// IKボーン番号
33 | ///
34 | /// 影響IKボーン。ない場合は0
35 | public WORD IKParentBoneIndex { get; set; } // IKボーン番号(影響IKボーン。ない場合は0)
36 | ///
37 | /// ボーンのヘッドの位置(x,y,z)
38 | ///
39 | public float[] BoneHeadPos { get; private set; } // x, y, z // ボーンのヘッドの位置
40 | ///
41 | /// ボーン名(英語、拡張)
42 | ///
43 | public string BoneNameEnglish { get; set; }////20byte分char ボーン名(英語、拡張(無い場合はnull))
44 | ///
45 | /// 既定のコンストラクタ
46 | ///
47 | public ModelBone()
48 | {
49 | BoneHeadPos = new float[3];
50 | }
51 | internal void Read(BinaryReader reader, float CoordZ, float scale)
52 | {
53 | BoneHeadPos = new float[3];
54 | BoneName = MMDModel1.GetString(reader.ReadBytes(20));
55 | ParentBoneIndex = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
56 | TailPosBoneIndex = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
57 | BoneType = reader.ReadByte();
58 | IKParentBoneIndex = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
59 | for (int i = 0; i < BoneHeadPos.Length; i++)
60 | BoneHeadPos[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0) * scale;
61 | //英名拡張はReadではnullにする(あるならReadEngilishで上書きされる)
62 | BoneNameEnglish = null;
63 | BoneHeadPos[2] = BoneHeadPos[2] * CoordZ;
64 | }
65 |
66 | //英名拡張分読み込み
67 | internal void ReadExpantion(BinaryReader reader)
68 | {
69 | BoneNameEnglish = MMDModel1.GetString(reader.ReadBytes(20));
70 | }
71 |
72 | internal void Write(BinaryWriter writer, float CoordZ, float scale)
73 | {
74 | BoneHeadPos[2] = BoneHeadPos[2] * CoordZ * scale;
75 | writer.Write(MMDModel1.GetBytes(BoneName, 20));
76 | writer.Write(ParentBoneIndex);
77 | writer.Write(TailPosBoneIndex);
78 | writer.Write(BoneType);
79 | writer.Write(IKParentBoneIndex);
80 | for (int i = 0; i < BoneHeadPos.Length; i++)
81 | writer.Write(BoneHeadPos[i]);
82 | }
83 |
84 | internal void WriteExpantion(BinaryWriter writer)
85 | {
86 | writer.Write(MMDModel1.GetBytes(BoneNameEnglish, 20));
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDModelLibrary/Ver1/ModelVertex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using WORD = System.UInt16;
4 |
5 | namespace MikuMikuDance.Model.Ver1
6 | {
7 | ///
8 | /// モデルの頂点
9 | ///
10 | public class ModelVertex
11 | {
12 | ///
13 | /// x,y,z座標
14 | ///
15 | public float[] Pos { get; private set; } // x, y, z // 座標
16 | ///
17 | /// x,y,zの法線ベクトル
18 | ///
19 | public float[] NormalVector { get; private set; } // nx, ny, nz // 法線ベクトル
20 | ///
21 | /// UV座標(頂点UV)
22 | ///
23 | public float[] UV { get; private set; } // u, v // UV座標 // MMDは頂点UV
24 | ///
25 | /// ボーン番号
26 | ///
27 | /// 番号は1または2。モデル変形(頂点移動)時に影響
28 | public WORD[] BoneNum { get; private set; } // ボーン番号1、番号2 // モデル変形(頂点移動)時に影響
29 | ///
30 | /// 影響度
31 | ///
32 | /// ボーン1に与える影響度。min:0 max:100。ボーン2への影響度は、(100 - BoneWeight)
33 | public byte BoneWeight { get; private set; } // ボーン1に与える影響度 // min:0 max:100 // ボーン2への影響度は、(100 - bone_weight)
34 | ///
35 | /// エッジフラグ
36 | ///
37 | /// 0:通常、1:エッジ無効(エッジ(輪郭)が有効の場合)
38 | public byte NonEdgeFlag { get; private set; } // 0:通常、1:エッジ無効 // エッジ(輪郭)が有効の場合
39 | ///
40 | /// 既定のコンストラクタ
41 | ///
42 | public ModelVertex()
43 | {
44 | Pos = new float[3];
45 | NormalVector = new float[3];
46 | UV = new float[2];
47 | BoneNum = new WORD[2];
48 | BoneWeight = 0;
49 | NonEdgeFlag = 0;
50 | }
51 | internal void Read(BinaryReader reader, float CoordZ, float scale)
52 | {
53 | //サイズ
54 | Pos = new float[3];
55 | NormalVector = new float[3];
56 | UV = new float[2];
57 | BoneNum = new WORD[2];
58 | for (int i = 0; i < Pos.Length; i++)
59 | Pos[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0) * scale;
60 | for (int i = 0; i < NormalVector.Length; i++)
61 | NormalVector[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
62 | for (int i = 0; i < UV.Length; i++)
63 | UV[i] = BitConverter.ToSingle(reader.ReadBytes(4), 0);
64 | for (int i = 0; i < BoneNum.Length; i++)
65 | BoneNum[i] = BitConverter.ToUInt16(reader.ReadBytes(2), 0);
66 | BoneWeight = reader.ReadByte();
67 | NonEdgeFlag = reader.ReadByte();
68 | Pos[2] = Pos[2] * CoordZ;
69 | NormalVector[2] = NormalVector[2] * CoordZ;
70 | }
71 |
72 | internal void Write(BinaryWriter writer, float CoordZ, float scale)
73 | {
74 | Pos[2] = Pos[2] * CoordZ;
75 | NormalVector[2] = NormalVector[2] * CoordZ*scale;
76 | for (int i = 0; i < Pos.Length; i++)
77 | writer.Write(Pos[i]);
78 | for (int i = 0; i < NormalVector.Length; i++)
79 | writer.Write(NormalVector[i]);
80 | for (int i = 0; i < UV.Length; i++)
81 | writer.Write(UV[i]);
82 | for (int i = 0; i < BoneNum.Length; i++)
83 | writer.Write(BoneNum[i]);
84 | writer.Write(BoneWeight);
85 | writer.Write(NonEdgeFlag);
86 | }
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerTest/Vector3Test.cs:
--------------------------------------------------------------------------------
1 | using MMDIKBakerLibrary.Misc;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using System;
4 |
5 | namespace MMDIKBakerTest
6 | {
7 |
8 |
9 | ///
10 | ///Vector3Test のテスト クラスです。すべての
11 | ///Vector3Test 単体テストをここに含めます
12 | ///
13 | [TestClass()]
14 | public class Vector3Test
15 | {
16 |
17 |
18 | private TestContext testContextInstance;
19 |
20 | ///
21 | ///現在のテストの実行についての情報および機能を
22 | ///提供するテスト コンテキストを取得または設定します。
23 | ///
24 | public TestContext TestContext
25 | {
26 | get
27 | {
28 | return testContextInstance;
29 | }
30 | set
31 | {
32 | testContextInstance = value;
33 | }
34 | }
35 |
36 | #region 追加のテスト属性
37 | //
38 | //テストを作成するときに、次の追加属性を使用することができます:
39 | //
40 | //クラスの最初のテストを実行する前にコードを実行するには、ClassInitialize を使用
41 | //[ClassInitialize()]
42 | //public static void MyClassInitialize(TestContext testContext)
43 | //{
44 | //}
45 | //
46 | //クラスのすべてのテストを実行した後にコードを実行するには、ClassCleanup を使用
47 | //[ClassCleanup()]
48 | //public static void MyClassCleanup()
49 | //{
50 | //}
51 | //
52 | //各テストを実行する前にコードを実行するには、TestInitialize を使用
53 | //[TestInitialize()]
54 | //public void MyTestInitialize()
55 | //{
56 | //}
57 | //
58 | //各テストを実行した後にコードを実行するには、TestCleanup を使用
59 | //[TestCleanup()]
60 | //public void MyTestCleanup()
61 | //{
62 | //}
63 | //
64 | #endregion
65 |
66 |
67 | ///
68 | ///Transform のテスト
69 | ///
70 | [TestMethod()]
71 | public void TransformTest()
72 | {
73 | Quaternion[] rotationTestPatterns = { Quaternion.Identity, Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 0.72m), Quaternion.CreateFromAxisAngle(new Vector3(0.5m, 0.5m, 0), 0.72m), Quaternion.CreateFromAxisAngle(new Vector3(0, 0.5m, 0.5m), 0.72m) };
74 | Vector3[] transrationTestPatterns = { Vector3.Zero, Vector3.One, new Vector3(5, 1, 1), new Vector3(1, 5, 1), new Vector3(1, 1, 5), new Vector3(5, 5, 1), new Vector3(5, 1, 5), new Vector3(1, 5, 5), new Vector3(5, 5, 5) };
75 |
76 | foreach (var rot in rotationTestPatterns)
77 | {
78 | foreach (var vec in transrationTestPatterns)
79 | {
80 | Vector3 value = vec, result;
81 | Quaternion rotation = rot;
82 | Vector3.Transform(ref value, ref rotation, out result);
83 | Microsoft.Xna.Framework.Vector3 value2 = new Microsoft.Xna.Framework.Vector3((float)vec.X, (float)vec.Y, (float)vec.Z), actual_xna;
84 | Microsoft.Xna.Framework.Quaternion rotation2 = new Microsoft.Xna.Framework.Quaternion((float)rot.X, (float)rot.Y, (float)rot.Z, (float)rot.W);
85 | Microsoft.Xna.Framework.Vector3.Transform(ref value2, ref rotation2, out actual_xna);
86 | Vector3 acutual = new Vector3((decimal)actual_xna.X, (decimal)actual_xna.Y, (decimal)actual_xna.Z);
87 | Assert.IsTrue(Math.Abs(result.X - acutual.X) < 0.001m);
88 | Assert.IsTrue(Math.Abs(result.Y - acutual.Y) < 0.001m);
89 | Assert.IsTrue(Math.Abs(result.Z - acutual.Z) < 0.001m);
90 |
91 | }
92 | }
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDMotionLibrary/MotionManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using MikuMikuDance.Motion.Motion2;
4 |
5 | namespace MikuMikuDance.Motion
6 | {
7 | ///
8 | /// MikuMikuDance(MMD)モーションの読み込みを行うFactory Class
9 | ///
10 | public static class MotionManager
11 | {
12 | ///
13 | /// ファイルからMMDモーションを読み込む
14 | ///
15 | /// MMDモーションファイル
16 | /// 変換先座標系
17 | /// MMDモーションオブジェクト
18 | /// スケーリング値
19 | public static MMDMotion Read(string filename, CoordinateType coordinate, float scale=1.0f)
20 | {
21 | //フルパス取得
22 | filename = Path.GetFullPath(filename);
23 | //ファイルチェック
24 | if (!File.Exists(filename))
25 | throw new FileNotFoundException("MMDモーションファイル:" + filename + "が見つかりません");
26 | //戻り値用変数
27 | MMDMotion result = null;
28 | //ファイルリーダー
29 | using (FileStream fs = new FileStream(filename, FileMode.Open))
30 | {
31 | BinaryReader reader = new BinaryReader(fs);
32 | //マジック文字列
33 | string magic = MMDMotion2.GetString(reader.ReadBytes(30));
34 | if (magic.Substring(0, 20) != "Vocaloid Motion Data")
35 | throw new FileLoadException("MMDモーションファイルではありません");
36 | //バージョン
37 | int version = Convert.ToInt32(magic.Substring(21));
38 | if (version == 2)
39 | result = new MMDMotion2();
40 | else
41 | throw new FileLoadException("version=" + version.ToString() + "モデルは対応していません");
42 |
43 | result.Read(reader, coordinate,scale);
44 | if (fs.Length != fs.Position)
45 | Console.WriteLine("警告:ファイル末尾以降に不明データ?");
46 | fs.Close();
47 | }
48 | return result;
49 | }
50 | ///
51 | /// ファイルからMMDモーションを読み込む
52 | ///
53 | /// MMDモーションファイル
54 | /// スケーリング値
55 | /// MMDモーションオブジェクト
56 | public static MMDMotion Read(string filename, float scale=0.1f)
57 | {
58 | return Read(filename, CoordinateType.LeftHandedCoordinate, scale);
59 | }
60 | ///
61 | /// ファイルへの書き出し
62 | ///
63 | /// ファイル名
64 | /// モーション
65 | /// スケーリング値
66 | public static void Write(string filename, MMDMotion motion, float scale=1f)
67 | {
68 | //フルパス取得
69 | filename = Path.GetFullPath(filename);
70 | //ファイルリーダー
71 | using (FileStream fs = new FileStream(filename, FileMode.Create))
72 | {
73 | BinaryWriter writer = new BinaryWriter(fs);
74 | //マジック文字列
75 | if (motion is MMDMotion2)
76 | {
77 | writer.Write(MMDMotion2.GetBytes("Vocaloid Motion Data 0002", 25));
78 | writer.Write((byte)0);
79 | writer.Write(MMDMotion2.GetBytes("JKLM", 4));
80 | }
81 | else
82 | new NotImplementedException("その他のバーションは未作成");
83 |
84 | motion.Write(writer, scale);
85 | fs.Close();
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/IK/CCDIKSolver.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | public class CCDIKSolver : MonoBehaviour
6 | {
7 | /* MEMO
8 | * --------------------
9 | * IKボーンにこのスクリプトを適用して、Solveを呼び出す。
10 | * target = ターゲット(IKボーンを目指すボーン)
11 | * chains = IK影響下ボーン
12 | * --------------------
13 | */
14 |
15 | // Target
16 | // IKボーンを目指すボーン
17 | public Transform target;
18 |
19 | // Loop count
20 | // ushortだとInspectorに出ない
21 | public int iterations;
22 |
23 | // rad limit
24 | // "単位角"
25 | public float controll_weight;
26 |
27 | // IK影響下ボーン
28 | public Transform[] chains;
29 |
30 | // レイの描画(デバッグ用)
31 | public bool drawRay = false;
32 |
33 | // 計算
34 | public void Solve()
35 | {
36 | // 有効化されてなかった場合は実行しない
37 | if (!this.enabled) return;
38 |
39 | // ループ回数で計算していく
40 | for (int tries = 0, _mt = iterations; tries < _mt; tries++)
41 | {
42 | // IK影響下ボーンごとに
43 | for (int _i = 0, _m = chains.Length; _i < _m; _i++)
44 | {
45 | var bone = chains[_i];
46 | var bonePos = bone.position;
47 |
48 | // エフェクタ設定
49 | var effectorPos = target.position;
50 | var effectorDirection = (effectorPos - bonePos);
51 |
52 | // ターゲット設定
53 | var targetDirection = (transform.position - bonePos);
54 |
55 | // 線を引いといてみる
56 | if (drawRay)
57 | {
58 | Debug.DrawRay(bonePos, effectorDirection, Color.green);
59 | Debug.DrawRay(bonePos, targetDirection, Color.red);
60 | }
61 |
62 | // 内積
63 | effectorDirection = effectorDirection.normalized;
64 | targetDirection = targetDirection.normalized;
65 | float rotateDot = Vector3.Dot(effectorDirection, targetDirection);
66 |
67 | // 角度算出。
68 | // controll_weightによる一回の計算での制限
69 | float rotateAngle = Mathf.Acos(rotateDot);
70 | if (float.IsNaN(rotateAngle)) continue;
71 | var limit = 4 * controll_weight * (_i + 1);
72 | if (rotateAngle > limit)
73 | rotateAngle = limit;
74 | if (rotateAngle < -limit)
75 | rotateAngle = -limit;
76 | rotateAngle *= Mathf.Rad2Deg;
77 |
78 | // 外積で回転軸算出
79 | // lockDirectionを見て、回転制限 => 一旦なし
80 | var rotateAxis = Vector3.Cross(effectorDirection, targetDirection).normalized;
81 |
82 | // 大丈夫そうなら
83 | if (float.IsNaN(rotateAxis.x) || float.IsNaN(rotateAxis.y) || float.IsNaN(rotateAxis.z))
84 | continue;
85 |
86 | // 回す
87 | var rotate = Quaternion.AngleAxis(rotateAngle, rotateAxis);
88 | bone.rotation = rotate * bone.rotation;
89 |
90 | // 角度制限
91 | limitter(bone);
92 | }
93 | }
94 | }
95 |
96 | // 角度制限
97 | void limitter(Transform bone)
98 | {
99 | // 足首のZ回転
100 | if (bone.name.Contains("足首"))
101 | {
102 | var vv = bone.localEulerAngles;
103 | vv.z = 0;
104 | bone.localRotation = Quaternion.Euler(vv);
105 | return;
106 | }
107 |
108 | // 本来なら設定値に基づいてやるけど、とりあえず膝限定
109 | if (!bone.name.Contains("ひざ"))
110 | return;
111 |
112 | // オイラー角を取得
113 | var v = bone.localEulerAngles;
114 |
115 | // y,z回転を無効化
116 | if (adjust_rot(v.y) == adjust_rot(v.z))
117 | {
118 | v.y = adjust_rot(v.y);
119 | v.z = adjust_rot(v.z);
120 | }
121 |
122 | // 逆に曲がらないように、制限してあげる
123 | if (v.x < 90 && v.x > 2 && ((v.y == 0 && v.z == 0) || (v.y == 180 && v.z == 180)))
124 | v.x = 360 - v.x * 0.99f;
125 |
126 | bone.localRotation = Quaternion.Euler(v);
127 | }
128 |
129 | // 0か180か近い方に固定
130 | int adjust_rot(float n)
131 | {
132 | if (Mathf.Abs(n) > Mathf.Abs(180 - n) && Mathf.Abs(360 - n) > Mathf.Abs(180 - n))
133 | return 180;
134 | else
135 | return 0;
136 | }
137 |
138 | // MMDEngine.cs の方でIKボーン全体も保持してるので、
139 | // そっちからSolve()を呼び出している。
140 | //--------------------
141 | //void LateUpdate()
142 | //{
143 | // Solve();
144 | //}
145 | }
146 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerLibrary/Motion/MMDMotionTrack.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using MMDIKBakerLibrary.Misc;
5 |
6 | namespace MMDIKBakerLibrary.Motion
7 | {
8 | class MMDMotionTrack
9 | {
10 | ///
11 | /// デフォルトモーション再生FPS
12 | ///
13 | public const decimal DefaultFPS = 30m;
14 | decimal m_NowFrame = 0;
15 | decimal m_MaxFrame = 0;
16 | //モーションデータ
17 | Dictionary> boneFrames;
18 | //モーションデータの読み出し位置
19 | Dictionary bonePos = new Dictionary();
20 | //トラックから抽出されたボーンの差分一覧
21 | Dictionary subPoses;
22 | ///
23 | /// モーション再生用FPS
24 | ///
25 | public decimal FramePerSecond { get; set; }
26 | ///
27 | /// 現在のボーン差分一覧
28 | ///
29 | public Dictionary SubPoses { get { return subPoses; } }
30 |
31 | public MMDMotionTrack(MMDMotion motionData)
32 | {
33 | //ボーンの配列抜き出し
34 | boneFrames = motionData.BoneFrames;
35 | //モーションのFPS=30
36 | FramePerSecond = DefaultFPS;
37 | //差分一覧を作成
38 | subPoses = new Dictionary(motionData.BoneFrames.Count);
39 | //現在の再生位置を設定&最大フレーム数のチェック
40 | foreach (KeyValuePair> it in motionData.BoneFrames)
41 | {
42 | bonePos.Add(it.Key, 0);
43 | foreach (MMDBoneKeyFrame it2 in it.Value)
44 | {
45 | if (it2.FrameNo > m_MaxFrame)
46 | m_MaxFrame = it2.FrameNo;
47 | }
48 | }
49 | }
50 |
51 | //終了したらfalseを返す
52 | public bool Update()
53 | {
54 | bool result = !TimeUpdate();
55 | SubPoses.Clear();
56 | //ボーンの更新
57 | foreach (KeyValuePair> frameList in boneFrames)
58 | {
59 | //カーソル位置の更新
60 | int CursorPos = bonePos[frameList.Key];
61 | for (; CursorPos < frameList.Value.Count && frameList.Value[CursorPos].FrameNo < m_NowFrame; ++CursorPos) ;
62 | for (; CursorPos > 0 && frameList.Value[CursorPos - 1].FrameNo > m_NowFrame; --CursorPos) ;
63 | bonePos[frameList.Key] = CursorPos;
64 | if (CursorPos == frameList.Value.Count)
65 | {//通常再生時の最終フレーム
66 | SQTTransform subPose;
67 | frameList.Value[CursorPos - 1].GetSQTTransform(out subPose);
68 | SubPoses.Add(frameList.Key, subPose);
69 | }
70 | else
71 | {
72 | //時間経過取得
73 | decimal Progress = (m_NowFrame - frameList.Value[CursorPos - 1].FrameNo) / (frameList.Value[CursorPos].FrameNo - frameList.Value[CursorPos - 1].FrameNo);
74 | SQTTransform subPose;
75 | MMDBoneKeyFrame pose1 = frameList.Value[CursorPos - 1], pose2 = frameList.Value[CursorPos];
76 | MMDBoneKeyFrame.Lerp(pose1, pose2, Progress, out subPose);
77 | SubPoses.Add(frameList.Key, subPose);
78 | }
79 | }
80 | return result;
81 | }
82 | private bool TimeUpdate()
83 | {
84 | decimal elapsedSeconds = 1m / 30m;
85 | bool result = false;
86 | m_NowFrame += elapsedSeconds * FramePerSecond;
87 | if (m_NowFrame > m_MaxFrame)
88 | {
89 | result = true;
90 | m_NowFrame = m_MaxFrame;
91 | }
92 | return result;
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/Morph/BoneMorph.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | public class BoneMorph : MorphBase
6 | {
7 | public MorphManager.PanelType panel;
8 | public int[] indices;
9 | public BoneMorphParameter[] values;
10 |
11 | private float prev_weight_ = 0.0f;
12 | private BoneMorphParameter[] values_cache_ = null;
13 |
14 | ///
15 | /// モーフ処理
16 | ///
17 | /// 更新したか(true:更新した、false:未更新)
18 | /// モーフ値
19 | public bool Compute(BoneMorphParameter[] composite)
20 | {
21 | bool result = false;
22 | //キャッシュ設定
23 | float weight = base.GetWeight(transform);
24 | if ((prev_weight_ != weight) || (null == values_cache_)) {
25 | values_cache_ = values.Select(x=>x * weight).ToArray();
26 | prev_weight_ = weight;
27 | result = true;
28 | }
29 |
30 | //反映
31 | for (int i = 0, i_max = values_cache_.Length; i < i_max; ++i) {
32 | composite[indices[i]] += values_cache_[i];
33 | }
34 | return result;
35 | }
36 |
37 | ///
38 | /// ボーンモーフパラメータ
39 | ///
40 | [System.Serializable]
41 | public class BoneMorphParameter {
42 | public Vector3 position; //移動
43 | public Quaternion rotation; //回転
44 |
45 | ///
46 | /// 零
47 | ///
48 | public static BoneMorphParameter zero {
49 | get {
50 | BoneMorphParameter result = new BoneMorphParameter();
51 | result.position = Vector3.zero;
52 | result.rotation = Quaternion.identity;
53 | return result;
54 | }
55 | }
56 |
57 | ///
58 | /// パラメータの線形補間
59 | ///
60 | /// 補間値
61 | /// 補間始点
62 | /// 補間終点
63 | /// 補間係数(0.0fなら始点、1.0fなら終点)
64 | public static BoneMorphParameter Lerp (BoneMorphParameter lhs, BoneMorphParameter rhs, float weight) {
65 | BoneMorphParameter result = new BoneMorphParameter();
66 | result.position = Vector3.Lerp(lhs.position, rhs.position, weight);
67 | result.rotation = Quaternion.Slerp(lhs.rotation, rhs.rotation, weight);
68 | return result;
69 | }
70 |
71 | ///
72 | /// 加算
73 | ///
74 | /// 加算値
75 | /// 被加数
76 | /// 加数
77 | public static BoneMorphParameter operator+ (BoneMorphParameter lhs, BoneMorphParameter rhs) {
78 | BoneMorphParameter result = new BoneMorphParameter();
79 | result.position = lhs.position + rhs.position;
80 | result.rotation = lhs.rotation * rhs.rotation; //順回転乗算
81 | return result;
82 | }
83 |
84 | ///
85 | /// 減算
86 | ///
87 | /// 減算値
88 | /// 被加数
89 | /// 加数
90 | public static BoneMorphParameter operator- (BoneMorphParameter lhs, BoneMorphParameter rhs) {
91 | BoneMorphParameter result = new BoneMorphParameter();
92 | result.position = lhs.position - rhs.position;
93 | result.rotation = lhs.rotation * Quaternion.Inverse(rhs.rotation); //逆回転乗算
94 | return result;
95 | }
96 |
97 | ///
98 | /// スカラー乗算
99 | ///
100 | /// スカラー乗算値
101 | /// 被乗数
102 | /// 乗数
103 | public static BoneMorphParameter operator* (BoneMorphParameter lhs, float rhs) {
104 | BoneMorphParameter result = new BoneMorphParameter();
105 | result.position = lhs.position * rhs;
106 | result.rotation = Quaternion.Slerp(Quaternion.identity, lhs.rotation, rhs); //0.0fが掛けられればQuaternion.identity化する
107 | return result;
108 | }
109 | public static BoneMorphParameter operator* (float lhs, BoneMorphParameter rhs) {
110 | return rhs * lhs;
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Editor/MorphManagerEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEditor;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | ///
7 | /// 表情用Inspector拡張
8 | ///
9 | [CustomEditor(typeof(MorphManager))]
10 | public sealed class MorphManagerEditor : Editor
11 | {
12 | ///
13 | /// スタティックコンストラクタ
14 | ///
15 | static MorphManagerEditor()
16 | {
17 | panel_displays_ = new bool[System.Enum.GetValues(typeof(MorphManager.PanelType)).Length];
18 | for (int i = 0, i_max = panel_displays_.Length; i < i_max; ++i) {
19 | panel_displays_[i] = true;
20 | }
21 | }
22 |
23 | ///
24 | /// 初回処理
25 | ///
26 | public void Awake()
27 | {
28 | MorphManager self = (MorphManager)target;
29 |
30 | children_ = new Transform[System.Enum.GetValues(typeof(MorphManager.PanelType)).Length][];
31 | //子登録
32 | for (int i = 0, i_max = children_.Length; i < i_max; ++i) {
33 | children_[i] = self.vertex_morph.script.Where(x=>x.panel == (MorphManager.PanelType)i)
34 | .Select(x=>x.transform)
35 | .Concat(self.uv_morph.SelectMany(x=>x.script)
36 | .Where(x=>x.panel == (MorphManager.PanelType)i)
37 | .Select(x=>x.transform)
38 | )
39 | .Concat(self.material_morph.script.Where(x=>x.panel == (MorphManager.PanelType)i)
40 | .Select(x=>x.transform)
41 | )
42 | .Concat(self.bone_morph.script.Where(x=>x.panel == (MorphManager.PanelType)i)
43 | .Select(x=>x.transform)
44 | )
45 | .Concat(self.group_morph.script.Where(x=>x.panel == (MorphManager.PanelType)i)
46 | .Select(x=>x.transform)
47 | )
48 | .ToArray();
49 | }
50 | }
51 |
52 | ///
53 | /// Inspector描画
54 | ///
55 | public override void OnInspectorGUI()
56 | {
57 | bool is_dirty = false;
58 |
59 | is_dirty = OnInspectorGUIforPanelList() || is_dirty;
60 |
61 | if (is_dirty) {
62 | //更新が有ったなら
63 | //Inspector更新
64 | EditorUtility.SetDirty(target);
65 | }
66 | }
67 |
68 | ///
69 | /// パネルリストの為のInspector描画
70 | ///
71 | /// 更新が有ったか(true:更新有り, false:未更新)
72 | private bool OnInspectorGUIforPanelList()
73 | {
74 | bool is_update = false;
75 |
76 | for (int i = 0, i_max = children_.Length; i < i_max; ++i) {
77 | if (MorphManager.PanelType.Base == (MorphManager.PanelType)i) {
78 | //Baseだったらスキップ
79 | continue;
80 | }
81 |
82 | //パネルツリータイトル
83 | string panel_name = ((MMDSkinsScript.SkinType)i).ToString();
84 | panel_displays_[i] = EditorGUILayout.Foldout(panel_displays_[i], panel_name);
85 | //パネルツリー内部
86 | if (panel_displays_[i]) {
87 | //このパネルを表示するなら
88 | ++EditorGUI.indentLevel;
89 | EditorGUILayout.BeginVertical();
90 | {
91 | //モーフオブジェクト走査
92 | foreach (Transform child in children_[i]) {
93 | float value = child.localPosition.z;
94 | value = EditorGUILayout.Slider(child.name, value, 0.0f, 1.0f);
95 | if (child.localPosition.z != value) {
96 | //変更が掛かったなら
97 | //Undo登録
98 | #if !UNITY_4_2 //4.3以降
99 | Undo.RecordObject(child, "Morph Change");
100 | #else
101 | Undo.RegisterUndo(child, "Morph Change");
102 | #endif
103 | //Z位置更新
104 | Vector3 position = child.localPosition;
105 | position.z = value;
106 | child.localPosition = position;
107 | //改変モーフオブジェクトのInspector更新
108 | EditorUtility.SetDirty(child.transform);
109 |
110 | is_update = true;
111 | }
112 | }
113 | }
114 | EditorGUILayout.EndVertical();
115 | --EditorGUI.indentLevel;
116 | }
117 | }
118 | return is_update;
119 | }
120 |
121 | private static bool[] panel_displays_; //パネルの表示
122 | private Transform[][] children_; //パネル別子モーフオブジェクト
123 | }
124 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/.MMDIKBaker/MMDIKBakerGUI/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.IO;
10 | using MikuMikuDance.Model;
11 | using MikuMikuDance.Model.Ver1;
12 | using MikuMikuDance.Motion;
13 | using MikuMikuDance.Motion.Motion2;
14 | using MMDIKBakerLibrary;
15 |
16 | namespace MMDIKBakerGUI
17 | {
18 | public partial class Form1 : Form
19 | {
20 | public Form1()
21 | {
22 | InitializeComponent();
23 | }
24 |
25 | private void startBake_Click(object sender, EventArgs e)
26 | {
27 | // 入力チェック
28 | if (!File.Exists(pmdFileName.Text))
29 | {
30 | MessageBox.Show(
31 | "PMDファイルが見つかりません!:\n" + pmdFileName.Text,
32 | "PMD読み込みエラー",
33 | MessageBoxButtons.OK,
34 | MessageBoxIcon.Error);
35 | return;
36 | }
37 |
38 | if (!File.Exists(vmdFileName.Text))
39 | {
40 | MessageBox.Show(
41 | "VMDファイルが見つかりません!:\n" + vmdFileName.Text,
42 | "VMD読み込みエラー",
43 | MessageBoxButtons.OK,
44 | MessageBoxIcon.Error);
45 | return;
46 | }
47 |
48 | // saveVMDの上書き確認
49 | if (File.Exists(saveVmdName.Text))
50 | {
51 | var result = MessageBox.Show(
52 | "VMDファイルが存在します。\n" + saveVmdName.Text + "\n上書きしてよろしいですか?",
53 | "上書き確認",
54 | MessageBoxButtons.YesNoCancel,
55 | MessageBoxIcon.Question);
56 |
57 | if(result != System.Windows.Forms.DialogResult.Yes)
58 | return;
59 |
60 | // bakeでエラー出るっぽいので削除しておく
61 | File.Delete(saveVmdName.Text);
62 | }
63 |
64 | // Bake!
65 | try
66 | {
67 | MMDModel1 model = (MMDModel1)ModelManager.Read(pmdFileName.Text, MikuMikuDance.Model.CoordinateType.RightHandedCoordinate);
68 | MMDMotion2 motion = (MMDMotion2)MotionManager.Read(vmdFileName.Text, MikuMikuDance.Motion.CoordinateType.RightHandedCoordinate);
69 | motion = IKBaker.bake(motion, model);
70 | MotionManager.Write(saveVmdName.Text, motion);
71 |
72 | MessageBox.Show(
73 | "Bake完了",
74 | "Baked!!");
75 | }
76 | catch
77 | {
78 | MessageBox.Show(
79 | "Bake中にエラーが発生しました",
80 | "未知のエラー",
81 | MessageBoxButtons.OK,
82 | MessageBoxIcon.Error);
83 | return;
84 | }
85 | }
86 |
87 | private void pmdRef_Click(object sender, EventArgs e)
88 | {
89 | var dialog = new OpenFileDialog();
90 | dialog.Filter = "PMDファイル|*.pmd";
91 | if (dialog.ShowDialog() == DialogResult.OK)
92 | {
93 | pmdFileName.Text = dialog.FileName;
94 | }
95 | }
96 |
97 | private void vmdRef_Click(object sender, EventArgs e)
98 | {
99 | var dialog = new OpenFileDialog();
100 | dialog.Filter = "VMDファイル|*.vmd";
101 | if (dialog.ShowDialog() == DialogResult.OK)
102 | {
103 | vmdFileName.Text = dialog.FileName;
104 |
105 | var f = new FileInfo(vmdFileName.Text);
106 | saveVmdName.Text = Path.Combine(f.DirectoryName, f.Name.Replace(f.Extension, "_baked") + f.Extension);
107 | }
108 | }
109 |
110 | private void saveRef_Click(object sender, EventArgs e)
111 | {
112 | var dialog = new SaveFileDialog();
113 | dialog.Filter = "VMDファイル|*.vmd";
114 | if (dialog.ShowDialog() == DialogResult.OK)
115 | {
116 | saveVmdName.Text = dialog.FileName;
117 | }
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/Resources/MMDEngine.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | public class MMDEngine : MonoBehaviour {
7 |
8 | public float scale = 1.0f; //読み込みスケール
9 | public bool useRigidbody = false;
10 | public int[] groupTarget; // 非衝突剛体リスト
11 | public GameObject[] rigids; // 剛体リスト
12 | public GameObject[] joints; // ConfigurableJointの入っているボーンのリスト
13 | #if UNITY_EDITOR
14 | public float outline_width; //エッジ幅係数(エディタ用)
15 | public float[] material_outline_widths; //材質のエッジ幅(エディタ用)
16 | public bool enable_render_queue; //カスタムレンダーキューの使用
17 | public int render_queue_value; //カスタムレンダーキュー値
18 | #endif
19 |
20 | // 訳があってこうなってる
21 | public int[] ignore1;
22 | public int[] ignore2;
23 | public int[] ignore3;
24 | public int[] ignore4;
25 | public int[] ignore5;
26 | public int[] ignore6;
27 | public int[] ignore7;
28 | public int[] ignore8;
29 | public int[] ignore9;
30 | public int[] ignore10;
31 | public int[] ignore11;
32 | public int[] ignore12;
33 | public int[] ignore13;
34 | public int[] ignore14;
35 | public int[] ignore15;
36 | public int[] ignore16;
37 | List ignoreList;
38 |
39 | // ボーンの計算
40 | public BoneController[] bone_controllers;
41 | // IKの計算順
42 | public CCDIKSolver[] ik_list;
43 |
44 | // Use this for initialization
45 | void Start ()
46 | {
47 | if (useRigidbody)
48 | {
49 | ignoreList = new List();
50 | ignoreList.Add(ignore1);
51 | ignoreList.Add(ignore2);
52 | ignoreList.Add(ignore3);
53 | ignoreList.Add(ignore4);
54 | ignoreList.Add(ignore5);
55 | ignoreList.Add(ignore6);
56 | ignoreList.Add(ignore7);
57 | ignoreList.Add(ignore8);
58 | ignoreList.Add(ignore9);
59 | ignoreList.Add(ignore10);
60 | ignoreList.Add(ignore11);
61 | ignoreList.Add(ignore12);
62 | ignoreList.Add(ignore13);
63 | ignoreList.Add(ignore14);
64 | ignoreList.Add(ignore15);
65 | ignoreList.Add(ignore16);
66 |
67 | // 非衝突グループの設定
68 | for (int i = 0; i < rigids.Length; i++)
69 | {
70 | for (int shift = 0; shift < 16; shift++)
71 | {
72 | // フラグチェック
73 | if ((groupTarget[i] & (1 << shift)) == 0)
74 | {
75 | for (int j = 0; j < ignoreList[shift].Length; j++)
76 | {
77 | int ignoreIndex=ignoreList[shift][j];
78 | if (i == ignoreIndex) continue;
79 | Physics.IgnoreCollision(rigids[i].GetComponent(),
80 | rigids[ignoreIndex].GetComponent(), true);
81 | }
82 | }
83 | }
84 | }
85 | }
86 | }
87 |
88 | void LateUpdate()
89 | {
90 | //IK反映
91 | foreach (CCDIKSolver ik_script in this.ik_list) {
92 | ik_script.Solve();
93 | }
94 |
95 | if (0 < bone_controllers.Length) {
96 | //ボーンコントローラーが有れば(PMXなら)
97 | //ボーン計算
98 | foreach (BoneController bone_controller in bone_controllers) {
99 | bone_controller.Process();
100 | }
101 | //差分基点座標更新
102 | foreach (BoneController bone_controller in bone_controllers) {
103 | bone_controller.UpdatePrevTransform();
104 | }
105 | }
106 | }
107 |
108 | public static void Initialize(MMDEngine engine, int[] groupTarget, List[] ignoreGroups, GameObject[] rigidArray)
109 | {
110 | if (!engine.useRigidbody)
111 | {
112 | engine.groupTarget = groupTarget;
113 | engine.rigids = rigidArray;
114 | engine.useRigidbody = true;
115 |
116 | engine.ignore1 = ignoreGroups[0].ToArray();
117 | engine.ignore2 = ignoreGroups[1].ToArray();
118 | engine.ignore3 = ignoreGroups[2].ToArray();
119 | engine.ignore4 = ignoreGroups[3].ToArray();
120 | engine.ignore5 = ignoreGroups[4].ToArray();
121 | engine.ignore6 = ignoreGroups[5].ToArray();
122 | engine.ignore7 = ignoreGroups[6].ToArray();
123 | engine.ignore8 = ignoreGroups[7].ToArray();
124 | engine.ignore9 = ignoreGroups[8].ToArray();
125 | engine.ignore10 = ignoreGroups[9].ToArray();
126 | engine.ignore11 = ignoreGroups[10].ToArray();
127 | engine.ignore12 = ignoreGroups[11].ToArray();
128 | engine.ignore13 = ignoreGroups[12].ToArray();
129 | engine.ignore14 = ignoreGroups[13].ToArray();
130 | engine.ignore15 = ignoreGroups[14].ToArray();
131 | engine.ignore16 = ignoreGroups[15].ToArray();
132 | }
133 | }
134 | }
135 |
136 |
--------------------------------------------------------------------------------
/MMD2UnityTool/Assets/MMD2UnityTool/3rd/mmd-for-unity-master/tutorial.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: Tutorial
4 | ---
5 |
6 | MMD for Unityの使い方
7 | ========================
8 |
9 | ## MikuMikuDanceの基礎
10 | MikuMikuDanceとは,樋口優氏が開発した3DCGアニメーションソフトの1種です.
11 | 3DCGの初音ミクが踊っている動画を作成するために作られたフリーソフトです.
12 |
13 | MikuMikuDanceではニコニコ動画やYoutubeを中心に,多くの動画が公開されています.
14 | また,有志によって多くのモデルデータやモーションデータが公開されているため,
15 | 初音ミクの他に色々なキャラクターが踊る動画を作ることができます.
16 |
17 | ### データの基本
18 | MikuMikuDanceでは,3種類のデータを扱うことができます.
19 | シーンデータを扱うための **PMMファイル** ,
20 | モデルデータを扱うための **PMD/PMXファイル** ,
21 | モーションデータを扱うための **VMDファイル** の3種類です.
22 |
23 | MikuMikuDanceでは,キャラクターを3DCGのデータとして扱っています.
24 | そのデータが **PMD/PMX** ファイルです.
25 | また,キャラクターを踊らせた時のデータ(モーション)が **VMDファイル** です.
26 |
27 | MikuMikuDanceではモデルデータ(キャラクター)をいくつか読み込み,
28 | それぞれ踊りや振り付けなどを編集します.
29 | この時,編集している場面を **シーン** と呼びます.
30 | このシーンを保存するためのデータが **PMMファイル** です.
31 |
32 | VMDファイルとPMMファイルの違いは,
33 | PMMファイルはMikuMikuDanceで編集している場面全体を保存するためのデータなのに対し,
34 | VMDファイルはキャラクター1体だけのモーションを保存するためのデータとなっていることです.
35 | このことから,場面全体を保存したい場合はPMM,モーションを公開したい場合はVMDになっています.
36 |
37 | ### モーションを保存する
38 | MikuMikuDanceのキャラクターでゲームを作るのに,
39 | ダウンロードしたモーションだけでは足りないこともあります.
40 | その時はMikuMikuDanceでモーションを自作し,
41 | モーションデータをMMD for Unityで読み込みます.
42 |
43 | 自作したモーションは,
44 | 保存したいキーフレームを選択してから「ファイル-モーションデータを保存」で保存することができます.
45 | キーフレームが選択されていないと正しく保存されないので注意して下さい.
46 | キーフレームを選択する方法はいくつかありますが,
47 | その中でも一般的な方法を紹介します.
48 |
49 | 
50 |
51 | まず,フレーム操作下部のプルダウンメニューから,「全フレーム」を選択して下さい.
52 | 次に,隣のテキストボックスに保存したいフレーム数の範囲を入力し,
53 | 範囲選択ボタンをクリックします.
54 | これで指定範囲のキーフレームが選択状態になります.
55 |
56 | 他にも,プルダウンメニューから「選択ボーン」を選ぶことで,
57 | 選択したボーンだけを保存することのできる機能もあります.
58 |
59 | ## MMD for Unityのインストール
60 | MMD for Unityでは,パッケージではなく圧縮ファイルで提供しています.
61 | ページ上部のZIPボタンから圧縮ファイルをダウンロードすることができます.
62 | ダウンロードした圧縮ファイルを解凍すると,mmd-for-unityというフォルダが現れます.
63 | このフォルダがMMD for Unityとなります.
64 |
65 | MMD for UnityのフォルダをUnityのProjectに置くだけでインストールが完了します.
66 |
67 | ## MMD for Unityの使い方
68 | MMD for Unityでは,PMD/PMXファイルの読み込みと,VMDファイルの読み込みができます.
69 | それぞれの操作方法について説明します.
70 |
71 | ### PMD Loader
72 | PMD Loaderとは,PMDファイルを読み込むための機能です.
73 | MikuMikuDanceのモデルデータをUnityにインポートします.
74 | PMD LoaderはメニューバーのMMD for Unity(旧バージョンではPlugins),
75 | もしくはPMDファイルをクリックし,Inspectorを操作することで利用できます.
76 |
77 | 
78 |
79 | まず,PMD Loaderを起動する前にモデルデータをProjectに追加する必要があります.
80 | モデルデータが入っているフォルダごと,Projectへドラッグ&ドロップしてください.
81 | なお,このフォルダの中身を変更したり移動すると読み込みに失敗します.
82 |
83 | PMD Fileには,MikuMikuDanceのPMDファイルをドラッグ&ドロップしてください.
84 | PMDファイルをドラッグ&ドロップすると,Convertボタンが現れるのでクリックすると読み込みが始まります.
85 | 読み込みが完了するとProjectにPrefabが追加されます.
86 | また,読み込んだキャラクターがHierarchyに追加されるので,成功の目安にしてください.
87 |
88 | それぞれの項目の意味について説明します.
89 |
90 | Shader Typeは描画するのに使われるシェーダの種類を選択します.デフォルトはMMDShaderです.
91 | 他にもいくつかシェーダに種類があります.
92 |
93 | Rigidbodyは剛体を利用したいときにチェックします.
94 | 剛体を利用することで,物理エンジンによって髪の毛やスカートの揺れ等が表現できるようになります.
95 | (ただし,モデルデータに剛体の情報がある場合のみ)
96 |
97 | Use Mecanimをチェックすると,Mecanimが利用できるように調整します.
98 |
99 | Use IKは,IKを利用したいときにチェックします.
100 | 通常,胴体や腕などのボーンはFK(Forward Kinematics,順運動学)と呼ばれる方法でアニメーションされます.
101 | 例えば,肩,肘,手首などのように,根本から末端の順番でアニメーションさせる仕組みです.
102 | 一方,IK(Inverce Kinematics,逆運動学)は,
103 | 手首の位置だけ先に決めておいて,肘と肩の角度は後から決めるような仕組みになっています.
104 | 通常,MikuMikuDanceではこのIKが多用されているので,
105 | 完全に動かしたい場合はオンにすることを推奨します.
106 |
107 | Scaleは読み込んだモデルの大きさです.
108 | UnityとMikuMikuDanceでは,大きさの単位が異なるため,
109 | MikuMikuDanceからUnityへ大きさを揃える必要があります.
110 | Originalボタンを押すと,1メートルを基準とした大きさに揃えられます.
111 | 1.0ボタンを押すと,MikuMikuDanceを基準とした大きさに揃えられます.
112 | Use PMX Base Importは,PMXファイルを読み込みたいときにチェックします.
113 |
114 | ### VMD Loader
115 | VMD Loaderとは,VMDファイルを読み込むための機能です.
116 | MikuMikuDanceのモーションデータをUnityにインポートします.
117 | VMD LoaderはメニューバーのMMD for Unity(旧バージョンではPlugins),
118 | もしくはVMDファイルをクリックし,Inspectorを操作することで利用できます.
119 |
120 | 
121 |
122 | PMD Prefabには,PMD Loaderで生成されたPrefabをドラッグ&ドロップします.
123 | また,VMD Fileには,VMDファイルをドラッグ&ドロップしてください.
124 | VMD Loaderでは,PMD Prefabにモーションデータを流し込み,アニメーションクリップを生成します.
125 | この2つの項目を埋めることでConvertボタンが出現します.
126 | クリックすると変換が始まります.
127 |
128 | それぞれの項目の意味について説明します.
129 |
130 | Create Assetをチェックすると,アニメーションクリップをPrefabの中だけでなく,アセットファイルとして出力します.
131 |
132 | Interpolation Qualityは,線形補間の品質です.
133 | UnityとMikuMikuDanceでは線形補間の方法が異なります.
134 | そのため,擬似的にMikuMikuDanceの線形補間を再現するため,
135 | アニメーションの中にキーフレームをいくつか打つ方式を取っています.
136 | Interpolation Qualityを高くするほど多くのキーフレームを打ちますが,
137 | それだけデータ量が多くなるので注意してください.
--------------------------------------------------------------------------------