public static async Task <RenderVertex[]> GetVerticesAsync(string filename) { var result = await Collada.ImportAsync(filename, new ColladaImportOptions(), new Progress <float>(), CancellationToken.None); var vertices = new List <RenderVertex>(); foreach (var scene in result.Scenes) { foreach (var subMesh in scene.Model.Children) { for (int i = 0; i < subMesh.Primitives.Triangles.Count; i++) { var face = subMesh.Primitives.GetFace(i); vertices.Add(GetVertex(face.Vertex0)); vertices.Add(GetVertex(face.Vertex1)); vertices.Add(GetVertex(face.Vertex2)); } } } return(vertices.ToArray()); }
private async void btnImport_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text)) { return; } _cancel = new CancellationTokenSource(); btnCancel.Enabled = true; Progress <float> progress = new Progress <float>(); progress.ProgressChanged += Progress_ProgressChanged; tabControl1.SelectTab(1); var scenes = await Collada.ImportAsync(textBox1.Text, _options, progress, _cancel.Token); btnCancel.Enabled = false; _cancel = null; PrintOutput(scenes); progress.ProgressChanged -= Progress_ProgressChanged; progressBar1.Value = progressBar1.Maximum; }