示例#1
0
        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());
        }
示例#2
0
        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);

            MeshSourceOps = new List <ConstantMeshSourceOp>();
            SceneMeshes   = new List <DMesh3>();
            foreach (var so in InputSOs)
            {
                var    xform     = SceneTransforms.ObjectToSceneXForm(so);
                DMesh3 sceneMesh = new DMesh3(so.Mesh);
                MeshTransforms.PerVertexTransform(sceneMesh, xform);
                SceneMeshes.Add(sceneMesh);
                MeshSourceOps.Add(
                    new ConstantMeshSourceOp(sceneMesh, false, true));
            }

            EditOp    = edit_op_factory(MeshSourceOps.Cast <DMeshSourceOp>());
            ComputeOp = new ThreadedMeshComputeOp()
            {
                MeshSource = EditOp
            };

            PreviewSO = new DMeshSO()
            {
                EnableSpatial = EnablePreviewSpatial
            };
            PreviewSO.Create(new DMesh3(), PreviewMaterial);
            Scene.AddSceneObject(PreviewSO);

            postprocess_target_objects();
            base_initialize_parameters();
        }
示例#3
0
        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();
        }