Пример #1
0
        void OnOpenClicked()
        {
#if UNITY_STANDALONE_WIN
            var path = ComDialog.Open("open VRM", "*.vrm", "*.glb", "*.bvh");
#else
            var path = Application.dataPath + "/default.vrm";
#endif
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var ext = Path.GetExtension(path).ToLower();
            switch (ext)
            {
            case ".gltf":
            case ".glb":
            case ".vrm":
                StartCoroutine(LoadModelAsync(path));
                break;

            case ".bvh":
                LoadMotionAsync(path);
                break;
            }
        }
Пример #2
0
        private void OnOpenClickedBVH()
        {
            var path = ComDialog.Open("open BVH", "*.bvh");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            _errorMessagePanel.gameObject.SetActive(false);
            LoadMotion(path);
        }
Пример #3
0
        private void OnOpenClickedVRM()
        {
            var path = ComDialog.Open("open VRM", "*.vrm");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            _errorMessagePanel.gameObject.SetActive(false);
            LoadModel(path);
        }
Пример #4
0
        void Export()
        {
            var path = ComDialog.Save("write file", "export.vrm");

            if (string.IsNullOrEmpty(path))
            {
                Debug.Log($"cancel save");
                return;
            }

            Debug.Log($"save to {path}");
            var exporter = new UniVRM10.RuntimeVrmConverter();
            var meta     = ScriptableObject.CreateInstance <UniVRM10.VRMMetaObject>();

            meta.Name       = "";
            meta.Copyrights = "";
            meta.Version    = "";
            meta.Authors    = new[] {
                "PriMan"
            };
            meta.ContactInformation = "";
            meta.Reference          = "";
            meta.OtherPermissionUrl = "";
            meta.OtherLicenseUrl    = "";

            var model = exporter.ToModelFrom10(m_builder.Root.gameObject, meta);

            foreach (var kv in exporter.Nodes)
            {
                kv.Value.HumanoidBone = m_builder.GetHumanBone(kv.Key.transform);
            }

            // normalize
            var modifier = new ModelModifier(model);

            modifier.SkinningBake();

            VrmLib.ModelExtensionsForCoordinates.ConvertCoordinate(model, VrmLib.Coordinates.Gltf);
            var bytes = Vrm10.ModelExtensions.ToGlb(model);

            File.WriteAllBytes(path, bytes);
        }