Пример #1
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"));
 }
Пример #2
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");
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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");
        }
Пример #6
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);
 }
Пример #7
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);
 }
Пример #8
0
 public LdrBuilder Ellipse(string name, Colour32 colour, AxisId axis_id, bool solid, float radiusx, float radiusy, v4 position)
 {
     return(Append("*Circle ", name, " ", colour, " {", radiusx, " ", radiusy, " ", axis_id, " ", Ldr.Solid(solid), " ", Ldr.Position(position), "}\n"));
 }
Пример #9
0
 public LdrBuilder Pie(string name, Colour32 colour, AxisId axis_id, bool solid, float ang0, float ang1, float rad0, float rad1, float sx, float sy, int facets, v4 position)
 {
     return(Append("*Pie ", name, " ", colour, " {", ang0, " ", ang1, " ", rad0, " ", rad1, " ", axis_id, " ", Ldr.Solid(solid), " ", Ldr.Facets(facets), " *Scale ", sx, " ", sy, " ", Ldr.Position(position), "}\n"));
 }
Пример #10
0
 public LdrBuilder Sphere(string name, Colour32 colour, float radius, v4 position)
 {
     return(Append("*Sphere ", name, " ", colour, " {", radius, " ", Ldr.Position(position), "}\n"));
 }
Пример #11
0
 public LdrBuilder Cylinder(string name, Colour32 colour, AxisId axis_id, float height, float radius, m4x4?o2w = null, v4?pos = null)
 {
     return(Append("*Cylinder ", name, " ", colour, " {", height, " ", radius, " ", axis_id, " ", Ldr.Transform(o2w, pos), "}\n"));
 }
Пример #12
0
 public void Quad(string name, Colour32 colour, v4 tl, v4 tr, v4 br, v4 bl, v4 position)
 {
     Append("*Quad ", name, " ", colour, " {", bl, " ", br, " ", tr, " ", tl, " ", Ldr.Position(position), "}\n");
 }
Пример #13
0
 public LdrBuilder Box(string name, Colour32 colour, v4 dim, m4x4?o2w = null, v4?pos = null)
 {
     return(Append("*Box ", name, " ", colour, " {", dim.x, " ", dim.y, " ", dim.z, " ", Ldr.Transform(o2w, pos), "}\n"));
 }
Пример #14
0
 public LdrBuilder Axis(string name, Colour32 colour, m4x4 basis, float scale)
 {
     return(Append("*Matrix3x3 ", name, " ", colour, " {", basis.x * scale, " ", basis.y * scale, " ", basis.z * scale, " ", Ldr.Position(basis.pos), "}\n"));
 }
Пример #15
0
 public LdrBuilder Triangle(string name, Colour32 colour, IEnumerable <v4> pts, m4x4?o2w = null)
 {
     return(Append("*Triangle ", name, " ", colour, " {", pts, Ldr.Transform(o2w), "}"));
 }
Пример #16
0
 public LdrBuilder LineD(string name, Colour32 colour, v4 start, v4 direction, float width)
 {
     return(Append("*LineD ", name, " ", colour, " {", Ldr.Width(width), start, " ", direction, "}"));
 }
Пример #17
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"));
 }
Пример #18
0
 public void Triangle(string name, Colour32 colour, IEnumerable <v4> pts, m4x4?o2w = null)
 {
     Append("*Triangle ", name, " ", colour, " {", pts, Ldr.Transform(o2w), "}");
 }
Пример #19
0
 public void Circle(string name, Colour32 colour, AxisId axis_id, bool solid, float radius, v4 position)
 {
     Append("*Circle ", name, " ", colour, " {", radius, " ", axis_id, " ", Ldr.Solid(solid), " ", Ldr.Position(position), "}\n");
 }
Пример #20
0
 public LdrBuilder GroupClose(m4x4 transform)
 {
     return(Append(Ldr.Transform(transform, newline: true), "}\n"));
 }
Пример #21
0
 public LdrBuilder Rect(string name, Colour32 colour, AxisId axis_id, float width, float height, bool solid, float corner_radius, v4 position)
 {
     return(Append("*Rect ", name, " ", colour, " {", width, " ", height, " ", axis_id, " ", Ldr.Solid(solid), " ", Ldr.CornerRadius(corner_radius), " ", Ldr.Position(position), "}\n"));
 }
Пример #22
0
 public void Triangle(string name, Colour32 colour, v4 a, v4 b, v4 c, m4x4?o2w = null)
 {
     Append("*Triangle ", name, " ", colour, " {", a, " ", b, " ", c, " ", Ldr.Transform(o2w), "}");
 }
Пример #23
0
 public LdrBuilder Triangle(string name, Colour32 colour, v4 a, v4 b, v4 c, m4x4?o2w = null)
 {
     return(Append("*Triangle ", name, " ", colour, " {", a, " ", b, " ", c, " ", Ldr.Transform(o2w), "}"));
 }
Пример #24
0
 public LdrBuilder Box(string name, Colour32 colour, float sx, float sy, float sz, m4x4?o2w = null, v4?pos = null)
 {
     return(Append("*Box ", name, " ", colour, " {", sx, " ", sy, " ", sz, " ", Ldr.Transform(o2w, pos), "}\n"));
 }
Пример #25
0
 public LdrBuilder Quad(string name, Colour32 colour, v4 tl, v4 tr, v4 br, v4 bl, v4 position)
 {
     return(Append("*Quad ", name, " ", colour, " {", bl, " ", br, " ", tr, " ", tl, " ", Ldr.Position(position), "}\n"));
 }
Пример #26
0
 public void Axis(string name, Colour32 colour, m4x4 basis, float scale)
 {
     Append("*Matrix3x3 ", name, " ", colour, " {", basis.x * scale, " ", basis.y * scale, " ", basis.z * scale, " ", Ldr.Position(basis.pos), "}\n");
 }
Пример #27
0
 public LdrBuilder Ribbon(string name, Colour32 colour, IEnumerable <v4> points, AxisId axis_id, float width, bool smooth, m4x4?o2w = null)
 {
     return(Append("*Ribbon ", name, " ", colour, " {", points, " ", axis_id, Ldr.Width(width), Ldr.Smooth(smooth), Ldr.Transform(o2w), "}\n"));
 }
Пример #28
0
 public void Rect(string name, Colour32 colour, AxisId axis_id, float width, float height, bool solid, v4 position)
 {
     Append("*Rect ", name, " ", colour, " {", width, " ", height, " ", axis_id, " ", Ldr.Solid(solid), " ", Ldr.Position(position), "}\n");
 }
Пример #29
0
 public void ToFile(string filepath, bool append = false)
 {
     Ldr.Write(ToString(), filepath, append);
 }
Пример #30
0
 public LdrBuilder Grid(string name, Colour32 colour, AxisId axis_id, int width, int height, int wdiv, int hdiv, v4 position)
 {
     return(Append("*Grid ", name, " ", colour, " {", width, " ", height, " ", wdiv, " ", hdiv, " ", axis_id, " ", Ldr.Position(position), "}\n"));
 }