Exemplo n.º 1
0
    // Update plotters and show if visualizeData[idx] is true;
    // Update the materials before to ensure there is a renderer attached to the child object.
    public override void UpdateMesh()
    {
        float[] yStartPos = new float[numberOfSamples];
        for (int i = 0; i < numberOfSamples; i++)
        {
            yStartPos[i] = 0;
        }
        Vector3[] lines = new Vector3[numberOfSamples * 2];



        Transform trans = PlotterGroup.transform;

        float xScale = chartSize.x / (numberOfSamples);
        float yScale = chartSize.y;

        for (int childIdx = 0; childIdx < trans.childCount; childIdx++)
        {
            string     name = MeshUtils.NameGenerator(Identifier, childIdx);
            GameObject obj  = trans.Find(name).gameObject;
            DataSeries pltr = obj.GetComponent <DataSeries>();

            // Sometimes the materials might have been changed during scheduledUpdate
            if (childIdx < Materials.Length)
            {
                pltr.UpdateMaterial(Materials[childIdx]);
            }

            // Sometimes the visualizeData might have been changed during scheduledUpdate
            if (childIdx < visualizeData.Length)
            {
                pltr.GetComponent <Renderer>().enabled = visualizeData[childIdx];
                if (!visualizeData[childIdx])
                {
                    continue;
                }
            }

            float[] currentSeries = pltr.GetRearrangedData();

            int   xIdx = numberOfSamples;
            int   lineIdx = 0;
            float xPos, yPos;
            for (int idx = 0; idx < currentSeries.Length; idx++)
            {
                xPos             = (xIdx - .5f) * xScale;
                yPos             = yStartPos[idx];
                lines[lineIdx++] = new Vector3(xPos, yPos);
                yPos            += currentSeries[idx] * yScale;
                lines[lineIdx++] = new Vector3(xPos, yPos);
                yStartPos[idx]   = yPos;
                xIdx--;
            }


            pltr.UpdateMesh(MeshUtils.GenerateLineMesh(lines, xScale));
        }
    }
Exemplo n.º 2
0
    // Update plotters and show if visualizeData[idx] is true;
    // Update the materials before to ensure there is a renderer attached to the child object.
    public override void UpdateMesh()
    {
        Transform trans = PlotterGroup.transform;

        for (int childIdx = 0; childIdx < trans.childCount; childIdx++)
        {
            string     name = MeshUtils.NameGenerator(Identifier, childIdx);
            GameObject obj  = trans.Find(name).gameObject;
            DataSeries pltr = obj.GetComponent <DataSeries>();

            //// GetRearrangedData make the latest sampling as the last point of the Line chart.
            //// Prepare the input for making the mesh of the each Line.
            //Vector3[] lines = CreateLineFromData(pltr.GetRearrangedData());

            //// Generate Line Mesh in the DataSeries which contain a mesh Renderer.
            //pltr.UpdateMesh(MeshUtils.GenerateLineMesh(lines, currentWidth));

            // Sometimes the materials might have been changed during scheduledUpdate
            if (childIdx < Materials.Length)
            {
                pltr.UpdateMaterial(Materials[childIdx]);
            }

            pltr.UpdateMesh();

            //pltr.UpdateFloatingValue(timeSliderPosition);

            //// TODO: A method that pre-arrange yPos of floating values so that
            ////       it won't be overlapping (when there are several Lines)

            //// Update the floating value tracing the last sampling of the each Line.
            //// GetRearrangedData() begins with the lastest sampling.
            //pltr.UpdateFloatingValue(lines[0]);

            // Sometimes the visualizeData might have been changed during scheduledUpdate
            if (childIdx < visualizeData.Length)
            {
                pltr.GetComponent <Renderer>().enabled = visualizeData[childIdx];
            }
        }
    }