HelixToolkit.Wpf.MeshBuilder.ToMesh C# (CSharp) Method

ToMesh() public method

Converts the geometry to a MeshGeometry3D .
public ToMesh ( bool freeze = false ) : System.Windows.Media.Media3D.MeshGeometry3D
freeze bool /// freeze the mesh if set to true . ///
return System.Windows.Media.Media3D.MeshGeometry3D
        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;
        }

Usage Example

コード例 #1
3
 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();
 }
All Usage Examples Of HelixToolkit.Wpf.MeshBuilder::ToMesh