public static void CheckHandTarget(Handle handle)
        {
            HandTarget handTarget = (HandTarget)EditorGUILayout.ObjectField("Hand Target", handle.handTarget, typeof(HandTarget), true);

            if (handTarget != handle.handTarget)
            {
                if (handTarget != null)
                {
                    if (handle.handTarget != null)
                    {
                        HandInteraction.LetGo(handle.handTarget);
                    }
                    if (handTarget.grabbedObject != null)
                    {
                        HandInteraction.LetGo(handTarget);
                    }

                    HandInteraction.MoveAndGrabHandle(handTarget, handle);
                    handTarget.transform.parent = handle.transform;
                }
                else
                {
                    HandInteraction.LetGo(handle.handTarget);
                }
            }
        }
        public void RpcLetGo(int humanoidId, bool isLeft)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                PhotonLog("RpcLetGo");
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    PhotonLogWarning("Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = isLeft ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            if (handTarget != null)
            {
                HandInteraction.LocalLetGo(handTarget);
            }
        }
        public void RpcGrab(int humanoidId, int objViewID, bool isLeft, bool rangeCheck)
        {
            PhotonView objView = PhotonView.Find(objViewID);
            GameObject obj     = objView.gameObject;

            if (debug <= HumanoidNetworking.Debug.Info)
            {
                PhotonLog("RpcGrab " + obj);
            }

            if (obj == null)
            {
                return;
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    PhotonLogWarning("Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = isLeft ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            if (handTarget != null)
            {
                HandInteraction.LocalGrab(handTarget, obj, rangeCheck);
            }
        }
示例#4
0
 public void LetGo()
 {
     if (handTarget != null && handTarget.grabbedObject != null)
     {
         Debug.Log("LetGo" + handTarget + " " + handTarget.grabbedObject);
         HandInteraction.LetGo(handTarget);
     }
 }
示例#5
0
 public void Grab()
 {
     if (handTarget != null && handTarget.grabbedObject == null)
     {
         Debug.Log("Grab" + handTarget + " " + handTarget.grabbedObject + " " + this.gameObject);
         HandInteraction.Grab(handTarget, this.gameObject, false);
     }
 }
示例#6
0
        public virtual void OnCollisionExit(Collision collision)
        {
            Rigidbody objRigidbody = collision.rigidbody;

            if (objRigidbody != null)
            {
                HandInteraction.OnTouchEnd(handTarget, objRigidbody.gameObject);
            }
            else
            {
                HandInteraction.OnTouchEnd(handTarget, collision.gameObject);
            }
        }
示例#7
0
        public override void OnTriggerEnter(Collider collider)
        {
            bool otherHasKinematicPhysics = false;
            bool otherIsHumanoid          = false;

            Rigidbody otherRigidbody = collider.attachedRigidbody;

            if (otherRigidbody != null)
            {
                AdvancedHandPhysics kp = otherRigidbody.GetComponent <AdvancedHandPhysics>();
                otherHasKinematicPhysics = (kp != null);
                HumanoidControl humanoid = otherRigidbody.GetComponent <HumanoidControl>();
                otherIsHumanoid = (humanoid != null);
            }

            if (handRigidbody != null &&
                handRigidbody.isKinematic &&
                (!collider.isTrigger || otherHasKinematicPhysics) &&
                !otherIsHumanoid)
            {
                colliding   = true;
                hasCollided = true;
                if (otherRigidbody != null)
                {
                    handTarget.touchedObject = otherRigidbody.gameObject;
                    SetNonKinematic(handRigidbody, handTarget.colliders);
                }
                else
                {
                    handTarget.touchedObject = collider.gameObject;
                    SetNonKinematic(handRigidbody, handTarget.colliders);
                }

                ProcessFirstCollision(handRigidbody, collider);
            }

            if (hasCollided)
            {
                Rigidbody objRigidbody = collider.attachedRigidbody;
                if (objRigidbody != null)
                {
                    HandInteraction.GrabCheck(handTarget, objRigidbody.gameObject);
                }
                else
                {
                    HandInteraction.GrabCheck(handTarget, collider.gameObject);
                }
            }
        }
示例#8
0
        public virtual void OnTriggerExit(Collider collider)
        {
            Rigidbody objRigidbody = collider.attachedRigidbody;

            if (objRigidbody != null)
            {
                HandInteraction.OnTouchEnd(handTarget, objRigidbody.gameObject);
            }
            else
            {
                HandInteraction.OnTouchEnd(handTarget, collider.gameObject);
            }

            handTarget.touchedObject = null;
        }
        public void OnSceneGUI()
        {
            Handle handle = (Handle)target;

            if (handle.handTarget == null)
            {
                return;
            }

            if (!Application.isPlaying)
            {
                handle.handTarget.poseMixer.ShowPose(handle.handTarget.humanoid, handle.handTarget.side);
                HandInteraction.MoveHandTargetToHandle(handle.handTarget, handle);

                ArmMovements.Update(handle.handTarget);
                FingerMovements.Update(handle.handTarget);
                handle.handTarget.MatchTargetsToAvatar();
            }
        }
示例#10
0
        public void GrabObject()
        {
            if (objectInFocus == null)
            {
                return;
            }

            HandTarget handTarget = transform.GetComponentInParent <HandTarget>();

            if (handTarget == null)
            {
                return;
            }

            Rigidbody rigidbodyInFocus = objectInFocus.GetComponentInParent <Rigidbody>();

            if (rigidbodyInFocus != null)
            {
                HandInteraction.GrabOrLetGo(handTarget, rigidbodyInFocus.gameObject, false);
            }
        }
示例#11
0
        public virtual void OnTriggerEnter(Collider collider)
        {
            if (collider.isTrigger)
            {
                // We cannot touch trigger colliders
                return;
            }

            Rigidbody objRigidbody = collider.attachedRigidbody;

            if (objRigidbody != null)
            {
                handTarget.touchedObject = objRigidbody.gameObject;
            }
            else
            {
                handTarget.touchedObject = collider.gameObject;
            }

            HandInteraction.OnTouchStart(handTarget, handTarget.touchedObject);
        }
示例#12
0
        [ClientRpc] // @ remote client
        public void RpcClientLetGo(int nwId, int humanoidId, bool leftHanded)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log(netId + ": RpcLetGo " + humanoidId);
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = leftHanded ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            HandInteraction.LocalLetGo(handTarget);
        }
示例#13
0
        [ClientRpc] // @ remote client
        public void RpcClientGrab(int nwId, int humanoidId, GameObject obj, bool leftHanded, bool rangeCheck)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log(nwId + ": RpcGrab " + obj);
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = leftHanded ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            HandInteraction.LocalGrab(handTarget, obj, rangeCheck);
        }
示例#14
0
        public override void ManualFixedUpdate(HandTarget _handTarget)
        {
            handTarget = _handTarget;

            if (hasCollided && !colliding)
            {
                HandInteraction.OnTouchEnd(handTarget, handTarget.touchedObject);
                handTarget.touchedObject = null;
            }

            if (handTarget.touchedObject == null)   // Object may be destroyed
            {
                hasCollided = false;
            }

            if (handRigidbody == null)
            {
                Initialize();
            }

            // Check for stuck hands. Only when hand is kinematic you can pull the hand loose
            // it will then turn into a kinematic hand, which results in snapping the hand back
            // onto the forearm.
            if (handTarget.forearm.bone.transform != null && !handRigidbody.isKinematic)
            {
                float distance = Vector3.Distance(handTarget.hand.bone.transform.position, handTarget.forearm.bone.transform.position) - handTarget.forearm.bone.length;
                if (distance > 0.05F)
                {
                    //SetKinematic(handRigidbody, true);
                    handTarget.colliders = SetKinematic(handRigidbody);
                }
            }

            UpdateRigidbody();

            colliding = false;
        }
示例#15
0
        private void GrabObject(HandTarget handTarget, GameObject obj)
        {
            if (handTarget.otherHand.grabbedObject == obj)
            {
                LetGoObject(handTarget.otherHand);
            }

            HandInteraction.Grab(handTarget, obj, false);
            if (handTarget.grabbedObject == null)
            {
                Debug.LogWarning("Could not grab object");
            }
            else
            {
                Handle handle = obj.GetComponent <Handle>();
                if (handle == null)
                {
                    BarHandle.Create(obj, handTarget);
                }
                //handTarget.hand.MatchTargetToAvatar();
                //ArmMovements.Update(handTarget);
                //handTarget.CopyRigToTarget();
            }
        }
示例#16
0
 private void LetGoObject(HandTarget handTarget)
 {
     HandInteraction.LetGo(handTarget);
     grabbedObjectProp.objectReferenceValue = null;
 }
示例#17
0
 private static void GrabMe(Handle handle)
 {
     HandInteraction.MoveHandTargetToHandle(handle.handTarget, handle);
     handle.SetHandPose(handle.handTarget);
 }
示例#18
0
 public virtual void OnTriggerStay(Collider collider)
 {
     HandInteraction.GrabCheck(handTarget, handTarget.touchedObject);
 }