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 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); }
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); }
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() { 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 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); }
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); }
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 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 } }
public void UpdateData() { game.SetActive(true); DetectionManager.DetectionHand detectHand_R = DetectionManager.Get().GetHand(EHand.eRightHand); game.transform.position = detectHand_R.GetFinger(EFinger.eIndex).GetTipPosition(); }