예제 #1
0
파일: DrawRect.cs 프로젝트: ahmad811/Markup
    void OnDrawing(Vector3 cumulativeDelta, Vector3 headPosition)
    {
        if (rect != null)
        {
            Vector3 move = cumulativeDelta - manipulationDelta;
            Vector3 handPosition;

            if (GazeGestureUtils.GetManipulationHandPosition(out handPosition))
            {
                Vector3 fromHeadToModel = myPos - headPosition;
                Vector3 fromHeadToHand  = handPosition - headPosition;

                float moveAmplifier = fromHeadToModel.magnitude / fromHeadToHand.magnitude;

                if (moveAmplifier > 1)
                {
                    move *= moveAmplifier;
                }
            }

            myPos += move;
            if (!startDraw)
            {
                startPoint = MathUtilsExt.ProjectPointOnPlane(normal, myPos, myPos);
                endPoint   = startPoint;
                ////???? AHMAD   FIXME
                startDraw = true;
            }
            CursorManager.Instance.ActiveCursor.transform.position = myPos;
            //endPoint = myPos;
            endPoint = MathUtilsExt.ProjectPointOnPlane(normal, startPoint, myPos);
            //startPoint.z= endPoint.z;
            endPoint.z  = startPoint.z;
            debug.text  = "Start: " + startPoint.ToString();
            debug.text += "\nEnd : " + endPoint.ToString();
            debug.text += "\nFWD : " + Camera.main.transform.forward;

            rect.SetPosition(0, startPoint);
            rect.SetPosition(1, new Vector3(endPoint.x, startPoint.y, startPoint.z));
            rect.SetPosition(2, endPoint);
            rect.SetPosition(3, new Vector3(startPoint.x, endPoint.y, startPoint.z));
        }
        else
        {
            StartDrawing(cumulativeDelta, headPosition);
        }
        manipulationDelta = cumulativeDelta;
    }
예제 #2
0
    void OnDrawing(Vector3 cumulativeDelta, Vector3 headPosition)
    {
        if (currentLine)
        {
            Vector3 move = cumulativeDelta - manipulationDelta;
            Vector3 handPosition;
            if (GazeGestureUtils.GetManipulationHandPosition(out handPosition))
            {
                Vector3 fromHeadToModel = myPos - headPosition;
                Vector3 fromHeadToHand  = handPosition - headPosition;

                float moveAmplifier = fromHeadToModel.magnitude / fromHeadToHand.magnitude;

                if (moveAmplifier > 1)
                {
                    move *= moveAmplifier;
                }
                myPos += move;
            }

            CursorManager.Instance.ActiveCursor.transform.position = myPos;

            Vector3 pos = myPos;
            if (pointsList.Count == 0 || !MathUtilsExt.V3Equal(pointsList[pointsList.Count - 1], pos))
            {
                pointsList.Add(pos);
                currentLine.positionCount = pointsList.Count;
                currentLine.SetPosition(pointsList.Count - 1, pointsList[pointsList.Count - 1]);
            }
        }
        else
        {
            StartDrawing(cumulativeDelta, headPosition);
        }
        manipulationDelta = cumulativeDelta;
    }