// inits the mesh and related data
        private void InitMesh()
        {
            // create mesh
            mesh = new Mesh
            {
                name        = "User" + playerIndex + "Mesh-S" + sensorIndex,
                indexFormat = UnityEngine.Rendering.IndexFormat.UInt32
            };

            MeshFilter meshFilter = GetComponent <MeshFilter>();

            if (meshFilter != null)
            {
                meshFilter.mesh = mesh;
            }
            else
            {
                Debug.LogWarning("MeshFilter not found! You may not see the mesh on screen");
            }

            // create depth image buffer
            if (depthImageBuffer == null)
            {
                int depthImageLength = sensorData.depthImageWidth * sensorData.depthImageHeight;
                depthImageCopy = new ushort[depthImageLength];

                int depthBufferLength = sensorData.depthImageWidth * sensorData.depthImageHeight / 2;
                depthImageBuffer = KinectInterop.CreateComputeBuffer(depthImageBuffer, depthBufferLength, sizeof(uint));
                //depthBufferCreated = true;
            }

            // create body index buffer
            if (bodyIndexBuffer == null)
            {
                int bodyIndexLength = sensorData.depthImageWidth * sensorData.depthImageHeight;
                bodyIndexCopy = new byte[bodyIndexLength];

                int bodyIndexBufferLength = sensorData.depthImageWidth * sensorData.depthImageHeight / 4;
                bodyIndexBuffer = KinectInterop.CreateComputeBuffer(bodyIndexBuffer, bodyIndexBufferLength, sizeof(uint));
                //bodyIndexBufferCreated = true;
            }

            // create point cloud color texture
            if (sensorData != null && sensorData.sensorInterface != null)
            {
                sensorInt = (DepthSensorBase)sensorData.sensorInterface;

                Vector2Int imageRes = Vector2Int.zero;
                if (sensorInt.pointCloudColorTexture == null)
                {
                    sensorInt.pointCloudResolution = sourceImageResolution;
                    imageRes = sensorInt.GetPointCloudTexResolution(sensorData);

                    colorTexture = KinectInterop.CreateRenderTexture(colorTexture, imageRes.x, imageRes.y, RenderTextureFormat.ARGB32);
                    sensorInt.pointCloudColorTexture = colorTexture;
                    colorTextureCreated = true;
                }
                else
                {
                    sourceImageResolution = sensorInt.pointCloudResolution;
                    imageRes            = sensorInt.GetPointCloudTexResolution(sensorData);
                    colorTexture        = sensorInt.pointCloudColorTexture;
                    colorTextureCreated = false;
                }

                // create space table
                spaceTable = sensorInt.pointCloudResolution == DepthSensorBase.PointCloudResolution.DepthCameraResolution ?
                             sensorInt.GetDepthCameraSpaceTable(sensorData) : sensorInt.GetColorCameraSpaceTable(sensorData);

                int spaceBufferLength = imageRes.x * imageRes.y * 3;
                spaceTableBuffer = new ComputeBuffer(spaceBufferLength, sizeof(float));
                spaceTableBuffer.SetData(spaceTable);
                spaceTable = null;

                // create copy texture
                colorTextureCopy = KinectInterop.CreateRenderTexture(colorTextureCopy, imageRes.x, imageRes.y, RenderTextureFormat.ARGB32);

                // set the color texture
                Renderer meshRenderer = GetComponent <Renderer>();
                if (meshRenderer && meshRenderer.material /**&& meshRenderer.material.mainTexture == null*/)
                {
                    meshShaderMat = meshRenderer.material;
                }

                // get reference to the transform
                trans = GetComponent <Transform>();

                // image width & height
                imageWidth  = imageRes.x;
                imageHeight = imageRes.y;

                // create mesh vertices & indices
                CreateMeshVertInd();
                bMeshInited = true;
            }
        }
        // inits the mesh and related data
        private void InitMesh()
        {
            // create mesh
            mesh = new Mesh
            {
                name        = "User" + playerIndex + "Mesh-S" + sensorIndex,
                indexFormat = UnityEngine.Rendering.IndexFormat.UInt32
            };

            MeshFilter meshFilter = GetComponent <MeshFilter>();

            if (meshFilter != null)
            {
                meshFilter.mesh = mesh;
            }
            else
            {
                Debug.LogWarning("MeshFilter not found! You may not see the mesh on screen");
            }

            // set the color texture
            Renderer meshRenderer = GetComponent <Renderer>();

            if (meshRenderer && meshRenderer.material /**&& meshRenderer.material.mainTexture == null*/)
            {
                Shader meshShader = Shader.Find("Kinect/UserMeshUShader");  // Kinect/UserMeshVShader
                if (meshShader != null)
                {
                    meshShaderMat         = new Material(meshShader);
                    meshRenderer.material = meshShaderMat;
                }
            }

            // get reference to the transform
            trans = GetComponent <Transform>();

            // get sensor interface
            sensorInt = sensorData != null ? (DepthSensorBase)sensorData.sensorInterface : null;

            // create point cloud color texture
            if (sensorData != null && sensorInt != null && meshShaderMat != null)
            {
                Vector2Int imageRes = Vector2Int.zero;
                if (sensorInt.pointCloudColorTexture == null)
                {
                    sensorInt.pointCloudResolution = sourceImageResolution;
                    imageRes = sensorInt.GetPointCloudTexResolution(sensorData);

                    //colorTexture = KinectInterop.CreateRenderTexture(colorTexture, imageRes.x, imageRes.y, RenderTextureFormat.ARGB32);
                    //sensorInt.pointCloudColorTexture = colorTexture;
                    colorTextureCreated = true;
                }
                else
                {
                    sourceImageResolution = sensorInt.pointCloudResolution;
                    imageRes            = sensorInt.GetPointCloudTexResolution(sensorData);
                    colorTexture        = sensorInt.pointCloudColorTexture;
                    colorTextureCreated = false;
                }

                // get space scale
                sensorSpaceScale = kinectManager.GetSensorSpaceScale(sensorIndex);  // kinectManager.GetDepthImageScale(sensorIndex)

                // update textures and buffers
                UpdateTexturesAndBuffers();

                bMeshInited = true;
            }
        }