Exemple #1
0
 void SelectIndexObject()
 {
     if (!grabPoser)
     {
         SelectedIndexColliders    = Physics.OverlapSphere(IndexPoint(), indexRadius, layerColliderChecker);
         SelectedIndexInteractible = null;
         float tempCloseDistance = float.MaxValue;
         for (int i = 0; i < SelectedIndexColliders.Length; i++)
         {
             CustomInteractible tempCustomInteractible = SelectedIndexColliders[i].GetComponentInParent <CustomInteractible>();
             if (tempCustomInteractible != null && tempCustomInteractible.isInteractible && tempCustomInteractible.grabType == GrabType.Select)
             {
                 if (Vector3.Distance(tempCustomInteractible.transform.position, IndexPoint()) < tempCloseDistance)
                 {
                     tempCloseDistance         = Vector3.Distance(tempCustomInteractible.transform.position, IndexPoint());
                     SelectedIndexInteractible = tempCustomInteractible;
                 }
             }
         }
     }
     else
     {
         if (SelectedIndexInteractible)
         {
             SelectedIndexColliders = Physics.OverlapSphere(IndexPoint(), indexRadius * 2f, layerColliderChecker);
             if (SelectedIndexColliders == null || SelectedIndexColliders.Length == 0)
             {
                 SelectedIndexInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                 GrabEnd();
                 SelectedIndexInteractible = null;
                 return;
             }
             for (int i = 0; i < SelectedIndexColliders.Length; i++)
             {
                 CustomInteractible tempCustomInteractible = SelectedIndexColliders[i].GetComponentInParent <CustomInteractible>();
                 if (tempCustomInteractible && tempCustomInteractible == SelectedIndexInteractible)
                 {
                     return;
                 }
             }
             SelectedIndexInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
             GrabEnd();
             SelectedIndexInteractible = null;
         }
     }
 }
Exemple #2
0
 void SelectObject(Vector3 selectPoint, GrabType grabType, Collider[] colliders, ref CustomInteractible interactible)
 {
     if (!grabPoser)
     {
         colliders    = Physics.OverlapSphere(selectPoint, gripRadius, layerColliderChecker);
         interactible = null;
         float tempCloseDistance = float.MaxValue;
         for (int i = 0; i < colliders.Length; i++)
         {
             CustomInteractible tempCustomInteractible = colliders[i].GetComponentInParent <CustomInteractible>();
             if (tempCustomInteractible != null && tempCustomInteractible.isInteractible && tempCustomInteractible.grabType == grabType)
             {
                 if (Vector3.Distance(tempCustomInteractible.transform.position, selectPoint) < tempCloseDistance)
                 {
                     tempCloseDistance = Vector3.Distance(tempCustomInteractible.transform.position, selectPoint);
                     interactible      = tempCustomInteractible;
                 }
             }
         }
     }
     else if (grabType == GrabType.Select) // HANDLE SELECT TYPE
     {
         if (interactible)
         {
             colliders = Physics.OverlapSphere(selectPoint, indexRadius * 2f, layerColliderChecker);
             if (colliders == null || colliders.Length == 0)
             {
                 interactible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                 GrabEnd();
                 interactible = null;
                 return;
             }
             for (int i = 0; i < colliders.Length; i++)
             {
                 CustomInteractible tempCustomInteractible = colliders[i].GetComponentInParent <CustomInteractible>();
                 if (tempCustomInteractible && tempCustomInteractible == interactible)
                 {
                     return;
                 }
             }
             interactible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
             GrabEnd();
             interactible = null;
         }
     }
 }
Exemple #3
0
 private void InteractionProcessor(CustomInteractible oldgrabInteractible, CustomInteractible grabInteractible, GrabType procGrabType)
 {
     if (grabInteractible != oldgrabInteractible)
     {
         if (oldgrabInteractible)
         {
             oldgrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
         }
         if (grabInteractible)
         {
             grabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver);
             setHandTransform = false;
             grabType         = procGrabType;
             renderModelVisible(!grabInteractible.hideController);
             SkeletonUpdate();
             blendToPose           = 1;
             blendToPoseMoveObject = 1;
             endFramePos           = transform.parent.InverseTransformPoint(skeleton.transform.position);
             endFrameRot           = skeleton.transform.rotation;
         }
     }
 }
Exemple #4
0
    public void GrabCheck()
    {
        if (grabType != GrabType.None && GrabInteractible)
        {
            if (grabType == GrabType.Pinch && pinchButton.GetStateUp(handType))
            {
                GrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                GrabEnd();
            }
            if (grabType == GrabType.Grip && grabButton.GetStateUp(handType))
            {
                GrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                GrabEnd();
            }
        }

        if (!grabPoser)
        {
            if (blend > 0)
            {
                blendToAnimation      += 1f / blend * Time.deltaTime;
                blendToAnimation       = Mathf.Clamp01(blendToAnimation);
                blendToPose           += 1f / blendPosition * Time.deltaTime;
                blendToPose            = Mathf.Clamp01(blendToPose);
                blendToPoseMoveObject += 1f / blendPosition * Time.deltaTime;
                blendToPoseMoveObject  = Mathf.Clamp01(blendToPoseMoveObject);
            }
            else
            {
                blendToAnimation = 1;
            }

            CustomInteractible OldGrabInteractible = GrabInteractible;
            if (SelectedIndexInteractible)
            {
                GrabInteractible = SelectedIndexInteractible;
                if (GrabInteractible != OldGrabInteractible)
                {
                    if (OldGrabInteractible)
                    {
                        OldGrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                    }
                    if (GrabInteractible)
                    {
                        GrabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver);
                        setHandTransform = false;
                        grabType         = GrabType.Select;
                        RenderModelVisible(!GrabInteractible.HideController);
                        SkeletonUpdate();
                        blendToPose           = 1;
                        blendToPoseMoveObject = 1;
                        endFramePos           = transform.parent.InverseTransformPoint(skeleton.transform.position);
                        endFrameRot           = skeleton.transform.rotation;
                    }
                }
            }
            else
            {
                if (SelectedPinchInteractible && pinchButton.GetStateDown(handType))
                {
                    GrabInteractible = SelectedPinchInteractible;
                    if (GrabInteractible != OldGrabInteractible)
                    {
                        if (OldGrabInteractible)
                        {
                            OldGrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                        }
                        if (GrabInteractible)
                        {
                            GrabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver);
                            setHandTransform = false;
                            grabType         = GrabType.Pinch;
                            RenderModelVisible(!GrabInteractible.HideController);
                            SkeletonUpdate();
                            blendToPose           = 1;
                            blendToPoseMoveObject = 1;
                            endFramePos           = transform.parent.InverseTransformPoint(skeleton.transform.position);
                            endFrameRot           = skeleton.transform.rotation;
                        }
                    }
                }
                else
                {
                    if (SelectedGpibInteractible && grabButton.GetStateDown(handType))
                    {
                        GrabInteractible = SelectedGpibInteractible;
                        if (GrabInteractible != OldGrabInteractible)
                        {
                            if (OldGrabInteractible)
                            {
                                OldGrabInteractible.SendMessage("GrabEnd", this, SendMessageOptions.DontRequireReceiver);
                            }
                            if (GrabInteractible)
                            {
                                GrabInteractible.SendMessage("GrabStart", this, SendMessageOptions.DontRequireReceiver);
                                setHandTransform = false;
                                grabType         = GrabType.Grip;
                                RenderModelVisible(!GrabInteractible.HideController);
                                SkeletonUpdate();
                                blendToPose           = 1;
                                blendToPoseMoveObject = 1;
                                endFramePos           = transform.parent.InverseTransformPoint(skeleton.transform.position);
                                endFrameRot           = skeleton.transform.rotation;
                            }
                        }
                    }
                }
            }
        }
    }