public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bLeftMouseDown)
     {
         pCapturing.UpdateCapture(InputEvent.Mouse(input.ToOrthoLayerInput()));
         return(Capture.Continue);
     }
     else if (input.bLeftMouseReleased)
     {
         pCapturing.EndCapture(InputEvent.Mouse(input.ToOrthoLayerInput()));
         pCapturing = null;
         return(Capture.End);
     }
     else
     {
         DebugUtil.Log(2, "VRMouseUIBehavior.UpdateCapture: somehow ended up bere without left mouse release!");
         if (pCapturing != null)
         {
             pCapturing.EndCapture(InputEvent.Mouse(input.ToOrthoLayerInput()));
             pCapturing = null;
         }
         return(Capture.End);
     }
 }
Beispiel #2
0
        public void Remove(SceneUIElement element, bool bDestroy)
        {
            LayoutItem item;
            bool       bFound = find_item(element, out item);

            if (bFound == false)
            {
                throw new Exception("BoxModelLayoutEngine.Remove: element is not in layout");
            }
            if (element is HUDStandardItem == false)
            {
                throw new Exception("BoxModelLayoutEngine.Add: element must be a HUDStandardItem");
            }

            remove_item(element);
            Solver.RemoveLayoutItem(element);

            // [RMS] cannot do this because we do not have control over panel
            if (bDestroy)
            {
                childSet.Remove(element);
                // [TODO] how to destroy??
            }
        }
 public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bTouchDown)
     {
         pCapturing.UpdateCapture(InputEvent.Touch(input));
         return(Capture.Continue);
     }
     else if (input.bTouchReleased)
     {
         pCapturing.EndCapture(InputEvent.Touch(input));
         pCapturing = null;
         return(Capture.End);
     }
     else
     {
         DebugUtil.Log(2, "TouchUIBehavior.UpdateCapture: somehow ended up here without left mouse release!");
         if (pCapturing != null)
         {
             pCapturing.EndCapture(InputEvent.Touch(input));
             pCapturing = null;
         }
         return(Capture.End);
     }
 }
Beispiel #4
0
 public void Show(SceneUIElement elem)
 {
     elem.RootGameObject.SetVisible(true);
 }
Beispiel #5
0
 public Mouse2DCockpitUIBehavior(FContext scene)
 {
     this.scene = scene;
     pCapturing = null;
     Priority   = 0;
 }
        protected override Vector3f layout_item(SceneUIElement e)
        {
            AxisAlignedBox2f box = Container.Bounds2D;

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

            Vector3f vNewPos3 = Vector3f.Zero;   // 2.5d center coordinate

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

                // [TODO] We have to xform the center of the object. But if we pin
                //   a corner, we want to enforce the corner position in 3D (eg on curved surf).
                //   Currently we pin the corner in 2D, but then conver that to a 2D-center
                //   and then use that position. So on curved surf, things overlap, etc

                // 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);
                Vector2f center2 = Vector2f.Zero;

                // construct new 2D position
                Vector2f vOffset = SourcePos - center2;
                Vector2f vNewPos = PinToPos - vOffset;
                vNewPos3 = new Vector3f(vNewPos.x, vNewPos.y, pin.fZ);

                // map 2D position back to 3D surface and orient object
                Frame3f frame = Region.From2DCoords(vNewPos, pin.fZ);
                eFramed.SetObjectFrame(frame);
            }
            else if (boxElem != null)
            {
                Vector2f vNewPos = Vector2f.Zero;
                vNewPos3 = new Vector3f(vNewPos.x, vNewPos.y, 0);

                // position object at center of box region
                Frame3f frame = Region.From2DCoords(vNewPos, 0);
                eFramed.SetObjectFrame(frame);
            }
            else
            {
                // do nothing?
            }

            if (PostTransforms.ContainsKey(e))
            {
                foreach (var xform in PostTransforms[e])
                {
                    xform(e);
                }
            }

            return(vNewPos3);
        }
 // must implement these
 protected abstract Vector3f layout_item(SceneUIElement e);
Beispiel #8
0
 public bool Contains(SceneUIElement element)
 {
     return(has_item(element));
 }
Beispiel #9
0
 bool has_item(SceneUIElement e)
 {
     return(items.FindIndex((x) => { return x.element == e; }) >= 0);
 }
        // Update is called once per frame
        public void Update()
        {
            GetCockpit().Update();
            GetMouseCursor().Update();

            if (Input.GetKeyDown("escape"))
            {
                Cursor.lockState = CursorLockMode.None;
                Application.Quit();
            }


            DoShortcutkeys();


            if (Input.GetKeyDown(KeyCode.LeftAlt))
            {
                bInCameraControl = true;
            }
            else if (Input.GetKeyUp(KeyCode.LeftAlt))
            {
                bInCameraControl = false;
            }
            else if (bInCameraControl)
            {
                DoCameraControl();
            }
            else
            {
                // if we have a capturing UIElement, let it update capture, and if it consumes, we are done
                if (pCapturing != null)
                {
                    bool bConsumed = TryDoCapturingUI();
                    if (bConsumed)
                    {
                        return;
                    }
                }

                // check for UI hit on mouse down, and if found and wants to capture, begin capture
                if (Input.GetMouseButtonDown(0))
                {
                    Ray      eyeRay = GetWorldRayAtWorkplaneCursor();
                    UIRayHit uiHit;
                    if (FindUIHit(eyeRay, out uiHit))
                    {
                        if (uiHit.hitUI.BeginCapture(eyeRay, uiHit))
                        {
                            pCapturing = uiHit.hitUI;
                        }
                    }
                }
                else if (Input.GetMouseButtonUp(0))
                {
                    Ray eyeRay = GetWorldRayAtWorkplaneCursor();

                    SORayHit rayHit;
                    if (scene.FindSORayIntersection(eyeRay, out rayHit))
                    {
                        if (scene.Selected.Count == 0)
                        {
                            scene.Select(rayHit.hitSO);
                        }
                        else if (scene.IsSelected(rayHit.hitSO) == false)
                        {
                            scene.ClearSelection();
                            scene.Select(rayHit.hitSO);
                        }
                        else
                        {
                            // interact with selected object
                        }
                    }
                    else
                    {
                        if (scene.Selected.Count > 0)
                        {
                            scene.ClearSelection();
                        }
                    }
                }
            }
        }          // end Update
 public virtual void AddListItem(SceneUIElement element)
 {
     AddListItem(element, Vector3f.Zero);
 }
Beispiel #12
0
 // must implement these
 protected abstract void layout_item(SceneUIElement e);
Beispiel #13
0
 public HUDElementLayout(SceneUIElement parent, IContainerBoundsProvider elementBoundsProvider, IChildren <SceneUIElement> children)
 {
     initialize(parent, elementBoundsProvider, children);
 }
Beispiel #14
0
 public HUDElementLayout(SceneUIElement parent, IBoxModelElement boxElement, IChildren <SceneUIElement> children)
 {
     initialize(parent, new BoxModelElementContainerProvider(boxElement), children);
 }
Beispiel #15
0
 public void Hide(SceneUIElement elem)
 {
     elem.RootGameObject.SetVisible(false);
 }
Beispiel #16
0
 public TouchUIBehavior(FContext scene)
 {
     this.scene = scene;
     pCapturing = null;
     Priority   = 0;
 }
Beispiel #17
0
        // handle situations where someone else has removed the UIElement
        private void Element_OnDisconnected(object sender, EventArgs e)
        {
            SceneUIElement elem = sender as SceneUIElement;

            remove_item(elem);
        }