예제 #1
0
 public override OpStatus Apply()
 {
     if (space == CoordSpace.SceneCoords)
     {
         Frame3f localF = SceneTransforms.SceneToObject(Target, toFrame);
         Frame3f setF   = Target.GetLocalFrame(CoordSpace.ObjectCoords).FromFrame(localF);
         Target.RepositionPivot(setF);
     }
     else
     {
         Target.RepositionPivot(toFrame);
     }
     return(OpStatus.Success);
 }
예제 #2
0
        public RepositionPivotChangeOp(Frame3f toPivot, DMeshSO target, CoordSpace space = CoordSpace.ObjectCoords)
        {
            Util.gDevAssert(space != CoordSpace.WorldCoords);       // not supported for now

            Target     = target;
            toFrame    = toPivot;
            this.space = space;
            if (space == CoordSpace.ObjectCoords)
            {
                initialFrame = Target.GetLocalFrame(CoordSpace.ObjectCoords);
            }
            else
            {
                initialFrame = Target.GetLocalFrame(CoordSpace.SceneCoords);
            }
        }
예제 #3
0
        public virtual void BeginStroke(Ray3f rayS)
        {
            Vector3f camDirW = Scene.ActiveCamera.Forward();
            Vector3f camDirS = Scene.ToSceneP(camDirW);

            PlaneFrameS = new Frame3f(Target.GetLocalFrame(CoordSpace.SceneCoords).Origin, camDirS);

            CurrentStroke.Clear();
            CurrentStroke.Add(rayS);

            CurrentStart = PlaneFrameS.RayPlaneIntersection(rayS.Origin, rayS.Direction, 2);
            CurrentEnd   = CurrentStart;

            if (currentLine == null)
            {
                currentLine = new LineIndicator()
                {
                    SceneStartF = () => { return(CurrentStart); },
                    SceneEndF   = () => { return(CurrentEnd); },
                    VisibleF    = () => { return(CurrentStroke.Count > 1); },
                    ColorF      = () => { return(this.LineColor); },
                    LineWidth   = fDimension.Scene(LineWidth)
                };
                Indicators.AddIndicator(currentLine);
            }
        }
예제 #4
0
        public static void AppendMeshSO(DMeshSO appendTo, DMeshSO append)
        {
            FScene scene = appendTo.GetScene();

            if (scene.IsSelected(appendTo))
            {
                scene.Deselect(appendTo);
            }
            if (scene.IsSelected(append))
            {
                scene.Deselect(append);
            }

            Frame3f  f1     = appendTo.GetLocalFrame(CoordSpace.ObjectCoords);
            Vector3f scale1 = appendTo.GetLocalScale();
            Frame3f  f2     = append.GetLocalFrame(CoordSpace.ObjectCoords);
            Vector3f scale2 = append.GetLocalScale();

            DMesh3 mesh1 = appendTo.Mesh;

            DMesh3 mesh2 = append.Mesh;

            foreach (int vid in mesh2.VertexIndices())
            {
                // convert point in mesh2 to scene coords
                Vector3f v2 = (Vector3f)mesh2.GetVertex(vid);
                v2 *= scale2;
                Vector3f v2s = f2.FromFrameP(v2);

                // transfer that scene coord into local coords of mesh1
                Vector3f v2in1 = f1.ToFrameP(v2s);
                v2in1 /= scale1;
                mesh2.SetVertex(vid, v2in1);

                if (mesh1.HasVertexNormals && mesh2.HasVertexNormals)
                {
                    Vector3f n   = mesh2.GetVertexNormal(vid);
                    Vector3f ns  = f2.FromFrameV(n);
                    Vector3f ns2 = f1.ToFrameV(ns);
                    mesh2.SetVertexNormal(vid, ns2);
                }
            }

            MeshEditor editor = new MeshEditor(mesh1);

            editor.AppendMesh(mesh2);

            appendTo.NotifyMeshEdited();

            // [TODO] change record!

            scene.RemoveSceneObject(append, false);
        }