Beispiel #1
0
    private void ScaleMarkedSpace()
    {
        var grabVec = (grabHand.GetGraspPoint() - transform.position) - initialGrabOffset;
        var baseVec = grabSphere.transform.position - transform.position;

        var delta = grabVec.magnitude / baseVec.magnitude - 1;

        delta = Mathf.Sign(delta) * CoolMath.SmoothStep(0.05f, 0.3f, Mathf.Abs(delta));
        delta = Time.deltaTime * delta * mark.Radius;
        mark.transform.localScale += new Vector3(delta, delta, delta);
        mark.transform.localScale.Clamp(MinMarkSize, MaxMarkSize);
    }
Beispiel #2
0
 private void GrabSphereGraspBegin()
 {
     grabHand = grabSphereLeap.graspingController.intHand;
     if (grabHand.NoFistPinchStrength() < 0.6f)
     {
         initialGrabOffset = grabHand.GetGraspPoint() - grabSphere.transform.position;
         grabSphereMaterial.DOColor(GrabSphereGrabbedColor, 0.1f);
     }
 }
Beispiel #3
0
    private void HandleAnchoring()
    {
        if (!anchorHand.isTracked)
        {
            anchoringStopTimer += Time.deltaTime;
        }
        else if (anchorHand.intHand.leapHand.GrabStrength < 0.8f)
        {
            var dropTargets = GetValidDropTargets(anchorHand.hoveredObjects);
            if (dropTargets.Count == 0)
            {
                anchoringStopTimer += Time.deltaTime;
            }
            else
            {
                // TODO: we just use the first. Could do filtering.
                proxyNode.Anchor(dropTargets[0]);
                anchoringStopTimer = AnchoringTimeout;
            }
        }
        else
        {
            anchoringStopTimer = 0f;
        }

        if (anchoringStopTimer >= AnchoringTimeout)
        {
            lineRenderer.enabled = false;
            ChangeMode(ManipulationMode.Hover);
            Player.Instance?.HideAnchoringTarget();
            return;
        }

        lineRenderer.positionCount = 2;
        lineRenderer.SetPosition(0, anchoringStart);
        lineRenderer.SetPosition(1, anchorHand.isGraspingObject ? anchorHand.GetGraspPoint() : anchorHand.position);
    }
Beispiel #4
0
    private void HandleActiveMode()
    {
        bool hasHoverHand = false;

        foreach (var controller in leap.hoveringControllers)
        {
            if (controller.isGraspingObject)
            {
                continue;
            }
            hasHoverHand |= IsHandInActivationPose(controller.intHand);
        }
        if (hasHoverHand)
        {
            hoverTime += Time.deltaTime;
        }
        else
        {
            hoverTime = 0f;
        }

        if (graspedPoseHandler.InteractingHands == 0)
        {
            inactiveTime += Time.deltaTime;
            if (inactiveTime > InactiveTimeout)
            {
                ChangeMode(ManipulationMode.Hover);
                graspedPoseHandler.SetEnabled(false);
            }
            else
            {
                ChangeMode(ManipulationMode.Active);
            }
        }
        else if (graspedPoseHandler.InteractingHands == 1)
        {
            inactiveTime = 0f;
            // Don't allow going from Translating into anchoring
            if (Mode == ManipulationMode.Translating)
            {
                hasHoverHand = false;
            }
            // Have slight delay on anchoring start as not to trigger it on rotation/scaling
            if (hasHoverHand && hoverTime > 0.2f)
            {
                anchorHand           = leap.graspingController.intHand;
                anchoringStart       = anchorHand.isGraspingObject ? anchorHand.GetGraspPoint() : anchorHand.position;
                anchoringStopTimer   = 0f;
                lineRenderer.enabled = true;
                ChangeMode(ManipulationMode.Anchoring);
                Player.Instance?.ShowAnchoringTarget();
                graspedPoseHandler.SetEnabled(false);
            }
            else
            {
                ChangeMode(ManipulationMode.Translating);
            }
        }
        else if (graspedPoseHandler.InteractingHands == 2)
        {
            inactiveTime = 0f;
            if (proxyNode.Radius < MINIMIZE_THRESHOLD)
            {
                graspedPoseHandler.SetEnabled(false);
                proxyNode.Minimize();
                ChangeMode(ManipulationMode.Minimized);
            }
            else
            {
                ChangeMode(ManipulationMode.ScalingAndRotating);
            }
        }
    }