void Update()
        {
            // if press Button1 on menu hand toggle menu on off
            Handedness oppositeHand = rig.mainHand == Handedness.Left ? Handedness.Right : Handedness.Left;

            if (rig.GetInput(oppositeHand) != null && rig.GetInput(oppositeHand).GetButtonDown(InputOptions.Button.Button1))
            {
                ToggleVRGestureUI();
            }

            Vector3 handToCamVector = vrCam.position - vrMenuHand.position;

            vrHandUIPanel.position = vrMenuHand.position + (offsetZ * handToCamVector);
            if (-handToCamVector != Vector3.zero)
            {
                vrHandUIPanel.rotation = Quaternion.LookRotation(-handToCamVector, Vector3.up);
            }

            if (rig.uiState == VRGestureUIState.Detecting)
            {
                UpdateConfidenceThresholdUI();
            }

            UpdateCurrentNeuralNetworkText();
            UpdateNowRecordingStatus();
        }
예제 #2
0
        void Update()
        {
            // if press Button1 on menu hand toggle menu on off
            HandType oppositeHand = VRGestureManager.Instance.gestureHand == HandType.Left ? HandType.Right : HandType.Left;

            if (myAvatar.GetInput(oppositeHand) != null && myAvatar.GetInput(oppositeHand).GetButtonDown(InputOptions.Button.Button1))
            {
                ToggleVRGestureUI();
            }

            Vector3 handToCamVector = vrCam.position - vrMenuHand.position;

            vrHandUIPanel.position = vrMenuHand.position + (offsetZ * handToCamVector);
            if (-handToCamVector != Vector3.zero)
            {
                vrHandUIPanel.rotation = Quaternion.LookRotation(-handToCamVector, Vector3.up);
            }

            if (VRGestureManager.Instance.state == VRGestureManagerState.Detecting)
            {
                UpdateDetectMenu();
            }

            UpdateCurrentNeuralNetworkText();
            UpdateNowRecordingStatus();
        }
예제 #3
0
        void UpdateRecord()
        {
            // get input
            if (input == null)
            {
                input = rig.GetInput(hand);
            }

            // if not pressing gesture button stop recording
            if (!input.GetButton(rig.gestureButton))
            {
                state = VRGestureCaptureState.ReadyToCapture;
                if (input.GetButtonUp(rig.gestureButton))
                {
                    StopRecording();
                }
            }

            // if pressed button start recording
            if (input.GetButtonDown(rig.gestureButton) && state == VRGestureCaptureState.ReadyToCapture)
            {
                state = VRGestureCaptureState.Capturing;
                StartRecording();
            }

            // if capturing, capture points
            if (state == VRGestureCaptureState.Capturing)
            {
                CapturePoint();
            }
        }
예제 #4
0
 void GetHands()
 {
     //rig = VRGestureManager.Instance.rig;
     rig         = VRGestureRig.GetPlayerRig(gestureSettings.playerID);
     vrHand      = rig.GetHand(rig.mainHand);
     vrHandInput = rig.GetInput(rig.mainHand);
 }
예제 #5
0
        void Start()
        {
            if (stateInitial == VRGestureManagerState.ReadyToDetect)
            {
                BeginDetect("");
            }
            else if (FindObjectOfType <VRGestureUI>() == null)
            {
                Debug.LogError("Cannot find VRGestureUI in scene. Please add it or select Begin In Detect Mode in the VR Gesture Manager Settings");
            }


            state           = stateInitial;
            stateLast       = state;
            gestureToRecord = "";

            input = rig.GetInput(gestureHand);

            //create a new Trainer
            currentTrainer = new Trainer(Gestures, currentNeuralNet);

            currentCapturedLine = new List <Vector3>();
            if (displayGestureTrail)
            {
                myTrail = gameObject.AddComponent <GestureTrail>();
            }


            perpTransform        = new GameObject("Perpindicular Head").transform;
            perpTransform.parent = this.transform;
        }
예제 #6
0
        void GetHands()
        {
            HandType handedness = VRGestureManager.Instance.gestureHand; // needed to set it to something to prevent error

            rig         = VRGestureManager.Instance.rig;
            vrHand      = rig.GetHand(handedness);
            vrHandInput = rig.GetInput(handedness);
        }
예제 #7
0
 void Init()
 {
     if (FindObjectOfType <VRGestureRig>() != null)
     {
         rig        = FindObjectOfType <VRGestureRig>();
         playerHead = rig.head;
         playerHand = rig.GetHand(gestureHand);
         input      = rig.GetInput(gestureHand);
     }
 }
예제 #8
0
        void Start()
        {
            rig = FindObjectOfType <VRGestureRig>();
            if (rig == null)
            {
                Debug.Log("there is no VRGestureRig in the scene, please add one");
            }

            playerHead  = rig.head;
            playerHandR = rig.handRight;
            playerHandL = rig.handLeft;

            input = rig.GetInput(rig.mainHand);
        }
예제 #9
0
        public CaptureHand(VRGestureRig _rig, Transform _perp, Handedness _hand, GestureTrail _myTrail = null)
        {
            rig                 = _rig;
            hand                = _hand;
            playerHand          = rig.GetHand(hand);
            playerHead          = rig.head;
            perpTransform       = _perp;
            input               = rig.GetInput(hand);
            currentCapturedLine = new List <Vector3>();
            if (_myTrail != null)
            {
                myTrail = _myTrail;
                myTrail.AssignHand(this);
            }

            Start();
        }
예제 #10
0
 public void GetHand()
 {
     if (GameObject.Find("Controller Manager").GetComponent <NewEarthController>().isLeft == true)
     {
         gestureHand = HandType.Left;
         rig         = FindObjectOfType <VRGestureRig>();
         playerHead  = rig.head;
         playerHand  = rig.GetHand(gestureHand);
         input       = rig.GetInput(gestureHand);
         //Debug.Log("hand is left");
     }
     else
     {
         gestureHand = HandType.Right;
         rig         = FindObjectOfType <VRGestureRig>();
         playerHead  = rig.head;
         playerHand  = rig.GetHand(gestureHand);
         input       = rig.GetInput(gestureHand);
         //Debug.Log("hand is right");
     }
 }
        protected override void Start()
        {
            base.Start();

            SetInputModule();
            rig = VRGestureManager.Instance.rig;
            ControllerInputLeft  = rig.GetInput(HandType.Left);
            ControllerInputRight = rig.GetInput(HandType.Right);

            if (Initialized == false)
            {
                Instance = this;

                ControllerCamera = new GameObject("Controller UI Camera").AddComponent <Camera>();
                ControllerCamera.transform.parent = this.transform;
                ControllerCamera.clearFlags       = CameraClearFlags.Nothing; //CameraClearFlags.Depth;
                ControllerCamera.cullingMask      = 0;                        // 1 << LayerMask.NameToLayer("UI");
                ControllerCamera.nearClipPlane    = 0.0001f;

                Controllers = new Transform[] { rig.handLeft, rig.handRight };
                Cursors     = new RectTransform[2];

                for (int index = 0; index < Cursors.Length; index++)
                {
                    GameObject cursor = new GameObject("Cursor " + index);
                    Canvas     canvas = cursor.AddComponent <Canvas>();
                    //cursor.transform.parent = this.transform;
                    cursor.AddComponent <CanvasRenderer>();
                    cursor.AddComponent <CanvasScaler>();
                    cursor.AddComponent <UIIgnoreRaycast>();
                    cursor.AddComponent <GraphicRaycaster>();

                    // set cursor size
                    cursor.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, CursorSize);
                    cursor.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, CursorSize);

                    canvas.renderMode   = RenderMode.WorldSpace;
                    canvas.sortingOrder = 1000; //set to be on top of everything

                    Image image = cursor.AddComponent <Image>();
                    image.sprite   = CursorSprite;
                    image.material = CursorMaterial;


                    if (CursorSprite == null)
                    {
                        Debug.LogError("Set CursorSprite on " + this.gameObject.name + " to the sprite you want to use as your cursor.", this.gameObject);
                    }

                    Cursors[index] = cursor.GetComponent <RectTransform>();
                }

                CurrentPoint    = new GameObject[Cursors.Length];
                CurrentPressed  = new GameObject[Cursors.Length];
                CurrentDragging = new GameObject[Cursors.Length];
                PointEvents     = new PointerEventData[Cursors.Length];

                Canvas[] canvases = GameObject.FindObjectsOfType <Canvas>();
                foreach (Canvas canvas in canvases)
                {
                    canvas.worldCamera = ControllerCamera;
                }

                Initialized = true;
            }
        }