Esempio n. 1
0
        public static void Translate(IBoxModelElement element, Vector2f delta, float z = 0)
        {
            IElementFrame item = element as IElementFrame;
            Frame3f       f    = item.GetObjectFrame();

            f.Origin += new Vector3f(delta.x, delta.y, z);
            item.SetObjectFrame(f);
        }
Esempio n. 2
0
        protected override void layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

            IBoxModelElement boxElem = e as IBoxModelElement;
            IElementFrame    eFramed = e as IElementFrame;

            if (PinConstraints.ContainsKey(e))
            {
                Pin pin = PinConstraints[e];

                // evaluate pin constraints in 2D box space
                Vector2f SourcePos = pin.FromF();
                Vector2f PinToPos  = pin.ToF();

                // map center of object into box space
                //  note: ignores orientation!
                Frame3f  objF    = eFramed.GetObjectFrame();
                Vector2f center2 = Region.To2DCoords(objF.Origin);

                // construct new 2D position
                Vector2f vOffset = SourcePos - center2;
                Vector2f vNewPos = PinToPos - vOffset;

                // map 2D position back to 3D surface and orient object
                Frame3f frame = Region.From2DCoords(vNewPos, pin.fZ);
                eFramed.SetObjectFrame(frame);
            }
            else if (boxElem != null)
            {
                // position object at center of box region
                Frame3f frame = Region.From2DCoords(Vector2f.Zero, 0);
                eFramed.SetObjectFrame(frame);
            }
            else
            {
                // do nothing?
            }
        }