Exemple #1
0
    private void UpdatePinchSingle(PinchDetector pinchDetector, ClosestNode closestNode, ref PinchInfo pinchInfo)
    {
        // if pinch detected, update pinch info
        if (pinchDetector.DidStartPinch)
        {
            pinchInfo = GetPinchInfo(pinchDetector, closestNode);
        }

        if (pinchInfo.node != null)
        {
            // set node as pinched when pinch starts
            if (pinchDetector.DidStartPinch)
            {
                pinchInfo.node.Pinched = true;
            }

            // update node position to match pinch movement
            if (pinchDetector.IsPinching)
            {
                transformSingleAnchor(pinchDetector, pinchInfo);
            }

            // release node when pinch ends
            if (pinchDetector.DidEndPinch)
            {
                pinchInfo.node.Pinched = false;
            }
        }
    }
Exemple #2
0
    private void transformSingleAnchor(PinchDetector singlePinch)
    {
        // Added by Viola Jertschat -----------------------------------------------
        Vector3 newPosition = singlePinch.Position;

        Vector3 rotateBy        = lastPos - newPosition;
        float   rotationAmountY = Vector3.SignedAngle(rotateBy.normalized, rotateBy.normalized, Vector3.forward);
        float   rotationAmountX = Vector3.SignedAngle(rotateBy.normalized, rotateBy.normalized, Vector3.right);
        float   rotationAmountZ = Vector3.SignedAngle(rotateBy.normalized, rotateBy.normalized, Vector3.up);

        /*
         * var rotation = new Quaternion(rotateBy.y * rotateFactor,
         *      rotateBy.x * rotateFactor,
         *      rotateBy.z * rotateFactor,
         *      0f);
         *
         * _anchor.rotation = Quaternion.Euler(
         *  new Vector3(lastRotation.x + rotation.x,
         *       lastRotation.y + rotation.y,
         *       lastRotation.z + rotation.z));
         */
        _anchor.Rotate(rotateBy * rotateFactor, Space.World);

        lastPos = newPosition;
        // ------------------------------------------------------------------------
    }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        isPinching    = false;
        objectGrabbed = null;

        m_pinchDetector = leapHand.GetComponent <PinchDetector>();
    }
Exemple #4
0
 private PinchInfo GetPinchInfo(PinchDetector pinchDetector, ClosestNode closestNode)
 {
     return(new PinchInfo {
         node = closestNode.curr,
         nodeInitialPosition = (closestNode.curr == null) ? Vector3.zero : closestNode.curr.gameObject.transform.position,
         pinchDetectorInitialPosition = pinchDetector.Position,
     });
 }
    void Start()
    {
        robotController         = robot.GetComponent <RobotController>();
        touchDetector           = cube.GetComponent <TouchDetector>();
        tablePositionRandomizer = cube.GetComponent <TablePositionRandomizer>();

        pinchDetector     = cube.GetComponent <PinchDetector>();
        pincherController = endEffector.GetComponent <PincherController>();
    }
 public override void Create(InteractionManager interactionManager, PinchDetector leftPinchDetector, PinchDetector rightPinchDetector)
 {
     base.Create(interactionManager, leftPinchDetector, rightPinchDetector);
     _isSticky = GameManager.Instance.StickyCubes;
     if (_isSticky)
     {
         _outlineMesh.material = SettingsManager.Instance.StickyOutlineMaterial;
         IlluminateOutlineBloom();
         DimOutlineBloom(1);
     }
 }
Exemple #7
0
        protected override void Start()
        {
            base.Start();

            if (isPinchGrip)
            {
                DataHand dataHand = (_isLeft) ? userRig.LeftHand.DataHand : userRig.RightHand.DataHand;

                pinchGrabDetector = dataHand.PinchDetector;
            }
        }
Exemple #8
0
    public void onPinchRight()
    {
        GameObject hand = null;

        if (pinchDetectorRight == null && (hand = GameObject.FindGameObjectWithTag("RightHandInteraction")) != null)
        {
            pinchDetectorRight = hand.GetComponent <PinchDetector>();
        }
        pinchPositionRight = pinchDetectorRight.Position;
        Debug.Log("LeapGrab: Right Pinch with position = " + pinchPositionRight);
        rightPinch = true;
    }
Exemple #9
0
 public static void deplacementMode(ref GameObject currentSelection, PinchDetector scriptPDL, PinchDetector scriptPDR, ref Vector3 lastPosition, ref Vector3 lastPositionR, ref Vector3 lastPositionL)
 {
     if (scriptPDL.IsPinching)
     {
         currentSelection.transform.position += (scriptPDL.Position - lastPositionL);
     }
     else
     {
         currentSelection.transform.position += (scriptPDR.Position - lastPositionR);
     }
     lastPosition = (scriptPDL.Position + scriptPDR.Position) / 2;
 }
Exemple #10
0
        IEnumerable <bool> ProcessDetectors(MotionEvent e)
        {
            RotationDetector.OnTouchEvent(e);
            yield return(RotationDetector.IsInProgress);

            PinchDetector.OnTouchEvent(e);
            yield return(PinchDetector.IsInProgress);

            MoveDetector.OnTouchEvent(e);
            yield return(MoveDetector.IsInProgress);

            yield return(Detector.OnTouchEvent(e));
        }
        private void Start()
        {
            base.Start();

            if (isPinchGrip)
            {
                HandModelBase handModelBase = (_isLeft) ? switcher.LeftAbstractHandModel : switcher.RightAbstractHandModel;

                PinchDetector pinchDetector = pinchGrabDetector;
                pinchDetector.HandModel = handModelBase;
                pinchDetector.enabled   = true;
            }
        }
Exemple #12
0
        private void UpdateStroke(int pinchIdx)
        {
            Vector3       lastAddedStrokePoint = _lastAddedStrokePointPerIdx[pinchIdx];
            PinchDetector pinchDetector        = _pinchDetectors[pinchIdx];

            bool shouldAdd = lastAddedStrokePoint == Vector3.zero ||
                             Vector3.Distance(lastAddedStrokePoint, pinchDetector.transform.position) >= _minSegmentLength;

            if (shouldAdd)
            {
                _liveStrokeMeshGenerators[pinchIdx].AddStrokeMeshPoint(pinchDetector.transform.position, pinchDetector.transform.rotation * Quaternion.Euler(new Vector3(90F, 0F, 180F)));
                _lastAddedStrokePointPerIdx[pinchIdx] = pinchDetector.transform.position;
            }
        }
        // Update is called once per frame
        void Update()
        {
            // check for color zones
            DoColorZoneUpdate();

            if (currentZone)
            {
                signifierRenderer.enabled = true;
                if (!currentZone.CanDrop)
                {
                    // always allow sampling
                    // set preview color
                    signifierRenderer.material.SetColor(colorHash, currentZone.GetColorAtPoint(GetTipPosition()));
                    signifierRenderer.material.SetTextureScale(signifierTextureHash, sampleTextureScale);
                }
                else
                {
                    // allow sampling dependent upon whether or not there is
                    // ink in the dropper
                    if (hasColor)
                    {
                        signifierRenderer.material.SetColor(colorHash, currentColor);
                        signifierRenderer.material.SetTextureScale(signifierTextureHash, dropTextureScale);
                    }
                    else
                    {
                        signifierRenderer.material.SetColor(colorHash, currentZone.GetColorAtPoint(GetTipPosition()));
                        signifierRenderer.material.SetTextureScale(signifierTextureHash, sampleTextureScale);
                    }
                }
            }
            else
            {
                signifierRenderer.enabled = false;
            }

            if (EitherPinchValid())
            {
                PinchDetector closestPinch = ClosestPinch();

                float distanceTValue = 1 - Mathf.InverseLerp(pinchActivateDist, pinchDeActivateDist * 1.5f, closestPinch.Distance);
                topRenderer.SetBlendShapeWeight(0, distanceTValue * 100);
            }
            else
            {
                topRenderer.SetBlendShapeWeight(0, 0);
            }
        }
        private void Awake()
        {
            colorHash            = Shader.PropertyToID("_Color");
            signifierTextureHash = Shader.PropertyToID("_MainTex");

            interaction = GetComponent <InteractionBehaviour>();

            PinchDetector[] allPinchers = GetComponents <PinchDetector>();

            leftPinch = allPinchers.First(item => item.HandModel.Handedness == Chirality.Left);
            leftPinch.ActivateDistance   = pinchActivateDist;
            leftPinch.DeactivateDistance = pinchDeActivateDist;
            rightPinch = allPinchers.First(item => item.HandModel.Handedness == Chirality.Right);
            rightPinch.ActivateDistance   = pinchActivateDist;
            rightPinch.DeactivateDistance = pinchDeActivateDist;
        }
Exemple #15
0
        private void TransformSingleAnchor(PinchDetector singlePinch)
        {
            isPinched = true;

            SetInitialState();

            if (allowTranslation)
            {
                _anchor.position = singlePinch.Position;
            }

            if (allowRotation)
            {
                _anchor.rotation = singlePinch.Rotation;
            }

            _anchor.localScale = Vector3.one;
        }
Exemple #16
0
        private void DrawPinchDetectorAlignmentGizmo(PinchDetector pinchDetector, RuntimeGizmoDrawer drawer)
        {
            if (_alignmentGizmoEnabled)
            {
                drawer.PushMatrix();

                drawer.matrix = pinchDetector.transform.localToWorldMatrix;

                drawer.color = Color.red;
                drawer.DrawLine(Vector3.zero, Vector3.right * 0.01F);
                drawer.color = Color.green;
                drawer.DrawLine(Vector3.zero, Vector3.up * 0.01F);
                drawer.color = Color.blue;
                drawer.DrawLine(Vector3.zero, Vector3.forward * 0.01F);

                drawer.PopMatrix();
            }
        }
Exemple #17
0
        /// <summary> Returns the closest WearableUI to the PinchDetector, or null of they are all further than _pinchGrabDistance.</summary>
        private IWearable EvaluatePossiblePinch(PinchDetector pinchToTest)
        {
            IWearable closestWearable       = null;
            float     closestDistance       = 1000000F;
            float     pinchWearableDistance = 0F;

            for (int i = 0; i < _wearables.Count; i++)
            {
                if (_wearables[i].CanBeGrabbed())
                {
                    pinchWearableDistance = Vector3.Distance(_wearables[i].GetPosition(), pinchToTest.transform.position);
                    if (pinchWearableDistance < _pinchGrabDistance && pinchWearableDistance < closestDistance)
                    {
                        closestDistance = pinchWearableDistance;
                        closestWearable = _wearables[i];
                    }
                }
            }
            return(closestWearable);
        }
Exemple #18
0
        // wait, currentSelection, scriptPDL, scriptPDR (à remplacer par des "scripts" ou direct les objets),  lastPosition[,L,R], cam
        public static void sizingMode(ref GameObject currentSelection, PinchDetector scriptPDL, PinchDetector scriptPDR, ref Vector3 lastPosition, Camera cam, ref Vector3 lastPositionR, ref Vector3 lastPositionL)
        {
            Debug.Log("Ca passe 1");
            currentSelection.transform.position += ((scriptPDL.Position + scriptPDR.Position) / 2 - lastPosition);
            Debug.Log("Ca passe 2");
            float TanFOV  = (float)Math.Tan((double)cam.fieldOfView * 0.5 * Math.PI / 180);
            float distCam = Vector3.Distance(cam.transform.position, currentSelection.transform.position);

            Debug.Log("Ca passe 3");
            float tmp = ((Vector3.Distance(scriptPDL.Position, scriptPDR.Position) - Vector3.Distance(lastPositionL, lastPositionR))) * TanFOV * 2 * distCam;

            Debug.Log(tmp);
            Vector3 t = new Vector3(tmp, tmp, tmp);

            if ((currentSelection.transform.localScale + t).x > 0)
            {
                currentSelection.transform.localScale += t;
            }
            lastPosition = (scriptPDL.Position + scriptPDR.Position) / 2;
        }
Exemple #19
0
 public void AddPinchDetector(PinchDetector pinchDetector)
 {
     if (_pinchDetectors == null || _pinchDetectors.Length <= 0)
     {
         _pinchDetectors    = new PinchDetector[2];
         _drawStates        = new DrawState[2];
         renderers          = new MeshRenderer[2];
         _pinchDetectors[0] = pinchDetector;
         _drawStates[0]     = new DrawState(this);
         renderers[0]       = pinchDetector.pinchTool.GetComponent <MeshRenderer>();
         baseColor          = renderers[0].material.color;
     }
     else
     {
         _pinchDetectors[1] = pinchDetector;
         _drawStates[1]     = new DrawState(this);
         renderers[1]       = pinchDetector.pinchTool.GetComponent <MeshRenderer>();
     }
     myPhotonView = gameObject.GetComponent <PhotonView>();
     myPhotonView.RPC("MakeDrawStateRPCs", PhotonTargets.AllBuffered, _pinchDetectors.Length);
 }
        private void Awake()
        {
            SkeletalControllerHand[] controllerHands = FindObjectsOfType <SkeletalControllerHand>();

            foreach (SkeletalControllerHand controllerHand in controllerHands)
            {
                if (controllerHand.IsLeft == _isLeft)
                {
                    skeletalControllerHand = controllerHand;
                    break;
                }
            }

            steamVRRemapper = skeletalControllerHand.GetComponent <SteamVRRemapper>();
            _graspManipulatorPoints.Add(position);

            _contactBones = new ContactBone[] { };

            primaryHoverPoints.Add(skeletalControllerHand.IndexMetacarpal.GetChild(0).GetChild(0).GetChild(0));

            switcher          = FindObjectOfType <ProviderSwitcher>();
            pinchGrabDetector = GetComponent <PinchDetector>();
        }
Exemple #21
0
    private void UpdateClosestNode(PinchDetector pinchDetector, ClosestNode closestNode)
    {
        closestNode.prev = closestNode.curr;

        // get closest node to index tip
        var handModel = pinchDetector.HandModel;

        if (handModel.IsTracked)
        {
            var index            = handModel.GetLeapHand().Fingers[1];
            var indexTipPosition = index.TipPosition.ToVector3();

            var         closestNodeToIndexTip = gameObject.GetComponent <Graph>().GetClosestNodeOrNull(indexTipPosition);
            const float maxDistance           = 0.03f;
            closestNode.curr = Vector3.Distance(indexTipPosition, closestNodeToIndexTip.transform.position) <= maxDistance ? closestNodeToIndexTip : null;
        }
        else
        {
            closestNode.curr = null;
        }

        UpdateClosestNodeSelection(ref closestNode);
    }
        void SetUpDetectors()
        {
            _Left      = UnityHelper.CreateGameObjectAsChild("Pinch Detector", transform).gameObject.AddComponent <PinchDetector>();
            _Right     = UnityHelper.CreateGameObjectAsChild("Pinch Detector", transform).gameObject.AddComponent <PinchDetector>();
            _Proximity = VR.Mode.LeftHand.PinchPoint.gameObject.AddComponent <ProximityDetector>();
            _Proximity.TargetObjects = new GameObject[] { VR.Mode.RightHand.PinchPoint.gameObject };
            _Proximity.OnDistance    = 0.1f;
            _Proximity.OffDistance   = 0.11f;
            _Detector      = gameObject.AddComponent <DetectorLogicGate>();
            _StartDetector = gameObject.AddComponent <DetectorLogicGate>();

            _Left._handModel  = VR.Mode.LeftHand;
            _Right._handModel = VR.Mode.RightHand;

            _StartDetector.AddDetector(_Left);
            _StartDetector.AddDetector(_Right);
            _StartDetector.AddDetector(_Proximity);

            _Detector.AddDetector(_Left);
            _Detector.AddDetector(_Right);

            _StartDetector.OnActivate.AddListener(OnStartPinch);
            _Detector.OnDeactivate.AddListener(OnStopPinch);
        }
Exemple #23
0
 private void Awake()
 {
     Instance = this;
 }
 // Use this for initialization
 void Start()
 {
     _proximityDetector = GetComponent <ProximityDetector>();
     _pinchDetector     = GetComponent <PinchDetector>();
 }
        virtual public void Create(Leap.Unity.Interaction.InteractionManager interactionManager, PinchDetector leftPinchDetector, PinchDetector rightPinchDetector)
        {
            _velocityFrames                 = new Vector3[ObjectManager.Instance.CreationForceWindowSize];
            _creating                       = true;
            LeapRTSComponent.AllowScale     = !OverrideLeapRTSScaling;
            LeapRTSComponent.enabled        = true;
            LeapRTSComponent.PinchDetectorA = leftPinchDetector;
            LeapRTSComponent.PinchDetectorB = rightPinchDetector;

            LeapInteractionBehaviour.enabled = false;
            LeapInteractionBehaviour.Manager = interactionManager;

            // Turn off Collider and Rigidbody components to disable physics
            EnableCollidersAndRigidbodies(false);

            // Turn off materialized meshes
            EnableMaterializedMeshes(false);

            // Turn on outline meshes
            EnableOutlineMeshes(true);
            IlluminateOutlineBloom();

            // Enable looping and play the creation sound effect
            EffectAudioSource.loop = true;
            EffectAudioSource.clip = AudioManager.Instance.GetAudioClip(GameAudioClipType.INTERACTABLE_OBJECT_CREATING);
            EffectAudioSource.Play();
        }
Exemple #26
0
        public static void creationMain(ref int nb_pinch, ref bool creating, PinchDetector scriptPDL, PinchDetector scriptPDR, ref GameObject currentSelection, Camera cam,
                                        ref Vector3 lastPosition, ref Vector3 lastPositionR, ref Vector3 lastPositionL, float referenceWait, ref float wait)
        {
            if (creating)
            {
                if (nb_pinch == 1)
                {
                    //Debug.Log(" DEPLACEMENT MODE");
                    wait = 0;
                    LeapCommon.deplacementMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, ref lastPositionR, ref lastPositionL);
                }
                else if (nb_pinch == 2)
                {
                    //Debug.Log(" SIZING MODE");
                    // wait, currentSelection, scriptPDL, scriptPDR (à remplacer par des "scripts" ou direct les objets),  lastPosition[,L,R], cam,
                    wait = 0;
                    Debug.Log(currentSelection != null);
                    LeapCommon.sizingMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, cam, ref lastPositionR, ref lastPositionL);
                }
                else
                {
                    // Debug.Log(" FINISHED MODE");
                    wait += Time.deltaTime;
                    if (wait >= referenceWait)
                    {
                        creating = false;
                    }
                }
            }
            else if (!creating)
            {
                if (nb_pinch == 2)
                {
                    /*
                     * //Debug.Log(" CREATION MODE");
                     * creating = true;
                     * currentSelection = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                     * currentSelection.transform.position = (scriptPDL.Position + scriptPDR.Position) / 2;
                     * float tmp = (Vector3.Distance(scriptPDL.Position, scriptPDR.Position));
                     * currentSelection.transform.localScale = new Vector3(tmp, tmp, tmp);
                     */

                    /*
                     * The following code is supposed to do the exat same thing but with
                     * the prefab sphereMesh instead of standard sphere
                     */

                    creating = true;
                    // Gets the prefab
                    GameObject volumesNode = GameObject.Find("Volumes");
                    currentSelection = Instantiate(Resources.Load("Prefab/sphereMesh", typeof(GameObject))) as GameObject;
                    if (volumesNode != null)
                    {
                        currentSelection.transform.parent = volumesNode.transform;
                    }
                    //Modifies the position and scale
                    currentSelection.transform.position = (scriptPDL.Position + scriptPDR.Position) / 2;
                    float tmp = (Vector3.Distance(scriptPDL.Position, scriptPDR.Position));
                    currentSelection.transform.localScale = new Vector3(tmp, tmp, tmp);
                    /* End here*/

                    lastPosition = currentSelection.transform.position;
                }
            }
        }
Exemple #27
0
 public static Collider selectionMain(bool Pointing, Vector3 PointingDirection, Vector3 Fingertip, ref int nb_pinch, ref bool creating, PinchDetector scriptPDL, PinchDetector scriptPDR, ref GameObject currentSelection, Camera cam,
                                      ref Vector3 lastPosition, ref Vector3 lastPositionR, ref Vector3 lastPositionL) // si le doigt pointe, un Vector3 (direction de raycast), le bout du doigt
 {
     if (nb_pinch == 1 && currentSelection != null)
     {
         Debug.Log("1 pinch");
         LeapCommon.deplacementMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, ref lastPositionR, ref lastPositionL);
     }
     else if (nb_pinch == 2 && currentSelection != null)
     {
         Debug.Log("2 pinch");
         LeapCommon.sizingMode(ref currentSelection, scriptPDL, scriptPDR, ref lastPosition, cam, ref lastPositionR, ref lastPositionL);
     }
     //LineRenderer lr = new LineRenderer();
     //lr.positionCount = 2;
     if (Pointing) //si je pointe avec mon doigt
     {
         //lr.SetPosition(0, Fingertip);
         //lr.SetPosition(1, Fingertip + PointingDirection * 10);
         if (currentCollider == null || timer >= timerDelay) //dans le cas où j'arrive pour la première fois ou que je peux changer de couche
         {
             timer = 0;
             Ray r = new Ray(Fingertip, PointingDirection);
             SphereArray = Physics.RaycastAll(r); // PTET FAIRE GAFFE AU MASK UTILISE POUR PAS SELECTIONNER LES POINTS
             Debug.Log(SphereArray.Length);
             return(chooseSphere());
         }
         else // le cas où je dois attendre avant de changer de couche
         {
             timer += Time.deltaTime;
             return(currentCollider);
         }
     }
     else
     {
         timer = timerDelay;
         return(currentCollider);
     }
 }
 private void RegisterRightHand()
 {
     RightHandPinchDetector             = gameObject.AddComponent <PinchDetector>();
     RightHandPinchDetector.OVRHand     = GetOVRHand(OVRHand.Hand.HandRight);
     RightHandPinchDetector.OVRSkeleton = GetOVRSkeleton(OVRSkeleton.SkeletonType.HandRight);
 }
Exemple #29
0
        // Update is called once per frame
        void Update()
        {
            if (!initializedMenu)
            {
                //Connects to the menu
                cMenu = GameObject.Find("Palm UI L").GetComponent <CurrentMenu>();
                if (cMenu != null)
                {
                    //Debug.Log("IL EST INITIALISEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
                    initializedMenu = true;
                }
            }

            if (!initializedLeft)
            {
                Left = GameObject.Find("Capsule Hand Left");
                if (Left != null)
                {
                    //Debug.Log("ALLO");
                    scriptPDL  = Left.GetComponent <PinchDetector>();
                    scriptEFDL = Left.GetComponent <ExtendedFingerDetector>();
                    //Debug.Log(scriptEFDL, scriptPDL);
                    scriptPDL.OnActivate.AddListener(PinchLeftDetected);
                    scriptPDL.OnDeactivate.AddListener(PinchLeftEnded);
                    scriptEFDL.OnActivate.AddListener(ExtendedFingerDetected);
                    scriptEFDL.OnDeactivate.AddListener(ExtendedFingerEnded);
                    initializedLeft = true;
                }
            }
            if (!initializedRight)
            {
                Right = GameObject.Find("Capsule Hand Right");
                if (Right != null)
                {
                    //Debug.Log("ALLO");
                    scriptPDR  = Right.GetComponent <PinchDetector>();
                    scriptEFDR = Right.GetComponent <ExtendedFingerDetector>();
                    //Debug.Log(scriptEFDR, scriptPDR);
                    scriptPDR.OnActivate.AddListener(PinchRightDetected);
                    scriptPDR.OnDeactivate.AddListener(PinchRightEnded);
                    scriptEFDR.OnActivate.AddListener(ExtendedFingerDetected);
                    scriptEFDR.OnDeactivate.AddListener(ExtendedFingerEnded);
                    initializedRight = true;
                }
            }


            if (initializedLeft && initializedRight && initializedMenu)
            {
                switch (cMenu.GetCurrentMenu())
                {
                case CurrentMenu.Menu.NoMenuSelected:
                    break;

                case CurrentMenu.Menu.Creation:     //CREATION
                    LeapCreation.creationMain(ref nb_pinch, ref creating, scriptPDL, scriptPDR, ref currentSelection, cam,
                                              ref lastPosition, ref lastPositionR, ref lastPositionL, referenceWait, ref wait);
                    break;

                case CurrentMenu.Menu.Selection:     //SELECTION (!!! ptet avec un modulo pour gérer les différents sous-cas de la sélection)
                    switch (cMenu.GetCurrentMenuSelection())
                    {
                    case CurrentMenu.Selection.SetOperation:

                        break;

                    case CurrentMenu.Selection.Modification:
                        LeapDeformation.Update();
                        break;

                    default:
                        break;
                    }
                    Vector3 PointingDirection = new Vector3(0, 0, 0);
                    Vector3 Fingertip         = new Vector3(0, 0, 0);
                    //if (currentSelection != null)
                    //Debug.Log("CURRENT OBJECT:", currentSelection);
                    Finger f  = null;
                    Hand   hl = Left.GetComponent <HandModelBase>().GetLeapHand();
                    Hand   hr = Right.GetComponent <HandModelBase>().GetLeapHand();
                    if (Pointing > 0)
                    {
                        if (hl.Fingers[1].IsExtended)
                        {
                            f = hl.GetIndex();
                        }
                        else
                        {
                            f = hr.GetIndex();
                        }
                        PointingDirection = f.Direction.ToVector3();
                        Fingertip         = f.TipPosition.ToVector3();
                    }
                    Collider tempo = LeapSelection.selectionMain((Pointing > 0), PointingDirection, Fingertip, ref nb_pinch, ref creating, scriptPDL, scriptPDR, ref currentSelection, cam,
                                                                 ref lastPosition, ref lastPositionR, ref lastPositionL);
                    if (tempo != null)
                    {
                        if (currentSelection != null)
                        {
                            currentSelection.GetComponent <Renderer>().material.color = Color.white;
                        }
                        currentSelection = tempo.gameObject;
                        currentSelection.GetComponent <Renderer>().material.color = Color.red;
                    }
                    else
                    {
                        if (currentSelection != null)
                        {
                            currentSelection.GetComponent <Renderer>().material.color = Color.white;
                        }
                        currentSelection = null;
                    }

                    break;
                }
                lastPositionL = scriptPDL.Position;
                lastPositionR = scriptPDR.Position;
            }
        }
Exemple #30
0
    private void transformSingleAnchor(PinchDetector pinchDetector, PinchInfo pinchInfo)
    {
        var pinchPositionDelta = pinchInfo.pinchDetectorInitialPosition - pinchDetector.Position;

        pinchInfo.node.transform.position = pinchInfo.nodeInitialPosition - pinchPositionDelta;
    }