public MeshGeometry3D ToMesh(bool freeze = false) { if (this.normals != null && this.positions.Count != this.normals.Count) { throw new InvalidOperationException(WrongNumberOfNormals); } if (this.textureCoordinates != null && this.positions.Count != this.textureCoordinates.Count) { throw new InvalidOperationException(WrongNumberOfTextureCoordinates); } var mg = new MeshGeometry3D { Positions = this.positions, TriangleIndices = this.triangleIndices, Normals = this.normals, TextureCoordinates = this.textureCoordinates }; if (freeze) { mg.Freeze(); } return mg; }
public MainViewModel() { var gm = new MeshBuilder(); gm.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1); gm.AddCylinder(new Point3D(5, 0, 0), new Point3D(5, 0, 5), 1, 36); this.Model = new GeometryModel3D(gm.ToMesh(true), Materials.Blue); this.Model.Freeze(); }