Ejemplo n.º 1
0
        public void Line(string name, Colour32 colour, int width, bool smooth, IEnumerable <v4> points)
        {
            if (!points.Any())
            {
                return;
            }
            var w = width != 0 ? $"*Width {{{width}}}" : string.Empty;
            var s = smooth ? "*Smooth " : string.Empty;

            Append("*LineStrip ", name, " ", colour, " {", w, s, points.Select(x => Ldr.Vec3(x)), "}\n");
        }
Ejemplo n.º 2
0
        public LdrBuilder Arrow(string name, Colour32 colour, Ldr.EArrowType type, float width, bool smooth, Func <int, v4?> points)
        {
            int idx = 0;

            Append("*Arrow ", name, " ", colour, " {");
            for (v4?pt; (pt = points(idx++)) != null;)
            {
                Append(Ldr.Vec3(pt.Value));
            }
            Append(Ldr.Width(width), Ldr.Smooth(smooth), type.ToString(), "}\n");
            return(this);
        }
Ejemplo n.º 3
0
        public LdrBuilder Line(string name, Colour32 colour, float width, bool smooth, Func <int, v4?> points)
        {
            int idx = 0;

            Append("*LineStrip ", name, " ", colour, " {", Ldr.Width(width), Ldr.Smooth(smooth));
            for (v4?pt; (pt = points(idx++)) != null;)
            {
                Append(Ldr.Vec3(pt.Value));
            }
            Append("}\n");
            return(this);
        }
Ejemplo n.º 4
0
        public void Line(string name, Colour32 colour, int width, bool smooth, Func <int, v4?> points)
        {
            int idx = 0;
            var w   = width != 0 ? $"*Width {{{width}}}" : string.Empty;
            var s   = smooth ? "*Smooth " : string.Empty;

            Append("*LineStrip ", name, " ", colour, " {", w, s);
            for (v4?pt; (pt = points(idx++)) != null;)
            {
                Append(Ldr.Vec3(pt.Value));
            }
            Append("}\n");
        }
Ejemplo n.º 5
0
 public LdrBuilder Append(object part)
 {
     if (part is string str)
     {
         m_sb.Append(str);
     }
     else if (part is Color col)
     {
         m_sb.Append(Ldr.Colour(col));
     }
     else if (part is v4 vec4)
     {
         m_sb.Append(Ldr.Vec3(vec4));
     }
     else if (part is v2 vec2)
     {
         m_sb.Append(Ldr.Vec2(vec2));
     }
     else if (part is m4x4 o2w)
     {
         m_sb.Append(Ldr.Mat4x4(o2w));
     }
     else if (part is AxisId axisid)
     {
         m_sb.Append(Ldr.AxisId(axisid.Id));
     }
     else if (part is EAxisId axisid2)
     {
         m_sb.Append(Ldr.AxisId(axisid2));
     }
     else if (part is IEnumerable)
     {
         foreach (var x in (IEnumerable)part)
         {
             Append(" ").Append(x ?? string.Empty);
         }
     }
     else if (part != null)
     {
         m_sb.Append(part.ToString());
     }
     return(this);
 }
Ejemplo n.º 6
0
 public LdrBuilder Mesh(string name, Colour32 colour, IList <v4>?verts, IList <v4>?normals = null, IList <Colour32>?colours = null, IList <v2>?tex = null, IList <ushort>?faces = null, IList <ushort>?lines = null, IList <ushort>?tetra = null, bool generate_normals = false, v4?position = null)
 {
     Append("*Mesh ", name, " ", colour, " {\n");
     if (verts != null)
     {
         Append("*Verts {").Append(verts.Select(x => Ldr.Vec3(x))).Append("}\n");
     }
     if (normals != null)
     {
         Append("*Normals {").Append(normals.Select(x => Ldr.Vec3(x))).Append("}\n");
     }
     if (colours != null)
     {
         Append("*Colours {").Append(colours.Select(x => Ldr.Colour(x))).Append("}\n");
     }
     if (tex != null)
     {
         Append("*TexCoords {").Append(tex.Select(x => Ldr.Vec2(x))).Append("}\n");
     }
     if (verts != null && faces != null)
     {
         Debug.Assert(faces.All(i => i >= 0 && i < verts.Count)); Append("*Faces {").Append(faces).Append("}\n");
     }
     if (verts != null && lines != null)
     {
         Debug.Assert(lines.All(i => i >= 0 && i < verts.Count)); Append("*Lines {").Append(lines).Append("}\n");
     }
     if (verts != null && tetra != null)
     {
         Debug.Assert(tetra.All(i => i >= 0 && i < verts.Count)); Append("*Tetra {").Append(tetra).Append("}\n");
     }
     if (generate_normals)
     {
         Append("*GenerateNormals\n");
     }
     if (position != null)
     {
         Append(Ldr.Position(position.Value));
     }
     Append("}\n");
     return(this);
 }
Ejemplo n.º 7
0
 public LdrBuilder Arrow(string name, Colour32 colour, Ldr.EArrowType type, float width, bool smooth, IEnumerable <v4> points)
 {
     if (!points.Any())
     {
         return(this);
     }
     return(Append("*Arrow ", name, " ", colour, " {", type.ToString(), points.Select(x => Ldr.Vec3(x)), Ldr.Width(width), Ldr.Smooth(smooth), "}\n"));
 }
Ejemplo n.º 8
0
 public LdrBuilder Line(string name, Colour32 colour, float width, bool smooth, IEnumerable <v4> points)
 {
     if (!points.Any())
     {
         return(this);
     }
     return(Append("*LineStrip ", name, " ", colour, " {", Ldr.Width(width), Ldr.Smooth(smooth), points.Select(x => Ldr.Vec3(x)), "}\n"));
 }