private void SelectDistanceGribObject() { LastSelectedInteractabble = null; if (!hand.grabPoser && hand.SelectedGpibColliders.Length == 0) { SelectedDistanceGripColliders = Physics.OverlapSphere(dot.transform.position, hand.gripRadius, hand.layerColliderChecker); hand.SelectedGpibInteractible = null; float tempCloseDistance = float.MaxValue; for (int i = 0; i < SelectedDistanceGripColliders.Length; i++) { CustomInteractible tempCustomInteractible = SelectedDistanceGripColliders[i].GetComponentInParent <CustomInteractible>(); if (tempCustomInteractible != null && tempCustomInteractible.isInteractible && tempCustomInteractible.grabType == CustomHand.GrabType.Grip && tempCustomInteractible.DistanceGrabbable) { if (Vector3.Distance(tempCustomInteractible.transform.position, dot.transform.position) < tempCloseDistance) { tempCloseDistance = Vector3.Distance(tempCustomInteractible.transform.position, dot.transform.position); hand.SelectedGpibInteractible = tempCustomInteractible; LastSelectedInteractabble = tempCustomInteractible; } } } } else { LastSelectedInteractabble = null; } }
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; } } }
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; } } }
public void SelectGribObject() { if (!grabPoser) { SelectedGpibColliders = Physics.OverlapSphere(GrabPoint(), gripRadius, layerColliderChecker); SelectedGpibInteractible = null; float tempCloseDistance = float.MaxValue; for (int i = 0; i < SelectedGpibColliders.Length; i++) { CustomInteractible tempCustomInteractible = SelectedGpibColliders[i].GetComponentInParent <CustomInteractible>(); if (tempCustomInteractible != null && tempCustomInteractible.isInteractible && tempCustomInteractible.grabType == GrabType.Grip) { if (Vector3.Distance(tempCustomInteractible.transform.position, GrabPoint()) < tempCloseDistance) { tempCloseDistance = Vector3.Distance(tempCustomInteractible.transform.position, GrabPoint()); SelectedGpibInteractible = tempCustomInteractible; } } } } }
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; } } }
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) { BlendControll(true); CustomInteractible oldgrabInteractible = grabInteractible; if (selectedIndexInteractible) { grabInteractible = selectedIndexInteractible; InteractionProcessor(oldgrabInteractible, grabInteractible, GrabType.Select); } else if (selectedPinchInteractible && pinchButton.GetStateDown(handType)) { grabInteractible = selectedPinchInteractible; InteractionProcessor(oldgrabInteractible, grabInteractible, GrabType.Pinch); } else if (selectedGripInteractible && grabButton.GetStateDown(handType)) { grabInteractible = selectedGripInteractible; InteractionProcessor(oldgrabInteractible, grabInteractible, GrabType.Grip); } } }
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; } } } } } } }