fPolylineGameObject make_path <T>(LinearToolpath3 <T> path, fMaterial material, float width, Vector3d origin) where T : IToolpathVertex { Vector3d prev = Vector3d.Zero; tempPolyLine.Clear(); foreach (T vtx in path) { Vector3d v = origin + vtx.Position; v = MeshTransforms.ConvertZUpToYUp(v); v = MeshTransforms.FlipLeftRightCoordSystems(v); // [RMS] because of the sharp turns we make, unity polyline will get twisted up unless we put // in some duplicate vertices =\ if (tempPolyLine.Count > 0) { tempPolyLine.Add((Vector3f)Vector3d.Lerp(prev, v, 0.001)); tempPolyLine.Add((Vector3f)Vector3d.Lerp(prev, v, 0.998)); tempPolyLine.Add((Vector3f)Vector3d.Lerp(prev, v, 0.999)); } tempPolyLine.Add((Vector3f)v); prev = v; } fPolylineGameObject go = PolylinePool.Allocate(); go.SetMaterial(material, true); go.SetLineWidth(width); go.SetVertices(tempPolyLine.ToArray(), false, true); return(go); }
/// <summary> /// Set up materials and gizmos /// </summary> public static void InitializeF3Scene(FContext context) { // initialize materials and selection-materials context.Scene.DisableSelectionMaterial = false; context.Scene.SelectedMaterial = MaterialUtil.CreateStandardVertexColorMaterialF(Colorf.VideoYellow); context.Scene.PerTypeSelectionMaterial.Add( BodyModelSOTypes.Scan, MaterialUtil.ToUnityMaterial(OrthogenMaterials.ScanMaterial)); context.Scene.PerTypeSelectionMaterial.Add( BodyModelSOTypes.Leg, MaterialUtil.ToUnityMaterial(OrthogenMaterials.LegMaterial)); fMaterial selectedCurveMat = MaterialUtil.CreateFlatMaterialF(Colorf.Gold, 1); context.Scene.PerTypeSelectionMaterial.Add(BodyModelSOTypes.PlaneIntersectionCurve, selectedCurveMat); context.Scene.PerTypeSelectionMaterial.Add(BodyModelSOTypes.TrimLoop, selectedCurveMat); context.Scene.PerTypeSelectionMaterial.Add(BodyModelSOTypes.EnclosedPatch, selectedCurveMat); // if you had other gizmos, you would register them here //context.TransformManager.RegisterGizmoType("snap_drag", new SnapDragGizmoBuilder()); //controller.TransformManager.SetActiveGizmoType("snap_drag"); context.TransformManager.RegisterGizmoType(AxisTransformGizmo.DefaultName, new AxisTransformGizmoBuilder()); context.TransformManager.RegisterGizmoType(LenthenMovePivotGizmoType, new MoveLengthenPivotGizmoBuilder() { WidgetScale = 0.5f * Vector3f.One }); context.TransformManager.SetActiveGizmoType(TransformManager.NoGizmoType); BodyModelSOTypes.RegisterSocketGenTypes(context.Scene.TypeRegistry); }
public override void postprocess_target_objects() { bool is_closed = true; if (InputSOs.Count == 1) { is_closed = InputSOs[0].Mesh.CachedIsClosed; MaxDimension = InputSOs[0].Mesh.CachedBounds.MaxDim / base.sceneToObjUnitScale; } else { foreach (var so in InputSOs) { is_closed = is_closed && so.Mesh.CachedIsClosed; } MaxDimension = base.combineMesh.CachedBounds.MaxDim; } double cell_size = 0.5 * ToolDefaults.DefaultVoxelSceneSizeF(new AxisAlignedBox3d(MaxDimension, MaxDimension, MaxDimension)); set_grid_cell_size(cell_size); set_mesh_cell_size(cell_size); set_min_comp_size(2.0); set_wall_thickness(2.4); set_infill_thickness(2.0); set_infill_spacing(10.0); show_original = is_closed; fOuterPreviewMaterial = OuterPreviewMaterial.ToFMaterial(); }
static void DisableWireframe() { if (CCState.WireframeEnabled == false) { return; } CCMaterials.PrintMeshMaterial.EnableWireframe = false; CCMaterials.SelectedMaterial.EnableWireframe = false; CCMaterials.PreviewMeshMaterial.EnableWireframe = false; foreach (SceneObject so in CC.ActiveScene.SceneObjects) { if (so is DMeshSO) { fMaterial mat = (so as DMeshSO).CurrentMaterial; if (mat is fMeshMaterial) { (mat as fMeshMaterial).EnableWireframe = false; } } } CCState.WireframeEnabled = false; }
public override void postprocess_target_objects() { bool is_closed = true; if (InputSOs.Count == 1) { is_closed = InputSOs[0].Mesh.CachedIsClosed; MaxDimension = InputSOs[0].Mesh.CachedBounds.MaxDim / base.sceneToObjUnitScale; } else { foreach (var so in InputSOs) { is_closed = is_closed && so.Mesh.CachedIsClosed; } MaxDimension = base.combineMesh.CachedBounds.MaxDim; } ShellOp.ShellType = (is_closed) ? MeshShellOp.ShellTypes.DistanceField : MeshShellOp.ShellTypes.Extrusion; double cell_size = ToolDefaults.DefaultVoxelSceneSizeF(new AxisAlignedBox3d(MaxDimension, MaxDimension, MaxDimension));; set_grid_cell_size(cell_size); set_mesh_cell_size(cell_size); set_min_comp_size(2.0); show_original = is_closed; fOuterPreviewMaterial = OuterPreviewMaterial.ToFMaterial(); }
// creates a button in the desired geometry shape public void Create(SmoothCockpitTracker tracker, Cockpit cockpit) { this.tracker = tracker; this.cockpit = cockpit; fGameObject cockpitGO = cockpit.RootGameObject; Frame3f cockpitF = cockpitGO.GetWorldFrame(); matFixed = MaterialUtil.CreateStandardMaterialF(ColorUtil.ForestGreen); matTracking = MaterialUtil.CreateStandardMaterialF(ColorUtil.SelectionGold); matHover = MaterialUtil.CreateStandardMaterialF(ColorUtil.Lighten(ColorUtil.ForestGreen, 0.1f)); matLocked = MaterialUtil.CreateStandardMaterialF(ColorUtil.CgRed); matLockedHover = MaterialUtil.CreateStandardMaterialF(ColorUtil.Lighten(ColorUtil.CgRed, 0.1f)); indicator = UnityUtil.CreatePrimitiveGO("tracking_indicator", UnityEngine.PrimitiveType.Capsule, matFixed, true); MaterialUtil.DisableShadows(indicator); UnityUtil.SetLayerRecursive(indicator, FPlatform.HUDLayer); indicator.SetLocalScale(0.025f * Vector3f.One); indicator.RotateD(Vector3f.AxisZ, 90.0f); Vector3f vDir = (1.0f * cockpitF.Z - 1.0f * cockpitF.Y).Normalized; indicator.SetPosition(cockpitF.Origin + IndicatorDistance * vDir); AppendExistingGO(indicator); //indicator.transform.SetParent(cockpit.RootGameObject.transform, true); }
public MeshSOComponentsViz(DMeshSO so) { SO = so; SO.OnMeshModified += OnInputMeshModified; CavityMaterial = CCMaterials.NestedComponentMaterial; //CavityMaterial = MaterialUtil.CreateTransparentMaterialF(ComponentColor); }
public override PolyCurveSO Create(SOMaterial defaultMaterial) { EnclosedPatchSO so = (EnclosedPatchSO)base.Create(defaultMaterial); previewMaterial = MaterialUtil.CreateTransparentMaterialF(Colorf.ForestGreen, 0.1f); return(so); }
public ToolpathDeviationViz(ToolpathSO so) { SO = so; //SO.OnMeshModified += OnInputModified; HighDeviationMaterial = MaterialUtil.CreateTransparentMaterialF(Colorf.VideoRed); MedDeviationMaterial = MaterialUtil.CreateTransparentMaterialF(Colorf.Orange); LowDeviationMaterial = MaterialUtil.CreateTransparentMaterialF(Colorf.Yellow); }
public virtual void Setup() { // turn on xform gizmo Scene.Context.TransformManager.PushOverrideGizmoType(BendPlanePivotGizmo.DefaultTypeName); Vector3d ctrPt = TargetSO.Mesh.CachedBounds.Center; Frame3f nearestF = MeshQueries.NearestPointFrame(TargetSO.Mesh, TargetSO.Spatial, ctrPt, true); BendPlaneOriginS = SceneTransforms.ObjectToSceneP(TargetSO, nearestF.Origin); BendPlaneNormalS = Vector3d.AxisY; bendPlaneGizmoSO = new BendPlanePivotSO(); bendPlaneGizmoSO.Create(Scene.PivotSOMaterial, Scene.FrameSOMaterial); bendPlaneGizmoSO.OnTransformModified += OnBendPlaneTransformModified; Scene.AddSceneObject(bendPlaneGizmoSO); Frame3f cutFrameS = new Frame3f(BendPlaneOriginS); cutFrameS.AlignAxis(1, (Vector3f)BendPlaneNormalS); bendPlaneGizmoSO.SetLocalFrame(cutFrameS, CoordSpace.SceneCoords); allow_selection_changes = true; Scene.Select(bendPlaneGizmoSO, true); allow_selection_changes = false; StandardIndicatorFactory factory = new StandardIndicatorFactory(); SectionPlaneIndicator bendPlane = factory.MakeSectionPlaneIndicator( 100, "bendPlane", fDimension.Scene(100), () => { return(new Frame3f(BendPlaneOriginS, BendPlaneNormalS)); }, () => { return(new Colorf(Colorf.LightGreen, 0.5f)); }, () => { return(true); } ); Indicators.AddIndicator(bendPlane); // save initial vtx positions VertexPositions = new Vector3d[TargetSO.Mesh.MaxVertexID]; foreach (int vid in TargetSO.Mesh.VertexIndices()) { VertexPositions[vid] = TargetSO.Mesh.GetVertex(vid); } PreviewSO = TargetSO.Duplicate() as DMeshSO; Scene.AddSceneObject(PreviewSO); //PreviewSO.AssignSOMaterial(Scene.TransparentNewSOMaterial); fMaterial transMat = MaterialUtil.CreateTransparentMaterial(Colorf.BlueMetal.SetAlpha(0.1f)); TargetSO.PushOverrideMaterial(transMat); TargetSO.SetLayer(FPlatform.WidgetOverlayLayer); }
public override fMaterial MakeMaterial(AxisGizmoFlags widget) { switch (widget) { case AxisGizmoFlags.AxisTranslateY: if (MyYMaterial == null) { MyYMaterial = MaterialUtil.CreateStandardMaterial(Colorf.VideoGreen); } return(MyYMaterial); default: return(null); } }
//GameObject trailGO; //TrailRenderer trailRen; public PrintTempParticleSystem(GameObject parentGO) { heatParticlesGO = new GameObject("heatParticleSystem"); ps = heatParticlesGO.AddComponent <ParticleSystem>(); parentGO.AddChild(heatParticlesGO, false); Material heatMat = MaterialUtil.SafeLoadMaterial("HeatParticleMaterial"); heatParticlesGO.GetComponent <ParticleSystemRenderer>().material = heatMat; //MaterialUtil.SafeLoadMaterial("Particles/Alpha Blended Premultiply"); heatParticlesGO.SetLayer(FPlatform.WidgetOverlayLayer); heatParticlesGO.GetComponent <Renderer>().material.renderQueue = 4000; MaterialUtil.DisableShadows(heatParticlesGO); ps.Stop(); sparksGO = UnityUtil.FindGameObjectByName("SparksPS"); sparksGO.SetVisible(true); sparksPS = sparksGO.GetComponent <ParticleSystem>(); sparksPS.Stop(); parentGO.AddChild(sparksGO, false); fMaterial mat = MaterialUtil.CreateFlatMaterial(Colorf.VideoRed, 0.75f); trailGO = GameObjectFactory.CreatePolylineGO("trail", new List <Vector3f>(), mat, true, 0.5f, LineWidthType.World); trailGO.GetComponent <Renderer>().material.renderQueue = 3500; trailGO.SetCornerQuality(fCurveGameObject.CornerQuality.Minimal); trailGO.SetParent(parentGO); trailGO.SetLayer(FPlatform.WidgetOverlayLayer); MaterialUtil.DisableShadows(trailGO); //trailGO = new GameObject("heatTrail"); //trailRen = trailGO.AddComponent<TrailRenderer>(); //parentGO.AddChild(trailGO, false); //trailRen.material = MaterialUtil.CreateFlatMaterial(Colorf.VideoRed); //trailRen.material.renderQueue = 3500; //trailRen.minVertexDistance = 0.2f; //trailRen.numCornerVertices = 4; //trailRen.startWidth = 0.5f; //trailRen.endWidth = 0.1f; //trailRen.time = 2.0f; }
void compute_slice_polylines() { fMaterial mat1 = MaterialUtil.CreateFlatMaterialF(Colorf.Black); fMaterial mat2 = MaterialUtil.CreateFlatMaterialF(Colorf.BlueMetal); // [TODO] do we need to hold data_lock here? seems like no since main thread is blocked, // then it would never be the case that we are setting SliceSet = null // create geometry int slice_i = 0; SlicePolylines = new List <fPolylineGameObject>(); foreach (PlanarSlice slice in SliceSet.Slices) { //DebugUtil.Log(2, "Slice has {0} solids", slice.Solids.Count); Colorf slice_color = (slice_i % 2 == 0) ? Colorf.Black : Colorf.BlueMetal; fMaterial slice_mat = (slice_i % 2 == 0) ? mat1 : mat2; slice_i++; foreach (GeneralPolygon2d poly in slice.Solids) { List <Vector3f> polyLine = new List <Vector3f>(); for (int pi = 0; pi <= poly.Outer.VertexCount; ++pi) { int i = pi % poly.Outer.VertexCount; Vector2d v2 = poly.Outer[i]; Vector2d n2 = poly.Outer.GetTangent(i).Perp; Vector3d v3 = new Vector3d(v2.x, v2.y, slice.Z); v3 = MeshTransforms.ConvertZUpToYUp(v3); v3 = MeshTransforms.FlipLeftRightCoordSystems(v3); Vector3d n3 = MeshTransforms.ConvertZUpToYUp(new Vector3d(n2.x, n2.y, 0)); n3 = MeshTransforms.FlipLeftRightCoordSystems(n3); n3.Normalize(); v3 += 0.1f * n3; polyLine.Add((Vector3f)v3); } //DebugUtil.Log(2, "Polyline has {0} vertiecs", polyLine.Count); fPolylineGameObject go = GameObjectFactory.CreatePolylineGO( "slice_outer", polyLine, slice_color, 0.1f, LineWidthType.World); go.SetMaterial(slice_mat, true); CC.ActiveScene.RootGameObject.AddChild(go, false); SlicePolylines.Add(go); } } }
static void set_all_material_clip(int mode) { CCMaterials.PrintMeshMaterial.ClipPlaneMode = (SOMeshMaterial.ClipPlaneModes)mode; CCMaterials.SelectedMaterial.ClipPlaneMode = (fMeshMaterial.ClipPlaneModes)mode; CCMaterials.PreviewMeshMaterial.ClipPlaneMode = (SOMeshMaterial.ClipPlaneModes)mode; foreach (SceneObject so in CC.ActiveScene.SceneObjects) { if (so is DMeshSO) { fMaterial mat = (so as DMeshSO).CurrentMaterial; if (mat is fMeshMaterial) { (mat as fMeshMaterial).ClipPlaneMode = (fMeshMaterial.ClipPlaneModes)mode; } } } }
public DrawTubeTool(FScene scene) { this.scene = scene; behaviors = new InputBehaviorSet(); // TODO is this where we should be doing this?? behaviors.Add( new DrawTubeTool_MouseBehavior(scene.Context) { Priority = 5 }); behaviors.Add( new DrawTubeTool_SpatialDeviceBehavior(this, scene.Context) { Priority = 5 }); // restore radius if (SavedSettings.Restore("DrawTubeTool_radius") != null) { radius = (float)SavedSettings.Restore("DrawTubeTool_radius"); } indicators = new ToolIndicatorSet(this, scene); BrushCursorSphere brushSphere = new BrushCursorSphere() { PositionF = () => { return(lastPreviewPos.Origin); }, Radius = fDimension.Scene(() => { return(Radius); }) }; brushSphereMat = MaterialUtil.CreateTransparentMaterialF(Colorf.CornflowerBlue, 0.2f); brushSphere.material = brushSphereMat; indicators.AddIndicator(brushSphere); }
public void Initialize(Cockpit cockpit) { cockpit.Name = "modelCockpit"; // Configure how the cockpit moves //cockpit.PositionMode = Cockpit.MovementMode.TrackPosition; // [RMS] use orientation mode to make cockpit follow view orientation. // (however default widgets below are off-screen!) cockpit.PositionMode = Cockpit.MovementMode.TrackOrientation; BoxContainer screenContainer = new BoxContainer(new Cockpit2DContainerProvider(cockpit)); PinnedBoxes2DLayoutSolver screenLayout = new PinnedBoxes2DLayoutSolver(screenContainer); PinnedBoxesLayout layout = new PinnedBoxesLayout(cockpit, screenLayout) { StandardDepth = 2.0f }; cockpit.AddLayout(layout, "2D", true); Func <string, float, HUDLabel> MakeButtonF = (label, buttonW) => { HUDLabel button = new HUDLabel() { Shape = CotangentUI.MakeMenuButtonRect(buttonW, CotangentUI.MenuButtonHeight), TextHeight = CotangentUI.MenuButtonTextHeight, AlignmentHorz = HorizontalAlignment.Center, BackgroundColor = CotangentUI.ButtonBGColor, TextColor = CotangentUI.ButtonTextColor, Text = label, EnableBorder = true, BorderWidth = CotangentUI.StandardButtonBorderWidth, BorderColor = CotangentUI.ButtonTextColor }; button.Create(); button.Name = label; button.Enabled = true; return(button); }; Vector2f progressOffsetY = 4 * CotangentUI.PixelScale * Vector2f.AxisY; HUDRadialProgress slicerProgress = new HUDRadialProgress() { Radius = 18 * CotangentUI.PixelScale }; slicerProgress.Create(); slicerProgress.Name = "slicer_progress"; int MAX_PROGRESS = 1000; slicerProgress.MaxProgress = MAX_PROGRESS; CC.SlicingProgressEvent += (status) => { if (status.bFailed) { double t = 0.5 * (double)status.curProgress / (double)status.maxProgress; slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = Colorf.VideoRed; } else { double t = 0.5 * (double)status.curProgress / (double)status.maxProgress; slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = Colorf.BlueMetal; } }; CC.ToolpathProgressEvent += (status) => { if (status.bFailed) { double t = 0.5 + 0.5 * (double)status.curProgress / (double)status.maxProgress; slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = Colorf.VideoRed; } else { double t = 0.5 + 0.5 * (double)status.curProgress / (double)status.maxProgress; if (status.curProgress == 0 && status.maxProgress == 1) { t = 0; } slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = (status.curProgress == status.maxProgress) ? Colorf.LightGreen : Colorf.BlueMetal; } }; layout.Add(slicerProgress, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.BoxPointF(slicerProgress, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(screenContainer, BoxPosition.CenterBottom, progressOffsetY) }); HUDButton progressClick = new HUDButton() { Shape = new HUDShape(HUDShapeType.Disc, slicerProgress.Radius) }; fMaterial normalMaterial = MaterialUtil.CreateFlatMaterialF(Colorf.White, 0); fMaterial pauseMaterial = MaterialUtil.CreateTransparentImageMaterialF("icons/progress_pause"); fMaterial pausedMaterial = MaterialUtil.CreateTransparentImageMaterialF("icons/progress_play"); if (CCPreferences.ActiveSlicingUpdateMode == CCPreferences.SlicingUpdateModes.ImmediateSlicing) { progressClick.Create(normalMaterial, null, pauseMaterial); } else { progressClick.Create(pausedMaterial, null, null); } progressClick.Name = "progress_click"; layout.Add(progressClick, new LayoutOptions() { Flags = LayoutFlags.None, DepthShift = -0.1f, PinSourcePoint2D = LayoutUtil.BoxPointF(progressClick, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(screenContainer, BoxPosition.CenterBottom, progressOffsetY) }); progressClick.OnClicked += (o, e) => { if (CCPreferences.ActiveSlicingUpdateMode == CCPreferences.SlicingUpdateModes.ImmediateSlicing) { CCPreferences.ActiveSlicingUpdateMode = CCPreferences.SlicingUpdateModes.SliceOnDemand; progressClick.StandardMaterial = pausedMaterial; progressClick.HoverMaterial = null; } else { CCPreferences.ActiveSlicingUpdateMode = CCPreferences.SlicingUpdateModes.ImmediateSlicing; progressClick.StandardMaterial = normalMaterial; progressClick.HoverMaterial = pauseMaterial; } if (CC.Toolpather.ToolpathsValid == false) { // not sure why we have to invalidate slicing here, but if we don't toolpath // computation will not stop when we pause... CC.Slicer.InvalidateSlicing(); //CC.InvalidateToolPaths(); } }; CotangentUI.PrintViewHUDItems = new List <HUDStandardItem>() { slicerProgress, progressClick }; screenLayout.RecomputeLayout(); // Configure interaction behaviors // - below we add behaviors for mouse, gamepad, and spatial devices (oculus touch, etc) // - keep in mind that Tool objects will register their own behaviors when active // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new CotangentKeyHandler(cockpit.Context)); // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch) cockpit.InputBehaviors.Add(new Mouse2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 1 }); // selection / multi-selection behaviors // Note: this custom behavior implements some selection redirects that we use in various parts of Archform cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context) { Priority = 10 }); // left click-drag to tumble, and left click-release to de-select cockpit.InputBehaviors.Add(new MouseClickDragSuperBehavior() { Priority = 100, DragBehavior = new MouseViewRotateBehavior(cockpit.Context) { Priority = 100, RotateSpeed = 3.0f }, ClickBehavior = new MouseDeselectBehavior(cockpit.Context) { Priority = 999 } }); // also right-click-drag to tumble cockpit.InputBehaviors.Add(new MouseViewRotateBehavior(cockpit.Context) { Priority = 100, RotateSpeed = 3.0f, ActivateF = MouseBehaviors.RightButtonPressedF, ContinueF = MouseBehaviors.RightButtonDownF }); // middle-click-drag to pan cockpit.InputBehaviors.Add(new MouseViewPanBehavior(cockpit.Context) { Priority = 100, PanSpeed = 0.01f, Adaptive = true, ActivateF = MouseBehaviors.MiddleButtonPressedF, ContinueF = MouseBehaviors.MiddleButtonDownF }); cockpit.OverrideBehaviors.Add(new MouseWheelZoomBehavior(cockpit) { Priority = 100, ZoomScale = 0.2f, Adaptive = true }); // touch input cockpit.InputBehaviors.Add(new TouchUIBehavior(cockpit.Context) { Priority = 1 }); cockpit.InputBehaviors.Add(new Touch2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new TouchViewManipBehavior(cockpit.Context) { Priority = 999, TouchZoomSpeed = 0.1f, TouchPanSpeed = 0.03f }); }
public BoundaryCurveSet(fGameObject parentGO, fMaterial curveMaterial) { this.parentGO = parentGO; this.curveMaterial = curveMaterial; }
public virtual void initialize(fGameObject go, fMaterial material, bool bSharedMaterial) { initialize(go, material.color); }
void compute_toolpath_polylines() { Func <Vector3d, byte> LayerFilterF = (v) => { return(255); }; Vector3d origin = BedOrigin; Interval1d zrange = ZInterval; double width = Settings.Machine.NozzleDiamMM; float extrude_width = (float)width / 2; float travel_width = (float)width / 3; Polylines.Clear(); // should already be empty, no? Action <LinearToolpath3 <PrintVertex> > drawPath3F = (polyPath) => { Vector3d v0 = polyPath.Start.Position; // LAYER FILTER if (zrange.Contains(v0.z) == false) { return; } byte layer_alpha = LayerFilterF(v0); if (layer_alpha == 0) { return; } bool is_below = (layer_alpha < 255); fMaterial mat = CCMaterials.PathMaterial_Default; float w = 0.1f; if (polyPath.Type == ToolpathTypes.Deposition) { if ((polyPath.TypeModifiers & FillTypeFlags.SupportMaterial) != 0) { mat = CCMaterials.PathMaterial_Support; } else { mat = CCMaterials.PathMaterial_Extrude; } w = extrude_width; } else if (polyPath.Type == ToolpathTypes.Travel) { mat = CCMaterials.PathMaterial_Travel; w = travel_width; } else if (polyPath.Type == ToolpathTypes.PlaneChange) { mat = CCMaterials.PathMaterial_PlaneChange; w = travel_width; } else { // } // todo layer alpha... //paint.Color = SkiaUtil.Color(paint.Color, layer_alpha); if (is_below) { w *= 6; } fPolylineGameObject path = make_path(polyPath, mat, w, origin); Polylines.Add(path); }; process_linear_paths(Toolpaths, drawPath3F); foreach (fPolylineGameObject go in Polylines) { AppendNewGO(go, parentGO, false); go.SetLayer(FPlatform.WidgetOverlayLayer); } }
public IEnumerator UpdateGeometryOnMainThread() { if (Deviation == null) { yield break; } if (Deviation.DeviationPoints.Count == 0) { yield break; } if (is_disconnected) { yield break; } if (internalSO == null) { internalSO = new GOWrapperSO(); internalSO.Create(GameObjectFactory.CreateParentGO("toolpath_deviation_so")); CC.ActiveScene.AddSceneObject(internalSO); internalSO.SetLocalFrame(SO.GetLocalFrame(CoordSpace.SceneCoords), CoordSpace.SceneCoords); SOFrameLink link = new SOFrameLink(internalSO, SO); CC.ActiveScene.LinkManager.AddLink(link); } var settings = SO.GetSettings(); double nozzleDiam = settings.Machine.NozzleDiamMM; double tolerance = nozzleDiam * 0.5 + DeviationToleranceMM; float layerHeight = (float)settings.LayerHeightMM; float ptWidth = (float)nozzleDiam * 0.5f; // probably should just make a mesh for all these... int counter = 0; int N = Deviation.DeviationPoints.Count; for (int i = 0; i < N; ++i) { if (is_disconnected) { yield break; } DeviationPt pt = Deviation.DeviationPoints[i]; fMaterial useMaterial = HighDeviationMaterial; if (pt.dist < tolerance * 1.5) { useMaterial = LowDeviationMaterial; } //else if (pt.dist < tolerance * 1.2) // useMaterial = LowDeviationMaterial; fGameObject go = GameObjectFactory.CreateBoxGO("deviation", ptWidth, layerHeight, ptWidth, useMaterial, true, false); go.SetLocalPosition((Vector3f)pt.pos); internalSO.AppendNewGO(go, internalSO.RootGameObject, false); go.SetLayer(FPlatform.WidgetOverlayLayer); PointGOs.Add(go); if (counter++ == 10) { counter = 0; yield return(null); } } }