public virtual void Setup() { // do this here ?? behaviors = new InputBehaviorSet(); SpatialDeviceGrabBehavior behavior = new SpatialDeviceGrabBehavior(Scene.Context, (so) => { return(so == this.Target); }) { Priority = 1, RotationSpeed = 0.25f, TranslationSpeed = 0.25f }; behaviors.Add(behavior); indicators = new ToolIndicatorSet(this, Scene); float h = 300.0f; Frame3f f1 = Frame3f.Identity.Rotated(Quaternionf.AxisAngleD(Vector3f.AxisZ, 90.0f)).Translated(h * 0.5f * Vector3f.AxisY); var plane1 = new SectionPlaneIndicator() { Width = fDimension.Scene(h), // in mm SceneFrameF = () => { return(f1); } }; indicators.AddIndicator(plane1); Frame3f f2 = Frame3f.Identity.Rotated(Quaternionf.AxisAngleD(Vector3f.AxisX, 90.0f)).Translated(h * 0.5f * Vector3f.AxisY); var plane2 = new SectionPlaneIndicator() { Width = fDimension.Scene(h), // in mm SceneFrameF = () => { return(f2); } }; indicators.AddIndicator(plane2); }
public virtual void Setup() { Func <Vector3f> centerPosF = () => { return((Vector3f)(snappedPointsS[0] + snappedPointsS[1]) * 0.5f); }; centerPos = fPosition.Scene(centerPosF); fDimension textHeight = null; if (TextHeightDimensionType == DimensionType.VisualAngle) { textHeight = fDimension.VisualAngle(centerPos, TextHeightDimension); } else if (TextHeightDimensionType == DimensionType.SceneUnits) { textHeight = fDimension.Scene(() => { return(TextHeightDimension); }); } else { textHeight = fDimension.World(() => { return(TextHeightDimension); }); } Func <Vector3f> labelPosF = () => { Vector3f p = centerPos.ScenePoint; float h = textHeight.SceneValuef; p += 0.5f * h * scene.ToSceneN(Vector3f.AxisY); return(p); }; indicators = new ToolIndicatorSet(this, scene); LineIndicator diag = new LineIndicator() { VisibleF = () => { return(Initialized); }, SceneStartF = () => { return((Vector3f)snappedPointsS[0]); }, SceneEndF = () => { return((Vector3f)snappedPointsS[1]); }, ColorF = () => { return(Colorf.VideoRed); }, LineWidth = fDimension.VisualAngle(centerPos, 0.5f), }; indicators.AddIndicator(diag); dimension = new TextLabelIndicator() { VisibleF = () => { return(Initialized && ShowTextLabel); }, ScenePositionF = labelPosF, TextHeight = textHeight, DimensionTextF = () => { return(string.Format("{0:F4}", snappedPointsS[0].Distance(snappedPointsS[1]))); } }; indicators.AddIndicator(dimension); }
virtual public 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(); brushIndicator = new BrushCursorSphere() { PositionF = () => { return(Scene.ToWorldP(lastBrushPosS.Origin)); }, Radius = fDimension.World(() => { return(radius.WorldValue); }) }; Indicators.AddIndicator(brushIndicator); brushIndicator.material = MaterialUtil.CreateTransparentMaterialF(Colorf.DarkRed, 0.8f); if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateFlatShaded("MeshEditor_generated", Colorf.DimGrey); } previewSO = new DMeshSO(); previewSO.EnableSpatial = false; previewSO.Create(new DMesh3(Target.Mesh), PreviewMaterial); previewSO.Name = "MeshEditorTool_preview"; previewSO.SetLocalFrame(Target.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); previewSO.SetLocalScale(Target.GetLocalScale()); Scene.AddSceneObject(previewSO); PreviewSpatial = new EditMeshSpatial() { SourceMesh = Target.Mesh, SourceSpatial = Target.Spatial, EditMesh = PreviewMesh }; }
public OldPlaneCutTool(FScene scene, SceneObject target) { this.scene = scene; this.target = target as DMeshSO; double plane_dim = 1.5 * this.target.Mesh.CachedBounds.DiagonalLength; behaviors = new InputBehaviorSet(); // TODO is this where we should be doing this?? behaviors.Add( new PlaneCutTool_SpatialBehavior(this, scene.Context) { Priority = 5 }); // shut off transform gizmo scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType); indicators = new ToolIndicatorSet(this, scene); SectionPlaneIndicator section_plane = new SectionPlaneIndicator() { SceneFrameF = () => { return(cut_plane); }, Width = fDimension.Scene(() => { return((float)(plane_dim)); }) }; indicators.AddIndicator(section_plane); }
/// <summary> /// called on click-down /// </summary> override public void Begin(SceneObject so, Vector2d downPos, Ray3f downRayWorld) { SORayHit hit; if (TargetSO.FindRayIntersection(downRayWorld, out hit) == false) { return; } Vector3d scenePos = SceneTransforms.WorldToSceneP(this.Scene, hit.hitPos); if (have_source == false) { CurrentSourceHitPosS = new Frame3f(scenePos); sourceIndicator = new SphereIndicator() { SceneFrameF = () => { return(CurrentSourceHitPosS); }, Radius = fDimension.Scene(SourceIndicatorSizeScene * 0.5), ColorF = () => { return(Colorf.Orange); } }; indicators.AddIndicator(sourceIndicator); have_source = true; source_modified = true; } else if (have_extent == false) { CurrentExtentHitPosS = new Frame3f(scenePos); extentIndicator = new SphereIndicator() { SceneFrameF = () => { return(CurrentExtentHitPosS); }, Radius = fDimension.Scene(ExtentIndicatorSizeScene * 0.5), ColorF = () => { return(Colorf.CornflowerBlue); } }; indicators.AddIndicator(extentIndicator); have_extent = true; extent_modified = true; } }
protected override void OnAddedClickPoint(Vector3d vNew, bool bFirst) { Vector3f pos = (Vector3f)preview[preview.VertexCount - 1]; Vector3f color = (bFirst) ? Colorf.VideoRed : Colorf.ForestGreen; SphereIndicator dot = new SphereIndicator() { SceneFrameF = () => { return(new Frame3f(pos)); }, Radius = indicator_size, ColorF = () => { return(color); } }; indicators.AddIndicator(dot); }
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 RadialMeasureTool(FScene scene, SceneObject target) { this.scene = scene; behaviors = new InputBehaviorSet(); // TODO is this where we should be doing this?? behaviors.Add( new RadialMeasureTool_MouseBehavior(scene.Context) { Priority = 5 }); //behaviors.Add( // new RevolveTool_SpatialDeviceBehavior(scene.ActiveController) { Priority = 5 }); // shut off transform gizmo scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType); scene.SelectionChangedEvent += Scene_SelectionChangedEvent; this.meshTarget = target as MeshSO; var boundsW = meshTarget.GetBoundingBox(CoordSpace.WorldCoords); measureHitPos = boundsW.Center; update_measurement(); indicators = new ToolIndicatorSet(this, scene); TextLabelIndicator dimensionLabel = new TextLabelIndicator() { ScenePositionF = () => { return(displayPosS + 0.01f * Vector3f.AxisY); }, TextHeight = fDimension.Scene(0.05f), DimensionTextF = () => { return(" " + (curDimension * 100).ToString("F2") + "cm"); } }; indicators.AddIndicator(dimensionLabel); CircleIndicator circle = new CircleIndicator() { SceneFrameF = () => { return(new Frame3f(circleCenterS)); }, RadiusF = () => { return((float)(curDimension * 0.5)); }, ColorF = () => { return(new Colorf(Colorf.VideoRed, 0.5f)); }, LineWidth = fDimension.Scene(0.001f) }; indicators.AddIndicator(circle); LineIndicator diag = new LineIndicator() { SceneStartF = () => { return(maxStart); }, SceneEndF = () => { return(maxEnd); }, ColorF = () => { return(Colorf.VideoRed); }, LineWidth = fDimension.Scene(0.001f) }; indicators.AddIndicator(diag); SectionPlaneIndicator section_plane = new SectionPlaneIndicator() { SceneFrameF = () => { return(new Frame3f(displayPosS)); }, Width = fDimension.Scene(() => { return((float)(curDimension * 1.5)); }) }; indicators.AddIndicator(section_plane); }