예제 #1
0
    // Start is called before the first frame update
    void OnEnable()
    {
        var src   = new FileInfo(m_vrmPath);
        var vrm0x = Import(File.ReadAllBytes(m_vrmPath), src);

        // Export 1.0
        var exporter = new UniVRM10.RuntimeVrmConverter();
        var model    = exporter.ToModelFrom10(vrm0x);

        // 右手系に変換
        model.ConvertCoordinate(VrmLib.Coordinates.Vrm1);
        var exportedBytes = model.ToGlb();

        // Import 1.0
        var vrm10 = Import(exportedBytes, src);
        var pos   = vrm10.transform.position;

        pos.x += 1.5f;
        vrm10.transform.position = pos;
        vrm10.name = vrm10.name + "_Imported_v1_0";

        // write
        var path = Path.GetFullPath("vrm10.vrm");

        Debug.Log($"write : {path}");
        File.WriteAllBytes(path, exportedBytes);
    }
예제 #2
0
        private Model ToVrmModel(GameObject root)
        {
            var exporter = new UniVRM10.RuntimeVrmConverter();
            var model    = exporter.ToModelFrom10(root);

            model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false);
            return(model);
        }
예제 #3
0
        private Model ToVrmModel(GameObject root)
        {
            var exporter = new UniVRM10.RuntimeVrmConverter();
            var model    = exporter.ToModelFrom10(root, root.GetComponent <VRM10Controller>().Meta);

            model.ConvertCoordinate(VrmLib.Coordinates.Gltf, ignoreVrm: false);
            return(model);
        }
예제 #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);
        }