Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        //mousePos =  (GameObject.Find("HandLeft").transform.position);
        //transform.position = mousePos;

        //Debug.Log(GameObject.Find("HandLeft").transform.position);

        if (GameObject.Find("HandLeft") != null)
        {
            dropLeft = GameObject.Find("HandLeft").GetComponent <DragAndDrop>();
        }
        if (GameObject.Find("HandRight") != null)
        {
            dropRight = GameObject.Find("HandRight").GetComponent <DragAndDrop>();
        }

        //creates initial bin
        if (collisionManager.CheckHandsShowing() && GameObject.Find("bin(Clone)") == null)
        {
            Transform tester = new GameObject().transform;

            Debug.Log(tester.ToString());
            GameObject newBin = Instantiate(bin, tester);
        }


        if (bodySourceView.getLeftCloseFlag() && gameObject.name == "HandLeft")
        {
            dropLeft.DragOrPickUp("HandLeft");
        }
        if (bodySourceView.getRightCloseFlag() && gameObject.name == "HandRight")
        {
            dropRight.DragOrPickUp("HandRight");
        }

        //if hand is open
        if (!bodySourceView.getLeftCloseFlag() && gameObject.name == "HandLeft" && dropLeft.getDrag())
        {
            dropLeft.DropItem();
        }
        //this is to check whether the hand are active


        /*
         * if (HasInput) {
         *              drop.DragOrPickUp ();
         *      } else {
         *              if (drop.getDrag()) {
         *                      drop.DropItem();
         *              }
         *      }
         */
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //mousePos =  (GameObject.Find("HandLeft").transform.position);
        //transform.position = mousePos;

        //Debug.Log(GameObject.Find("HandLeft").transform.position);

        if (GameObject.Find("HandLeft") != null)
        {
            dropLeft = GameObject.Find("HandLeft").GetComponent <DragAndDrop>();
        }
        if (GameObject.Find("HandRight") != null)
        {
            dropRight = GameObject.Find("HandRight").GetComponent <DragAndDrop>();
        }

        //creates initial bin + brench
        if (collisionManager.CheckHandsShowing() && GameObject.Find("bin") == null)
        {
            /* Tina: Don't think we need the tester as it just create a random new gameobject
             * Transform tester = new GameObject().transform;
             *
             * Debug.Log(tester.ToString());
             * GameObject newBin = Instantiate(bin, tester);*/

            // destroy the crowd once the hand is activated
            if (GameObject.Find("crowd") != null)
            {
                Destroy(GameObject.Find("crowd"));
            }
            if (GameObject.Find("crowd1") != null)
            {
                Destroy(GameObject.Find("crowd1"));
            }

            GameObject newBin    = Instantiate(bin);
            GameObject newBrench = Instantiate(brench);
            newBin.name    = "bin";
            newBrench.name = "brench";
        }


        if (bodySourceView.getLeftCloseFlag() && gameObject.name == "HandLeft")
        {
            dropLeft.DragOrPickUp("HandLeft");
        }
        if (bodySourceView.getRightCloseFlag() && gameObject.name == "HandRight")
        {
            dropRight.DragOrPickUp("HandRight");
        }

        //if hand is open
        if (!bodySourceView.getLeftCloseFlag() && gameObject.name == "HandLeft" && dropLeft.getDrag())
        {
            dropLeft.DropItem();
        }
        //this is to check whether the hand are active


        /*
         * if (HasInput) {
         *              drop.DragOrPickUp ();
         *      } else {
         *              if (drop.getDrag()) {
         *                      drop.DropItem();
         *              }
         *      }
         */
    }
Esempio n. 3
0
    void Update()
    {
        Kinect.Body[] data = mBodySourceManager.GetData();

        //check to see if kenect is returning data
        if (data == null)
        {
            return;
        }

        //all tracking ids that the kinect can see
        List <ulong> trackedIds = new List <ulong>();



        foreach (var body in data)
        {
            //check to see if data isnt a body
            if (body == null)
            {
                continue;
            }

            //if body is currently being tracked add it to trackedIds list

            if (body.IsTracked)
            {
                trackedIds.Add(body.TrackingId);
            }
        }

        //the keys of the bodies dictionary
        List <ulong> knownIds = new List <ulong>(mBodies.Keys);

        foreach (ulong trackingId in knownIds)
        {
            //if trackedIds list does not contain the tracking id from know ids delete from scene
            if (!trackedIds.Contains(trackingId))
            {
                Destroy(mBodies[trackingId]);

                mBodies.Remove(trackingId);

                //reset bool tests
                resetTest();
            }
        }

        int counter = 0;

        //create bodies
        foreach (var body in data)
        {
            //if no body, skip
            if (body == null)
            {
                continue;
            }

            //body.TrackingId == trackedIds[0] ie/ if the bodys tracking ID is the first body that was tracked, creater and update it
            if (body.IsTracked && body.TrackingId == trackedIds[0])
            {
                chosenBody = body;

                //if body doesnt exist, create it
                if (!mBodies.ContainsKey(body.TrackingId))
                {
                    mBodies[body.TrackingId] = CreateBodyObject(body.TrackingId);
                }


                UpdateBodyObject(body, mBodies[body.TrackingId]);
                //update position

                counter++;

                if (collisionManager.CheckHandsShowing())
                {
                    //MAKE rightState be grabbed from BodySourceView as body is not defined here.
                    Kinect.HandState rightState = chosenBody.HandRightState;

                    if (rightState == Kinect.HandState.Closed)
                    {
                        rightCloseFlag = true;
                        GameObject.Find("HandRight").GetComponent <SpriteRenderer>().sprite = mClosedRight;
                        //drop.DragOrPickUp();
                    }
                    if (rightState == Kinect.HandState.Open)
                    {
                        rightCloseFlag = false;
                        GameObject.Find("HandRight").GetComponent <SpriteRenderer>().sprite = mOpenRight;
                        //drop.DropItem();
                    }

                    //left hand
                    Kinect.HandState leftState = chosenBody.HandLeftState;

                    if (leftState == Kinect.HandState.Closed)
                    {
                        leftCloseFlag = true;
                        GameObject.Find("HandLeft").GetComponent <SpriteRenderer>().sprite = mClosedLeft;
                    }
                    if (leftState == Kinect.HandState.Open)
                    {
                        leftCloseFlag = false;
                        GameObject.Find("HandLeft").GetComponent <SpriteRenderer>().sprite = mOpenLeft;
                    }
                }
            }
        }
    }