示例#1
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);
 }
示例#2
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);
 }