Exemplo n.º 1
0
    /// <summary>
    /// Checks the gesture.
    /// </summary>
    /// <param name="skeleton">The skeleton.</param>
    /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
    public GesturePartResult CheckGesture(SkeletonWrapper skeletonWrapper)
    {
        // //Right hand in front of right shoulder
        if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].z > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowRight].z)
        //skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
        {
            // Debug.WriteLine("GesturePart 1 - Right hand in front of right shoulder - PASS");
            // //right hand below shoulder height but above hip height
            if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y <skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.Head].y &&
                                                                                              skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y> skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
            {
                // Debug.WriteLine("GesturePart 1 - right hand below shoulder height but above hip height - PASS");
                // //right hand left of right shoulder & right of left shoulder
                if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ShoulderRight].x)     //&&
                //skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].x > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ShoulderLeft].x)
                {
                    // Debug.WriteLine("GesturePart 1 - right hand left of right shoulder & right of left shoulder - PASS");
                    return(GesturePartResult.Suceed);
                }

                // Debug.WriteLine("GesturePart 1 - right hand left of right shoulder & right of left shoulder - UNDETERMINED");
                return(GesturePartResult.Pausing);
            }

            // Debug.WriteLine("GesturePart 1 - right hand below shoulder height but above hip height - FAIL");
            return(GesturePartResult.Fail);
        }

        // Debug.WriteLine("GesturePart 1 - Right hand in front of right shoulder - FAIL");
        return(GesturePartResult.Fail);
    }
Exemplo n.º 2
0
    // Use this for initialization

    void Start()
    {
        kinect   = devOrEmu.getKinect();
        sw       = new SkeletonWrapper();
        skeleton = GameObject.Find("SkeletonWrapper");
        StartCoroutine("WaveSegments");
    }
Exemplo n.º 3
0
    /// <summary>
    /// Checks the gesture.
    /// </summary>
    /// <param name="skeleton">The skeleton.</param>
    /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
    public GesturePartResult CheckGesture(SkeletonWrapper skeletonWrapper)
    {
        // //Right hand in front of right Shoulder
            if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].z > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowRight].z)
                //skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
            {
                // Debug.WriteLine("GesturePart 2 - Right hand in front of right shoulder - PASS");
                // //right hand below shoulder height but above hip height
                if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.Head].y &&
                    skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
                {
                    // Debug.WriteLine("GesturePart 2 - right hand below shoulder height but above hip height - PASS");
                    // //right hand left of left Shoulder
                    if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ShoulderLeft].x)
                    {
                        // Debug.WriteLine("GesturePart 2 - right hand left of left Shoulder - PASS");
                        return GesturePartResult.Suceed;
                    }

                    // Debug.WriteLine("GesturePart 2 - right hand left of right Shoulder - UNDETERMINED");
                    return GesturePartResult.Pausing;
                }

                // Debug.WriteLine("GesturePart 2 - right hand below shoulder height but above hip height - FAIL");
                return GesturePartResult.Fail;
            }

            // Debug.WriteLine("GesturePart 2 - Right hand in front of right Shoulder - FAIL");
            return GesturePartResult.Fail;
    }
    // Use this for initialization
    void Start()
    {
        skeletonWrapper = GameObject.Find("KinectPrefab(Clone)").GetComponent<SkeletonWrapper>();
        kinectPointController = gameObject.GetComponent<KinectPointController>();

        kinectPointController.sw = skeletonWrapper;
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        //handCtr = gameObject.GetComponent<HandCtrl>();

        sw = GameObject.Find("/KinectPrefab").GetComponent <SkeletonWrapper>();

        motion = MotionFactory.CreateHandleChain();
    }
Exemplo n.º 6
0
 void Start()
 {
     sw = new SkeletonWrapper();
     openconnection();
     kinect = devOrEmu.getKinect();
     StartCoroutine("SetGuard");
     tex = new Texture2D(320, 240, TextureFormat.ARGB32, false);
     GetComponent <Renderer>().material.mainTexture = tex;
 }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        sw = GameObject.Find("/KinectPrefab").GetComponent <SkeletonWrapper>();
        dw = GameObject.Find("/KinectPrefab").GetComponent <DepthWrapper>();

        // Initialize depth map
        depthMapTex  = new Texture2D(DepthWidth, DepthHeight);       //depthMapTex = new Texture2D(DepthWidth, DepthHeight, TextureFormat.ARGB32, false);
        depthMapRect = new Rect((Screen.width + DisplayWidth) / 2,
                                (Screen.height - DisplayHeight) / 2, //10, //
                                -DisplayWidth,
                                DisplayHeight);
    }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     sw = GameObject.Find("KinectPrefab").GetComponent <SkeletonWrapper>();
     //store bones in a list for easier access
     _bones = new GameObject[(int)Kinect.NuiSkeletonPositionIndex.Count] {
         Hip_Center, Spine, Shoulder_Center, Head,
         Shoulder_Left, Elbow_Left, Wrist_Left, Hand_Left,
         Shoulder_Right, Elbow_Right, Wrist_Right, Hand_Right,
         Hip_Left, Knee_Left, Ankle_Left, Foot_Left,
         Hip_Right, Knee_Right, Ankle_Right, Foot_Right
     };
     //_bonePos = new Vector4[(int)BoneIndex.Num_Bones];
 }
Exemplo n.º 9
0
    /// <summary>
    /// Occurs when [gesture recognised].
    /// </summary>
    ///public event EventHandler<GestureEventArgs> GestureRecognised;

    /// <summary>
    /// Updates the gesture.
    /// </summary>
    /// <param name="data">The skeleton data.</param>
    public void UpdateGesture(SkeletonWrapper skeletonWrapper)
    {
        if (this.paused)
        {
            if (this.frameCount == this.pausedFrameCount)
            {
                this.paused = false;
            }

            this.frameCount++;
        }

        GesturePartResult result = this.gestureParts[this.currentGesturePart].CheckGesture(skeletonWrapper);

        if (result == GesturePartResult.Suceed)
        {
            if (this.currentGesturePart + 1 < this.gestureParts.Length)
            {
                this.currentGesturePart++;
                this.frameCount       = 0;
                this.pausedFrameCount = 10;
                this.paused           = true;
            }
            else
            {    //動作結束
                //Debug.Log("動作結束");
                this.Reset();

                /*
                 * if (this.GestureRecognised != null)
                 * {
                 *  this.GestureRecognised(this, new GestureEventArgs(this.type, data.TrackingID, data.UserIndex));
                 *  this.Reset();
                 * }
                 */
            }
        }
        else if (result == GesturePartResult.Fail || this.frameCount == 50)
        {
            this.currentGesturePart = 0;
            this.frameCount         = 0;
            this.pausedFrameCount   = 5;
            this.paused             = true;
        }
        else
        {
            this.frameCount++;
            this.pausedFrameCount = 5;
            this.paused           = true;
        }
    }
    // Use this for initialization
    void Start()
    {
        sw = (SkeletonWrapper) FindObjectOfType(typeof(SkeletonWrapper));
        if(sw == null)
        {
            Instantiate(KinectPrefab);
            sw = (SkeletonWrapper) FindObjectOfType(typeof(SkeletonWrapper));
        }

        ks = (KinectSensor) FindObjectOfType(typeof(KinectSensor));

        this.mainManager = (MainManager) FindObjectOfType(typeof(MainManager));
        noteGauche = noteDroite = noteGenous = Note.Which.NONE;
        bonusActivated = false;
    }
    // Use this for initialization
    void Start()
    {
        sw = (SkeletonWrapper) FindObjectOfType(typeof(SkeletonWrapper));
        if(sw == null)
        {
            Instantiate(KinectPrefab);
            sw = (SkeletonWrapper) FindObjectOfType(typeof(SkeletonWrapper));
        }
        leftCursor = (GUITexture) GameObject.Find("LeftCursor").GetComponent<GUITexture>();
        rightCursor = (GUITexture) GameObject.Find("RightCursor").GetComponent<GUITexture>();
        debug = (GUIText) GameObject.Find("DebugLabel").GetComponent<GUIText>();

        leftText = (Texture2D) Resources.Load("Images/left_cursor", typeof(Texture2D));
        rightText = (Texture2D) Resources.Load("Images/right_cursor", typeof(Texture2D));
        leftPushedText = (Texture2D) Resources.Load("Images/left_cursor_grip", typeof(Texture2D));
        rightPushedText = (Texture2D) Resources.Load("Images/right_cursor_grip", typeof(Texture2D));
    }
Exemplo n.º 12
0
    /// <summary>
    /// Checks the gesture.
    /// </summary>
    /// <param name="skeleton">The skeleton.</param>
    /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
    public GesturePartResult CheckGesture(SkeletonWrapper skeletonWrapper)
    {
        // //Right hand in front of right shoulder [ 注意 Z 軸 ]
        if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].z > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowRight].z)
        // skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
        {
            // //right hand above right eblow height
            if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowRight].y)
            {
                // //right hand above spine height
                if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.Spine].y)
                {
                    return(GesturePartResult.Suceed);
                }

                return(GesturePartResult.Pausing);
            }

            // Debug.WriteLine("GesturePart 0 - right hand below shoulder height but above hip height - FAIL");
            return(GesturePartResult.Fail);
        }
        else
        {
            if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].z > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowLeft].z)
            {
                // //left hand above left eblow height
                if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowLeft].y)
                {
                    // //left hand above spine height
                    if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.Spine].y)
                    {
                        return(GesturePartResult.Suceed);
                    }

                    return(GesturePartResult.Pausing);
                }

                // Debug.WriteLine("GesturePart 0 - right hand below shoulder height but above hip height - FAIL");
                return(GesturePartResult.Fail);
            }
        }

        // Debug.WriteLine("GesturePart 0 - Right hand in front of right shoulder - FAIL");
        return(GesturePartResult.Fail);
    }
Exemplo n.º 13
0
 /// <summary>
 /// Wave to swape player , wave hand action recognise
 /// </summary>
 /// <param name="player"></param>
 /// <returns></returns>
 public bool Recognise(SkeletonWrapper sw, int player)
 {
     if (sw.trackedPlayers[player] != -1)
     {
         if (sw.rawBonePos[player, (int)JointType.HandRight].y > sw.rawBonePos[player, (int)JointType.Spine].y)
         {
             return(Recognise(sw.rawBonePos[player, (int)JointType.HandRight]));
         }
         if (sw.rawBonePos[player, (int)JointType.HandLeft].y > sw.rawBonePos[player, (int)JointType.Spine].y)
         {
             return(Recognise(sw.rawBonePos[player, (int)JointType.HandLeft]));
         }
         ResetData();
     }
     else
     {
         ResetData();
     }
     return(false);
 }
	void Awake()
	{
		GO_KINECT_PREFAB = go_KinectPrefab;

		GO_GUI_MANAGER = go_guiManager;

		GO_HAND_INPUT_MANAGER = go_handInputManager;

		GO_AUDIO_MANAGER = go_audioManager;

		GO_BIRD = go_bird;

		GO_BIRDS_FACTORY = go_birdsFactory;

		I_DEPTH_PRODUCE_BIRD = i_depthProduceBird;

		F_MAX_SPEED_BIRD_AXIS_Z = f_maxSpeedBirdAxisZ;

		I_MAX_HEALTH_POINTS = i_maxHealthPoints;
	}
Exemplo n.º 15
0
    /// <summary>
    /// Checks the gesture.
    /// </summary>
    /// <param name="skeleton">The skeleton.</param>
    /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
    public GesturePartResult CheckGesture(SkeletonWrapper skeletonWrapper)
    {
        // Left and right hands below hip
            if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y &&
               skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
            {
                // left hand 0.3 to left of center hip
                if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].x - 0.3)
                {
                    // left hand 0.2 to left of left elbow
                    if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowLeft].x - 0.2)
                    {
                        return GesturePartResult.Suceed;
                    }
                }

                return GesturePartResult.Pausing;
            }

            return GesturePartResult.Fail;
    }
Exemplo n.º 16
0
    /// <summary>
    /// Checks the gesture.
    /// </summary>
    /// <param name="skeleton">The skeleton.</param>
    /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
    public GesturePartResult CheckGesture(SkeletonWrapper skeletonWrapper)
    {
        // Left and right hands below hip
        if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y &&
            skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
        {
            // left hand 0.3 to left of center hip
            if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].x - 0.3)
            {
                // left hand 0.2 to left of left elbow
                if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowLeft].x - 0.2)
                {
                    return(GesturePartResult.Suceed);
                }
            }

            return(GesturePartResult.Pausing);
        }

        return(GesturePartResult.Fail);
    }
Exemplo n.º 17
0
 /// <summary>
 /// Checks the gesture.
 /// </summary>
 /// <param name="skeleton">The skeleton.</param>
 /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
 ///
 public GesturePartResult CheckGesture(SkeletonWrapper skeletonWrapper)
 {
     // //Left hand in front of left shoulder
     if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].z > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowLeft].z)
     //skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
     {
         // //left hand below shoulder height but above hip height
         if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y <skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.Head].y &&
                                                                                          skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].y> skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
         {
             // //left hand left of left shoulder & Left of left shoulder
             if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandLeft].x > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ShoulderLeft].x)     //&&
             //skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].x > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ShoulderLeft].x)
             {
                 return(GesturePartResult.Suceed);
             }
             return(GesturePartResult.Pausing);
         }
         return(GesturePartResult.Fail);
     }
     else
     {
         if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].z > skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ElbowRight].z)
         {
             if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y <skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.Head].y &&
                                                                                               skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].y> skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HipCenter].y)
             {
                 if (skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.HandRight].x < skeletonWrapper.bonePos[0, (int)Kinect.NuiSkeletonPositionIndex.ShoulderRight].x)     //&&
                 {
                     return(GesturePartResult.Suceed);
                 }
                 return(GesturePartResult.Pausing);
             }
             return(GesturePartResult.Fail);
         }
     }
     return(GesturePartResult.Fail);
 }
Exemplo n.º 18
0
    private void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("There is multiple instance of singleton GameManager");
            return;
        }

        Instance = this;

        sw  = SkeletonWrapper.Instance;
        him = HandInputManager.Instance;
        bim = BodyInputManager.Instance;

        gameMode         = GlobalVariables.gameMode;
        TargetScore      = targetScore;
        TargetDamage     = targetDamage;
        TargetBonusScore = bonusTargetScore;
        TargetBonusTime  = bonusTargetTime;
        TargetBonusLife  = bonusTargetLife;

        SetupUI();
    }
 // Use this for initialization
 void Start()
 {
     m_skeletonWrapper = __m_skeletonWrapper;
 }
Exemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     skeletonWrapper = GameObject.Find("Kinect_Prefab").GetComponent <SkeletonWrapper>();
 }
Exemplo n.º 21
0
 void Awake()
 {
     GO_KINECT_PREFAB      = kinectPrefab;
     GO_HAND_INPUT_MANAGER = handInputManager;
     GO_BODY_INPUT_MANAGER = bodyInputManager;
 }
Exemplo n.º 22
0
    private Vector3 originL = Vector3.zero; // Left hand origin

    /// <summary>
    /// 通过左右手来控制适应UI操作
    /// </summary>
    /// <param name="sw"></param>
    /// <param name="player"></param>
    /// <returns></returns>
    public bool Adaptive(SkeletonWrapper sw, int player)
    {
        if (!gameObject.activeSelf)
        {
            return(false);
        }

        if (sw.rawBonePos[player, (int)JointType.HandRight].y > sw.rawBonePos[player, (int)JointType.Spine].y)
        {
            rightHandStatus = true;
        }
        else
        {
            rightHandStatus = false;
            handRightCtrl.ResetPosition();
        }
        if (sw.rawBonePos[player, (int)JointType.HandLeft].y > sw.rawBonePos[player, (int)JointType.Spine].y)
        {
            leftHandStatus = true;
        }
        else
        {
            leftHandStatus = false;
            handLeftCtrl.ResetPosition();
        }

        if (!rightHandStatus && !leftHandStatus)
        {
            return(false);
        }

        // use for the virtual hand mouse plane
        float moveOffsetThread = sw.rawBonePos[player, (int)JointType.ShoulderCenter].y - sw.rawBonePos[player, (int)JointType.Spine].y;
        float pushOffsetThread = moveOffsetThread;//sw.rawBonePos[player, (int)JointType.ShoulderCenter].y - sw.rawBonePos[player, (int)JointType.Hip].y;

        //float head2ShoulderCenterHeight = 0.5f * (sw.rawBonePos[player, (int)JointType.Head].y - sw.rawBonePos[player, (int)JointType.ShoulderCenter].y);

        // both hand y and z
        originR.y = originL.y = (sw.rawBonePos[player, (int)JointType.Head].y + sw.rawBonePos[player, (int)JointType.Spine].y) / 2;
        originR.z = originL.z = sw.rawBonePos[player, (int)JointType.Head].z;

        if (rightHandStatus && leftHandStatus)
        {
            moveOffsetThread *= 0.7f;

            originR.x = sw.rawBonePos[player, (int)JointType.Spine].x + moveOffsetThread;
            originL.x = sw.rawBonePos[player, (int)JointType.Spine].x - moveOffsetThread;
            Vector3 uiHandR = sw.rawBonePos[player, (int)JointType.HandRight] - originR;
            Vector3 uiHandL = sw.rawBonePos[player, (int)JointType.HandLeft] - originL;
            handRightCtrl.UpdateMovePush(uiHandR, moveOffsetThread, pushOffsetThread, handMoveSmooth, 1);
            handLeftCtrl.UpdateMovePush(uiHandL, moveOffsetThread, pushOffsetThread, handMoveSmooth, -1);
            //// make left and right hand not cross
            //if (handRightCtrl.transform.localPosition.x < handLeftCtrl.transform.localPosition.x)
            //{
            //    handLeftCtrl.transform.localPosition = new Vector3(handRightCtrl.transform.localPosition.x,
            //        handLeftCtrl.transform.localPosition.y, handLeftCtrl.transform.localPosition.z);
            //}
        }
        else
        {
            moveOffsetThread *= 0.5f;
            if (rightHandStatus)
            {
                originR.x = sw.rawBonePos[player, (int)JointType.Spine].x + moveOffsetThread;
                handRightCtrl.UpdateMovePush(sw.rawBonePos[player, (int)JointType.HandRight] - originR, moveOffsetThread, pushOffsetThread, handMoveSmooth);
            }
            else if (leftHandStatus)
            {
                originL.x = sw.rawBonePos[player, (int)JointType.Spine].x - moveOffsetThread;
                handLeftCtrl.UpdateMovePush(sw.rawBonePos[player, (int)JointType.HandLeft] - originL, moveOffsetThread, pushOffsetThread, handMoveSmooth);
            }
        }
        return(true);
    }
	// Use this for initialization
	void Start () {
		sw = SkeletonWrapper.Instance;
	}
Exemplo n.º 24
0
    private void Awake()
    {
        if (Instance != null) {
            Debug.LogError("There is multiple instance of singleton GameManager");
            return;
        }

        Instance = this;

        sw = SkeletonWrapper.Instance;
        him = HandInputManager.Instance;
        bim = BodyInputManager.Instance;

        gameMode = GlobalVariables.gameMode;
        TargetScore = targetScore;
        TargetDamage = targetDamage;
        TargetBonusScore = bonusTargetScore;
        TargetBonusTime = bonusTargetTime;
        TargetBonusLife = bonusTargetLife;

        SetupUI ();
    }
Exemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     sw = SkeletonWrapper.Instance;
 }
Exemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     skeletonWrapper   = GameObject.Find("Kinect_Prefab").GetComponent <SkeletonWrapper>();
     Screen.showCursor = false;
 }
Exemplo n.º 27
0
 // Use this for initialization
 void Start()
 {
     GameObject obj = GameObject.Find("KinectPrefab");
     sw = obj.GetComponent<SkeletonWrapper> ();
     //store bones in a list for easier access
     _bones = new GameObject[(int)Kinect.NuiSkeletonPositionIndex.Count] {Hip_Center, Spine, Shoulder_Center, Head,
         Shoulder_Left, Elbow_Left, Wrist_Left, Hand_Left,
         Shoulder_Right, Elbow_Right, Wrist_Right, Hand_Right,
         Hip_Left, Knee_Left, Ankle_Left, Foot_Left,
         Hip_Right, Knee_Right, Ankle_Right, Foot_Right};
     //_bonePos = new Vector4[(int)BoneIndex.Num_Bones];
 }
Exemplo n.º 28
0
 void Awake()
 {
     GO_KINECT_PREFAB = kinectPrefab;
     GO_HAND_INPUT_MANAGER = handInputManager;
     GO_BODY_INPUT_MANAGER = bodyInputManager;
 }
Exemplo n.º 29
0
    /// <summary>
    /// Occurs when [gesture recognised].
    /// </summary>
    ///public event EventHandler<GestureEventArgs> GestureRecognised;
    /// <summary>
    /// Updates the gesture.
    /// </summary>
    /// <param name="data">The skeleton data.</param>
    public void UpdateGesture(SkeletonWrapper skeletonWrapper)
    {
        if (this.paused)
            {
                if (this.frameCount == this.pausedFrameCount)
                {
                    this.paused = false;
                }

                this.frameCount++;
            }

            GesturePartResult result = this.gestureParts[this.currentGesturePart].CheckGesture(skeletonWrapper);
            if (result == GesturePartResult.Suceed)
            {
                if (this.currentGesturePart + 1 < this.gestureParts.Length)
                {
                    this.currentGesturePart++;
                    this.frameCount = 0;
                    this.pausedFrameCount = 10;
                    this.paused = true;
                }
                else
                {//動作結束
                    //Debug.Log("動作結束");
                    this.Reset();
                    /*
                    if (this.GestureRecognised != null)
                    {
                        this.GestureRecognised(this, new GestureEventArgs(this.type, data.TrackingID, data.UserIndex));
                        this.Reset();
                    }
                    */
                }
            }
            else if (result == GesturePartResult.Fail || this.frameCount == 50)
            {
                this.currentGesturePart = 0;
                this.frameCount = 0;
                this.pausedFrameCount = 5;
                this.paused = true;
            }
            else
            {
                this.frameCount++;
                this.pausedFrameCount = 5;
                this.paused = true;
            }
    }
	// Use this for initialization
	void Start () {

		sw = SkeletonWrapper.Instance;

		//store bones in a list for easier access
		_bones = new GameObject[(int)Kinect.NuiSkeletonPositionIndex.Count] {Hip_Center, Spine, Shoulder_Center, Head,
			Shoulder_Left, Elbow_Left, Wrist_Left, Hand_Left,
			Shoulder_Right, Elbow_Right, Wrist_Right, Hand_Right,
			Hip_Left, Knee_Left, Ankle_Left, Foot_Left,
			Hip_Right, Knee_Right, Ankle_Right, Foot_Right};
		//_bonePos = new Vector4[(int)BoneIndex.Num_Bones];

		// init the position log file
		//this.positionLogFile = new System.IO.StreamWriter(@positionLogPath, true);
		//this.positionLogFile.AutoFlush = true;
		//Debug.Log(@positionLogPath);

		sw = SkeletonWrapper.Instance;
	}
 void Awake()
 {
     sw = SkeletonWrapper.Instance;
     him = HandInputManager.Instance;
 }
Exemplo n.º 32
0
 // Use this for initialization
 void Start()
 {
     skeletonWrapper = GameObject.Find("Kinect_Prefab").GetComponent<SkeletonWrapper>();
     Screen.showCursor = false;
 }
Exemplo n.º 33
0
    /// <summary>
    /// Occurs when [gesture recognised].
    /// </summary>
    ///public event EventHandler<GestureEventArgs> GestureRecognised;

    /// <summary>
    /// Updates the gesture.
    /// </summary>
    /// <param name="data">The skeleton data.</param>
    public void UpdateGesture(SkeletonWrapper skeletonWrapper)
    {
        if (this.paused)
        {
            if (this.frameCount == this.pausedFrameCount)
            {
                this.paused = false;
            }

            this.frameCount++;
        }

        GesturePartResult result = this.gestureParts[this.currentGesturePart].CheckGesture(skeletonWrapper);

        if (result == GesturePartResult.Suceed)
        {
            if (this.currentGesturePart + 1 < this.gestureParts.Length)
            {
                this.currentGesturePart++;
                this.frameCount       = 0;
                this.pausedFrameCount = 10;
                this.paused           = true;
            }
            else
            {
                //動作結束
                //範例
                if (this.type == GestureType.LeftSwipe)
                {
                    isSwipeLeft = true;
                    Debug.Log("揮左成功");
                }
                if (this.type == GestureType.RightSwipe)
                {
                    isSwipeRight = true;
                    Debug.Log("揮右");
                }
                if (this.type == GestureType.UpSwipe)
                {
                    isSwipeUp = true;
                    //這裡加入避免揮上下連續判斷的緩衝-->不知如何加
                    Debug.Log("揮上");
                }
                if (this.type == GestureType.DownSwipe)
                {
                    isSwipeDown = true;
                    Debug.Log("揮下");
                }

                Debug.Log("動作結束");
                this.Reset();

                /*
                 * if (this.GestureRecognised != null)
                 * {
                 *  this.GestureRecognised(this, new GestureEventArgs(this.type, data.TrackingID, data.UserIndex));
                 *  this.Reset();
                 * }
                 */
            }
        }
        else if (result == GesturePartResult.Fail || this.frameCount == 50)
        {
            this.currentGesturePart = 0;
            this.frameCount         = 0;
            this.pausedFrameCount   = 5;
            this.paused             = true;
        }
        else
        {
            this.frameCount++;
            this.pausedFrameCount = 5;
            this.paused           = true;
        }
    }
 void Awake()
 {
     sw  = SkeletonWrapper.Instance;
     him = HandInputManager.Instance;
 }
	private Vector3 _chestRight; //right vectory of the chest
	
	
	// Use this for initialization
	void Start () {

		sw = SkeletonWrapper.Instance;

		//store bones in a list for easier access, everything except Hip_Center will be one
		//higher than the corresponding Kinect.NuiSkeletonPositionIndex (because of the hip_override)
		_bones = new GameObject[(int)Kinect.NuiSkeletonPositionIndex.Count + 5] {
			null, Hip_Center, Spine, Shoulder_Center,
			Collar_Left, Shoulder_Left, Elbow_Left, Wrist_Left,
			Collar_Right, Shoulder_Right, Elbow_Right, Wrist_Right,
			Hip_Override, Hip_Left, Knee_Left, Ankle_Left,
			null, Hip_Right, Knee_Right, Ankle_Right,
			//extra joints to determine the direction of some bones
			Head, Hand_Left, Hand_Right, Foot_Left, Foot_Right};
		
		//determine which bones are not available
		for(int ii = 0; ii < _bones.Length; ii++)
		{
			if(_bones[ii] == null)
			{
				_nullMask |= (uint)(1 << ii);
			}
		}
		
		//store the base rotations and bone directions (in bone-local space)
		_baseRotation = new Quaternion[(int)Kinect.NuiSkeletonPositionIndex.Count];
		_boneDir = new Vector3[(int)Kinect.NuiSkeletonPositionIndex.Count];
		
		//first save the special rotations for the hip and spine
		_hipRight = Hip_Right.transform.position - Hip_Left.transform.position;
		_hipRight = Hip_Override.transform.InverseTransformDirection(_hipRight);
		
		_chestRight = Shoulder_Right.transform.position - Shoulder_Left.transform.position;
		_chestRight = Spine.transform.InverseTransformDirection(_chestRight);
		
		//get direction of all other bones
		for( int ii = 0; ii < (int)Kinect.NuiSkeletonPositionIndex.Count; ii++)
		{
			if((_nullMask & (uint)(1 << ii)) <= 0)
			{
				//save initial rotation
				_baseRotation[ii] = _bones[ii].transform.localRotation;
				
				//if the bone is the end of a limb, get direction from this bone to one of the extras (hand or foot).
				if(ii % 4 == 3 && ((_nullMask & (uint)(1 << (ii/4) + (int)Kinect.NuiSkeletonPositionIndex.Count)) <= 0))
				{
					_boneDir[ii] = _bones[(ii/4) + (int)Kinect.NuiSkeletonPositionIndex.Count].transform.position - _bones[ii].transform.position;
				}
				//if the bone is the hip_override (at boneindex Hip_Left, get direction from average of left and right hips
				else if(ii == (int)Kinect.NuiSkeletonPositionIndex.HipLeft && Hip_Left != null && Hip_Right != null)
				{
					_boneDir[ii] = ((Hip_Right.transform.position + Hip_Left.transform.position) / 2F) - Hip_Override.transform.position;
				}
				//otherwise, get the vector from this bone to the next.
				else if((_nullMask & (uint)(1 << ii+1)) <= 0)
				{
					_boneDir[ii] = _bones[ii+1].transform.position - _bones[ii].transform.position;
				}
				else
				{
					continue;
				}
				//Since the spine of the kinect data is ~40 degrees back from the hip,
				//check what angle the spine is at and rotate the saved direction back to match the data
				if(ii == (int)Kinect.NuiSkeletonPositionIndex.Spine)
				{
					float angle = Vector3.Angle(transform.up,_boneDir[ii]);
					_boneDir[ii] = Quaternion.AngleAxis(-40 + angle,transform.right) * _boneDir[ii];
				}
				//transform the direction into local space.
				_boneDir[ii] = _bones[ii].transform.InverseTransformDirection(_boneDir[ii]);
			}
		}
		//make _chestRight orthogonal to the direction of the spine.
		_chestRight -= Vector3.Project(_chestRight, _boneDir[(int)Kinect.NuiSkeletonPositionIndex.Spine]);
		//make _hipRight orthogonal to the direction of the hip override
		Vector3.OrthoNormalize(ref _boneDir[(int)Kinect.NuiSkeletonPositionIndex.HipLeft],ref _hipRight);
	}
Exemplo n.º 36
0
 // Use this for initialization
 void Awake()
 {
     sw = SkeletonWrapper.Instance;
 }
    //private ShowStopUI gameRunUi = null; //¿ØÖÆÓÎÏ·ÔËÐнçÃæµÄ½Å±¾¶ÔÏó

    //private ItweenCtr playerCtr = null;

    // Use this for initialization
    void Start()
    {
        //gameRunUi = GameObject.Find("/Sence UI Root").GetComponent<ShowStopUI>();
        //zhf
        sw = GameObject.Find("/KinectPrefab").GetComponent <SkeletonWrapper>();
        sw.offsetCalibrated = false;
        //playerCtr = GameObject.FindWithTag("Player").GetComponent<ItweenCtr>();

        //store bones in a list for easier access, everything except Hip_Center will be one
        //higher than the corresponding Kinect.NuiSkeletonPositionIndex (because of the hip_override)
        _bones = new GameObject[(int)Kinect.NuiSkeletonPositionIndex.Count + 5] {
            null, Hip_Center, Spine, Shoulder_Center,
            Collar_Left, Shoulder_Left, Elbow_Left, Wrist_Left,
            Collar_Right, Shoulder_Right, Elbow_Right, Wrist_Right,
            Hip_Override, Hip_Left, Knee_Left, Ankle_Left,
            null, Hip_Right, Knee_Right, Ankle_Right,
            //extra joints to determine the direction of some bones
            Head, Hand_Left, Hand_Right, Foot_Left, Foot_Right
        };

        //determine which bones are not available
        for (int ii = 0; ii < _bones.Length; ii++)
        {
            if (_bones[ii] == null)
            {
                _nullMask |= (uint)(1 << ii);
            }
        }

        //store the base rotations and bone directions (in bone-local space)
        _baseRotation = new Quaternion[(int)Kinect.NuiSkeletonPositionIndex.Count];
        _boneDir      = new Vector3[(int)Kinect.NuiSkeletonPositionIndex.Count];

        //first save the special rotations for the hip and spine
        _hipRight = Hip_Right.transform.position - Hip_Left.transform.position;
        _hipRight = Hip_Override.transform.InverseTransformDirection(_hipRight);

        _chestRight = Shoulder_Right.transform.position - Shoulder_Left.transform.position;
        _chestRight = Spine.transform.InverseTransformDirection(_chestRight);


        //get direction of all other bones
        for (int ii = 0; ii < (int)Kinect.NuiSkeletonPositionIndex.Count; ii++)
        {
            if ((_nullMask & (uint)(1 << ii)) <= 0)
            {
                //save initial rotation
                _baseRotation[ii] = _bones[ii].transform.localRotation;

                //if the bone is the end of a limb, get direction from this bone to one of the extras (hand or foot).
                if (ii % 4 == 3 && ((_nullMask & (uint)(1 << (ii / 4) + (int)Kinect.NuiSkeletonPositionIndex.Count)) <= 0))
                {
                    _boneDir[ii] = _bones[(ii / 4) + (int)Kinect.NuiSkeletonPositionIndex.Count].transform.position - _bones[ii].transform.position;
                }
                //if the bone is the hip_override (at boneindex Hip_Left, get direction from average of left and right hips
                else if (ii == (int)Kinect.NuiSkeletonPositionIndex.HipLeft && Hip_Left != null && Hip_Right != null)
                {
                    _boneDir[ii] = ((Hip_Right.transform.position + Hip_Left.transform.position) / 2F) - Hip_Override.transform.position;
                }
                //otherwise, get the vector from this bone to the next.
                else if ((_nullMask & (uint)(1 << ii + 1)) <= 0)
                {
                    _boneDir[ii] = _bones[ii + 1].transform.position - _bones[ii].transform.position;
                }
                else
                {
                    continue;
                }
                //Since the spine of the kinect data is ~40 degrees back from the hip,
                //check what angle the spine is at and rotate the saved direction back to match the data
                if (ii == (int)Kinect.NuiSkeletonPositionIndex.Spine)
                {
                    float angle = Vector3.Angle(transform.up, _boneDir[ii]);
                    _boneDir[ii] = Quaternion.AngleAxis(-40 + angle, transform.right) * _boneDir[ii];
                }
                //transform the direction into local space.
                _boneDir[ii] = _bones[ii].transform.InverseTransformDirection(_boneDir[ii]);
            }
        }
        //make _chestRight orthogonal to the direction of the spine.
        _chestRight -= Vector3.Project(_chestRight, _boneDir[(int)Kinect.NuiSkeletonPositionIndex.Spine]);
        //make _hipRight orthogonal to the direction of the hip override
        Vector3.OrthoNormalize(ref _boneDir[(int)Kinect.NuiSkeletonPositionIndex.HipLeft], ref _hipRight);

        //// Waterstrong Add
        //_featureData = new FeatureData();
        //_motion = MotionFactory.CreateHandleChain();
    }
Exemplo n.º 38
0
 // Use this for initialization
 void Awake()
 {
     sw = SkeletonWrapper.Instance;
 }