Esempio n. 1
0
        public static void AddLine(
            Vector2 start, Vector2 end, Vector2 dir,
            Geometry geometry,
            float startThickness,
            float endThickness)
        {
            Vector2 right      = MathsHelper.Perp2D(dir);
            Vector2 startRight = right * (startThickness / 2f);
            Vector2 endRight   = right * (endThickness / 2f);

            int baseIndex = geometry.Vertices.Count;

            geometry.Vertices.Add(end - endRight);
            geometry.Vertices.Add(start + startRight);
            geometry.Vertices.Add(end + endRight);
            geometry.Vertices.Add(start - startRight);

            //if (geometry.ColliderPoints != null)
            //{
            //    for (int i = baseIndex; i < geometry.Vertices.Count; ++i)
            //    {
            //        geometry.ColliderPoints.Add((Vector2)geometry.Vertices[i]);
            //    }
            //}

            geometry.UVs.Add(new Vector2(0, 1));
            geometry.UVs.Add(new Vector2(1, 0));
            geometry.UVs.Add(new Vector2(1, 1));
            geometry.UVs.Add(new Vector2(0, 0));

            geometry.Indices.Add(baseIndex + 0);
            geometry.Indices.Add(baseIndex + 2);
            geometry.Indices.Add(baseIndex + 1);

            geometry.Indices.Add(baseIndex + 0);
            geometry.Indices.Add(baseIndex + 1);
            geometry.Indices.Add(baseIndex + 3);

            geometry.CreateDefaultNormals();
        }