Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Frame.PointCloud.IsUpdatedThisFrame)
        {
            if (logger != null)
            {
                logger.text = "Have Points";
            }
            if (AddVoxels)
            {
                CameraImageBytes cim = Frame.CameraImage.AcquireCameraImageBytes();

                for (int i = 0; i < Frame.PointCloud.PointCount; i++)
                {
                    Color colour      = new Color(0, 0, 0);
                    bool  foundColour = false;

                    PointCloudPoint p = Frame.PointCloud.GetPointAsStruct(i);
                    Vector3         cameraCoordinates = arCamera.WorldToViewportPoint(p);

                    if (cim.IsAvailable)
                    {
                        var uvQuad = Frame.CameraImage.DisplayUvCoords;
                        int cx     = (int)(cameraCoordinates.x * cim.Width);
                        int cy     = (int)((1.0f - cameraCoordinates.y) * cim.Height);
                        colour = GetColourAt(cim, cx, cy, out foundColour);
                    }
                    if (foundColour)
                    {
                        tree.addPoint(p, colour);
                    }
                }
                cim.Release();
            }
            tree.renderOctTree(voxelParent);
        }
        else
        {
            if (logger != null)
            {
                logger.text = "No Points";
            }
        }
    }