Inheritance: MonoBehaviour
Exemplo n.º 1
0
    //Draws a line straight forward from the index finguer
    public Vector3 getShootingFingerPoint(int index)
    {
        FingerModel finger = hand_model.fingers[index];

        Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red);

        Ray finger_ray = new Ray(finger.GetTipPosition(), finger.GetRay().direction);

        RaycastHit hit;
        Vector3    shooting_point;

        bool collision = Physics.Raycast(finger_ray, out hit);

        if (collision)
        {
            shooting_point = hit.point;
        }
        else
        {
            int infinite_distance = 100;
            shooting_point = finger_ray.origin + (finger_ray.direction.normalized * infinite_distance);
        }

        return(shooting_point);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Do a raycast from each finger of a hand.
    /// </summary>
    /// <param name="castDistance"> The distance the raycast should check.</param>
    /// <param name="rayIsEmpty"> If the ray is the 'empty' default ray that returns when no valid raycast hits.</param>
    /// <returns>A RaycastHit. If rayIsEmpty is false then this hit is the first hit from a finger onto an object.</returns>
    public RaycastHit RaycastFromFingers(float castDistance, out bool rayIsEmpty)
    {
        RaycastHit hit;
        bool       raycastHit;

        //Iterate through each finger
        for (int i = 0; i < HandModel.NUM_FINGERS; i++)
        {
            FingerModel finger = hand_model.fingers[i]; //This is sometimes null? Apparently? Not sure why?

            // draw ray from finger tips (enable Gizmos in Game window to see)
            Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red);

            //Do actual raycast
            raycastHit = Physics.Raycast(finger.GetTipPosition(), finger.GetRay().direction, out hit, castDistance);

            if (raycastHit == true)
            {
                rayIsEmpty = false;
                return(hit);
            }
        }

        rayIsEmpty = true;

        //Default raycast, should never actually be called
        raycastHit = Physics.Raycast(Vector3.zero, Vector3.one, out hit, castDistance);
        return(hit);
    }
Exemplo n.º 3
0
 void OnTriggerEnter(Collider collider)
 {
     if (IsFinger(collider) && gm.getColorChoserActive()) {
         if (!hasSphere)
         {
             fingerModel = collider.gameObject.GetComponentInParent<FingerModel>();
             f = fingerModel.GetLeapFinger();
     //                Debug.Log(f);
             if(fingerModel.fingerType.ToString().Equals("TYPE_INDEX"))
             {
                 col = collider;
                 // Neue Sphere erstellen mit der Farbe vom Bucket
                 QuizManager.setHasColor(true);
                 Destroy(drop);
                 Colors.drop = Instantiate(Resources.Load("Drop")) as GameObject;
                 Colors.drop.transform.position = new Vector3(0, 1.5F, 0);
                 Colors.drop.transform.localScale = new Vector3(0.5F,0.5F,0.5F);
                 Renderer m = Colors.drop.GetComponent<Renderer>();
                 QuizManager.shaderName = bucketMat.name;
                 m.material = bucketMat;
                 Colors.drop.transform.position = fingerModel.GetTipPosition();
                 hasSphere = true;
                 QuizManager.setHasColor(true);
             }
         }
     }
     if (IsHand(collider))
     {
      //           print("Hand berührt");
     }
 }
Exemplo n.º 4
0
    void Update()
    {
        FingerModel finger = hand_model.fingers[1];

        line = GetComponent <LineRenderer>();
        RaycastHit hit;

        Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red);
        Physics.Raycast(finger.GetTipPosition(), finger.GetRay().direction, out hit, Mathf.Infinity);

        line.SetWidth(0.01f, 0.01f);

        Vector3[] points = new Vector3[2];
        points[0] = finger.GetTipPosition();
        points[1] = finger.GetTipPosition() + 1000 * finger.GetRay().direction;

        line.SetPositions(points);

        if (Input.GetKey(KeyCode.Space))
        {
            audio.Play();
            if (hit.transform.tag == "TARGET")
            {
                hit.transform.gameObject.SendMessage("Ding", targetHandler);
            }
            else
            {
            }
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Disegna prendendo il dito indice come riferimento.
    /// </summary>
    public void Draw()
    {
        //guarda se le dita sono nella giusta posizione
        if (!leftHand.GetComponent <ManageLeft>().IsFaceUp())
        {
            //prende come riferimento il dito indice
            FingerModel finger = hand_model.fingers[1];
            RaycastHit  hit;
            //guardo se il raycost colpisce la tela
            if (Physics.Raycast(finger.GetTipPosition(), Vector3.forward, 1000))
            {
                Debug.Log("Tela colpita");
                //prendo la posizone del punto in cui è stata colpita la tela
                Debug.DrawRay(finger.GetTipPosition(), Vector3.forward, Color.red);
            }
            //prendo la texture dalla tela
            Texture2D tex = (Texture2D)tela.GetComponent <Renderer>().material.mainTexture;

            //disegno sulla tela
            tex = DrawCircle(tex, color, (int)(tex.width * (finger.GetTipPosition().x + 0.5)), (int)(tex.height * (finger.GetTipPosition().y - 3.5)), brushSize);
            //Debug.Log("X: " + finger.GetTipPosition().x);
            //Debug.Log("Y: " + finger.GetTipPosition().z);
            //Debug.Log("XT: " + (tex.width * (finger.GetTipPosition().x + width / 2)));
            //Debug.Log("YT: " + (tex.height * (finger.GetTipPosition().z + height / 2)));
            // applica il disegno sulla tela
            tex.Apply();
        }
    }
Exemplo n.º 6
0
        FingerPose SaveFinger(FingerModel fingerModel)
        {
            if (!fingerModel)
            {
                return(SaveFinger());
            }

            List <AbstractTsf> bones = new List <AbstractTsf>();

            for (int b = 0; b < fingerModel.bonesFromRootToTip.Count; b++)
            {
                bones.Add(new AbstractTsf(
                              fingerModel.bonesFromRootToTip[b].master.localPosition,
                              fingerModel.bonesFromRootToTip[b].master.localRotation,
                              Space.Self,
                              fingerModel.bonesFromRootToTip[b].master.transformRef.localScale,
                              fingerModel.bonesFromRootToTip[b].master.transformRef.name));
            }

            FingerPose fingerPose = new FingerPose(fingerModel.finger);

            fingerPose.bones = bones;

            return(fingerPose);
        }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        FingerModel finger = handmodel.fingers [1];

        Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red);
        InterfaceManager.Instance.leapMotionManager.screenPointToRay = finger.GetRay();
    }
Exemplo n.º 8
0
        // Update is called once per frame
        void Update()
        {
            FingerModel index = GetIndex();
            FingerModel thumb = GetThumb();

            if (index != null && thumb != null)
            {
                AnimateCursor(index, thumb);
                SetPinchAnimation();
                switch (GetPinch())
                {
                case 1:
                    state = PinchState.Full;
                    break;

                case 2:
                    state = PinchState.Part;
                    break;

                case 3:
                    state = PinchState.Open;
                    break;
                }
            }
            else
            {
                state = PinchState.NoHands;
            }

            SetFingerSpritePosition(index, thumb);
        }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        HandModel[] allGraphicHands = LeapHandController.GetAllGraphicsHands();

        if (allGraphicHands.Length <= 0) return;
        HandModel handModel = allGraphicHands[0];

        finger = handModel.fingers[(int)Finger.FingerType.TYPE_INDEX];

        fingerTipPos = finger.GetTipPosition();

        fingerdetect = (Input.GetKey(KeyCode.Space));

        if (fingerdetect)
        {
            // Using named temp variables like this helps me think more clearly about the code
            Vector3 previousPoint = (linePoints.Count > 0) ? linePoints[linePoints.Count - 1] : new Vector3(-1000, -1000, -1000); // If you've never seen this before, it's called a ternary expression.
                                                                                                        // It's just an if/else collapsed into a single line of code.
                                                                                                        // Also, the crazy out of bounds initial value here ensures the starting point will always draw.

            if (Vector3.Distance(fingerTipPos, previousPoint) > newPointDelta)
            {
                linePoints.Add(fingerTipPos);
                lineRenderer.SetVertexCount(linePoints.Count);
                lineRenderer.SetPosition(linePoints.Count - 1, (Vector3)linePoints[linePoints.Count - 1]);
                Debug.Log(string.Format("Added point at: {0}!", fingerTipPos));
            }
        }
    }
Exemplo n.º 10
0
        void EmitFingerEvents(FingerModel finger, FingerViewModel viewModel, bool wasPinching)
        {
            // Pinch events
            if (finger.isPinching != wasPinching)
            {
                if (finger.isPinching)
                {
                    viewModel.onPinch.Invoke();
                }
                else
                {
                    viewModel.onUnpinch.Invoke();
                }
            }

            // Pinch intention events
            if (finger.pinchIntentionLerp == 1.0f && !finger.isIntentionallyPinching)
            {
                finger.isIntentionallyPinching = true;
                viewModel.onLongPinch.Invoke();
            }
            else if (finger.pinchIntentionLerp == 0.0f && finger.isIntentionallyPinching)
            {
                finger.isIntentionallyPinching = false;
                viewModel.onLongUnpinch.Invoke();
            }
        }
Exemplo n.º 11
0
        public static float GetFingerLength(FingerModel finger, float scale)
        {
            float length = 0.0f;

            bool ignore = true;

            for (int i = 0; i < finger.bones.Length; i++)
            {
                if (finger.bones[i].transformRef == finger.fingerBase)
                {
                    ignore = false;
                }

                if (!ignore)
                {
                    if (i != finger.bones.Length - 1)
                    {
                        length += Vector3.Distance(finger.bones[i].transformRef.position, finger.bones[i + 1].transformRef.position);
                    }
                    else
                    {
                        length += Vector3.Distance(finger.bones[i].transformRef.position, finger.fingerTip.position);
                    }
                }
            }

            return(length / scale);
        }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        gameController = GameController.Instance;

        handModel = GetComponent <HandModel> ();
        thumb     = handModel.fingers [0];
        index     = handModel.fingers [1];

        GameObject middlePointContainerGO = new GameObject();

        middlePointContainerGO.AddComponent <MiddlePointContainer> ().SetPicker(this);
        middlePointContainer        = middlePointContainerGO.transform;
        middlePointContainer.parent = gameObject.transform;

        middlePointContainer.gameObject.AddComponent <Rigidbody> ();
        middlePointContainer.rigidbody.isKinematic = true;

        middlePoint           = middlePointContainer.gameObject.AddComponent <SphereCollider> ();
        middlePoint.radius    = 0.001953125f;      // / transform.localScale.x;
        middlePoint.isTrigger = true;

        Transform pointer = (Transform)Instantiate(PointerPrefab);

        pointer.parent = middlePointContainer;
    }
Exemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        HandModel[] allGraphicHands = LeapHandController.GetAllGraphicsHands();

        if (allGraphicHands.Length <= 0)
        {
            return;
        }
        HandModel handModel = allGraphicHands[0];

        finger = handModel.fingers[(int)Finger.FingerType.TYPE_INDEX];

        fingerTipPos = finger.GetTipPosition();

        fingerdetect = (Input.GetKey(KeyCode.Space));

        if (fingerdetect)
        {
            // Using named temp variables like this helps me think more clearly about the code
            Vector3 previousPoint = (linePoints.Count > 0) ? linePoints[linePoints.Count - 1] : new Vector3(-1000, -1000, -1000); // If you've never seen this before, it's called a ternary expression.
            // It's just an if/else collapsed into a single line of code.
            // Also, the crazy out of bounds initial value here ensures the starting point will always draw.

            if (Vector3.Distance(fingerTipPos, previousPoint) > newPointDelta)
            {
                linePoints.Add(fingerTipPos);
                lineRenderer.SetVertexCount(linePoints.Count);
                lineRenderer.SetPosition(linePoints.Count - 1, (Vector3)linePoints[linePoints.Count - 1]);
                Debug.Log(string.Format("Added point at: {0}!", fingerTipPos));
            }
        }
    }
Exemplo n.º 14
0
 void ApplyFinger(FingerPose pose, FingerModel finger)
 {
     if (finger)
     {
         PoseHelpers.ApplyFingerPose(pose, finger, representation, applyPos, applyRot, applyScale, applyInverted);
     }
 }
Exemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     for (int i = 0; i < HandModel.NUM_FINGERS; i++)
     {
         FingerModel finger = hand_model.fingers[i];
         Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red);
     }
 }
Exemplo n.º 16
0
    void Update()
    {
        FingerModel finger = hand_model.fingers[1];

        Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.blue);
        RaycastHit hit;

        isHit = Physics.Raycast(finger.GetTipPosition(), finger.GetRay().direction, out hit);

        if (isHit)
        {
            if (hit.transform.gameObject.name == "GeoSphere346")
            {
                isShow = !isShow;
                Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.clear);

                /* print("风池(足少阳胆经)【定位】在颈后区,枕骨下,胸锁乳突肌上端与斜方肌上端之间的凹陷中  【解剖】浅层布有枕小神经,枕动静脉的分支和属支。深层有枕大神经。  【针刺层次】皮肤——>皮下组织——>头夹肌——>头半棘肌  【主治】1.头痛,眩晕,失眠,癫痫,中风  2.目赤肿痛,视物不明,鼻塞,鼻窦,鼻渊,耳鸣,咽喉肿痛  3.感冒,热病  4.颈项强痛 ");
                 * print("【定位】在颈后区,枕骨下,胸锁乳突肌上端与斜方肌上端之间的凹陷中");
                 * print("【解剖】浅层布有枕小神经,枕动静脉的分支和属支。深层有枕大神经。");
                 * print("【针刺层次】皮肤——>皮下组织——>头夹肌——>头半棘肌");
                 * print("【主治】1.头痛,眩晕,失眠,癫痫,中风  2.目赤肿痛,视物不明,鼻塞,鼻窦,鼻渊,耳鸣,咽喉肿痛  3.感冒,热病  4.颈项强痛 ");*/
                //selectedObject = null;
            }
            if (hit.transform.gameObject.name == "GeoSphere347")
            {
                isShow = !isShow;
            }
            if (selectedObject != null && hit.transform.gameObject == selectedObject)
            {
                alreadyHit = true;
            }

            /*if (selectedObject != null && hit.transform.gameObject != selectedObject)
             * {
             *  alreadyHit = false;
             *  selectedObject.transform.GetComponent<MeshRenderer>().material.color = previousColour;
             *  selectedObject.transform.localScale = previousScale;
             *  selectedObject = hit.transform.gameObject;
             * }
             * selectedObject = hit.transform.gameObject;
             * if (selectedObject != null && !alreadyHit)
             * {
             *  Debug.Log(selectedObject.name);
             *  selectedObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
             *  MeshRenderer temp = selectedObject.GetComponent<MeshRenderer>();
             *  previousColour = temp.material.color;
             *  temp.material.color = Color.red;
             * }
             *
             * else if (selectedObject != null)
             * {
             *  alreadyHit = false;
             *  selectedObject.transform.GetComponent<MeshRenderer>().material.color = previousColour;
             *  selectedObject.transform.localScale = previousScale;
             *  selectedObject = null;
             * }*/
        }
    }
Exemplo n.º 17
0
 void Update()
 {
     for (int i = 0; i < HandModel.NUM_FINGERS; i++)
     {
         FingerModel finger = hand_model.fingers[i];
         // draw ray from finger tips (enable Gizmos in Game window to see)
         Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red);
     }
 }
 public void UpdateHand(FingerModel thumb, FingerModel index, FingerModel middle, FingerModel pinky,
                        FingerModel ring)
 {
     this.thumb.UpdateFinger(thumb);
     this.index.UpdateFinger(index);
     this.middle.UpdateFinger(middle);
     this.ring.UpdateFinger(ring);
     this.pinky.UpdateFinger(pinky);
 }
Exemplo n.º 19
0
 public void UpdateHand(FingerModel thumb, FingerModel index, FingerModel middle, FingerModel pinky,
                        FingerModel ring)
 {
     Thumb.UpdateFinger(thumb);
     Index.UpdateFinger(index);
     Middle.UpdateFinger(middle);
     Ring.UpdateFinger(ring);
     Pinky.UpdateFinger(pinky);
 }
Exemplo n.º 20
0
 void PrintFinger(FingerModel finger, TextMeshPro tmpro)
 {
     tmpro.text += "\n" + finger.name + "\n";
     tmpro.text += "Pinch: " + finger.pinchLerp + "\n";
     tmpro.text += "Pinch speed: " + finger.pinchSpeed + "\n";
     tmpro.text += "BaseRot: " + finger.baseRotationLerp + "\n";
     tmpro.text += "Flex: " + finger.flexLerp + "\n";
     tmpro.text += "Palm: " + finger.palmLineLerp + "\n";
     tmpro.text += "Strength: " + finger.strengthLerp + "\n";
 }
Exemplo n.º 21
0
        public static float GetPalmLineLerp(FingerModel finger, float maxRelDistance, float minRelDistance, float scale)
        {
            float maxAbsDistance = maxRelDistance * scale;
            float minAbsDistance = minRelDistance * scale;

            Vector3 nearestPointToLine = NearestPointOnFiniteLine(finger.hand.palmExterior.position, finger.hand.palmInterior.position, finger.fingerTip.position);
            float   distance           = Vector3.Distance(nearestPointToLine, finger.fingerTip.position);

            return(1.0f - Mathf.InverseLerp(minAbsDistance, maxAbsDistance, distance));
        }
Exemplo n.º 22
0
        public override sealed void InitGesture()
        {
            base.InitGesture();

            hand   = _model.finger.hand;
            finger = _model.finger;
            conf   = _model.parent.configuration;

            InitFingerGesture();
        }
Exemplo n.º 23
0
        public static Transform[] GetFingerTransforms(FingerModel finger)
        {
            Transform[] boneTransforms = new Transform[finger.bones.Length];

            for (int i = 0; i < boneTransforms.Length; i++)
            {
                boneTransforms[i] = finger.bones[i].transformRef;
            }

            return(boneTransforms);
        }
Exemplo n.º 24
0
 void SetFingerSpritePosition(FingerModel index, FingerModel thumb)
 {
     if (index != null)
     {
         fingerSprite.transform.position = TransformPosition(index.GetTipPosition());
     }
     if (thumb != null)
     {
         thumbSprite.transform.position = TransformPosition(thumb.GetTipPosition());
     }
 }
Exemplo n.º 25
0
        public static void changeFingerIDX(Leap.Unity.Chirality chirality, int fingerIDX, Color color)
        {
            PolyHand hand = right;

            if (chirality == Chirality.Left)
            {
                hand = left;
            }
            FingerModel finger = hand.fingers[fingerIDX];

            finger.GetComponent <MeshRenderer>().materials[0].color = color;
        }
Exemplo n.º 26
0
 void Update()
 {
     handModel = GetComponent <HandModel>();
     leapHand  = handModel.GetLeapHand();
     finger    = handModel.fingers[1];
     indexTip  = finger.GetTipPosition();
     AddPositionCache(indexTip);
     if (DetectCircleGesture() || DetectPolygonGesture())
     {
         // Detected!
     }
 }
Exemplo n.º 27
0
    private const float MIN_CONFIDENCE         = 0.2f;                                  //Minimum value of handmodel confidence
    #endregion

    // Update is called once per frame
    void Update()
    {
        //define LeapHands & Fingers
        handModel = GetComponent <HandModel> ();
        leapHand  = handModel.GetLeapHand();
        //get indexfinger
        indexFingerModel = handModel.fingers [1];
        //get indexfingerTip position
        indexTip = indexFingerModel.GetTipPosition();
        //get thumbTip position
        thumbTip = leapHand.Fingers [0].TipPosition.ToUnityScaled();

        //calculating velocity of finger
        currPosition = thumbTip;
        velocity     = (currPosition - prePosition).magnitude / Time.deltaTime;
        prePosition  = thumbTip;

        //Trigger test (true: thumbTip got close to rest of fingers)
        bool patternTrigger = false;

        for (int i = 1; i < 5 && !patternTrigger; ++i)
        {
            for (int j = 0; j < 4 && !patternTrigger; ++j)
            {
                Finger.FingerJoint joint      = (Finger.FingerJoint)(j);
                Vector3            difference = leapHand.Fingers[i].JointPosition(joint).ToUnityScaled() - thumbTip;
                if (difference.magnitude < THUMB_TRIGGER_DISTANCE &&
                    leapHand.Confidence > MIN_CONFIDENCE)
                {
                    //Trigger is ON
                    patternTrigger = true;
                }
            }
        }
        //Particle system On/Off
        switch (patternTrigger)
        {
        case (true):
            //Start recording finger position
            AddPositionCache(indexTip);
            transform.FindChild("particle").gameObject.SetActive(true);
            break;

        case (false):
            transform.FindChild("particle").gameObject.SetActive(false);
            break;
        }

        if (DetectFingerGesture())
        {
            //Detected!
        }
    }
Exemplo n.º 28
0
        void AnimateCursor(FingerModel index, FingerModel thumb)
        {
            Vector3 midPosition = (index.GetTipPosition() + thumb.GetTipPosition()) / 2;

            immediatePosition = (smoothCursor) ? Utils.ExponentialVectorSmoothing(immediatePosition, midPosition, cursorExp) : midPosition;
            if (state == PinchState.Open)
            {
                cursorPosition = immediatePosition;
            }
            curosrSprite.transform.position    = TransformPosition(cursorPosition);
            immediateSprite.transform.position = TransformPosition(immediatePosition);
        }
Exemplo n.º 29
0
        public static void ApplyHandPose(HandPoseAsset handPose, HandModel handDestination, string destinationReprKey, bool pos, bool rot, bool scale, bool inverted)
        {
            for (int f = 0; f < handDestination.fingers.Count; f++)
            {
                FingerModel finger = handDestination.fingers[f];
                FingerPose  pose   = handPose.fingers.Find(fng => fng.finger == finger.finger);

                if (pose != null)
                {
                    ApplyFingerPose(pose, finger, destinationReprKey, pos, rot, scale, inverted);
                }
            }
        }
    }     // END OF GUN GESTURE

    bool IsExtended(FingerModel finger)
    {
        // Is Finger not past forward and backward range
        if (((finger.bones[1].localEulerAngles.z - 360f) > forwardFingerRange) || (finger.bones[1].localEulerAngles.z < backwardFingerRange) ||
            ((finger.bones[2].localEulerAngles.z - 360f) > forwardFingerRange) || (finger.bones[2].localEulerAngles.z < backwardFingerRange))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }     // END OF IS EXTENDED
Exemplo n.º 31
0
    IEnumerator MoveLaser(FingerModel finger)
    {
        line.enabled = true;

        float rayLength = Vector3.Distance(finger.GetTipPosition(), selectedObject.transform.position);

        Ray ray = new Ray(finger.GetTipPosition(), finger.GetRay().direction);

        line.SetPosition(0, ray.origin);
        line.SetPosition(1, ray.GetPoint(rayLength));
        yield return(null);

        line.enabled = false;
    }
Exemplo n.º 32
0
 void OnTriggerEnter(Collider collider)
 {
     if (IsFinger(collider) && gm.getColorChoserActive() && QuizManager.getHasColor())
     {
         fingerModel = collider.gameObject.GetComponentInParent<FingerModel>();
         f = fingerModel.GetLeapFinger();
         controller = fingerModel.GetController();
         shoeRender.material = QuizManager.getChosenMaterial();
         //shoeRender.material = new Material(Shader.Find(QuizManager.shaderName));
         QuizManager.changedObjects.Add(shoeRender);
         QuizManager.setHasColor(false);
         Destroy(Colors.drop);
     }
 }
Exemplo n.º 33
0
        void InitFingerGestureGroup(FingerGesturesModel gestures, FingerModel model)
        {
            if (gestures && model)
            {
                gestures.finger = model;

                InitFingerGesture(gestures.pinch, gestures);
                InitFingerGesture(gestures.flex, gestures);
                InitFingerGesture(gestures.strength, gestures);
                InitFingerGesture(gestures.palmLine, gestures);
                InitFingerGesture(gestures.baseRotation, gestures);

                gestures.extra.ForEach(g => InitFingerGesture(g, gestures));
            }
        }
Exemplo n.º 34
0
 // Update is called once per frame
 void Update()
 {
     if (hasSphere)
     {
         try
         {
             fingerModel = col.gameObject.GetComponentInParent<FingerModel>();
             //Colors.sphere.transform.position = fingerModel.GetTipPosition();
             drop.transform.position = fingerModel.GetTipPosition();
             Vector3 pos = drop.transform.position;
             QuizManager.setColorMaterial(bucketMat);
         }
         catch (MissingReferenceException e)
         {
             hasSphere = !hasSphere;
             Destroy(Colors.sphere);
         }
     }
 }
				void AnimateCursor (FingerModel index, FingerModel thumb)
				{
						Vector3 midPosition = (index.GetTipPosition () + thumb.GetTipPosition ()) / 2;
						immediatePosition = (smoothCursor) ? Utils.ExponentialVectorSmoothing (immediatePosition, midPosition, cursorExp) : midPosition;
						if (state == PinchState.Open) {
								cursorPosition = immediatePosition;
						}
						curosrSprite.transform.position = TransformPosition (cursorPosition);
						immediateSprite.transform.position = TransformPosition (immediatePosition);
				}
				void SetFingerSpritePosition (FingerModel index, FingerModel thumb)
				{
						if (index != null)
								fingerSprite.transform.position = TransformPosition (index.GetTipPosition ());
						if (thumb != null)
								thumbSprite.transform.position = TransformPosition (thumb.GetTipPosition ());
				}
Exemplo n.º 37
0
    // Update is called once per frame
    void Update()
    {
        frame = cont.Frame(0);
        if (frame.Hands.Count > 0) {
        //			HandList hands = frame.Hands;
        //			hand = hands [0];
        //			hand2 = hands [1];
            fingers = righty.fingers;
            Lfingers = lefty.fingers;
            //fingers = hand.Fingers.Extended ();
            //Finger fing1 = hand.Fingers [1];
            fing1 = fingers [1];
            fing2 = fingers [2];
            thumb = fingers [0];
        }

        for (int i = 0; i < Lfingers.Length; i++)
        {
            if (Vector3.Distance (lefty.GetPalmPosition (), Lfingers [i].GetTipPosition ()) < triggerDistance) {
                fist = true;

            } else {
                fist = false;

            }
        }

        //Debug.Log (fist);

        //if (lefty.GetPalmRotation().x > 0.5f) {

        //Vector3 dir = lefty.GetPalmRotation () * Vector3.right;

        if (fist == false) {

            //if (lefty.
            Vector3 dir2 = -lefty.GetPalmNormal ();
            //transform.rotation = Quaternion.Lerp (transform.rotation, lefty.GetPalmRotation(), Time.deltaTime);
            transform.position = Vector3.Lerp (transform.position, transform.position + dir2 * 2, Time.deltaTime);

            thruster.emit = true;
        } else {
            thruster.emit = false;
        }

        //}

        //		Debug.Log (fing1.IsExtended);

        //FingerList fingses = fingers.Extended ();

        //		foreach (Finger fing in fings)
        //		{
        //			if (fing.Type ==
        //		}
        thruster.transform.position = lefty.GetPalmPosition ();

        if (righty.isActiveAndEnabled)
        {
            if (Vector3.Distance (righty.GetPalmPosition (), fing1.GetTipPosition ()) > triggerDistance
                && Vector3.Distance (righty.GetPalmPosition (), thumb.GetTipPosition ()) > triggerDistance) {
                //visualizer.transform.position = leapToWorld (fing1.TipPosition, frame.InteractionBox).ToUnityScaled ();
                //Debug.Log (fing1.Type);

                for (int i = 2; i < fingers.Length; i++) {
                    if (Vector3.Distance (righty.GetPalmPosition (), fingers [i].GetTipPosition ()) < triggerDistance)
                        shooting = true;
                    else
                        shooting = false;

                }

            } else {
                shooting = false;
            }

            if (Vector3.Distance (thumb.GetTipPosition (), fing1.GetTipPosition ()) < pinchDistance) {

                if (shouldSwitch) {
                    if (selectedBullet == bullet1) {
                        selectedBullet = bullet2;
                    } else {
                        selectedBullet = bullet1;
                    }
                    shouldSwitch = false;
                }
                //Debug.Log ("Could Switch");
            } else {
                shouldSwitch = true;
                //Debug.Log ("Can't Switch");
                //		}
            }
        //			if (Vector3.Distance (thumb.GetTipPosition (), fing2.GetTipPosition ()) < pinchDistance) {
        //				selectedBullet = bullet2;
        //			}
        //

        }
    }
Exemplo n.º 38
0
    // Update is called once per frame
    void Update()
    {
        frame = cont.Frame(0);
        if (frame.Hands.Count > 0) {
            //			HandList hands = frame.Hands;
            //			hand = hands [0];
            //			hand2 = hands [1];
            fingers = righty.fingers;
            Lfingers = lefty.fingers;
            //fingers = hand.Fingers.Extended ();
            //Finger fing1 = hand.Fingers [1];
            fing1 = fingers [1];
            fing2 = fingers [2];
            thumb = fingers [0];
        }

        if (!rightHanded) {

            for (int i = 0; i < Lfingers.Length; i++) {
                if (Vector3.Distance (lefty.GetPalmPosition (), Lfingers [i].GetTipPosition ()) < triggerDistance) {
                    fist = true;
                } else {
                    fist = false;
                }
            }
        } else if (righty.isActiveAndEnabled) {

            for (int i = 0; i < fingers.Length; i++) {
                if (Vector3.Distance (righty.GetPalmPosition (), fingers [i].GetTipPosition ()) < triggerDistance) {
                    CancelInvoke();
                    fist = true;

                } else {
                    fist = false;
                    Invoke ("StoreKnife", 2);

                }
            }

            if (lefty.isActiveAndEnabled) {
                passRot = lefty.GetArmRotation ();
                passPos = lefty.GetArmCenter ();
            }

        }

        if (fist) {
            knife.SetActive(true);

            knife.transform.position = (righty.GetPalmPosition () + righty.fingers[1].GetBoneCenter(2)) * 0.5f;
            knife.transform.rotation = righty.GetPalmRotation () * ogKnifeRot;
            MeshRenderer[] mat = knife.GetComponentsInChildren<MeshRenderer> ();
            foreach (MeshRenderer rend in mat)
            {

                //	MeshRenderer[] mat = knife.GetComponentsInChildren<MeshRenderer> ();

                if (rend.material.color.a < 1) {
                    //rend.material.color = Color.Lerp (rend.material.color, new Color (1, 1, 1, 1f), Time.deltaTime);
                    rend.material.SetColor("_Color", Color.Lerp(rend.material.color,new Color (1,1,1, 1f), Time.deltaTime*3));
                } else {
                    rend.material.SetFloat ("_Mode", 0);
                }
            }
        }

        //Debug.Log (fist);

        //if (lefty.GetPalmRotation().x > 0.5f) {

        //Vector3 dir = lefty.GetPalmRotation () * Vector3.right;

        //		if (fist == false) {
        //
        //			//if (lefty.
        //			Vector3 dir2 = -lefty.GetPalmNormal ();
        //			//transform.rotation = Quaternion.Lerp (transform.rotation, lefty.GetPalmRotation(), Time.deltaTime);
        //			transform.position = Vector3.Lerp (transform.position, transform.position + dir2 * 2, Time.deltaTime);
        //		}

        //}

        //		Debug.Log (fing1.IsExtended);

        //FingerList fingses = fingers.Extended ();

        //		foreach (Finger fing in fings)
        //		{
        //			if (fing.Type ==
        //		}
    }