public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_to_scene; } combineMesh = new DMesh3(); MeshEditor editor = new MeshEditor(combineMesh); foreach (var so in InputSOs) { DMesh3 inputMesh = so.Mesh; int[] mapV; if (editor.AppendMesh(so.Mesh, out mapV)) { MeshTransforms.PerVertexTransform(combineMesh, inputMesh, mapV, (v, old_id, new_id) => { return(SceneTransforms.ObjectToSceneP(so, v)); }); } } ; MeshSourceOp = new ConstantMeshSourceOp(combineMesh, true, true); SeparateOp = new SeparateSolidsOp() { MeshSource = MeshSourceOp }; ComputeOp = new ThreadedResultComputeOp <List <DMesh3> >() { ResultSource = SeparateOp }; if (HiddenPreviewMaterial == null) { HiddenPreviewMaterial = SOMaterial.CreateTransparent("remove_hidden_generated", new Colorf(Colorf.DimGrey, 0.5f)); } if (KeepPreviewMaterial == null) { KeepPreviewMaterial = SOMaterial.CreateFlatShaded("remove_keep_generated", Colorf.DimGrey); } }
public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_so_to_scene; } if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateMesh("tool_generated", Colorf.DimGrey); } if (ErrorMaterial == null) { ErrorMaterial = SOMaterial.CreateMesh("tool_generated_error", Colorf.VideoRed); } // clear selection here so that multi-select GroupSO goes away, otherwise // when we copy frmaes below, they are relative to that GroupSO, and things move inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); if (InputSOs.Count == 1 && ForceSceneSpaceComputation == false) { combineMesh = new DMesh3(InputSOs[0].Mesh); sceneToObjUnitScale = SceneTransforms.SceneToObject(InputSOs[0], 1.0f); } else { combineMesh = new DMesh3(); MeshEditor editor = new MeshEditor(combineMesh); foreach (var so in InputSOs) { TransformSequence xform = SceneTransforms.ObjectToSceneXForm(so); DMesh3 inputMesh = so.Mesh; int[] mapV; if (editor.AppendMesh(so.Mesh, out mapV)) { MeshTransforms.PerVertexTransform(combineMesh, inputMesh, mapV, (v, old_id, new_id) => { return(xform.TransformP(v)); }); } } ; sceneToObjUnitScale = 1.0; } MeshSourceOp = new ConstantMeshSourceOp(combineMesh, true, true); EditOp = edit_op_factory(MeshSourceOp); ComputeOp = new ThreadedMeshComputeOp() { MeshSource = EditOp }; PreviewSO = new DMeshSO() { EnableSpatial = EnablePreviewSpatial }; PreviewSO.Create(new DMesh3(), PreviewMaterial); if (InputSOs.Count == 1 && ForceSceneSpaceComputation == false) { PreviewSO.SetLocalFrame(InputSOs[0].GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); PreviewSO.SetLocalScale(InputSOs[0].GetLocalScale()); } Scene.AddSceneObject(PreviewSO); postprocess_target_objects(); base_initialize_parameters(); }