public void Export(GameObject root, Model model, ModelExporter converter, ExportArgs option, VRM10ObjectMeta vrmMeta = null) { Storage.Gltf.asset = ExportAsset(model); Storage.Reserve(CalcReserveBytes(model)); foreach (var material in ExportMaterials(model, m_textureExporter, m_settings)) { Storage.Gltf.materials.Add(material); } foreach (var mesh in ExportMeshes(model.MeshGroups, model.Materials, Storage, option)) { Storage.Gltf.meshes.Add(mesh); } foreach (var(node, skin) in ExportNodes(model.Nodes, model.MeshGroups, Storage, option)) { Storage.Gltf.nodes.Add(node); if (skin != null) { var skinIndex = Storage.Gltf.skins.Count; Storage.Gltf.skins.Add(skin); node.skin = skinIndex; } } Storage.Gltf.scenes.Add(new gltfScene() { nodes = model.Root.Children.Select(child => model.Nodes.IndexOfThrow(child)).ToArray() }); var(vrm, vrmSpringBone, thumbnailTextureIndex) = ExportVrm(root, model, converter, vrmMeta, Storage.Gltf.nodes, m_textureExporter); // Extension で Texture が増える場合があるので最後に呼ぶ var exportedTextures = m_textureExporter.Export(); for (var exportedTextureIdx = 0; exportedTextureIdx < exportedTextures.Count; ++exportedTextureIdx) { var(unityTexture, texColorSpace) = exportedTextures[exportedTextureIdx]; GltfTextureExporter.PushGltfTexture(Storage, unityTexture, texColorSpace, m_textureSerializer); } if (thumbnailTextureIndex.HasValue) { vrm.Meta.ThumbnailImage = Storage.Gltf.textures[thumbnailTextureIndex.Value].source; } UniGLTF.Extensions.VRMC_vrm.GltfSerializer.SerializeTo(ref Storage.Gltf.extensions, vrm); if (vrmSpringBone != null) { UniGLTF.Extensions.VRMC_springBone.GltfSerializer.SerializeTo(ref Storage.Gltf.extensions, vrmSpringBone); } // Fix Duplicated name gltfExporter.FixName(Storage.Gltf); }
public void Reserve(int bytesLength) { Storage.Reserve(bytesLength); }