Example #1
0
        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);
        }