コード例 #1
0
        protected override Matrix4F GetManipulatorMatrix()
        {
            ITransformable node = GetManipulatorNode(TransformationTypes.Scale);

            if (node == null)
            {
                return(null);
            }

            Path <DomNode> path         = new Path <DomNode>(node.Cast <DomNode>().GetPath());
            Matrix4F       localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            // local transform
            Matrix4F toworld = new Matrix4F(localToWorld);

            // Offset by pivot
            Matrix4F P = new Matrix4F();

            P.Translation = node.Pivot;
            toworld.Mul(P, toworld);

            // Normalize
            toworld.Normalize(toworld);

            return(toworld);
        }
コード例 #2
0
        protected override Matrix4F GetManipulatorMatrix()
        {
            ITransformable node = GetManipulatorNode(TransformationTypes.Translation);

            if (node == null)
            {
                return(null);
            }

            ISnapSettings  snapSettings = (ISnapSettings)DesignView;
            Path <DomNode> path         = new Path <DomNode>(node.Cast <DomNode>().GetPath());
            Matrix4F       localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            Matrix4F toworld = new Matrix4F();

            if (snapSettings.ManipulateLocalAxis)
            {
                toworld.Set(localToWorld);
                toworld.Normalize(toworld);
            }
            else
            {
                toworld.Translation = localToWorld.Translation;
            }

            Vec3F offset = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);

            // Offset by pivot
            Matrix4F P = new Matrix4F();

            P.Translation = offset;
            toworld.Mul(toworld, P);

            return(toworld);
        }
コード例 #3
0
        public override void OnBeginDrag(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None)
            {
                return;
            }
            var selectionCntx      = DesignView.Context.As <ISelectionContext>();
            var selection          = selectionCntx.Selection;
            var transactionContext = DesignView.Context.As <ITransactionContext>();

            m_activeOp = null;

            var op = new ManipulatorActiveOperation(
                "Rotate", DesignView.Context.As <ISelectionContext>(),
                (ITransformable node) => (node.TransformationType & TransformationTypes.Rotation) != 0,
                false);

            m_rotations = new Matrix4F[op.NodeList.Count];
            for (int k = 0; k < op.NodeList.Count; k++)
            {
                ITransformable node = op.NodeList[k];
                Matrix4F       m    = new Matrix4F(node.Transform);
                m.Translation = new Vec3F(0, 0, 0);
                m.Normalize(m);
                m_rotations[k] = m;
            }

            m_activeOp = op;
        }
コード例 #4
0
        public override void OnBeginDrag()
        {
            if (m_hitRegion == HitRegion.None)
            {
                return;
            }
            var selectionCntx      = DesignView.Context.As <ISelectionContext>();
            var selection          = selectionCntx.Selection;
            var transactionContext = DesignView.Context.As <ITransactionContext>();

            NodeList.Clear();

            IEnumerable <DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable <DomNode>());

            foreach (DomNode domNode in rootDomNodes)
            {
                ITransformable node = domNode.As <ITransformable>();

                if (node == null || (node.TransformationType & TransformationTypes.Rotation) == 0)
                {
                    continue;
                }

                IVisible vn = node.As <IVisible>();
                if (!vn.Visible)
                {
                    continue;
                }

                ILockable lockable = node.As <ILockable>();
                if (lockable.IsLocked)
                {
                    continue;
                }

                NodeList.Add(node);
                IManipulatorNotify notifier = node.As <IManipulatorNotify>();
                if (notifier != null)
                {
                    notifier.OnBeginDrag();
                }
            }

            m_rotations = new Matrix4F[NodeList.Count];

            for (int k = 0; k < NodeList.Count; k++)
            {
                ITransformable node = NodeList[k];
                Matrix4F       m    = new Matrix4F(node.Transform);
                m.Translation = new Vec3F(0, 0, 0);
                m.Normalize(m);
                m_rotations[k] = m;
            }

            if (NodeList.Count > 0)
            {
                transactionContext.Begin("Rotate".Localize());
            }
        }
コード例 #5
0
        protected override Matrix4F GetManipulatorMatrix()
        {
            ITransformable node = GetManipulatorNode(TransformationTypes.Translation);

            if (node == null)
            {
                return(null);
            }

            ISnapSettings  snapSettings = (ISnapSettings)DesignView;
            Path <DomNode> path         = new Path <DomNode>(node.Cast <DomNode>().GetPath());
            Matrix4F       localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            Matrix4F toworld = new Matrix4F();

            if (snapSettings.ManipulateLocalAxis)
            {
                toworld.Set(localToWorld);
                toworld.Normalize(toworld);
            }
            else
            {
                toworld.Translation = localToWorld.Translation;
            }

            //  DavidJ --   note -- this "pivot" behaviour was inherited from another manipulator
            //                  but appears to be broken! Check coordinate space of value returned from CalcSnapFromOffset
            // Vec3F offset = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);
            //
            // // Offset by pivot
            // Matrix4F P = new Matrix4F();
            // P.Translation = offset;
            // toworld.Mul(toworld,P);

            return(toworld);
        }
コード例 #6
0
ファイル: RotateManipulator.cs プロジェクト: coreafive/XLE
        protected override Matrix4F GetManipulatorMatrix()
        {
            ITransformable node = GetManipulatorNode(TransformationTypes.Rotation);
            if (node == null ) return null;
            
            Path<DomNode> path = new Path<DomNode>(node.Cast<DomNode>().GetPath());
            Matrix4F localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            // local transform
            Matrix4F toworld = new Matrix4F(localToWorld);

            // Offset by rotate pivot
            Matrix4F P = new Matrix4F();
            P.Translation = node.Pivot;
            toworld.Mul(P, toworld);

            // Normalize            
            toworld.Normalize(toworld);

            return toworld;
        }
コード例 #7
0
ファイル: RotateManipulator.cs プロジェクト: coreafive/XLE
        public override void OnBeginDrag()
        {
            if (m_hitRegion == HitRegion.None)
                return;
            var selectionCntx = DesignView.Context.As<ISelectionContext>();
            var selection = selectionCntx.Selection;
            var transactionContext = DesignView.Context.As<ITransactionContext>();

            m_activeOp = null;

            var op = new ManipulatorActiveOperation(
                "Rotate", DesignView.Context.As<ISelectionContext>(),
                (ITransformable node) => (node.TransformationType & TransformationTypes.Rotation) != 0,
                false);

            m_rotations = new Matrix4F[op.NodeList.Count];
            for (int k = 0; k < op.NodeList.Count; k++)
            {
                ITransformable node = op.NodeList[k];                
                Matrix4F m = new Matrix4F(node.Transform);
                m.Translation = new Vec3F(0, 0, 0);
                m.Normalize(m);
                m_rotations[k] = m;
            }

            m_activeOp = op;
        }
コード例 #8
0
        public override void OnBeginDrag()
        {
            if (m_hitRegion == HitRegion.None)
                return;
            var selectionCntx = DesignView.Context.As<ISelectionContext>();
            var selection = selectionCntx.Selection;
            var transactionContext = DesignView.Context.As<ITransactionContext>();

            NodeList.Clear();

            IEnumerable<DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable<DomNode>());
            foreach (DomNode domNode in rootDomNodes)
            {
                ITransformable node = domNode.As<ITransformable>();
                                
                if (node == null || (node.TransformationType & TransformationTypes.Rotation) == 0)
                    continue;

                IVisible vn = node.As<IVisible>();
                if (!vn.Visible) continue;

                ILockable lockable = node.As<ILockable>();
                if (lockable.IsLocked) continue;
                
                NodeList.Add(node);
                IManipulatorNotify notifier = node.As<IManipulatorNotify>();
                if (notifier != null) notifier.OnBeginDrag();
            }

            m_rotations = new Matrix4F[NodeList.Count];

            for (int k = 0; k < NodeList.Count; k++)
            {
                ITransformable node = NodeList[k];                
                Matrix4F m = new Matrix4F(node.Transform);
                m.Translation = new Vec3F(0, 0, 0);
                m.Normalize(m);
                m_rotations[k] = m;
            }

            if(NodeList.Count > 0)
                transactionContext.Begin("Rotate".Localize());
        }
コード例 #9
0
        protected override Matrix4F GetManipulatorMatrix()
        {
            ITransformable node = GetManipulatorNode(TransformationTypes.Translation);
            if (node == null) return null;

            ISnapSettings snapSettings = (ISnapSettings)DesignView;
            Path<DomNode> path = new Path<DomNode>(node.Cast<DomNode>().GetPath());
            Matrix4F localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            Matrix4F toworld = new Matrix4F();
            if (snapSettings.ManipulateLocalAxis)
            {
                toworld.Set(localToWorld);
                toworld.Normalize(toworld);
            }
            else
            {
                toworld.Translation = localToWorld.Translation;
            }

                //  DavidJ --   note -- this "pivot" behaviour was inherited from another manipulator
            //                  but appears to be broken! Check coordinate space of value returned from CalcSnapFromOffset
            // Vec3F offset = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);
            //
            // // Offset by pivot
            // Matrix4F P = new Matrix4F();
            // P.Translation = offset;
            // toworld.Mul(toworld,P);

            return toworld;
        }
コード例 #10
0
        protected override Matrix4F GetManipulatorMatrix()
        {
            ITransformable node = GetManipulatorNode(TransformationTypes.Translation);
            if (node == null ) return null;

            ISnapSettings snapSettings = (ISnapSettings)DesignView;            
            Path<DomNode> path = new Path<DomNode>(node.Cast<DomNode>().GetPath());
            Matrix4F localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);
            
            Matrix4F toworld = new Matrix4F();
            if (snapSettings.ManipulateLocalAxis)
            {
                toworld.Set(localToWorld);
                toworld.Normalize(toworld);                
            }
            else
            {
                toworld.Translation = localToWorld.Translation;                
            }

            Vec3F offset = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);
          
            // Offset by pivot
            Matrix4F P = new Matrix4F();
            P.Translation = offset;
            toworld.Mul(toworld,P);
                        
            return toworld;
        }