Ejemplo n.º 1
0
    // Use this for initialization
    void Awake()
    {
        leftHandDetector = new GameObject("LeftHandDetector");
        leftHandDetector.transform.parent = gameObject.transform;
        ZigMapJointToSession leftMap = leftHandDetector.AddComponent <ZigMapJointToSession>();

        leftMap.joint = ZigJointId.LeftHand;

        rightHandDetector = new GameObject("RightHandDetector");
        rightHandDetector.transform.parent = gameObject.transform;
        ZigMapJointToSession rightMap = rightHandDetector.AddComponent <ZigMapJointToSession>();

        rightMap.joint = ZigJointId.RightHand;

        leftHandSteady         = leftHandDetector.AddComponent <ZigSteadyDetector>();
        rightHandSteady        = rightHandDetector.AddComponent <ZigSteadyDetector>();
        leftHandSteady.Steady += delegate(object sender, EventArgs e) {
            ZigInputJoint hand  = trackedUser.Skeleton[(int)ZigJointId.LeftHand];
            ZigInputJoint elbow = trackedUser.Skeleton[(int)ZigJointId.LeftElbow];
            if (IsHandRaise(hand.Position, elbow.Position))
            {
                OnHandRaise(ZigJointId.LeftHand);
            }
        };
        rightHandSteady.Steady += delegate(object sender, EventArgs e) {
            ZigInputJoint hand  = trackedUser.Skeleton[(int)ZigJointId.RightHand];
            ZigInputJoint elbow = trackedUser.Skeleton[(int)ZigJointId.RightElbow];
            if (IsHandRaise(hand.Position, elbow.Position))
            {
                OnHandRaise(ZigJointId.RightHand);
            }
        };
    }
    void Awake()
    {
        leftHandDetector = new GameObject("LeftHandDetector");
        leftHandDetector.transform.parent = gameObject.transform;
        ZigMapJointToSession leftMap = leftHandDetector.AddComponent <ZigMapJointToSession>();

        leftMap.joint = ZigJointId.LeftHand;

        rightHandDetector = new GameObject("RightHandDetector");
        rightHandDetector.transform.parent = gameObject.transform;
        ZigMapJointToSession rightMap = rightHandDetector.AddComponent <ZigMapJointToSession>();

        rightMap.joint = ZigJointId.RightHand;

        if (StartOnSteady)
        {
            ZigSteadyDetector steadyLeft = leftHandDetector.AddComponent <ZigSteadyDetector>();
            steadyLeft.Steady += delegate(object sender, EventArgs ea) {
                CheckSessionStart((sender as ZigSteadyDetector).steadyPoint, ZigJointId.LeftHand);
            };

            ZigSteadyDetector steadyRight = rightHandDetector.AddComponent <ZigSteadyDetector>();
            steadyRight.Steady += delegate(object sender, EventArgs ea) {
                CheckSessionStart((sender as ZigSteadyDetector).steadyPoint, ZigJointId.RightHand);
            };
        }

        if (StartOnWave)
        {
            ZigWaveDetector waveLeft = leftHandDetector.AddComponent <ZigWaveDetector>();
            waveLeft.Wave += delegate(object sender, EventArgs ea) {
                Debug.Log("Wave from left");
                CheckSessionStart((sender as ZigWaveDetector).wavePoint, ZigJointId.LeftHand);
            };

            ZigWaveDetector waveRight = rightHandDetector.AddComponent <ZigWaveDetector>();
            waveRight.Wave += delegate(object sender, EventArgs ea) {
                Debug.Log("Wave from right");
                CheckSessionStart((sender as ZigWaveDetector).wavePoint, ZigJointId.RightHand);
            };
        }
    }