public void MapStep(Face f, otf_Obj obj, double treshold) { /* * but first we have to reorder the vertices for our grid cell. * that way the grid cell can figure out */ List <Vertex> faceVertices = LinkVertices(obj, f); var cell = new GridCell( new IntPoint[] { BlenderCoordToWpfPixel(faceVertices.OrderByDescending(x => x.Y).Take(2).OrderBy(y => y.X).FirstOrDefault()), BlenderCoordToWpfPixel(faceVertices.OrderByDescending(x => x.Y).Take(2).OrderByDescending(y => y.X).FirstOrDefault()), BlenderCoordToWpfPixel(faceVertices.OrderBy(x => x.Y).Take(2).OrderByDescending(y => y.X).FirstOrDefault()), BlenderCoordToWpfPixel(faceVertices.OrderBy(x => x.Y).Take(2).OrderBy(y => y.X).FirstOrDefault()) }, new double[] { faceVertices.OrderByDescending(x => x.Y).Take(2).OrderBy(y => y.X).FirstOrDefault().Z, faceVertices.OrderByDescending(x => x.Y).Take(2).OrderByDescending(y => y.X).FirstOrDefault().Z, faceVertices.OrderBy(x => x.Y).Take(2).OrderByDescending(y => y.X).FirstOrDefault().Z, faceVertices.OrderBy(x => x.Y).Take(2).OrderBy(y => y.X).FirstOrDefault().Z } ); //now that we have the gridCell, go ahead and draw it. //Drawer.DrawGridCell(mCanvas, cell); //for now it's hardcoded. //later on maybe more contours? like 5 between the lowest and highest height data? Application.Current.Dispatcher.Invoke(new Action(() => { Drawer.DrawLines(mCanvas, cell.GetLineEndings(treshold)); })); }
private List <Vertex> LinkVertices(otf_Obj obj, Face face) { //getting the actual vertex data from a face using its vertex indexes. var vList = new List <Vertex>(); for (int i = 0; i < face.VertexIndexList.Length; i++) { vList.Add(obj.VertexList[face.VertexIndexList[i]]); } return(vList); }
//reading the .obj file on demand using external lib private void OnKeyDownHandler(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { Message.Text = ""; //read obj file here. var dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".obj"; bool? res = dialog.ShowDialog(); string filename; if (res == false) { throw new System.Exception("Couldn't open yo dialog."); } filename = dialog.FileName; var obj = new otf_Obj(builder.MapStep, filename); builder.Init(obj.XExtents); //this ain's parallel just yet of course. //da is like the stuff draws right in front of u //Task t = new Task(() => //{ // obj.OnTheFlyProcess(filename, 0.01); //},TaskCreationOptions.LongRunning); //t.Start(); obj.OnTheFlyProcess(filename, 0.01); //da is like u wait for 4 mins and da image pops up //obj.OnTheFlyProcess(filename); } }