Пример #1
0
        private void _UpdateHandBox()
        {
            var handBox = m_hand.GetHandBox();

            if (handBox.Length < 2)
            {
                ARDebug.LogError("handbox's length is {0}", handBox.Length);
                return;
            }
            Vector3 glLeftTopCorner     = handBox[0];
            Vector3 glRightBottomCorner = handBox[1];
            Vector3 glLeftBottomCorner  = new Vector3(glLeftTopCorner.x, glRightBottomCorner.y);
            Vector3 glRightTopCorner    = new Vector3(glRightBottomCorner.x, glLeftTopCorner.y);

            m_boxLineRenderer.SetPosition(0, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftTopCorner));
            m_boxLineRenderer.SetPosition(1, _TransferGLCoord2UnityWoldCoordWithDepth(glRightTopCorner));
            m_boxLineRenderer.SetPosition(2, _TransferGLCoord2UnityWoldCoordWithDepth(glRightBottomCorner));
            m_boxLineRenderer.SetPosition(3, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftBottomCorner));
            m_boxLineRenderer.SetPosition(4, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftTopCorner));
            m_boxLineRenderer.gameObject.SetActive(true);
        }
Пример #2
0
        private void _UpdateHandBox()
        {
            var handBox = m_hand.GetHandBox();

            //The first one is the left top corner of the rectangle, and the second one is the right bottom corner
            if (handBox.Length < 2)
            {
                ARDebug.LogError("handbox's length is {0}", handBox.Length);
                return;
            }
            Vector3 glLeftTopCorner     = handBox[0];
            Vector3 glRightBottomCorner = handBox[1];
            Vector3 glLeftBottomCorner  = new Vector3(glLeftTopCorner.x, glRightBottomCorner.y);
            Vector3 glRightTopCorner    = new Vector3(glRightBottomCorner.x, glLeftTopCorner.y);

            float glCenterX = (glLeftTopCorner.x + glRightTopCorner.x) / 2;
            float glCenterY = (glLeftTopCorner.y + glLeftBottomCorner.y) / 2;

            Vector3 glCenter = new Vector3(glCenterX, glCenterY);

            m_boxLineRenderer.SetPosition(0, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftTopCorner));
            m_boxLineRenderer.SetPosition(1, _TransferGLCoord2UnityWoldCoordWithDepth(glRightTopCorner));
            m_boxLineRenderer.SetPosition(2, _TransferGLCoord2UnityWoldCoordWithDepth(glRightBottomCorner));
            m_boxLineRenderer.SetPosition(3, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftBottomCorner));
            m_boxLineRenderer.SetPosition(4, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftTopCorner));
            m_boxLineRenderer.material = (Material)Resources.Load("Line", typeof(Material));

            m_boxLineRenderer.startColor = new Color(1, 0, 0, 1);
            m_boxLineRenderer.endColor   = new Color(1, 0, 0, 1);
            m_boxLineRenderer.gameObject.SetActive(true);

            m_spider.transform.position      = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter));
            m_lightBlast.transform.position  = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter));
            m_bulbasaur.transform.position   = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter));
            m_spiderColor.transform.position = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter));
            m_hwCube.transform.position      = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter));

            switch (m_hand.GetGestureType())
            {
            case 0:
                _DonotShow3DObjects();
                break;

            case 1:
                _DonotShow3DObjects();
                m_spider.gameObject.SetActive(true);
                break;

            case 5:
                _DonotShow3DObjects();
                m_lightBlast.gameObject.SetActive(true);
                break;

            case 6:
                _DonotShow3DObjects();
                m_spiderColor.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
                break;

            case 7:
                _DonotShow3DObjects();
                m_hwCube.gameObject.SetActive(true);
                break;

            case 10:
                _DonotShow3DObjects();
                m_bulbasaur.gameObject.SetActive(true);
                break;
            }
        }