Пример #1
0
 internal protected void SetAttribute(int boneIndex,
                                      Hi5_Glove_Interaction_Finger_Type fingerType,
                                      Hi5_Glove_Interaction_Finger finger)
 {
     mBoneIndex  = boneIndex;
     mFingerType = fingerType;
     mFinger     = finger;
 }
Пример #2
0
        public override void End()
        {
            fingerTypeOne = Hi5_Glove_Interaction_Finger_Type.ENone;
            fingerTypeTwo = Hi5_Glove_Interaction_Finger_Type.ENone;
            handType      = Hi5_Object_Clap_Type.ENone;

            //if (Hi5_Interaction_Const.TestChangeState)
            {
                if (hand != null)
                {
                    hand.mState.ChangeState(E_Hand_State.ERelease);
                }
            }
            hand = null;
//			ObjectItem.SetIsKinematic (false);
//			ObjectItem.SetUseGravity (true);
//			ObjectItem.SetIsLockYPosition (false);
            //ObjectItem.ChangeColor(ObjectItem.orgColor);
        }
Пример #3
0
        internal bool IsClap(out int objectId, out Hi5_Glove_Interaction_Finger_Type fingerOneType, out Hi5_Glove_Interaction_Finger_Type fingerTwoType)
        {
            List <int> collisionIndexs;
            bool       index = Hand.mFingers[Hi5_Glove_Interaction_Finger_Type.EIndex].IsClap(out collisionIndexs);
            List <int> collisionMiddles;
            bool       middle = Hand.mFingers[Hi5_Glove_Interaction_Finger_Type.EMiddle].IsClap(out collisionMiddles);
            List <int> collisionRings;
            bool       ring = Hand.mFingers[Hi5_Glove_Interaction_Finger_Type.ERing].IsClap(out collisionRings);
            List <int> collisionPalms;
//			bool pinky = Hand.mFingers[Hi5_Glove_Interaction_Finger_Type.EPinky].IsClap(out collisionRings);
//			List<int> collisionPinkys;
            //手腕
            bool palm = Hand.mPalm.IsClap(out collisionPalms);

            if (palm && collisionPalms != null && collisionPalms.Count > 0)
            {
                for (int i = 0; i < collisionPalms.Count; i++)
                {
                    int idObject = collisionPalms[i];
                    Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(idObject);
                    //判断夹角
                    Transform palmTransform = Hand.mPalm.transform;
                    Transform onPoint       = item.transform;
                    Vector3   temp          = onPoint.position - palmTransform.position;
                    float     tempValue     = Vector3.Dot(temp, palmTransform.up);
                    if (tempValue < 0)
                    {
                        objectId      = collisionPalms[i];
                        fingerOneType = Hi5_Glove_Interaction_Finger_Type.ENone;
                        fingerTwoType = Hi5_Glove_Interaction_Finger_Type.ENone;
                        float angelUpWorld = Vector3.Angle(palmTransform.transform.up, Hi5_Interaction_Object_Manager.GetObjectManager().transform.up);
                        if (angelUpWorld < 45.0f && angelUpWorld > 0.0f)
                        {
                            return(true);
                        }
                        else
                        {
                            objectId      = -1;
                            fingerOneType = Hi5_Glove_Interaction_Finger_Type.ENone;
                            fingerTwoType = Hi5_Glove_Interaction_Finger_Type.ENone;
                            return(false);
                        }
                    }
                }
            }

            int middleObjectId = -1;
            Hi5_Glove_Interaction_Finger_Type fingerMiddleType = Hi5_Glove_Interaction_Finger_Type.ENone;
            {
                //中指
                if (middle && collisionMiddles != null && collisionMiddles.Count > 0)
                {
                    for (int i = 0; i < collisionMiddles.Count; i++)
                    {
                        int idObject = collisionMiddles[i];
                        Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(idObject);
                        //判断夹角
                        Transform palmTransform = Hand.mPalm.transform;
                        Transform onPoint       = item.transform;
                        Vector3   temp          = onPoint.position - palmTransform.position;
                        float     tempValue     = Vector3.Dot(temp, palmTransform.up);
                        if (tempValue < 0)
                        {
                            float angelUpWorld = Vector3.Angle(palmTransform.transform.up, Hi5_Interaction_Object_Manager.GetObjectManager().transform.up);
                            //Debug.Log("angelUpWorld=" + angelUpWorld);
                            if (angelUpWorld < 45.0f && angelUpWorld > 0.0f)
                            {
                                middleObjectId   = collisionMiddles[i];
                                fingerMiddleType = Hi5_Glove_Interaction_Finger_Type.EMiddle;
                                //return true;
                            }

                            else
                            {
                                middleObjectId   = -1;
                                fingerMiddleType = Hi5_Glove_Interaction_Finger_Type.ENone;
                                //return false;
                            }
                        }
                    }
                }
            }


            int indexObjectId = -1;
            Hi5_Glove_Interaction_Finger_Type fingerIndexType = Hi5_Glove_Interaction_Finger_Type.ENone;
            {
                //index
                if (index && collisionIndexs != null && collisionIndexs.Count > 0)
                {
                    for (int i = 0; i < collisionIndexs.Count; i++)
                    {
                        int idObject = collisionIndexs[i];
                        Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(idObject);
                        //判断夹角
                        Transform palmTransform = Hand.mPalm.transform;
                        Transform onPoint       = item.transform;
                        Vector3   temp          = onPoint.position - palmTransform.position;
                        float     tempValue     = Vector3.Dot(temp, palmTransform.up);
                        if (tempValue < 0)
                        {
                            float angelUpWorld = Vector3.Angle(palmTransform.transform.up, Hi5_Interaction_Object_Manager.GetObjectManager().transform.up);
                            //Debug.Log("angelUpWorld=" + angelUpWorld);
                            if (angelUpWorld < 45.0f && angelUpWorld > 0.0f)
                            {
                                indexObjectId   = collisionIndexs[i];
                                fingerIndexType = Hi5_Glove_Interaction_Finger_Type.EIndex;
                                //return true;
                            }
                            else
                            {
                                indexObjectId   = -1;
                                fingerIndexType = Hi5_Glove_Interaction_Finger_Type.ENone;
                                //return false;
                            }
                        }
                    }
                }
            }

            int ringObjectId = -1;
            Hi5_Glove_Interaction_Finger_Type fingerRingType = Hi5_Glove_Interaction_Finger_Type.ENone;

            {
                //ring
                if (ring && collisionRings != null && collisionRings.Count > 0)
                {
                    for (int i = 0; i < collisionRings.Count; i++)
                    {
                        int idObject = collisionRings[i];
                        Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(idObject);
                        //判断夹角
                        Transform palmTransform = Hand.mPalm.transform;
                        Transform onPoint       = item.transform;
                        Vector3   temp          = onPoint.position - palmTransform.position;
                        float     tempValue     = Vector3.Dot(temp, palmTransform.up);
                        if (tempValue < 0)
                        {
                            float angelUpWorld = Vector3.Angle(palmTransform.transform.up, Hi5_Interaction_Object_Manager.GetObjectManager().transform.up);
                            if (angelUpWorld < 45.0f && angelUpWorld > 0.0f)
                            {
                                ringObjectId   = collisionRings[i];
                                fingerRingType = Hi5_Glove_Interaction_Finger_Type.EMiddle;
                                //return true;
                            }

                            else
                            {
                                ringObjectId   = -1;
                                fingerRingType = Hi5_Glove_Interaction_Finger_Type.ENone;
                                //return false;
                            }
                        }
                    }
                }
            }

            if (middleObjectId != -1 && indexObjectId != -1 && middleObjectId == indexObjectId)
            {
                objectId      = middleObjectId;
                fingerOneType = Hi5_Glove_Interaction_Finger_Type.EMiddle;
                fingerTwoType = Hi5_Glove_Interaction_Finger_Type.EIndex;
                return(true);
            }
            if (middleObjectId != -1 && ringObjectId != -1 && middleObjectId == ringObjectId)
            {
                objectId      = middleObjectId;
                fingerOneType = Hi5_Glove_Interaction_Finger_Type.EMiddle;
                fingerTwoType = Hi5_Glove_Interaction_Finger_Type.ERing;
                return(true);
            }
            if (indexObjectId != -1 && ringObjectId != -1 && indexObjectId == ringObjectId)
            {
                objectId      = ringObjectId;
                fingerOneType = Hi5_Glove_Interaction_Finger_Type.EIndex;
                fingerTwoType = Hi5_Glove_Interaction_Finger_Type.ERing;
                return(true);
            }

            else
            {
                objectId      = -1;
                fingerOneType = Hi5_Glove_Interaction_Finger_Type.ENone;
                fingerTwoType = Hi5_Glove_Interaction_Finger_Type.ENone;
                return(false);
            }
        }
Пример #4
0
 internal protected bool IsTriggerObjectById(Hi5_Glove_Interaction_Finger_Type finger_type)
 {
     return(mFingers[finger_type].IsCollider());
 }