internal void Add(Geometrie geometrie) { foreach (var g in geometries) { if (g.id == geometrie.id) { return; } } geometries.Add(geometrie); }
private static Geometrie SaveMesh(Mesh mesh, string id) { var geo = new Geometrie { id = id, type = "mesh" }; var binBindle = new BinBundle(); geo.attr_position = $"{id}#{binBindle.Add(BytesUtility.ToBytes(mesh.vertices))}"; geo.indexs = $"{id}#{binBindle.Add(BytesUtility.ToBytes(mesh.triangles))}"; geo.attr_normal = $"{id}#{binBindle.Add(BytesUtility.ToBytes(mesh.normals))}"; geo.attr_uv = $"{id}#{binBindle.Add(BytesUtility.ToBytes(mesh.uv))}"; if (mesh.tangents != null && mesh.tangents.Length > 0) { geo.attr_tangent = $"{id}#{binBindle.Add(BytesUtility.ToBytes(mesh.tangents))}"; } var subList = new List <Geometrie.Sub>(); for (var i = 0; i < mesh.subMeshCount; i++) { var subMesh = mesh.GetSubMesh(i); var sub = new Geometrie.Sub { start = subMesh.indexStart, count = subMesh.indexCount, materialIndex = i }; subList.Add(sub); } if (subList.Count > 0) { geo.groups = subList.ToArray(); } var bytes = binBindle.ToBytes(); var json = JsonUtility.ToJson(geo); File.WriteAllText($"{AssetPath}/{id}.meta", json); File.WriteAllBytes($"{AssetPath}/{id}", bytes); return(geo); }