Exemple #1
0
 public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
 {
     base.ProcessInteractable(updatePhase);
     if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
     {
         if (isSelected)
         {
             Vector3 pullPostion = pullingInteractor.transform.position;
             PullAmount = CalculatePull(pullPostion);
         }
     }
 }
Exemple #2
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
        {
            if (isSelected)
            {
                AnimateBow(puller.PullAmount);
            }
        }
    }
Exemple #3
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (isSelected)
        {
            if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
            {
                Value = FindPullValue();
                ApplyValue(Value);
            }
        }
    }
Exemple #4
0
 public override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
 {
     base.ProcessInteractor(updatePhase);
     if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
     {
         if (isArrowArmed && currentArrow)
         {
             float normPullAmount = Mathf.InverseLerp(releaseThreshold, 1f, pullAmount);
             currentArrow.PreviewLaunchForce(normPullAmount);
             bow.PreviewLaunchForce(normPullAmount);
         }
     }
 }
Exemple #5
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        if (hoverInteractor)
        {
            float newHandHeight = GetLocalYPosition(hoverInteractor.transform.position);
            float handDiff      = prevHandHeight - newHandHeight;
            prevHandHeight = newHandHeight;
            float newPosition = transform.localPosition.y - handDiff;
            SetYPosition(newPosition);

            CheckPress();
        }
    }
Exemple #6
0
    public override void ProcessInteractable(
        XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (gripHand && guardHand)
        {
            SetGripRotation();
        }

        CheckDistance(gripHand, gripHold);
        CheckDistance(guardHand, guardHold);
    }
Exemple #7
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        if (hoverInteract)
        {
            float newHandHeight  = getYPos(hoverInteract.transform.position);
            float handDifference = previousHeight - newHandHeight;
            previousHeight = newHandHeight;

            float newPosition = transform.localPosition.y - handDifference;
            setY(newPosition);
            checkPress();
        }
    }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (isSelected)
        {
            // Update pull values while the measurer is grabbed
            if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
            {
                CheckForPull();
            }
        }
    }
Exemple #9
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);
        if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
        {
            if (secondGrab != null && secondHand != null)
            {
                transform.LookAt(secondHand.transform, Vector3.right);

                transform.position = selectingInteractor.transform.position;
            }
        }
    }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
        {
            if (isSelected)
            {
                Vector3 lookDirection = GetLookDirection();
                handle.forward = transform.TransformDirection(lookDirection);
            }
        }
    }
        public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
        {
            if (hoverInteractor)
            {
                var localZ = GetLocalPosition(hoverInteractor.transform.position).z;
                var deltaZ = localZ - previousZ;
                pressZ    = Mathf.Clamp(pressZ + deltaZ, -tMax, 0f);
                previousZ = localZ;
                CheckPress();
            }

            transform.position = rootPosition - transform.forward * offset + transform.forward * pressZ;
        }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        // If the object is held
        if (isSelected)
        {
            // During Update
            if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
            {
                UpdateMesh();
            }
        }
    }
Exemple #13
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);
        transform.position = new Vector3(transform.position.x, currentPos.y, transform.position.z);
        transform.rotation = new Quaternion(currentRot.x, currentRot.y, currentRot.z, currentRot.w);

        if (pv)
        {
            pv.RPC("calculateVelocity", RpcTarget.MasterClient);
        }
        //NewPos = transform.position;  // each frame track the new position
        //ObjVelocity = (NewPos - PrevPos) / Time.fixedDeltaTime;  // velocity = dist/time
        //PrevPos = NewPos;  // update position for next frame calculation
    }
Exemple #14
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        if (pushInteractor)
        {
            float newPushPos = GetLocalYPosition(pushInteractor.transform.position);
            float pushDelta  = previousPushDepth - newPushPos;
            previousPushDepth = newPushPos;

            float newPos = transform.localPosition.y - pushDelta;
            SetYPosition(newPos);

            PushButtonTriggered();
        }
    }
Exemple #15
0
    //When the object is going to be tracked
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        if (HoverInteractor)
        {
            float newHandHight   = GetLocalYPosition(HoverInteractor.transform.position);
            float HandDifference = PreviousHandHight - newHandHight;
            PreviousHandHight = newHandHight;

            float newPosition = transform.localPosition.y - HandDifference;
            SetYPosition(newPosition);

            CheckIfPress();
        }
    }
 void PerformInstantaneousUpdate(float timeDelta, XRInteractionUpdateOrder.UpdatePhase updatePhase)
 {
     if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic ||
         updatePhase == XRInteractionUpdateOrder.UpdatePhase.OnBeforeRender)
     {
         if (trackPosition)
         {
             transform.position = m_TargetWorldPosition;
         }
         if (trackRotation)
         {
             transform.rotation = m_TargetWorldRotation;
         }
     }
 }
Exemple #17
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
        {
            if (selectInteractor)
            {
                Angle = FindRotationValue();
                float finalRotation = ApplyRotation(Angle);

                SetValue(finalRotation);
                selectRotation = selectInteractor.transform.rotation;
            }
        }
    }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (isSelected)
        {
            if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
            {
                Vector3 targetPosition = selectInteractor.transform.position;
                Vector3 newRotation    = FindJoystickRotation(targetPosition);

                ApplyRotation(newRotation);
                SetValue(newRotation);
            }
        }
    }
Exemple #19
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (selectingInteractor)
        {
            transform.position = selectingInteractor.attachTransform.position;
            transform.rotation = selectingInteractor.attachTransform.rotation;
        }

        if (handPos && hand)
        {
            hand.position = handPos.position;
            hand.rotation = selectingInteractor.GetComponent <XRController>().controllerNode == UnityEngine.XR.XRNode.LeftHand || handPos.localRotation.z == 0 ? handPos.rotation : handPos.rotation * Quaternion.Euler(0, 0, 180);
        }
    }
Exemple #20
0
 public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
 {
     if (secondInteractor && selectingInteractor)
     {
         //Compute the rotation
         if (snapToSecondHand)
         {
             selectingInteractor.attachTransform.rotation = GetTwoHandRotation();
         }
         else
         {
             selectingInteractor.attachTransform.rotation = GetTwoHandRotation() * initialRotationOffset;
         }
     }
     base.ProcessInteractable(updatePhase);
 }
 void PerformKinematicUpdate(float timeDelta, XRInteractionUpdateOrder.UpdatePhase updatePhase)
 {
     if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Fixed)
     {
         if (trackPosition)
         {
             var positionDelta = m_TargetWorldPosition - m_RigidBody.worldCenterOfMass;
             m_RigidBody.velocity = Vector3.zero;
             m_RigidBody.MovePosition(m_RigidBody.position + positionDelta);
         }
         if (trackRotation)
         {
             m_RigidBody.angularVelocity = Vector3.zero;
             m_RigidBody.MoveRotation(m_TargetWorldRotation);
         }
     }
 }
Exemple #22
0
            /// <inheritdoc />
            public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
            {
                base.ProcessInteractable(updatePhase);

                if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
                {
                    if (interactor != null)
                    {
                        interactor.enabled = enableBehaviors;
                    }

                    if (interactable != null)
                    {
                        interactable.enabled = enableBehaviors;
                    }
                }
            }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Late)
        {
            if (isSelectExit && canSelect)
            {
                if (SelectRecognitionTime < selectRecognitionTimeVal)
                {
                    isSelectExit = false;
                    canSelect    = false;
                    return;
                }
                selectRecognitionTimeVal += Time.deltaTime;
            }
        }
    }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        if (selectingInteractor)
        {
            transform.position = selectingInteractor.attachTransform.position;
            transform.rotation = selectingInteractor.attachTransform.rotation;
        }

        if (secondInteractor && selectingInteractor)
        {
            onSecond = true;

            if (snapToSecondHand)
            {
                selectingInteractor.attachTransform.rotation = GetTwoHandRotation();
            }
            else if (!snapToSecondHand)
            {
                selectingInteractor.attachTransform.rotation = GetTwoHandRotation() * initalRotationOffset;
            }

            if (secondInteractor && second)
            {
                second.position = secondPos.position;
                second.rotation = secondInteractor.GetComponent <XRController>().controllerNode == UnityEngine.XR.XRNode.LeftHand || secondPos.localRotation.z == 0 ? secondPos.rotation : secondPos.rotation * Quaternion.Euler(0, 0, 180);
            }
            if (selectingInteractor && first)
            {
                first.position = firstPos.position;
                first.rotation = selectingInteractor.GetComponent <XRController>().controllerNode == UnityEngine.XR.XRNode.LeftHand || firstPos.localRotation.z == 0 ? firstPos.rotation : firstPos.rotation * Quaternion.Euler(0, 0, 180);
            }
        }
        else if (!secondInteractor && selectingInteractor)
        {
            onSecond = false;
            if (selectingInteractor && first)
            {
                first.position = firstPos.position;
                first.rotation = selectingInteractor.GetComponent <XRController>().controllerNode == UnityEngine.XR.XRNode.LeftHand || firstPos.localRotation.z == 0 ? firstPos.rotation : firstPos.rotation * Quaternion.Euler(0, 0, 180);
            }
        }
        base.ProcessInteractable(updatePhase);
    }
Exemple #25
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);
        if (isSelected)
        {
            if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
            {
                // check pull amount
                Vector3 targDir   = endPullT.position - startPullT.position;
                float   maxLength = targDir.magnitude;
                targDir.Normalize();

                Vector3 pullDir = pullingInteractor.transform.position - startPullT.position;
                float   nPull   = Vector3.Dot(pullDir, targDir) / maxLength;
                nPull = Mathf.Clamp01(nPull);
                SetPullAmount(nPull);
            }
        }
    }
        void PerformVelocityTrackingUpdate(float timeDelta, XRInteractionUpdateOrder.UpdatePhase updatePhase)
        {
            if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Fixed)
            {
                // Do velocity tracking
                if (trackPosition)
                {
                    // scale initialized velocity by prediction factor
                    m_RigidBody.velocity *= k_VelocityPredictionFactor;
                    var posDelta = m_TargetWorldPosition - m_RigidBody.worldCenterOfMass;
                    var velocity = posDelta / timeDelta;

                    if (!float.IsNaN(velocity.x))
                    {
                        m_RigidBody.velocity += velocity;
                    }
                }

                // Do angular velocity tracking
                if (trackRotation)
                {
                    // scale initialized velocity by prediction factor
                    m_RigidBody.angularVelocity *= k_VelocityPredictionFactor;
                    var   rotationDelta = m_TargetWorldRotation * Quaternion.Inverse(m_RigidBody.rotation);
                    float angleInDegrees; Vector3 rotationAxis;
                    rotationDelta.ToAngleAxis(out angleInDegrees, out rotationAxis);
                    if (angleInDegrees > 180)
                    {
                        angleInDegrees -= 360;
                    }

                    if (Mathf.Abs(angleInDegrees) > Mathf.Epsilon)
                    {
                        var angularVelocity = (rotationAxis * angleInDegrees * Mathf.Deg2Rad) / timeDelta;
                        if (!float.IsNaN(angularVelocity.x))
                        {
                            m_RigidBody.angularVelocity += angularVelocity * k_AngularVelocityDamping;
                        }
                    }
                }
            }
        }
Exemple #27
0
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);
        if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
        {
            Vector3 pos = transform.position;
            switch (axis)
            {
            case Axis.X:
                pos.x = FixPosition;
                break;

            case Axis.Y:
                pos.y = FixPosition;
                break;

            case Axis.Z:
                pos.z = FixPosition;
                break;
            }

            transform.position = pos;

            Quaternion angle = transform.rotation;
            switch (axis)
            {
            case Axis.X:
                angle.eulerAngles = new Vector3(angle.eulerAngles.x, 90, 90);
                break;

            case Axis.Y:
                angle.eulerAngles = new Vector3(90, angle.eulerAngles.y, 90);
                break;

            case Axis.Z:
                angle.eulerAngles = new Vector3(90, 90, angle.eulerAngles.z);
                break;
            }

            transform.rotation = angle;
        }
    }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        base.ProcessInteractable(updatePhase);

        if (unlocked)
        {
            screw1.screwedOut = 1f;
            screw2.screwedOut = 1f;
            screw3.screwedOut = 1f;
            screw4.screwedOut = 1f;
        }

        if (screw1.screwedOut >= 0.9f && screw2.screwedOut >= 0.9f && screw3.screwedOut >= 0.9f && screw4.screwedOut >= 0.9f)
        {
            colliders[0].enabled = true;
        }
        else
        {
            colliders[0].enabled = false;
        }
    }
 public override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
 {
     // perform toggling of selection state
     // and activation of selected object on activate
     if (updatePhase == XRInteractionUpdateOrder.UpdatePhase.Dynamic)
     {
         if (m_Controller)
         {
             if (m_Controller.selectInteractionState.activatedThisFrame)
             {
                 m_ToggleSelectActive = !m_ToggleSelectActive;
             }
             if (selectTarget && m_Controller.activateInteractionState.activatedThisFrame)
             {
                 selectTarget.OnActivate(this);
             }
             if (selectTarget && m_Controller.activateInteractionState.deActivatedThisFrame)
             {
                 selectTarget.OnDeactivate(this);
             }
         }
     }
 }
    public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    {
        if (selectingInteractor)
        {
            if (handPos)
            {
                var mesh = selectingInteractor.transform?.Find("Mesh");
                if (mesh != null)
                {
                    mesh.transform.position = handPos.position;
                    mesh.transform.rotation = selectingInteractor.GetComponent <XRController>().controllerNode == UnityEngine.XR.XRNode.LeftHand || handPos.localRotation.z == 0 ? handPos.rotation : handPos.rotation * Quaternion.Euler(0, 0, 180);
                }
            }

            if (!baseInteractable.isSelected)
            {
                Drop();
            }
        }


        base.ProcessInteractable(updatePhase);
    }