Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        f = m_leapController.Frame();

        if (f.Hands.Count > 0) {
            hand = f.Hands.Rightmost;
            position = hand.PalmPosition;

            if(previousFrame!=null){
                Vector rotationAxis = f.RotationAxis(previousFrame);
                int multiplier;

        //
        //				if(rotationAxis.x < -0.4 || rotationAxis.x > 0.4){
        //					if(rotationAxis.x > 0)
        //						multiplier = 1;
        //					else
        //						multiplier = -1;
        //
        //					transform.Rotate(-Vector3.right * Time.deltaTime * 20 * multiplier, Space.World);
        //				}
        //
        //				if(rotationAxis.z < -0.4 || rotationAxis.z > 0.4){
        //					if(rotationAxis.z > 0)
        //						multiplier = 1;
        //					else
        //						multiplier = -1;
        //
        //					transform.Rotate(Vector3.up * Time.deltaTime * 20 * multiplier, Space.Self);
        //				}

                if(hand.GrabStrength < 0.5){
                    transform.Rotate(Vector3.right * Time.deltaTime * 0.5f * position.z, Space.World);
                    transform.Rotate(Vector3.up * Time.deltaTime * 0.3f * position.x, Space.Self);
                }

            }else{
                previousFrame = f;
            }
        }else{
            previousFrame = null;
        }

        //string displayRotation = vectorToString(f.rotationAxis(previousFrame));
        //GUI.Box(new Rect(10,10,100,90), );
    }