Exemple #1
0
 public void ClearScene()
 {
     SliceHeightGizmo  = null;
     slice_gizmo_valid = false;
 }
Exemple #2
0
        private void update_slice_height_gizmo()
        {
            if (CurrentToolpaths == null)
            {
                if (SliceHeightGizmo != null && SceneUtil.IsVisible(SliceHeightGizmo))
                {
                    SceneUtil.SetVisible(SliceHeightGizmo, false);
                }
                slice_gizmo_valid = false;
                return;
            }

            if (slice_gizmo_valid)
            {
                return;
            }

            AxisAlignedBox3f bounds = GetPrintMeshesBounds(true);

            if (bounds == AxisAlignedBox3f.Empty)
            {
                return;   // will be rectified next frame?
            }
            int nSlices             = CurrentToolpaths.GetSlices().Count;
            PlanarSliceStack slices = CurrentToolpaths.GetSlices();

            // line is floating
            //bounds.Min.y = (float)slices[0].Z;
            //bounds.Max.y = (float)slices[slices.Count - 1].Z;
            // line at ground
            bounds.Min.y = 0;
            bounds.Max.y = (float)(slices[slices.Count - 1].Z - slices[0].Z);

            Vector3f basePos = new Vector3f(bounds.Max.x, bounds.Min.y, bounds.Max.z);

            basePos.x += 10; basePos.z += 10;
            Vector3f topPos = basePos + bounds.Height * Vector3f.AxisY;


            if (SliceHeightGizmo == null)
            {
                SliceHeightGizmo = new SlicePlaneHeightSO()
                {
                    LineAlwaysVisible = false
                };
                SliceHeightGizmo.Create(CC.ActiveScene.PivotSOMaterial, null);
                SliceHeightGizmo.DisableShadows();

                CC.ActiveScene.AddSceneObject(SliceHeightGizmo);
                SliceHeightGizmo.Name = "Slice_Height";

                SliceHeightGizmo.ConstraintFrameS = new Frame3f(basePos);
                SliceHeightGizmo.SetLocalFrame(SliceHeightGizmo.ConstraintFrameS, CoordSpace.SceneCoords);

                SliceHeightGizmo.MinPosS    = basePos;
                SliceHeightGizmo.MaxPosS    = topPos;
                SliceHeightGizmo.CenterPosS = bounds.Point(0, -1, 0);
                SliceHeightGizmo.BoundsDim  = (float)Math.Max(bounds.Width, bounds.Depth) + 10.0f;

                SliceHeightGizmo.OnTransformModified += SliceHeightGizmo_OnTransformModified;

                SliceHeightGizmo.InitializeLiveGizmo(CC.ActiveScene);
            }

            if (SceneUtil.IsVisible(SliceHeightGizmo) == false)
            {
                SceneUtil.SetVisible(SliceHeightGizmo, true);
            }


            SliceHeightGizmo.ConstraintFrameS = new Frame3f(basePos);
            ignore_xform_event = true;
            SliceHeightGizmo.SetLocalFrame(SliceHeightGizmo.ConstraintFrameS, CoordSpace.SceneCoords);
            ignore_xform_event          = false;
            SliceHeightGizmo.MinPosS    = basePos;
            SliceHeightGizmo.MaxPosS    = topPos;
            SliceHeightGizmo.CenterPosS = bounds.Point(0, -1, 0);
            SliceHeightGizmo.BoundsDim  = (float)Math.Max(bounds.Width, bounds.Depth) + 10.0f;

            set_slice_height_from_layer();

            slice_gizmo_valid = true;
        }