//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); }
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); }
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); }
static bool ThumbExtended(EHand Hand) { DetectionManager.DetectionHand CurrentHand = DetectionManager.sInstance.GetHand(Hand); if (CurrentHand.IsSet()) { return(CurrentHand.GetFinger(EFinger.eIndex).IsExtended()); } return(false); }
public override bool Detected() { DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand); if (detectHand.IsSet()) { return(detectHand.CheckWithDetails(m_GestureDetail)); } return(false); }
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); }
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); }
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 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; }
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(); } } } }
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; } } }
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); }
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); }