示例#1
0
        void GlDrawLine(VectorLine line)
        {
            int   end       = line.Points.Count - 1;
            float thisWidth = _lineWidth * line.Width;

            _lineMaterial.SetPass(0);

            if (line.Width == 1)
            {
                GL.Begin(GL.LINES);
                GL.Color(line.Color);
                for (int i = 0; i < end; ++i)
                {
                    GL.Vertex(_camera.ViewportToWorldPoint(new Vector3(line.Points[i].x, line.Points[i].y, _nearClip)));
                    GL.Vertex(_camera.ViewportToWorldPoint(new Vector3(line.Points[i + 1].x, line.Points[i + 1].y, _nearClip)));
                }
            }
            else
            {
                GL.Begin(GL.QUADS);
                GL.Color(line.Color);

                for (int i = 0; i < end; ++i)
                {
                    Vector3 perpendicular = (new Vector3(line.Points[i + 1].y, line.Points[i].x, _nearClip) -
                                             new Vector3(line.Points[i].y, line.Points[i + 1].x, _nearClip)).normalized * thisWidth;
                    Vector3 v1 = new Vector3(line.Points[i].x, line.Points[i].y, _nearClip);
                    Vector3 v2 = new Vector3(line.Points[i + 1].x, line.Points[i + 1].y, _nearClip);
                    GL.Vertex(_camera.ViewportToWorldPoint(v1 - perpendicular));
                    GL.Vertex(_camera.ViewportToWorldPoint(v1 + perpendicular));
                    GL.Vertex(_camera.ViewportToWorldPoint(v2 + perpendicular));
                    GL.Vertex(_camera.ViewportToWorldPoint(v2 - perpendicular));
                }
            }
            GL.End();
        }
示例#2
0
        public int AddLine(VectorLine line)         // will be drawed until remove called
        {
            _lines.Add(++_lastId, line);

            return(_lastId);
        }
示例#3
0
 public void DrawLine(VectorLine line)         // will be drawed only next frame
 {
     _oneFrameLines.Add(line);
 }