コード例 #1
0
    void UpdateMesh()
    {
        runningFrame++;

        positions = PointCloudSubscriber.GetPCL(runningFrame);

        Debug.Log("Renderer: points received");
        if (positions == null || positions.Length == 0)
        {
            Debug.Log("Empty array");
            return;
        }
        int size = positions.Length;

        colours = new Color[size];
        Debug.Log(size);

        for (int n = 0; n < size; n++)
        {
            //pcl[n] = new Vector3(points[n * 3], points[n * 3 + 1], points[n * 3 + 2]);
            colours[n] = new Color(1, 1, 1, 1);
        }

        mf.mesh.Clear();

        Mesh mesh2 = new Mesh
        {
            // Use 32 bit integer values for the mesh, allows for stupid amount of vertices (2,147,483,647 I think?)
            indexFormat = UnityEngine.Rendering.IndexFormat.UInt32
        };

        mesh2.vertices = positions;
        mesh2.colors   = colours;
        int[] indices = new int[positions.Length];

        for (int i = 0; i < positions.Length; i++)
        {
            indices[i] = i;
        }

        mesh2.SetIndices(indices, MeshTopology.Points, 0);
        mesh2.RecalculateNormals();
        mf.mesh = mesh2;
        Debug.Log("Renderer: points updated");
    }
コード例 #2
0
    void UpdateMesh()
    {
        //positions = subscriber.pcl;
        positions = subscriber.GetPCL();
        colours   = subscriber.GetPCLColor();
        if (positions == null)
        {
            return;
        }
        mesh.Clear();
        mesh.vertices = positions;
        mesh.colors   = colours;
        int[] indices = new int[positions.Length];

        for (int i = 0; i < positions.Length; i++)
        {
            indices[i] = i;
        }

        mesh.SetIndices(indices, MeshTopology.Points, 0);
        mf.mesh = mesh;
    }