Exemplo n.º 1
0
    void Start()
    {
        myLib = new MyLib ();
        openNI = GameObject.FindGameObjectWithTag ("OpenNI").GetComponent (typeof(OpenNI2)) as OpenNI2;
        depthGenerator = openNI.depth;

        // Find all triggers
        GameObject triggers = GameObject.FindGameObjectWithTag("Triggers") as GameObject;
        boxTriggers = new Transform[triggers.transform.GetChildCount()];
        audioSources = new AudioSource[triggers.transform.GetChildCount()];
        triggerCells = new TriggerCell[triggers.transform.GetChildCount()];
        int i = 0;
        foreach (Transform t in triggers.transform) {
            boxTriggers[i] = t;
            audioSources[i] = t.GetComponent (typeof(AudioSource)) as AudioSource;
            triggerCells[i] = t.GetComponent (typeof(TriggerCell)) as TriggerCell;
            i++;
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        bool doUpdate = true;

        context.WaitNoneUpdateAll ();

        // Draw the RGB data to a texture
        MyLib myLib = new MyLib ();
        IntPtr imageP = this.imageGenerator.GetImageMapPtr ();
        int texId = texture.GetNativeTextureID ();
        bool result = myLib.CamTexture (texId, 640, 480, imageP);
        Debug.Log ("Texture ID: " + texId + " Result: " + result);

        uint[] users = userGenerator.GetUsers ();
        foreach (uint user in users) {
            if (skeletonCapability.IsTracking (user)) {
                doUpdate = false;
                Debug.Log ("Here we go!");

                if (drawSkeleton) {
                    LineRenderer lineRenderer = center.GetComponent (typeof(LineRenderer)) as LineRenderer;
                    int i = 0;
                    lineRenderer.SetVertexCount (3);
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.Head));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.Neck));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.Torso));
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.Waist));

                    lineRenderer = leftArm.GetComponent (typeof(LineRenderer)) as LineRenderer;
                    i = 0;
                    lineRenderer.SetVertexCount (3);
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.LeftCollar));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.LeftShoulder));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.LeftElbow));
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.LeftWrist));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.LeftHand));

                    lineRenderer = rightArm.GetComponent (typeof(LineRenderer)) as LineRenderer;
                    i = 0;
                    lineRenderer.SetVertexCount (3);
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.RightCollar));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.RightShoulder));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.RightElbow));
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.RightWrist));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.RightHand));

                    lineRenderer = leftLeg.GetComponent (typeof(LineRenderer)) as LineRenderer;
                    i = 0;
                    lineRenderer.SetVertexCount (3);
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.LeftHip));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.LeftKnee));
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.LeftAnkle));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.LeftFoot));

                    lineRenderer = rightLeg.GetComponent (typeof(LineRenderer)) as LineRenderer;
                    i = 0;
                    lineRenderer.SetVertexCount (3);
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.RightHip));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.RightKnee));
                    //lineRenderer.SetPosition(i++, getJointVector3(user, SkeletonJoint.RightAnkle));
                    lineRenderer.SetPosition (i++, getJointVector3 (user, SkeletonJoint.RightFoot));
                }

                // Set transforms
                //Rigidbody rigidbody = leftHand.gameObject.GetComponent (typeof(Rigidbody)) as Rigidbody;
                //rigidbody.MovePosition (getJointVector3 (user, SkeletonJoint.LeftHand));
                //rigidbody = rightHand.gameObject.GetComponent (typeof(Rigidbody)) as Rigidbody;
                //rigidbody.MovePosition (getJointVector3 (user, SkeletonJoint.RightHand));

                if (head != null) {
                    head.position = getJointVector3 (user, SkeletonJoint.Head);
                }

                //leftHand.position = getJointVector3(user, SkeletonJoint.LeftHand);
                //rightHand.position = getJointVector3(user, SkeletonJoint.RightHand);
            }
        }
    }