Ejemplo n.º 1
0
    public static string GetJsonString(VrmLib.Model model)
    {
        // export vrm-1.0
        var exporter10 = new Vrm10Exporter();
        var option     = new VrmLib.ExportArgs
        {
            // vrm = false
        };
        var glbBytes10 = exporter10.Export(model, option);
        var glb10      = UniGLTF.Glb.Parse(glbBytes10);

        return(System.Text.Encoding.UTF8.GetString(glb10.Json.Bytes.Array, glb10.Json.Bytes.Offset, glb10.Json.Bytes.Count));
    }
Ejemplo n.º 2
0
        public void Sample()
        {
            var path = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm";

            Debug.Log($"load: {path}");

            Assert.IsTrue(Vrm10Parser.TryParseOrMigrate(path, true, out Vrm10Parser.Result result));

            var go = BuildGameObject(result.Data, result.Vrm, true);

            Debug.Log(go);

            // export
            var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer());

            Debug.Log($"export {vrmBytes.Length} bytes");
        }
Ejemplo n.º 3
0
        public void Sample()
        {
            var path = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm";

            Debug.Log($"load: {path}");

            using (var data = Vrm10Data.ParseOrMigrate(path, true, out Vrm10Data result, out MigrationData migration))
            {
                Assert.NotNull(result);

                var go = BuildGameObject(result, true);
                Debug.Log(go);

                // export
                var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer());

                Debug.Log($"export {vrmBytes.Length} bytes");
            }
        }
Ejemplo n.º 4
0
        public void Sample()
        {
            var path = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm";

            Debug.Log($"load: {path}");

            var migrated = MigrationVrm.Migrate(File.ReadAllBytes(path));

            var parser = new GltfParser();

            parser.Parse(path, migrated);

            var go = BuildGameObject(parser, true);

            Debug.Log(go);

            // export
            var vrmBytes = Vrm10Exporter.Export(go, AssetTextureUtil.GetTextureBytesWithMime);

            Debug.Log($"export {vrmBytes.Length} bytes");
        }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void OnEnable()
    {
        var src = new FileInfo(m_vrmPath);
        var go  = Import(File.ReadAllBytes(m_vrmPath), src);

        var exportedBytes = Vrm10Exporter.Export(go);

        // 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);
    }
Ejemplo n.º 6
0
        async void Run()
        {
            var src      = new FileInfo(m_vrmPath);
            var instance = await Vrm10.LoadPathAsync(m_vrmPath, true, true);

            var exportedBytes = Vrm10Exporter.Export(instance.gameObject);

            // Import 1.0
            var vrm10 = await Vrm10.LoadBytesAsync(exportedBytes, false, true);

            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);
        }