Ejemplo n.º 1
0
 public CurveHandleEditWidget(ITransformGizmo parent, PolyCurveSO curve, FScene scene)
 {
     //this.parent = parent;
     this.curve = curve;
     //this.scene = scene;
     VertexIndex = 0;
 }
Ejemplo n.º 2
0
        void set_curve(PolyCurveSO useSO, bool bAxisIsCurve)
        {
            if ((curvePreview == null && bAxisIsCurve) ||
                (preview == null && bAxisIsCurve == false))
            {
                CreateNewPreview(bAxisIsCurve);
            }

            if (curveSO != null)
            {
                curveSO.PopOverrideMaterial();
                curveSO.OnTransformModified -= CurveSO_OnTransformModified;
                curveSO.OnCurveModified     -= CurveSO_OnCurveModified;
            }

            curveSO = useSO;
            update_curve_vertices(curveSO);


            curveSO.PushOverrideMaterial(scene.SelectedMaterial);
            curveSO.OnTransformModified += CurveSO_OnTransformModified;
            curveSO.OnCurveModified     += CurveSO_OnCurveModified;

            update_preview();
        }
Ejemplo n.º 3
0
        /*
         * setup/teardown for Sculpt Curve tool, which is applied to area curves, trimline curve, etc
         */
        public static bool CanSculptCurve()
        {
            var M = OG.Model;

            if (M.Context.ToolManager.ActiveRightTool != null)
            {
                return(false);
            }

            // can always sculpt trimline
            if (SceneUtil.IsSelectionMatch(M.Scene, typeof(TrimLoopSO), 1))
            {
                return(true);
            }

            // if polycurve, check that it is attached to the right kind of modeling op
            if (SceneUtil.IsSelectionMatch(M.Scene, typeof(PolyCurveSO), 1) == false)
            {
                return(false);
            }
            PolyCurveSO      so = M.Scene.Selected[0] as PolyCurveSO;
            ModelingOperator op = M.leg.FindOpForSO(so);

            if (op is EnclosedRegionOffsetOp || op is EnclosedRegionSmoothOp)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public override List <ISnapPoint> GeneratePoints(SceneObject so)
        {
            List <ISnapPoint> v = new List <ISnapPoint>();

            if (so is PolyCurveSO)
            {
                PolyCurveSO curveSO = so as PolyCurveSO;
                DCurve3     curve   = curveSO.Curve;

                Frame3f f = Frame3f.Identity;

                Frame3f startFrame = new Frame3f((Vector3f)curve.Start, -(Vector3f)curve.Tangent(0), 1);
                v.Add(new SOFrameSnapPoint(curveSO)
                {
                    frame = f.FromFrame(startFrame)
                });
                Frame3f endFrame = new Frame3f((Vector3f)curve.End, (Vector3f)curve.Tangent(curve.VertexCount - 1), 1);
                v.Add(new SOFrameSnapPoint(curveSO)
                {
                    frame = f.FromFrame(endFrame)
                });
            }

            if (base.EnableGeometry)
            {
                base.build_geometry(so, v);
            }

            return(v);
        }
Ejemplo n.º 5
0
 void on_curve_modified(PolyCurveSO so)
 {
     foreach (var f in WidgetParameterUpdates)
     {
         f();
     }
 }
Ejemplo n.º 6
0
        protected override void BuildGizmo()
        {
            gizmo.SetName("EditPrimitiveGizmo");

            float fAlpha = 0.5f;

            stdMaterial      = MaterialUtil.CreateTransparentMaterial(Color.yellow, fAlpha);
            stdHoverMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow);

            // [TODO] this should iterate through targets... ??

            Debug.Assert(this.targets.Count == 1);

            PolyCurveSO target = this.targets[0] as PolyCurveSO;

            target.OnCurveModified += on_curve_modified;

            add_curve_widget(target, true,
                             () => { return((Vector3)target.Curve.Start); });
            add_curve_widget(target, false,
                             () => { return((Vector3)target.Curve.End); });


            gizmo.Hide();
        }
Ejemplo n.º 7
0
 private void CurveSO_OnCurveModified(PolyCurveSO so)
 {
     if (so == curveSO)
     {
         update_curve_vertices(curveSO);
         update_preview();
     }
 }
Ejemplo n.º 8
0
        public RevolveTool(FScene scene, List <SceneObject> targets)
        {
            this.scene = scene;

            behaviors = new InputBehaviorSet();

            // TODO is this where we should be doing this??
            behaviors.Add(
                new RevolveTool_MouseBehavior(scene.Context)
            {
                Priority = 5
            });
            behaviors.Add(
                new RevolveTool_SpatialDeviceBehavior(scene.Context)
            {
                Priority = 5
            });

            // generate snap target set
            Snaps = SnapSet.CreateStandard(scene);
            Snaps.EnableSnapSegments = false;
            Snaps.EnableSnapPoints   = false;

            // shut off transform gizmo
            //scene.ActiveController.TransformManager.SetOverrideGizmoType(TransformManager.NoGizmoType);

            scene.SelectionChangedEvent += Scene_SelectionChangedEvent;
            // initialize active set with input selection
            Scene_SelectionChangedEvent(null, null);


            if (targets != null)
            {
                if (targets.Count == 2 && targets[0] is PolyCurveSO && targets[1] is PolyCurveSO)
                {
                    PolyCurveSO curveSO = targets[0] as PolyCurveSO;
                    PolyCurveSO axisSO  = targets[1] as PolyCurveSO;
                    set_curve(curveSO, true);
                    set_axis(axisSO, true);
                }
                else
                {
                    SceneObject foundCurveSO = targets.Find((so) => { return(so is PolyCurveSO); });
                    if (foundCurveSO != null)
                    {
                        set_curve(foundCurveSO as PolyCurveSO, false);
                    }
                    SceneObject otherSO = targets.Find((so) => { return(!(so is PolyCurveSO)); });
                    if (otherSO != null)
                    {
                        set_axis(otherSO, false);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        void generate_points(PolyCurveSO curveSO, Frame3f targetSceneF)
        {
            CurveSnapGenerator snapGen = new CurveSnapGenerator();
            List <ISnapPoint>  points  = snapGen.GeneratePoints(curveSO);

            foreach (ISnapPoint pt in points)
            {
                Frame3f objF = targetSceneF.ToFrame(pt.FrameS);
                snapFramesL.Add(objF);
            }
        }
Ejemplo n.º 10
0
        private void update_axis_vertices(PolyCurveSO curveSO)
        {
            Vector3d[] verticesS   = axisCurveSO.Curve.Vertices.ToArray();
            Frame3f    curveFrameS = axisCurveSO.GetLocalFrame(CoordSpace.SceneCoords);

            for (int k = 0; k < verticesS.Length; ++k)
            {
                verticesS[k] = curveFrameS.FromFrameP((Vector3f)verticesS[k]);
            }
            axisCurve.SetVertices(verticesS);
        }
Ejemplo n.º 11
0
 private void SourceSO_OnCurveModified(PolyCurveSO so)
 {
     if (so == axisSource)
     {
         if (curvePreview != null)
         {
             update_axis_vertices(axisCurveSO);
         }
         update_preview();
     }
 }
Ejemplo n.º 12
0
        public void EndDraw()
        {
            if (preview.Curve.ArcLength > 2 * Width)
            {
                // store undo/redo record for new primitive
                PolyCurveSO CurveSO = preview.BuildSO(scene.DefaultCurveSOMaterial, 1.0f);
                scene.History.PushChange(
                    new AddSOChange()
                {
                    scene = scene, so = CurveSO, bKeepWorldPosition = false
                });
                scene.History.PushInteractionCheckpoint();
            }

            preview.Destroy();
            preview = null;

            SavedSettings.Save("DrawCurveTool_width", width);
        }
Ejemplo n.º 13
0
        void add_curve_widget(PolyCurveSO curve, bool bFirst, Func <Vector3> localPositionF)
        {
            GameObject go = AppendMeshGO("curve_endpoint",
                                         UnityUtil.GetPrimitiveMesh(PrimitiveType.Cube), stdMaterial, gizmo);

            go.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);

            Frame3f sourceFrame = new Frame3f(localPositionF());

            UnityUtil.SetGameObjectFrame(go, sourceFrame, CoordSpace.ObjectCoords);
            WidgetParameterUpdates.Add(() => {
                UnityUtil.SetGameObjectFrame(go, new Frame3f(localPositionF()), CoordSpace.ObjectCoords);
            });

            Widgets[go] = new CurveHandleEditWidget(this, curve, this.parentScene)
            {
                RootGameObject = go, StandardMaterial = stdMaterial, HoverMaterial = stdHoverMaterial,
                VertexIndex    = (bFirst) ? 0 : CurveHandleEditWidget.LastIndex
            };
        }
Ejemplo n.º 14
0
        void set_axis(SceneObject sourceSO, bool bAxisIsCurve)
        {
            if ((curvePreview == null && bAxisIsCurve) ||
                (preview == null && bAxisIsCurve == false))
            {
                CreateNewPreview(bAxisIsCurve);
            }

            if (axisSource != null && axisSource is SceneObject)
            {
                (axisSource as SceneObject).OnTransformModified -= SourceSO_OnTransformModified;
                if (axisCurveSO != null)
                {
                    axisCurveSO.OnCurveModified -= SourceSO_OnCurveModified;
                }
                axisSource  = null;
                axisCurveSO = null;
            }

            axisFrame   = sourceSO.GetLocalFrame(CoordSpace.SceneCoords);
            axisSource  = sourceSO;
            axisCurveSO = (bAxisIsCurve) ? (sourceSO as PolyCurveSO) : null;

            if (bAxisIsCurve)
            {
                update_axis_vertices(axisCurveSO);
                curvePreview.OutputFrame     = axisFrame;
                axisCurveSO.OnCurveModified += SourceSO_OnCurveModified;
            }
            else
            {
                preview.Axis = axisFrame;
            }

            sourceSO.OnTransformModified += SourceSO_OnTransformModified;


            update_preview();
        }
Ejemplo n.º 15
0
 void on_curve_modified(PolyCurveSO so)
 {
     curve_valid = false;
     PostOnOperatorModified();
 }