void initialize_cut_op() { if (MeshSourceOp != null) { return; } MeshSourceOp = new WrapDMeshSourceOp() { MeshSourceF = () => { return(InputMeshSO.Mesh); }, SpatialSourceF = () => { return(InputMeshSO.Spatial); } }; CutOp = new CutPolygonHoleOp() { MeshSource = MeshSourceOp }; ComputeOp = new ThreadedMeshComputeOp() { MeshSource = CutOp }; if (CutPreviewMaterial == null) { CutPreviewMaterial = SOMaterial.CreateFlatShaded("add_hole_cut", Colorf.DimGrey); } CutPreviewSO = new DMeshSO() { EnableSpatial = false }; CutPreviewSO.Create(new DMesh3(), CutPreviewMaterial); Scene.AddSceneObject(CutPreviewSO); CutPreviewSO.SetLocalFrame(InputMeshSO.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); CutPreviewSO.SetLocalScale(InputMeshSO.GetLocalScale()); }
public IEnumerator RunMainThreadProcessing(bool bSpawnBackgroundWrite = true) { int N = ExportMeshSOs.Count; ExportMeshes = new DMesh3[N]; MeshFrames = new Frame3f[N]; for (int k = 0; k < N; ++k) { DMeshSO so = ExportMeshSOs[k]; DMesh3 copy = new DMesh3(so.Mesh, false, MeshComponents.VertexColors | MeshComponents.VertexNormals); // if we have scaling or parent hierarchy, need to transform to scene in main // thread, because we have no way of storing transform stack currently if (so.GetLocalScale() != Vector3f.One || so.Parent != so.GetScene()) { foreach (int vid in copy.VertexIndices()) { Vector3d v = copy.GetVertex(vid); Vector3f n = copy.GetVertexNormal(vid); Frame3f f = new Frame3f(v, n); f = SceneTransforms.ObjectToScene(so, f); copy.SetVertex(vid, f.Origin); copy.SetVertexNormal(vid, f.Z); } MeshFrames[k] = Frame3f.Identity; } else { MeshFrames[k] = ExportMeshSOs[k].GetLocalFrame(CoordSpace.ObjectCoords); } ExportMeshes[k] = copy; yield return(null); } if (MainThreadWorkCompletedF != null) { MainThreadWorkCompletedF(); } DebugUtil.Log("MeshExporter: completed main thread processing"); if (bSpawnBackgroundWrite) { ThreadPool.QueueUserWorkItem((state) => { var result = RunBackgroundWrite(); if (OnCompletedF != null) { OnCompletedF(result); } }); } }
static PrintMeshSO emit_new_print_mesh(DMesh3 mesh, DMeshSO fromParent) { PrintMeshSO newSO = new PrintMeshSO(); newSO.Create(mesh, CCMaterials.PrintMeshMaterial); CCActions.AddNewPrintMesh(newSO); if (fromParent != null) { newSO.SetLocalScale(fromParent.GetLocalScale()); newSO.SetLocalFrame(fromParent.GetLocalFrame(CoordSpace.SceneCoords), CoordSpace.SceneCoords); } else { throw new NotImplementedException("have not implemented this path yet..."); // estimate frame?? } return(newSO); }