Exemple #1
0
    void postRender(Camera cam)
    {
        bool camCheck = true;

        if (cam.cameraType == CameraType.Game && !gameCams)
        {
            camCheck = false;
        }
        if (cam.cameraType == CameraType.SceneView && !sceneCam)
        {
            camCheck = false;
        }
        if (!camCheck)
        {
            return;
        }

        if (po == null)
        {
            return;
        }
        if (pointObjects == null)
        {
            return;
        }

        if (po.Count == 0)
        {
            return;
        }
        if (!processLines)
        {
            return;
        }


        lineMat.SetPass(0);
        GL.PushMatrix();
        //GL.MultMatrix(Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale));
        GL.Begin(GL.LINES);

        for (int i = 0; i < numValidPoints; i++)
        {
            Vector3          p          = pointObjects[i].point;
            PCLPointObject[] neighbours = po.GetNearbyAndPositive(p, maxDistance);

            foreach (PCLPointObject ppo in neighbours)
            {
                Vector3 np = ppo.point;

                //if (Vector3.Distance(np, p) > maxDistance) continue;

                if (drawLines)
                {
                    float dist        = Vector3.Distance(np, p);
                    float targetAlpha = alphaDecay.Evaluate(dist / maxDistance);


                    GL.Color(Color.Lerp(nearColor, farColor, targetAlpha));

                    //GL.TexCoord(Vector3.zero);
                    GL.TexCoord(new Vector3(Time.time * texSpeed * targetAlpha, 0, 0));
                    GL.Vertex(np);

                    //GL.TexCoord(Vector3.one);
                    GL.TexCoord(new Vector3(Time.time * texSpeed * targetAlpha + 1, 0, 0));
                    GL.Vertex(p);
                }
            }
        }

        GL.End();
        GL.PopMatrix();
    }