Example #1
0
    public override bool Detected()
    {
        DetectionManager.DetectionHand specifiedHand = DetectionManager.Get().GetHand(m_Hand);

        if (!DetectionManager.Get().IsHandSet(m_Hand))
        {
            return(false);
        }

        for (int i = 0; i < 5; i++)
        {
            EFinger type = EFinger.eThumb + i;

            if (type != EFinger.eIndex)
            {
                if (specifiedHand.GetFinger(type).IsExtended())
                {
                    return(false);
                }
            }
        }

        bool bIndexExtended = specifiedHand.GetFinger(EFinger.eIndex).IsExtended();

        return(bIndexExtended);
    }
    public override bool JustifiesRequirement(EHand Hand, GestureRequirementData RequirementData)
    {
        DetectionManager.DetectionHand SelectedHand = DetectionManager.Get().GetHand(Hand);
        if (SelectedHand.IsSet())
        {
            Vector3 FingerDirection = SelectedHand.GetFinger(RequirementData.m_FingerValue).GetFingerDirection();

            DetectionManager.DetectionFinger SelectedFinger = SelectedHand.GetFinger(RequirementData.m_FingerValue);

            Vector3 Bone1Dir = SelectedFinger.GetBoneDirection(ESpecificBone.eBone0);
            Vector3 Bone2Dir = SelectedFinger.GetBoneDirection(ESpecificBone.eBone1);
            Vector3 Bone3Dir = SelectedFinger.GetBoneDirection(ESpecificBone.eBone2);

            float boneDot;

            if (RequirementData.m_FingerValue == EFinger.eThumb)
            {
                boneDot = Mathf.Clamp(Vector3.Dot(Bone2Dir, Bone3Dir), 0.0f, 1.0f);
            }
            else
            {
                boneDot = Mathf.Clamp(Vector3.Dot(Bone1Dir, Bone3Dir), 0.0f, 1.0f);
            }

            float percentage = Mathf.Lerp(1.0f, 0.0f, boneDot);

            if (percentage > RequirementData.m_FloatValue)
            {
                return(true);
            }
        }

        return(false);
    }
    public override bool Detected()
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

        if (detectHand.IsSet())
        {
            if (detectHand.GetFinger(EFinger.eThumb).IsExtended())
            {
                for (int i = (int)EFinger.eThumb; i <= (int)EFinger.ePinky; i++)
                {
                    EFinger finger = EFinger.eThumb + i;

                    if (finger != EFinger.eThumb && finger != EFinger.eUnknown)
                    {
                        if (detectHand.GetFinger(finger).IsExtended())
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
        }

        return(false);
    }
Example #4
0
    //Get the current hand direction
    EDirection GetClosestDirection(ref bool a_bDetected)
    {
        DetectionManager.DetectionHand detectionHand = DetectionManager.Get().GetHand(m_Hand);

        if (!detectionHand.IsSet())
        {
            a_bDetected = false;
            return(EDirection.eDownwards);
        }

        Vector3 handDirection = detectionHand.GetHandAxis(m_HandAxis);

        float      currentDistance = float.MaxValue;
        EDirection currentDir      = EDirection.eUpwards;

        foreach (EDirection dir in m_DirectionMap.Keys)
        {
            float newDistance = Vector3.Distance(handDirection, m_DirectionMap[dir]);

            if (newDistance < currentDistance)
            {
                currentDistance = newDistance;
                currentDir      = dir;
                a_bDetected     = true;
            }
        }

        return(currentDir);
    }
Example #5
0
    public override bool Detected()
    {
        if (!DetectionManager.Get().IsHandSet(m_Hand))
        {
            return(false);
        }

        m_DetectHand = DetectionManager.Get().GetHand(m_Hand);

        bool bExtended = false;

        for (int i = 0; i < (int)EFinger.ePinky; i++)
        {
            EFinger finger = EFinger.eThumb + i;

            if (m_DetectHand.GetFinger(finger).IsExtended())
            {
                if (finger == m_Finger)
                {
                    bExtended = true;
                }
                else
                {
                    if (m_OthersClosed)
                    {
                        return(false);
                    }
                }
            }
        }

        return(bExtended);
    }
Example #6
0
    static bool ThumbExtended(EHand Hand)
    {
        DetectionManager.DetectionHand CurrentHand = DetectionManager.sInstance.GetHand(Hand);
        if (CurrentHand.IsSet())
        {
            return(CurrentHand.GetFinger(EFinger.eIndex).IsExtended());
        }

        return(false);
    }
Example #7
0
    public override bool Detected()
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

        if (detectHand.IsSet())
        {
            return(detectHand.CheckWithDetails(m_GestureDetail));
        }

        return(false);
    }
Example #8
0
    public override bool JustifiesRequirement(EHand Hand, GestureRequirementData RequirementData)
    {
        DetectionManager.DetectionHand SelectedHand = DetectionManager.Get().GetHand(Hand);
        if (SelectedHand.IsSet())
        {
            if (RequirementData.m_BoolValue == SelectedHand.GetFinger(RequirementData.m_FingerValue).IsExtended())
            {
                return(true);
            }
        }

        return(false);
    }
Example #9
0
    public override bool Detected()
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

        EFinger indexFinger = EFinger.eThumb + 1;

        if (detectHand.IsSet())
        {
            if (detectHand.CheckWithDetails(m_GestureDetail))
            {
                var rot = detectHand.GetRotation();

                if (timeBegin == false)
                {
                    timeElapsed = timeReset;
                    timeBegin   = true;
                }

                //Debug.DrawRay(detectHand.GetFinger(indexFinger).GetTipPosition(), detectHand.GetFinger(indexFinger).GetFingerDirection() * 3.0f, Color.white);
                //Debug.DrawRay(DetectionManager.Get().GetHand(m_Hand).GetHandPosition(), detectionHand.GetHandAxis(m_HandAxis) * 1000, Color.red);


                //Debug.Log(stayTime);


                if (rot.x > 0.25f && m_CoolDownLeft <= 0.0f && timeElapsed >= 3.5f && timeElapsed <= 8.0f && timeBegin)
                {
                    m_CoolDownLeft = m_CooldownTime;
                    GameObject projectile = Instantiate(prefab) as GameObject;
                    var        spawn      = detectHand.GetFinger(indexFinger).GetTipPosition();

                    projectile.transform.position = spawn;
                    Rigidbody rb = projectile.GetComponent <Rigidbody>();
                    //var di = detectHand.GetFinger(indexFinger).GetFingerDirection();
                    //di.y -= 0.6f;
                    // di.z += 0.3f;
                    //di.x += 0.2f;
                    //rb.AddForce(Camera.main.transform.forward * 20f, ForceMode.VelocityChange);
                    rb.velocity = Vector3.forward * 8;
                    timeBegin   = false;
                }


                return(true);
            }
        }

        return(false);
    }
    public override bool Detected()
    {
        if (DetectionManager.Get().IsHandSet(m_Hand))
        {
            DetectionManager.DetectionHand hand = DetectionManager.Get().GetHand(m_Hand);

            return(hand.IsFingerExtended(EFinger.eIndex) &&
                   hand.IsFingerExtended(EFinger.eMiddle) &&
                   !hand.IsFingerExtended(EFinger.eThumb) &&
                   !hand.IsFingerExtended(EFinger.eRing) &&
                   !hand.IsFingerExtended(EFinger.ePinky));
        }

        return(false);
    }
    bool IsSwiping(ref EDirection a_swipeDirection, float InVelocity, EHand InHand)
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(InHand);

        if (!detectHand.IsSet())
        {
            a_swipeDirection = EDirection.eOutwards;
            return(false);
        }

        Vector3 velocity = detectHand.GetVelocity();

        velocity = Camera.main.transform.InverseTransformDirection(velocity);

        if (velocity.x >= InVelocity) //right
        {
            a_swipeDirection = EDirection.eRight;
            return(true);
        }
        else if (velocity.x <= -InVelocity)//left
        {
            a_swipeDirection = EDirection.eLeft;
            return(true);
        }
        else if (velocity.y >= InVelocity) //up
        {
            a_swipeDirection = EDirection.eUpwards;
            return(true);
        }
        else if (velocity.y <= -InVelocity)//down
        {
            a_swipeDirection = EDirection.eDownwards;
            return(true);
        }
        else if (velocity.z >= InVelocity) //forward
        {
            a_swipeDirection = EDirection.eOutwards;
            return(true);
        }
        else if (velocity.z <= -InVelocity)//back
        {
            a_swipeDirection = EDirection.eInWards;
            return(true);
        }

        return(false);
    }
 void HandPunch(EHand InHand)
 {
     DetectionManager.DetectionHand DetectHand = DetectionManager.Get().GetHand(InHand);
     if (DetectHand.IsSet())
     {
         if (rb)
         {
             rb.useGravity = true;
             PunchBagCollider.isTrigger = false;
             rb.AddForce(DetectHand.GetVelocity() * 200);
             CurrentPunchState = EPunchingBagState.PunchState;
             if (SpawnedBy)
             {
                 SpawnedBy.StartSpawnTimer();
             }
         }
     }
 }
Example #13
0
    void IsHandAllExtended()
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

        if (detectHand.IsSet())
        {
            if (detectHand.CheckWithDetails(m_GestureDetail))
            {
                m_IsHandAllExtended = true;
                Debug.Log("success");
                //m_menumanager.PresentingthisObjectMenu();
                alreadyFist = false;
                //reset
                return;
            }
        }
        //m_IsHandAllExtended = false;
    }
Example #14
0
    void Update()
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

        if (detectHand.IsSet())
        {
            if (bSpawnBullet && bGunActive)
            {
                bSpawnBullet = false;

                Vector3 dir = detectHand.GetDirectionToFingers();
                dir.Normalize();
                Vector3 startPos = detectHand.GetFinger(EFinger.eIndex).GetTipPosition();

                GameObject obj = Instantiate(m_Bullet, startPos, m_Bullet.transform.rotation);
                obj.GetComponent <Rigidbody>().velocity = dir * m_Speed;
            }
        }
    }
Example #15
0
    public override bool Detected()
    {
        if (DetectionManager.Get().AreBothHandsVisible() && m_CoolDownLeft <= 0.0f)
        {
            DetectionManager.DetectionHand leftHand  = DetectionManager.Get().GetHand(EHand.eLeftHand);
            DetectionManager.DetectionHand rightHand = DetectionManager.Get().GetHand(EHand.eRightHand);

            if (leftHand.GetVelocity().magnitude >= m_SpeedThreshold &&
                rightHand.GetVelocity().magnitude >= m_SpeedThreshold)
            {
                if (DetectionManager.Get().GetDistanceBetweenHands() <= m_handDistance)
                {
                    m_CoolDownLeft = m_CooldownTime;
                    return(true);
                }
            }
        }

        return(false);
    }
Example #16
0
    public override bool Detected()
    {
        EFinger thumbFinger  = EFinger.eThumb;
        EFinger middleFinger = EFinger.eThumb + 2;

        m_DetectHand = DetectionManager.Get().GetHand(m_Hand);

        if (m_DetectHand.IsSet())
        {
            if (m_DetectHand.CheckWithDetails(m_GestureDetail))
            {
                //Debug.Log("ok");
                //Debug.DrawRay(m_DetectHand.GetFinger(indexFinger).GetTipPosition(), m_DetectHand.GetFinger(indexFinger).GetFingerDirection() * 1000, Color.white);
                snap = true;

                /*var thumbTipPosition = m_DetectHand.GetFinger(thumbFinger).GetTipPosition();
                 * var middleTipPosition = m_DetectHand.GetFinger(middleFinger).GetTipPosition();
                 * float distance = Vector3.Distance(thumbTipPosition, middleTipPosition);
                 * Debug.Log(distance);
                 * if (distance < DeactivateDistance)
                 *  return true;*/
                gapLeft = timeGap;
            }

            //Debug.Log(gapLeft);
            if (snap && gapLeft > 0.0f)
            {
                var   thumbTipPosition  = m_DetectHand.GetFinger(thumbFinger).GetTipPosition();
                var   middleTipPosition = m_DetectHand.GetFinger(middleFinger).GetTipPosition();
                float distance          = Vector3.Distance(thumbTipPosition, middleTipPosition);
                // Debug.Log(distance);
                if (distance < 0.02f)
                {
                    // Debug.Log("snap");
                    return(true);
                }
            }
        }

        return(false);
    }
Example #17
0
    bool IsSwiping(ref EDirection a_swipeDirection)
    {
        DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

        Vector3 velocity = detectHand.GetVelocity();

        if (velocity.x >= m_VelocityThreshold) //right
        {
            a_swipeDirection = EDirection.eRight;
            return(true);
        }
        else if (velocity.x <= -m_VelocityThreshold)//left
        {
            a_swipeDirection = EDirection.eLeft;
            return(true);
        }
        else if (velocity.y >= m_VelocityThreshold) //up
        {
            a_swipeDirection = EDirection.eUpwards;
            return(true);
        }
        else if (velocity.y <= -m_VelocityThreshold)//down
        {
            a_swipeDirection = EDirection.eDownwards;
            return(true);
        }
        else if (velocity.z >= m_VelocityThreshold) //forward
        {
            a_swipeDirection = EDirection.eOutwards;
            return(true);
        }
        else if (velocity.z <= -m_VelocityThreshold)//back
        {
            a_swipeDirection = EDirection.eInWards;
            return(true);
        }

        return(false);
    }
Example #18
0
    public void onGestureEnd()
    {
        if (pinching == null)
        {
            return;
        }
        CardBehavior cb = pinching.GetComponent <CardBehavior>();

        cb.pinched = false;

        DetectionManager.DetectionHand rightHand = DetectionManager.Get().GetHand(EHand.eRightHand);

        //pinching.GetComponent<Rigidbody>().velocity = rightHand.GetFinger(EFinger.eIndex).GetTipVelocity();
        pinching.GetComponent <Rigidbody>().velocity = rightHand.GetVelocity();
        Debug.Log(rightHand.GetVelocity().ToString());
        //Debug.Log(rightHand.GetFinger(EFinger.eThumb+1).GetTipVelocity().ToString());

        pinching.transform.parent = null;
        pinching = null;

        //TBD: after release a card,
    }
Example #19
0
    public override bool Detected()
    {
        bool       bFound           = false;
        EDirection currentDirection = GetClosestDirection(ref bFound);

        if (bFound)
        {
            if (currentDirection == m_Direction)
            {
                DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand);

                if (detectHand.IsSet())
                {
                    if (detectHand.GetFinger(EFinger.eThumb).IsExtended())
                    {
                        for (int i = (int)EFinger.eThumb; i <= (int)EFinger.ePinky; i++)
                        {
                            EFinger finger = EFinger.eThumb + i;

                            if (finger != EFinger.eThumb && finger != EFinger.eUnknown)
                            {
                                if (detectHand.GetFinger(finger).IsExtended())
                                {
                                    return(false);
                                }
                            }
                        }

                        return(true);
                    }
                }
            }
        }

        return(false);
    }
Example #20
0
 public void UpdateData()
 {
     game.SetActive(true);
     DetectionManager.DetectionHand detectHand_R = DetectionManager.Get().GetHand(EHand.eRightHand);
     game.transform.position = detectHand_R.GetFinger(EFinger.eIndex).GetTipPosition();
 }
Example #21
0
    public void onGestureStay()
    {
        if (DetectionManager.Get().IsHandSet(m_Hand))
        {
            // Detect index finger
            m_DetectHand = DetectionManager.Get().GetHand(m_Hand);
            EFinger finger = EFinger.eThumb + 1;

            // Do raycast here
            if (DetectionManager.Get().GetHand(m_Hand).IsPinching())
            {
                RaycastHit hit;

                // Draw ray
                Debug.DrawRay(m_DetectHand.GetFinger(finger).GetTipPosition(), m_DetectHand.GetFinger(finger).GetFingerDirection() * 0.06f, Color.white);

                if (pinching != null)
                {
                    return;
                }

                // Draw ray for palm instead
                //Debug.DrawRay(DetectionManager.Get().GetHand(m_Hand).GetHandPosition(), transform.TransformDirection(Vector3.forward) * 1000, Color.white);

                if (Physics.Raycast(m_DetectHand.GetFinger(finger).GetTipPosition(), m_DetectHand.GetFinger(finger).GetFingerDirection(), out hit, 0.06f)) // need a length limit on raycast
                {
                    if (hit.collider.tag == "Card")
                    {
                        Debug.Log("YEET");
                        //hit.collider.gameObject.transform.parent = parentObject.transform;

                        /*
                         * testObject.transform.parent = parentObject.transform;
                         * vector = parentObject.transform.position;
                         * vector.z += 0.25f;
                         */

                        GameObject   go = hit.collider.gameObject;
                        CardBehavior cb = go.GetComponent <CardBehavior>();
                        DeckBehavior db = deck.GetComponent <DeckBehavior>();
                        if (db.cardsInHand.Contains(cb)) // the card pinched is in hand
                        {
                            db.HandToPinch(go);
                        }
                        else // the card pinched is in wild
                        {
                            cb.pinched = true;
                        }


                        go.transform.parent = parentObject.transform;

                        pinching = go;

                        //vector = testObject.transform.position - parentObject.transform.position;
                        //testObject.transform.position = vector;
                        //testObject.transform.position = parentObject.transform.position + translateVector;
                        //hit.collider.gameObject.GetComponent<Rigidbody>().useGravity = false;
                    }
                }
            } // End raycast
        }
    }