public QuadNode(string text, v4?size = null, m4x4?position = null, NodeStyle?style = null) : base(size ?? new v4(50, 50, 0, 0), Guid.NewGuid(), text, position, style) { Size = Style.AutoSize ? PreferredSize(SizeMax) : Size; // Create a texture for drawing the node content into Surf = new Surface(Size.xi, Size.yi); // Create a quad model var ldr = new LdrBuilder(); ldr.Rect("node", Colour32.White, EAxisId.PosZ, Size.x, Size.y, true, (float)Style.CornerRadius, v4.Origin); Gfx = new View3d.Object(ldr, false, null, null); Gfx.SetTexture(Surf.Surf); }
[Test] public void LdrBuilder() { var ldr = new LdrBuilder(); using (ldr.Group("g")) { ldr.Box("b", Color.FromArgb(0, 0xFF, 0)); ldr.Sphere("s", Color.Red); } var expected = "*Group g FFFFFFFF {\n" + "*Box b FF00FF00 {1 }\n" + "*Sphere s FFFF0000 {1 }\n" + "}\n"; Assert.Equal(expected, ldr.ToString()); }
public static void Mesh(this LdrBuilder ldr, string name, Colour32 colour, View3d.EGeom geom, IList <View3d.Vertex> verts, IList <ushort>?faces = null, IList <ushort>?lines = null, IList <ushort>?tetra = null, bool generate_normals = false, v4?position = null) { ldr.Append("*Mesh ", name, " ", colour, " {\n"); if ((geom & View3d.EGeom.Vert) != 0) { ldr.Append("*Verts {").Append(verts.Select(x => Ldr.Vec3(x.m_pos))).Append("}\n"); } if ((geom & View3d.EGeom.Norm) != 0) { ldr.Append("*Normals {").Append(verts.Select(x => Ldr.Vec3(x.m_norm))).Append("}\n"); } if ((geom & View3d.EGeom.Colr) != 0) { ldr.Append("*Colours {").Append(verts.Select(x => Ldr.Colour(x.m_col))).Append("}\n"); } if ((geom & View3d.EGeom.Tex0) != 0) { ldr.Append("*TexCoords {").Append(verts.Select(x => Ldr.Vec2(x.m_uv))).Append("}\n"); } if (faces != null) { Debug.Assert(faces.All(i => i >= 0 && i < verts.Count)); ldr.Append("*Faces {").Append(faces).Append("}\n"); } if (lines != null) { Debug.Assert(lines.All(i => i >= 0 && i < verts.Count)); ldr.Append("*Lines {").Append(lines).Append("}\n"); } if (tetra != null) { Debug.Assert(tetra.All(i => i >= 0 && i < verts.Count)); ldr.Append("*Tetra {").Append(tetra).Append("}\n"); } if (generate_normals) { ldr.Append("*GenerateNormals\n"); } if (position != null) { ldr.Append(Ldr.Position(position.Value)); } ldr.Append("}\n"); }