Beispiel #1
0
    void Start()
    {
        _Sensor = KinectSensor.GetDefault();
        if (_Sensor != null)
        {
            _Mapper = _Sensor.CoordinateMapper;
            var frameDesc = _Sensor.DepthFrameSource.FrameDescription;

            // Downsample to lower resolution
            CreateMesh(MeshWidth, MeshHeight);


            this.transform.position = new Vector3(0, 0, 0);

            if (!_Sensor.IsOpen)
            {
                _Sensor.Open();
            }
        }

        gameData = FindObjectOfType <SandBoxData> ();

        //if (gameData == default(ProportionPoint)) {
        //	Debug.Log ("gameData == null");
        //}
    }
Beispiel #2
0
    void Start()
    {
        if (instance != null)
        {
            Destroy(this.gameObject);
            return;
        }

        Debug.Log("displays connected: " + Display.displays.Length);
        if (Display.displays.Length > 1)
        {
            Display.displays[1].Activate();
        }

        ARS_Data.SandDepth       = new Vector2(2200f, 2500);
        ARS_Data.InterationDepth = new Vector2(1400f, 2040);

        ARS_Data.Rot = 0;

        ARS_Data.DepthImageConfig_LRTB = new Vector4(162f, 343, 305, 126);
        ARS_Data.CameraPosition        = new Vector4(-5f, 0, 50, 0);

        //If it gets here then this is the only one.
        instance = this;                                                // There can be only one
        GameObject.DontDestroyOnLoad(this.gameObject);                  //
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        gameObjectData = GameObject.Find("_SandBoxData");
        gameData       = gameObjectData.GetComponent <SandBoxData> ();
        if (gameData == null)
        {
            Debug.Log("gameData == null");
        }

        MainCamera = GameObject.Find("Main Camera");
    }
    // Use this for initialization
    void Start()
    {
        gameObjectData = GameObject.Find("_SandBoxData");
        gameData       = gameObjectData.GetComponent <SandBoxData> ();
        if (gameData == null)
        {
            Debug.Log("gameData == null");
        }

        MainCamera    = GameObject.Find("Main Camera");
        DesktopCamera = GameObject.Find("DesktopCamera");
        MainCamera.GetComponent <Camera>().targetDisplay    = 1;
        DesktopCamera.GetComponent <Camera>().targetDisplay = 0;
    }
Beispiel #5
0
    void Start()
    {
        if (instance != null)
        {
            Destroy(this.gameObject);
            return;
        }

        ARS_Data.SandDepth       = new Vector2(2240f, 2462);
        ARS_Data.InterationDepth = new Vector2(1600f, 2040);

        ARS_Data.Rot = 180;

        ARS_Data.DepthImageConfig_LRTB = new Vector4(159f, 345, 322, 106);

        //If it gets here then this is the only one.
        instance = this;                                                // There can be only one
        GameObject.DontDestroyOnLoad(this.gameObject);                  //
    }
Beispiel #6
0
    void Start()
    {
        if (instance != null)
        {
            Destroy(this.gameObject);
            return;
        }

        ARS_Data.SandDepth       = new Vector2(2200f, 2500);
        ARS_Data.InterationDepth = new Vector2(1600f, 2040);

        ARS_Data.Rot = 0;

        ARS_Data.DepthImageConfig_LRTB = new Vector4(162f, 343, 305, 126);
        ARS_Data.CameraPosition        = new Vector4(-5f, 0, 50, 0);

        //If it gets here then this is the only one.
        instance = this;                                                // There can be only one
        GameObject.DontDestroyOnLoad(this.gameObject);                  //
    }
Beispiel #7
0
    private void RefreshData(ushort[] depthData, int colorWidth, int colorHeight)
    {
        gameData = FindObjectOfType <SandBoxData> ();

        var frameDesc = _Sensor.DepthFrameSource.FrameDescription;

        ColorSpacePoint[] colorSpace = new ColorSpacePoint[depthData.Length];

        float increment_x, increment_y;

        increment_x = (gameData.ARS_Data.DepthImageConfig_LRTB.y - gameData.ARS_Data.DepthImageConfig_LRTB.x) / MeshWidth;         //frameDesc.Height / MeshHeight;
        increment_y = (gameData.ARS_Data.DepthImageConfig_LRTB.z - gameData.ARS_Data.DepthImageConfig_LRTB.w) / MeshHeight;        //frameDesc.Height / MeshHeight;

        if (Mode == 0)
        {
            DepthCutOff = gameData.ARS_Data.SandDepth;
        }
        else
        {
            DepthCutOff = gameData.ARS_Data.InterationDepth;
        }



        for (int y = 0; y < MeshHeight; y++)
        {
            for (int x = 0; x < MeshWidth; x++)
            {
                int indexX     = (int)gameData.ARS_Data.DepthImageConfig_LRTB.x + (int)(x * increment_x);
                int indexY     = (int)gameData.ARS_Data.DepthImageConfig_LRTB.w + (int)(y * increment_y);
                int smallIndex = (y * MeshWidth) + x;
                int bigIndex   = (indexY * frameDesc.Width) + indexX;


                double avg;
                if (Mode == 0)
                {
                    if ((depthData [bigIndex] >= DepthCutOff.x) && (depthData [bigIndex] < DepthCutOff.y))
                    {
                        avg = depthData [bigIndex];

                        avg *= _DepthScale;
                        avg -= 125;
                        _Vertices [smallIndex].z = (float)avg;
                    }
                }
                else
                {
                    if ((depthData [bigIndex] >= DepthCutOff.x) && (depthData [bigIndex] < DepthCutOff.y))
                    {
                        avg = depthData [bigIndex];

                        avg *= _DepthScale;
                        _Vertices [smallIndex].z = (float)(avg - 125);
                    }
                    else
                    {
                        _Vertices [smallIndex].z = 0f;
                    }
                }



                // Update UV mapping with CDRP
                var colorSpacePoint = colorSpace[(y * frameDesc.Width) + x];
                _UV[smallIndex] = new Vector2((int)gameData.ARS_Data.DepthImageConfig_LRTB.x + (colorSpacePoint.X / (float)(colorWidth * MeshHeight)),
                                              (int)gameData.ARS_Data.DepthImageConfig_LRTB.w + (colorSpacePoint.Y / (float)(colorHeight * MeshHeight)));
            }
        }



        MeshCollider myMC = GetComponent <MeshCollider>();

        _Mesh.vertices  = _Vertices;
        _Mesh.uv        = _UV;
        _Mesh.triangles = _Triangles;
        _Mesh.RecalculateNormals();
        _Mesh.RecalculateBounds();
        myMC.sharedMesh = _Mesh;
    }