IsInteractionInited() public method

public IsInteractionInited ( ) : bool
return bool
コード例 #1
0
    void Update()
    {
        if (interactionManager != null && interactionManager.IsInteractionInited())
        {
            Vector3 screenPixelPos = Vector3.zero;

            if (selectedObject == null)
            {
                // no object is currently selected or dragged.
                // check if there is an underlying object to be selected
                if (lastHandEvent == InteractionManager.HandEventType.Grip && screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenNormalPos = isLeftHandDrag ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

                    screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
                    screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));
                    Ray ray = screenCamera ? screenCamera.ScreenPointToRay(screenPixelPos) : new Ray();

                    // check for underlying objects
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        if (hit.collider.gameObject == gameObject)
                        {
                            selectedObject = gameObject;

                            savedObjectMaterial = selectedObject.GetComponent <Renderer>().material;
                            selectedObject.GetComponent <Renderer>().material = selectedObjectMaterial;
                        }
                    }
                }
            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

                float angleArounfY = screenNormalPos.x * 360f;                  // horizontal rotation
                float angleArounfX = screenNormalPos.y * 360f;                  // vertical rotation

                Vector3    vObjectRotation = new Vector3(-angleArounfX, -angleArounfY, 180f);
                Quaternion qObjectRotation = screenCamera ? screenCamera.transform.rotation * Quaternion.Euler(vObjectRotation) : Quaternion.Euler(vObjectRotation);

                selectedObject.transform.rotation = Quaternion.Slerp(selectedObject.transform.rotation, qObjectRotation, smoothFactor * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = lastHandEvent == InteractionManager.HandEventType.Release;

                if (isReleased)
                {
                    // restore the object's material and stop dragging the object
                    selectedObject.GetComponent <Renderer>().material = savedObjectMaterial;
                    selectedObject = null;
                }
            }
        }
    }
コード例 #2
0
    void OnGUI()
    {
        if (infoGuiText != null && manager != null && manager.IsInteractionInited())
        {
            string sInfo = string.Empty;

            long userID = manager.GetUserID();
            if (userID != 0)
            {
                if (draggedObject != null)
                {
                    sInfo = "Dragging the " + draggedObject.name + " around.";
                }
                else
                {
                    sInfo = "Please grab and drag an object around.";
                }
            }
            else
            {
                KinectManager kinectManager = KinectManager.Instance;

                if (kinectManager && kinectManager.IsInitialized())
                {
                    sInfo = "Waiting for Users...";
                }
                else
                {
                    sInfo = "Kinect is not initialized. Check the log for details.";
                }
            }

            infoGuiText.GetComponent <GUIText>().text = sInfo;
        }
    }
コード例 #3
0
ファイル: GrabRotateScript.cs プロジェクト: sea0731/ATM
    void OnGUI()
    {
        if (infoGuiText != null && manager != null && manager.IsInteractionInited())
        {
            string sInfo = string.Empty;

            long userID = manager.GetUserID();
            if (userID != 0)
            {
                if (selectedObject != null)
                {
                    sInfo = selectedObject.name + " grabbed. You can turn it now in all directions.";
                }
                else
                {
                    sInfo = "Please grab the object to turn it.";
                }
            }
            else
            {
                KinectManager kinectManager = KinectManager.Instance;

                if (kinectManager && kinectManager.IsInitialized())
                {
                    sInfo = "Waiting for Users...";
                }
                else
                {
                    sInfo = "Kinect is not initialized. Check the log for details.";
                }
            }

            infoGuiText.text = sInfo;
        }
    }
コード例 #4
0
ファイル: ModelRotate.cs プロジェクト: ClarissaYL/MagicMirror
    void Update()
    {
        if (interactionManager != null && interactionManager.IsInteractionInited())
        {
            lastScreenPixelPos = screenPixelPos;

            // convert the normalized screen pos to pixel pos
            screenNormalPos = interactionManager.IsLeftHandPrimary() ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

            screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
            screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));

            //print(lastHandEvent);

            if (lastHandEvent != InteractionManager.HandEventType.Grip && nowHandEvent == InteractionManager.HandEventType.Grip)
            {
                rotation.x = (screenPixelPos.x - lastScreenPixelPos.x) * 0.0005f;
                rotation.y = (screenPixelPos.y - lastScreenPixelPos.y) * 0.000001f;

                print(rotation);
                if (rotation.x != 0)
                {
                    if (GameObject.FindGameObjectWithTag("model") != null)
                    {
                        GameObject.FindGameObjectWithTag("model").GetComponent <ModelViewer>().BeginDrag();
                        GameObject.FindGameObjectWithTag("model").GetComponent <ModelViewer>().Rotate(rotation);
                    }
                }
            }
        }
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        // update Kinect interaction
        if (kinectManager != null && kinectManager.IsInitialized() &&
            interactionManager != null && interactionManager.IsInteractionInited())
        {
            playerUserID = kinectManager.GetUserIdByIndex(playerIndex);

            if (playerUserID != 0)
            {
                rightFootPos = kinectManager.GetJointPosition(playerUserID, (int)KinectInterop.JointType.FootRight);
                leftFootPos  = kinectManager.GetJointPosition(playerUserID, (int)KinectInterop.JointType.FootLeft);

                //Debug.Log(rightFootPos);
                //Debug.Log(leftFootPos);

                if (calibracionConfirmada)
                {
                    //Primero miramos si está dentro del cuadro el pie derecho
                    bool pieDentro = EstaDentroDelCuadro(rightFootPos);

                    if (infoText != null)
                    {
                        infoText.text = "Pie derecho dentro del cuadro: " + pieDentro;
                    }

                    if (pieDentro)
                    {
                        //x=>ancho y=>alto  z=0 (no se usa)
                        Vector3 coordenadasPantalla = GetPosicionEnPantalla(rightFootPos);
                        //Asignamos la posición a la imagen del pie
                        playerFootRight.rectTransform.anchoredPosition3D = coordenadasPantalla;
                    }

                    //Despues miramos el izquierdo
                    pieDentro = EstaDentroDelCuadro(leftFootPos);

                    if (infoText != null)
                    {
                        infoText.text = infoText.text + "\nPie izquierdo dentro del cuadro: " + pieDentro;
                    }

                    if (pieDentro)
                    {
                        //x=>ancho y=>alto  z=0 (no se usa)
                        Vector3 coordenadasPantalla = GetPosicionEnPantalla(leftFootPos);
                        //Asignamos la posición a la imagen del pie
                        playerFootLeft.rectTransform.anchoredPosition3D = coordenadasPantalla;
                    }

                    //if (camera != null)
                    // CheckCollision(Vector3.zero);
                }
            }
        }
    }
コード例 #6
0
ファイル: GuiWindowScript.cs プロジェクト: calvarycat/BateGon
    // turn off or on mouse-cursor control
    private void SetMouseControl(bool controlMouseOn)
    {
        InteractionManager manager = InteractionManager.Instance;

        if (manager && manager.IsInteractionInited())
        {
            if (manager.controlMouseCursor != controlMouseOn)
            {
                manager.controlMouseCursor = controlMouseOn;
            }
        }
    }
コード例 #7
0
        void OnGUI()
        {
            // get the interaction manager instance
            //interactionManager = InteractionManager.Instance;
            if (interactionManager == null)
            {
                interactionManager = InteractionManager.GetInstance(playerIndex, isLeftHanded, !isLeftHanded);
            }

            Texture texture = null;

            if (interactionManager && interactionManager.IsInteractionInited())
            {
                if (isLeftHanded)
                {
                    lastHandEvent = interactionManager.GetLastLeftHandEvent();

                    if (lastHandEvent == InteractionManager.HandEventType.Grip)
                    {
                        texture = gripHandTexture;
                    }
                    else if (lastHandEvent == InteractionManager.HandEventType.Release)
                    {
                        texture = releaseHandTexture;
                    }
                }
                else
                {
                    lastHandEvent = interactionManager.GetLastRightHandEvent();

                    if (lastHandEvent == InteractionManager.HandEventType.Grip)
                    {
                        texture = gripHandTexture;
                    }
                    else if (lastHandEvent == InteractionManager.HandEventType.Release)
                    {
                        texture = releaseHandTexture;
                    }
                }
            }

            if (texture == null)
            {
                texture = normalHandTexture;
            }

            if ((cursorPos != Vector2.zero) && (texture != null))
            {
                Rect rectTexture = new Rect(cursorPos.x * Screen.width - texture.width / 2, (1 - cursorPos.y) * Screen.height - texture.height / 2, texture.width, texture.height);
                GUI.DrawTexture(rectTexture, texture);
            }
        }
コード例 #8
0
    void OnGUI()
    {
        InteractionManager intManager = InteractionManager.Instance;
        Texture            texture    = null;

        if (intManager && intManager.IsInteractionInited())
        {
            if (isLeftHanded)
            {
                lastHandEvent = intManager.GetLastLeftHandEvent();

                if (lastHandEvent == InteractionManager.HandEventType.Grip)
                {
                    texture = gripHandTexture;
                }
                else if (lastHandEvent == InteractionManager.HandEventType.Release)
                {
                    texture = releaseHandTexture;
                }
            }
            else
            {
                lastHandEvent = intManager.GetLastRightHandEvent();

                if (lastHandEvent == InteractionManager.HandEventType.Grip)
                {
                    texture = gripHandTexture;
                }
                else if (lastHandEvent == InteractionManager.HandEventType.Release)
                {
                    texture = releaseHandTexture;
                }
            }
        }

        if (texture == null)
        {
            texture = normalHandTexture;
        }

        if ((cursorPos != Vector2.zero) && (texture != null))
        {
            //handCursor.transform.position = cursorScreenPos; // Vector3.Lerp(handCursor.transform.position, cursorScreenPos, 3 * Time.deltaTime);
            Rect rectTexture = new Rect(cursorPos.x * Screen.width - texture.width / 2, (1f - cursorPos.y) * Screen.height - texture.height / 2,
                                        texture.width, texture.height);
            GUI.DrawTexture(rectTexture, texture);
        }
    }
コード例 #9
0
    private void OnGUI()
    {
        InteractionManager instance = InteractionManager.Instance;
        Texture            x        = null;

        if ((bool)instance && instance.IsInteractionInited())
        {
            if (isLeftHanded)
            {
                lastHandEvent = instance.GetLastLeftHandEvent();
                if (lastHandEvent == InteractionManager.HandEventType.Grip)
                {
                    x = gripHandTexture;
                }
                else if (lastHandEvent == InteractionManager.HandEventType.Release)
                {
                    x = releaseHandTexture;
                }
            }
            else
            {
                lastHandEvent = instance.GetLastRightHandEvent();
                if (lastHandEvent == InteractionManager.HandEventType.Grip)
                {
                    x = gripHandTexture;
                }
                else if (lastHandEvent == InteractionManager.HandEventType.Release)
                {
                    x = releaseHandTexture;
                }
            }
        }
        if (x == null)
        {
            x = normalHandTexture;
        }
        if (cursorPos != Vector2.zero && x != null)
        {
            Vector3 vector = new Vector3(cursorPos.x * (float)Screen.width, cursorPos.y * (float)Screen.height, 0f);
            handCursor.transform.position = vector;
            Vector3.Lerp(handCursor.transform.position, vector, 2f * Time.deltaTime);
        }
    }
コード例 #10
0
ファイル: HandCtr.cs プロジェクト: Hui49/facehacking
    void Update()
    {
        manager = InteractionManager.Instance;

        if (manager != null && manager.IsInteractionInited())
        {
            Vector3 screenNormalPos = Vector3.zero;
            Vector3 screenPixelPos  = Vector3.zero;

            //	if(selectedObject == null)
            //{
            // no object is currently selected or dragged.
            // if there is a hand grip, try to select the underlying object and start dragging it.


            if (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
            {
                //isLeftHandPress = true;
                //screenNormalPos = manager.GetLeftHandScreenPos();
                GetComponent <Button> ().onClick.Invoke();
            }
        }
    }
コード例 #11
0
 void Update()
 {
     if (manager != null && manager.IsInteractionInited())
     {
         // check for left hand grip
         if (manager.GetLeftHandEvent() == InteractionWrapper.InteractionHandEventType.Grip)
         {
             isLeftHandGripped  = true;
             isLeftHandReleased = false;
             //Debug.Log ("Left Hand Gripped");
             GameObject.Find("LeftHand").animation.Play("LeftHandGrip");
         }
         else if (manager.GetLeftHandEvent() == InteractionWrapper.InteractionHandEventType.Release)
         {
             isLeftHandGripped  = false;
             isLeftHandReleased = true;
             //Debug.Log ("Left Hand Released");
             GameObject.Find("LeftHand").animation.Play("LeftHandRelease");
         }
         //check for right hand grip
         if (manager.GetRightHandEvent() == InteractionWrapper.InteractionHandEventType.Grip)
         {
             isRightHandGripped  = true;
             isRightHandReleased = false;
             //Debug.Log ("Right Hand Gripped");
             GameObject.Find("RightHand").animation.Play("RightHandGrip");
         }
         else if (manager.GetRightHandEvent() == InteractionWrapper.InteractionHandEventType.Release)
         {
             isRightHandGripped  = false;
             isRightHandReleased = true;
             //Debug.Log ("Right Hand Released");
             GameObject.Find("RightHand").animation.Play("RightHandRelease");
         }
     }
 }
コード例 #12
0
    // Update is called once per frame
    void Update()
    {
        //如果交互管理器不为空,并且已经初始化
        if (interactionManager != null && interactionManager.IsInteractionInited())
        {
            // check if there is an underlying object to be selected    检查是否存在要选择的基础对象
            if (lastHandEvent == InteractionManager.HandEventType.Grip && screenNormalPos != Vector3.zero)
            {
                // convert the normalized screen pos to pixel pos   将标准化屏幕POS转换为像素POS
                screenNormalPos = interactionManager.IsLeftHandPrimary() ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

                screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
                screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));
                Ray ray = screenCamera ? screenCamera.ScreenPointToRay(screenPixelPos) : new Ray();

                game.transform.position = Camera.main.ScreenToWorldPoint(screenPixelPos);
                // check if there is an underlying objects  检查是否存在底层对象
                RaycastHit hit;

                Debug.Log("握拳");
                Debug.Log(screenPixelPos);
                //udpClient.SocketSend(screenPixelPos.x + "," + screenPixelPos.y);
                //udpClient.SocketSend(screenNormalPos.x + "," + screenNormalPos.y);
                //udpClient.SocketSend(screenNormalPos.x.ToString("f2") + "," + screenNormalPos.y.ToString("f2"));//f2保留两位小数
                //udpClient.SocketSend("anXia");
                if (Physics.Raycast(ray, out hit))
                {
                    Debug.Log("位置");
                    Debug.Log(hit.point);

                    /*foreach (GameObject obj in draggableObjects)
                     * {
                     *  if (hit.collider.gameObject == obj)
                     *  {
                     *      // an object was hit by the ray. select it and start drgging
                     *      draggedObject = obj;
                     *      draggedObjectOffset = hit.point - draggedObject.transform.position;
                     *      draggedObjectOffset.z = 0; // don't change z-pos
                     *
                     *      draggedNormalZ = (minZ + screenNormalPos.z * (maxZ - minZ)) -
                     *          draggedObject.transform.position.z; // start from the initial hand-z
                     *
                     *      // set selection material
                     *      draggedObjectMaterial = draggedObject.GetComponent<Renderer>().material;
                     *      draggedObject.GetComponent<Renderer>().material = selectedObjectMaterial;
                     *
                     *      // stop using gravity while dragging object
                     *      draggedObject.GetComponent<Rigidbody>().useGravity = false;
                     *      break;
                     *  }
                     * }*/
                }
            }
            else
            {
                // continue dragging the object 继续拖动对象
                screenNormalPos = interactionManager.IsLeftHandPrimary() ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

                // convert the normalized screen pos to 3D-world pos    将标准化的屏幕POS转换为3D世界POS
                screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
                screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));

                /*//screenPixelPos.z = screenNormalPos.z + draggedObjectDepth;
                 * screenPixelPos.z = (minZ + screenNormalPos.z * (maxZ - minZ)) - draggedNormalZ -
                 *  (screenCamera ? screenCamera.transform.position.z : 0f);*/


                //Debug.Log("手掌");
                //Debug.Log(screenPixelPos);
                //udpClient.SocketSend(screenPixelPos.x + "," + screenPixelPos.y);
                //udpClient.SocketSend(screenNormalPos.x + "," + screenNormalPos.y);
                //udpClient.SocketSend(screenNormalPos.x.ToString("f2") + "," + screenNormalPos.y.ToString("f2"));
                //udpClient.SocketSend("taiQi");
                //newObjectPos = screenCamera.ScreenToWorldPoint(screenPixelPos) - draggedObjectOffset;

                // check if the object (hand grip) was released

                /*bool isReleased = lastHandEvent == InteractionManager.HandEventType.Release;
                 *
                 * if (isReleased)
                 * {
                 *  // restore the object's material and stop dragging the object
                 *  draggedObject.GetComponent<Renderer>().material = draggedObjectMaterial;
                 *
                 *  if (useGravity)
                 *  {
                 *      // add gravity to the object
                 *      draggedObject.GetComponent<Rigidbody>().useGravity = true;
                 *  }
                 *
                 *  draggedObject = null;
                 * }*/
            }
        }
    }
コード例 #13
0
    void Update()
    {
        if (resetObjects && draggedObject == null)
        {
            // reset the objects as needed
            resetObjects = false;
            ResetObjects();
        }

        // get the interaction manager instance
        if (manager == null)
        {
            manager = InteractionManager.Instance;
        }

        if (manager != null && manager.IsInteractionInited())
        {
            Vector3 screenNormalPos = Vector3.zero;
            Vector3 screenPixelPos  = Vector3.zero;

            if (draggedObject == null)
            {
                // if there is a hand grip, select the underlying object and start dragging it.
                if (manager.IsLeftHandPrimary())
                {
                    // if the left hand is primary, check for left hand grip
                    if (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = true;
                        screenNormalPos = manager.GetLeftHandScreenPos();
                    }
                }
                else if (manager.IsRightHandPrimary())
                {
                    // if the right hand is primary, check for right hand grip
                    if (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = false;
                        screenNormalPos = manager.GetRightHandScreenPos();
                    }
                }

                // check if there is an underlying object to be selected
                if (screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                    screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                    Ray ray = Camera.main.ScreenPointToRay(screenPixelPos);

                    // check if there is an underlying objects
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        foreach (GameObject obj in draggableObjects)
                        {
                            if (hit.collider.gameObject == obj)
                            {
                                // an object was hit by the ray. select it and start drgging
                                draggedObject       = obj;
                                draggedObjectDepth  = draggedObject.transform.position.z - Camera.main.transform.position.z;
                                draggedObjectOffset = hit.point - draggedObject.transform.position;

                                // set selection material
                                draggedObjectMaterial = draggedObject.GetComponent <Renderer>().material;
                                draggedObject.GetComponent <Renderer>().material = selectedObjectMaterial;

                                // stop using gravity while dragging object
                                draggedObject.GetComponent <Rigidbody>().useGravity = false;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? manager.GetLeftHandScreenPos() : manager.GetRightHandScreenPos();

                // convert the normalized screen pos to 3D-world pos
                screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                screenPixelPos.z = screenNormalPos.z + draggedObjectDepth;

                Vector3 newObjectPos = Camera.main.ScreenToWorldPoint(screenPixelPos) - draggedObjectOffset;
                draggedObject.transform.position = Vector3.Lerp(draggedObject.transform.position, newObjectPos, dragSpeed * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = isLeftHandDrag ? (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Release) :
                                  (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Release);

                if (isReleased)
                {
                    // restore the object's material and stop dragging the object
                    draggedObject.GetComponent <Renderer>().material = draggedObjectMaterial;

                    if (useGravity)
                    {
                        // add gravity to the object
                        draggedObject.GetComponent <Rigidbody>().useGravity = true;
                    }

                    draggedObject = null;
                }
            }
        }
    }
コード例 #14
0
	void Update() 
	{
		manager = InteractionManager.Instance;

		if(manager != null && manager.IsInteractionInited())
		{
			Vector3 screenNormalPos = Vector3.zero;
			Vector3 screenPixelPos = Vector3.zero;

			if(selectedObject == null)
			{
				// no object is currently selected or dragged.
				// if there is a hand grip, try to select the underlying object and start dragging it.
				if(manager.IsLeftHandPrimary())
				{
					// if the left hand is primary, check for left hand grip
					if(manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Grip)
					{
						isLeftHandDrag = true;
						screenNormalPos = manager.GetLeftHandScreenPos();
					}
				}
				else if(manager.IsRightHandPrimary())
				{
					// if the right hand is primary, check for right hand grip
					if(manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
					{
						isLeftHandDrag = false;
						screenNormalPos = manager.GetRightHandScreenPos();
					}
				}
				
				// check if there is an underlying object to be selected
				if(screenNormalPos != Vector3.zero)
				{
					// convert the normalized screen pos to pixel pos
					screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
					screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
					Ray ray = Camera.main.ScreenPointToRay(screenPixelPos);
					
					// check for underlying objects
					RaycastHit hit;
					if(Physics.Raycast(ray, out hit))
					{
						if(hit.collider.gameObject == gameObject)
						{
							selectedObject = gameObject;
						
							savedObjectMaterial = selectedObject.GetComponent<Renderer>().material;
							selectedObject.GetComponent<Renderer>().material = selectedObjectMaterial;
						}
					}
				}
				
			}
			else
			{
				// continue dragging the object
				screenNormalPos = isLeftHandDrag ? manager.GetLeftHandScreenPos() : manager.GetRightHandScreenPos();

				float angleArounfY = screenNormalPos.x * 360f;  // horizontal rotation
				float angleArounfX = screenNormalPos.y * 360f;  // vertical rotation
				Vector3 newObjectRotation = new Vector3(-angleArounfX,-angleArounfY,180);

				selectedObject.transform.rotation = Quaternion.Slerp(selectedObject.transform.rotation, Quaternion.Euler(newObjectRotation), smoothFactor * Time.deltaTime);

				// check if the object (hand grip) was released
				bool isReleased = isLeftHandDrag ? (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Release) :
					(manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Release);

				if(isReleased)
				{
					// restore the object's material and stop dragging the object
					selectedObject.GetComponent<Renderer>().material = savedObjectMaterial;
					selectedObject = null;
				}
			}
		}
	}
コード例 #15
0
ファイル: GrabRotateScript.cs プロジェクト: sea0731/ATM
    void Update()
    {
        manager = InteractionManager.Instance;

        if (manager != null && manager.IsInteractionInited())
        {
            Vector3 screenNormalPos = Vector3.zero;
            Vector3 screenPixelPos  = Vector3.zero;

            if (selectedObject == null)
            {
                // no object is currently selected or dragged.
                // if there is a hand grip, try to select the underlying object and start dragging it.
                if (manager.IsLeftHandPrimary())
                {
                    // if the left hand is primary, check for left hand grip
                    if (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = true;
                        screenNormalPos = manager.GetLeftHandScreenPos();
                    }
                }
                else if (manager.IsRightHandPrimary())
                {
                    // if the right hand is primary, check for right hand grip
                    if (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = false;
                        screenNormalPos = manager.GetRightHandScreenPos();
                    }
                }

                // check if there is an underlying object to be selected
                if (screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                    screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                    Ray ray = Camera.main.ScreenPointToRay(screenPixelPos);

                    // check for underlying objects
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        if (hit.collider.gameObject == gameObject)
                        {
                            selectedObject = gameObject;

                            savedObjectMaterial = selectedObject.GetComponent <Renderer>().material;
                            selectedObject.GetComponent <Renderer>().material = selectedObjectMaterial;
                        }
                    }
                }
            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? manager.GetLeftHandScreenPos() : manager.GetRightHandScreenPos();

                float   angleArounfY      = screenNormalPos.x * 360f;           // horizontal rotation
                float   angleArounfX      = screenNormalPos.y * 360f;           // vertical rotation
                Vector3 newObjectRotation = new Vector3(-angleArounfX, -angleArounfY, 180);

                selectedObject.transform.rotation = Quaternion.Slerp(selectedObject.transform.rotation, Quaternion.Euler(newObjectRotation), smoothFactor * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = isLeftHandDrag ? (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Release) :
                                  (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Release);

                if (isReleased)
                {
                    // restore the object's material and stop dragging the object
                    selectedObject.GetComponent <Renderer>().material = savedObjectMaterial;
                    selectedObject = null;
                }
            }
        }
    }
コード例 #16
0
ファイル: UIClick.cs プロジェクト: ClarissaYL/MagicMirror
    void Update()
    {
        // by default set the main-camera to be screen-camera
        if (screenCamera == null)
        {
            screenCamera = Camera.main;
        }
        // get the interaction manager instance
        if (interactionManager == null)
        {
            interactionManager = InteractionManager.Instance;
        }
        // get all buttons in scene
        btns = GameObject.FindObjectsOfType <Button>();

        if (interactionManager != null && interactionManager.IsInteractionInited())
        {
            // convert the normalized screen pos to pixel pos
            screenNormalPos = interactionManager.IsLeftHandPrimary() ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

            screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
            screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));

            if (lastOnButton == null)
            {
                foreach (Button btn in btns)
                {
                    if (RectTransformUtility.RectangleContainsScreenPoint(btn.image.rectTransform, screenPixelPos, null))
                    {
                        lastOnButton    = btn;
                        btn.image.color = btn_focused;
                        break;
                    }
                }
            }
            else
            {
                if (!RectTransformUtility.RectangleContainsScreenPoint(lastOnButton.image.rectTransform, screenPixelPos, null))
                {
                    lastOnButton.image.color = btn_normal;
                    lastOnButton             = null;
                    return;
                }
                if (lastHandEvent != InteractionManager.HandEventType.Grip && nowHandEvent == InteractionManager.HandEventType.Grip)
                {
                    if (lastOnButton && lastGripTime < 0)
                    {
                        lastGripTime = Time.time;
                    }
                    if (lastOnButton == null)
                    {
                        lastGripTime  = -1;
                        lastHandEvent = InteractionManager.HandEventType.Grip;
                    }
                    if (lastGripTime > 0 && Time.time - lastGripTime > gripDelay)
                    {
                        lastOnButton.image.color = btn_pressed;
                        lastOnButton.onClick.Invoke();
                        lastHandEvent = InteractionManager.HandEventType.Grip;

                        lastGripTime = -1;
                    }
                }
                else if (lastHandEvent == InteractionManager.HandEventType.Grip && nowHandEvent != InteractionManager.HandEventType.Grip)
                {
                    lastOnButton.image.color = btn_focused;
                }
            }
        }
    }
コード例 #17
0
ファイル: GrabDropScript.cs プロジェクト: hazlett/Parkinsons
    void Update()
    {
        manager = InteractionManager.Instance;

        if(manager != null && manager.IsInteractionInited())
        {
            Vector3 screenNormalPos = Vector3.zero;
            Vector3 screenPixelPos = Vector3.zero;

            if(draggedObject == null)
            {
                // no object is currently selected or dragged.
                // if there is a hand grip, try to select the underlying object and start dragging it.
                if(manager.IsLeftHandPrimary())
                {
                    // if the left hand is primary, check for left hand grip
                    if(manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag = true;
                        screenNormalPos = manager.GetLeftHandScreenPos();
                    }
                }
                else if(manager.IsRightHandPrimary())
                {
                    // if the right hand is primary, check for right hand grip
                    if(manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag = false;
                        screenNormalPos = manager.GetRightHandScreenPos();
                    }
                }

                // check if there is an underlying object to be selected
                if(screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                    screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                    Ray ray = Camera.main.ScreenPointToRay(screenPixelPos);

                    // check for underlying objects
                    RaycastHit hit;
                    if(Physics.Raycast(ray, out hit))
                    {
                        foreach(GameObject obj in draggableObjects)
                        {
                            if(hit.collider.gameObject == obj)
                            {
                                // an object was hit by the ray. select it and start drgging
                                draggedObject = obj;
                                draggedObjectDepth = draggedObject.transform.position.z - Camera.main.transform.position.z;
                                draggedObjectOffset = hit.point - draggedObject.transform.position;

                                // set selection material
                                draggedObjectMaterial = draggedObject.renderer.material;
                                draggedObject.renderer.material = selectedObjectMaterial;
                                break;
                            }
                        }
                    }
                }

            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? manager.GetLeftHandScreenPos() : manager.GetRightHandScreenPos();

        //				// check if there is pull-gesture
        //				bool isPulled = isLeftHandDrag ? manager.IsLeftHandPull(true) : manager.IsRightHandPull(true);
        //				if(isPulled)
        //				{
        //					// set object depth to its original depth
        //					draggedObjectDepth = -Camera.main.transform.position.z;
        //				}

                // convert the normalized screen pos to 3D-world pos
                screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                screenPixelPos.z = screenNormalPos.z + draggedObjectDepth;

                Vector3 newObjectPos = Camera.main.ScreenToWorldPoint(screenPixelPos) - draggedObjectOffset;
                draggedObject.transform.position = Vector3.Lerp(draggedObject.transform.position, newObjectPos, dragSpeed * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = isLeftHandDrag ? (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Release) :
                    (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Release);

                if(isReleased)
                {
                    // restore the object's material and stop dragging the object
                    draggedObject.renderer.material = draggedObjectMaterial;
                    draggedObject = null;
                }
            }
        }
    }
コード例 #18
0
    void Update()
    {
        // get the interaction manager instance
        if (manager == null)
        {
            manager = InteractionManager.Instance;
        }

        if (manager != null && manager.IsInteractionInited())
        {
            Vector3 screenNormalPos = Vector3.zero;
            Vector3 screenPixelPos  = Vector3.zero;

            if (draggedObject == null)
            {
                // if there is a hand grip, select the underlying object and start dragging it.
                if (manager.IsLeftHandPrimary())
                {
                    // if the left hand is primary, check for left hand grip
                    if (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = true;
                        screenNormalPos = manager.GetLeftHandScreenPos();
                    }
                }
                else if (manager.IsRightHandPrimary())
                {
                    // if the right hand is primary, check for right hand grip
                    if (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = false;
                        screenNormalPos = manager.GetRightHandScreenPos();
                    }
                }

                // check if there is an underlying object to be selected
                if (screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                    screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);

                    Vector2    point       = Camera.main.ScreenToWorldPoint(screenPixelPos);
                    Collider2D collision2d = Physics2D.OverlapPoint(point);

                    if (collision2d)
                    {
                        RaycastHit2D hit = Physics2D.Raycast(point, -Vector2.up);
                        if (hit)
                        {
                            foreach (GameObject obj in draggableObjects)
                            {
                                if (hit.collider.gameObject == obj)
                                {
                                    // an object was hit by the ray. select it and start drgging
                                    draggedObject = obj;
                                    draggedObject.GetComponent <FruitController>().OnGrabbedKinect();
                                    Vector2 draggedObjectPos = new Vector2(draggedObject.transform.position.x, draggedObject.transform.position.y);
                                    draggedObjectOffset = hit.point - draggedObjectPos;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? manager.GetLeftHandScreenPos() : manager.GetRightHandScreenPos();

                // convert the normalized screen pos to 3D-world pos
                screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);

                if (screenPixelPos.y < Camera.main.pixelHeight / 4)
                {
                    screenPixelPos.y = Camera.main.pixelHeight / 4;
                }

                Vector2 newObjectPos = Camera.main.ScreenToWorldPoint(screenPixelPos) - draggedObjectOffset;
                draggedObject.transform.position = Vector3.Lerp(draggedObject.transform.position, newObjectPos, dragSpeed * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = isLeftHandDrag ? (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Release) :
                                  (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Release);

                if (isReleased)
                {
                    draggedObject.GetComponent <FruitController>().OnReleasedKinect();
                    draggedObject = null;
                }
            }
        }
    }
コード例 #19
0
ファイル: GrabDropScript.cs プロジェクト: hazlett/Parkinsons
    void Update()
    {
        manager = InteractionManager.Instance;

        if (manager != null && manager.IsInteractionInited())
        {
            Vector3 screenNormalPos = Vector3.zero;
            Vector3 screenPixelPos  = Vector3.zero;

            if (draggedObject == null)
            {
                // no object is currently selected or dragged.
                // if there is a hand grip, try to select the underlying object and start dragging it.
                if (manager.IsLeftHandPrimary())
                {
                    // if the left hand is primary, check for left hand grip
                    if (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = true;
                        screenNormalPos = manager.GetLeftHandScreenPos();
                    }
                }
                else if (manager.IsRightHandPrimary())
                {
                    // if the right hand is primary, check for right hand grip
                    if (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Grip)
                    {
                        isLeftHandDrag  = false;
                        screenNormalPos = manager.GetRightHandScreenPos();
                    }
                }

                // check if there is an underlying object to be selected
                if (screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                    screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                    Ray ray = Camera.main.ScreenPointToRay(screenPixelPos);

                    // check for underlying objects
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        foreach (GameObject obj in draggableObjects)
                        {
                            if (hit.collider.gameObject == obj)
                            {
                                // an object was hit by the ray. select it and start drgging
                                draggedObject       = obj;
                                draggedObjectDepth  = draggedObject.transform.position.z - Camera.main.transform.position.z;
                                draggedObjectOffset = hit.point - draggedObject.transform.position;

                                // set selection material
                                draggedObjectMaterial           = draggedObject.renderer.material;
                                draggedObject.renderer.material = selectedObjectMaterial;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? manager.GetLeftHandScreenPos() : manager.GetRightHandScreenPos();

//				// check if there is pull-gesture
//				bool isPulled = isLeftHandDrag ? manager.IsLeftHandPull(true) : manager.IsRightHandPull(true);
//				if(isPulled)
//				{
//					// set object depth to its original depth
//					draggedObjectDepth = -Camera.main.transform.position.z;
//				}

                // convert the normalized screen pos to 3D-world pos
                screenPixelPos.x = (int)(screenNormalPos.x * Camera.main.pixelWidth);
                screenPixelPos.y = (int)(screenNormalPos.y * Camera.main.pixelHeight);
                screenPixelPos.z = screenNormalPos.z + draggedObjectDepth;

                Vector3 newObjectPos = Camera.main.ScreenToWorldPoint(screenPixelPos) - draggedObjectOffset;
                draggedObject.transform.position = Vector3.Lerp(draggedObject.transform.position, newObjectPos, dragSpeed * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = isLeftHandDrag ? (manager.GetLastLeftHandEvent() == InteractionManager.HandEventType.Release) :
                                  (manager.GetLastRightHandEvent() == InteractionManager.HandEventType.Release);

                if (isReleased)
                {
                    // restore the object's material and stop dragging the object
                    draggedObject.renderer.material = draggedObjectMaterial;
                    draggedObject = null;
                }
            }
        }
    }
コード例 #20
0
    void Update()
    {
        if (interactionManager != null && interactionManager.IsInteractionInited())
        {
            if (resetObjects && draggedObject == null)
            {
                // reset the objects as needed
                resetObjects = false;
                ResetObjects();
            }

            if (draggedObject == null)
            {
                // check if there is an underlying object to be selected
                if (lastHandEvent == InteractionManager.HandEventType.Grip && screenNormalPos != Vector3.zero)
                {
                    // convert the normalized screen pos to pixel pos
                    screenNormalPos = isLeftHandDrag ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

                    screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
                    screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));
                    Ray ray = screenCamera ? screenCamera.ScreenPointToRay(screenPixelPos) : new Ray();

                    // check if there is an underlying objects
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        foreach (GameObject obj in draggableObjects)
                        {
                            if (hit.collider.gameObject == obj)
                            {
                                // an object was hit by the ray. select it and start drgging
                                draggedObject         = obj;
                                draggedObjectOffset   = hit.point - draggedObject.transform.position;
                                draggedObjectOffset.z = 0;                                 // don't change z-pos

                                draggedNormalZ = (minZ + screenNormalPos.z * (maxZ - minZ)) -
                                                 draggedObject.transform.position.z;                        // start from the initial hand-z

                                // set selection material
                                draggedObjectMaterial = draggedObject.GetComponent <Renderer>().material;
                                draggedObject.GetComponent <Renderer>().material = selectedObjectMaterial;

                                // stop using gravity while dragging object
                                draggedObject.GetComponent <Rigidbody>().useGravity = false;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                // continue dragging the object
                screenNormalPos = isLeftHandDrag ? interactionManager.GetLeftHandScreenPos() : interactionManager.GetRightHandScreenPos();

                // convert the normalized screen pos to 3D-world pos
                screenPixelPos.x = (int)(screenNormalPos.x * (screenCamera ? screenCamera.pixelWidth : Screen.width));
                screenPixelPos.y = (int)(screenNormalPos.y * (screenCamera ? screenCamera.pixelHeight : Screen.height));
                //screenPixelPos.z = screenNormalPos.z + draggedObjectDepth;
                screenPixelPos.z = (minZ + screenNormalPos.z * (maxZ - minZ)) - draggedNormalZ -
                                   (screenCamera ? screenCamera.transform.position.z : 0f);

                newObjectPos = screenCamera.ScreenToWorldPoint(screenPixelPos) - draggedObjectOffset;
                draggedObject.transform.position = Vector3.Lerp(draggedObject.transform.position, newObjectPos, dragSpeed * Time.deltaTime);

                // check if the object (hand grip) was released
                bool isReleased = lastHandEvent == InteractionManager.HandEventType.Release;

                if (isReleased)
                {
                    // restore the object's material and stop dragging the object
                    draggedObject.GetComponent <Renderer>().material = draggedObjectMaterial;

                    if (useGravity)
                    {
                        // add gravity to the object
                        draggedObject.GetComponent <Rigidbody>().useGravity = true;
                    }

                    draggedObject = null;
                }
            }
        }
    }
コード例 #21
0
    // Update is called once per frame
    void Update()
    {
        if (interactionManager != null && interactionManager.IsInteractionInited() && manager.IsUserDetected(0))
        {
            right_cube.position = ScreenToPixel(interactionManager.GetRightHandScreenPos()) / 100;

            left_cube.position = ScreenToPixel(interactionManager.GetLeftHandScreenPos()) / 100;

            RightHandEvent = interactionManager.GetRightHandEvent();
            LeftHandEvent  = interactionManager.GetLeftHandEvent();

            RightHand_pos = interactionManager.GetRightHandScreenPos();
            LeftHand_pos  = interactionManager.GetLeftHandScreenPos();

            if (RightHandEvent != InteractionManager.HandEventType.Grip && RightHandEvent != InteractionManager.HandEventType.None)
            {
                RightHandGrip_pos        = interactionManager.GetRightHandScreenPos();
                RightHandVerticalEvent   = HandGripVerticalType.None;
                RightHandHorizontalEvent = HandGripHorizontalType.None;
            }
            else
            {
                if (RightHand_pos.x < RightHandGrip_pos.x && Mathf.Abs(RightHand_pos.x - RightHandGrip_pos.x) > 0.1f)
                {
                    RightHandHorizontalEvent = HandGripHorizontalType.Left;
                }
                else if (RightHand_pos.x > RightHandGrip_pos.x && Mathf.Abs(RightHand_pos.x - RightHandGrip_pos.x) > 0.1f)
                {
                    RightHandHorizontalEvent = HandGripHorizontalType.Right;
                }
                else if (Mathf.Abs(RightHand_pos.x - RightHandGrip_pos.x) < 0.1f)
                {
                    RightHandHorizontalEvent = HandGripHorizontalType.None;
                }

                if (RightHand_pos.y > RightHandGrip_pos.y && Mathf.Abs(RightHand_pos.y - RightHandGrip_pos.y) > 0.1f)
                {
                    RightHandVerticalEvent = HandGripVerticalType.Up;
                }
                else if (RightHand_pos.y < RightHandGrip_pos.y && Mathf.Abs(RightHand_pos.y - RightHandGrip_pos.y) > 0.1f)
                {
                    RightHandVerticalEvent = HandGripVerticalType.Down;
                }
                else if (Mathf.Abs(RightHand_pos.y - RightHandGrip_pos.y) < 0.1f)
                {
                    RightHandVerticalEvent = HandGripVerticalType.None;
                }
            }


            if (LeftHandEvent != InteractionManager.HandEventType.Grip && LeftHandEvent != InteractionManager.HandEventType.None)
            {
                LeftHandGrip_pos        = interactionManager.GetLeftHandScreenPos();
                LeftHandHorizontalEvent = HandGripHorizontalType.None;
                LeftHandVerticalEvent   = HandGripVerticalType.None;
            }
            else
            {
                if (LeftHand_pos.x < LeftHandGrip_pos.x && Mathf.Abs(LeftHand_pos.x - LeftHandGrip_pos.x) > 0.1f)
                {
                    LeftHandHorizontalEvent = HandGripHorizontalType.Left;
                }
                else if (LeftHand_pos.x > LeftHandGrip_pos.x && Mathf.Abs(LeftHand_pos.x - LeftHandGrip_pos.x) > 0.1f)
                {
                    LeftHandHorizontalEvent = HandGripHorizontalType.Right;
                }
                else if (Mathf.Abs(LeftHand_pos.x - LeftHandGrip_pos.x) < 0.1f)
                {
                    LeftHandHorizontalEvent = HandGripHorizontalType.None;
                }

                if (LeftHand_pos.y > LeftHandGrip_pos.y && Mathf.Abs(LeftHand_pos.y - LeftHandGrip_pos.y) > 0.1f)
                {
                    LeftHandVerticalEvent = HandGripVerticalType.Up;
                }
                else if (LeftHand_pos.y < LeftHandGrip_pos.y && Mathf.Abs(LeftHand_pos.y - LeftHandGrip_pos.y) > 0.1f)
                {
                    LeftHandVerticalEvent = HandGripVerticalType.Down;
                }
                else if (Mathf.Abs(LeftHand_pos.y - LeftHandGrip_pos.y) < 0.1f)
                {
                    LeftHandVerticalEvent = HandGripVerticalType.None;
                }
            }

            if (LeftHandEvent == InteractionManager.HandEventType.Grip && RightHandEvent == InteractionManager.HandEventType.Grip && RightHandVerticalEvent == HandGripVerticalType.None && RightHandHorizontalEvent == HandGripHorizontalType.None && LeftHandHorizontalEvent == HandGripHorizontalType.None && LeftHandVerticalEvent == HandGripVerticalType.None)
            {
                t += Time.deltaTime;

                if (t > 2)
                {
                    handHover = true;
                }
            }
            else
            {
                handHover = false;
                t         = 0;
            }

            if (LeftHandEvent == InteractionManager.HandEventType.Release && RightHandEvent == InteractionManager.HandEventType.Release && game_ctr.UISTATE != GameCtr.UIState.Close)
            {
                s += Time.deltaTime;
                c += Time.deltaTime;

                if (s > 6)
                {
                    if (!standby)
                    {
                        standby = true;
                        s       = 0;
                    }
                    else
                    {
                        standby = false;
                        s       = 0;
                    }
                }

                if (c > 10)
                {
                    c     = 0;
                    s     = 0;
                    close = true;
                }
                else
                {
                    close = false;
                }
            }
            else
            {
                //standby = false;
                s     = 0;
                c     = 0;
                close = false;
            }


            //Debug.Log("Left:" + LeftHandEvent + "  "+ LeftHandHorizontalEvent + "   " + LeftHandVerticalEvent);
        }
    }