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

AddExtrudedGeometry() public method

Adds an extruded surface of the specified curve.
The y-axis is determined by the cross product between the specified x-axis and the p1-p0 vector.
public AddExtrudedGeometry ( IList points, System.Windows.Media.Media3D.Vector3D xaxis, System.Windows.Media.Media3D.Point3D p0, System.Windows.Media.Media3D.Point3D p1 ) : void
points IList /// The 2D points describing the curve to extrude. ///
xaxis System.Windows.Media.Media3D.Vector3D /// The x-axis. ///
p0 System.Windows.Media.Media3D.Point3D /// The start origin of the extruded surface. ///
p1 System.Windows.Media.Media3D.Point3D /// The end origin of the extruded surface. ///
return void
        public void AddExtrudedGeometry(IList<Point> points, Vector3D xaxis, Point3D p0, Point3D p1)
        {
            var ydirection = Vector3D.CrossProduct(xaxis, p1 - p0);
            ydirection.Normalize();
            xaxis.Normalize();

            int index0 = this.positions.Count;
            int np = 2 * points.Count;
            foreach (var p in points)
            {
                var v = (xaxis * p.X) + (ydirection * p.Y);
                this.positions.Add(p0 + v);
                this.positions.Add(p1 + v);
                v.Normalize();
                if (this.normals != null)
                {
                    this.normals.Add(v);
                    this.normals.Add(v);
                }

                if (this.textureCoordinates != null)
                {
                    this.textureCoordinates.Add(new Point(0, 0));
                    this.textureCoordinates.Add(new Point(1, 0));
                }

                int i1 = index0 + 1;
                int i2 = (index0 + 2) % np;
                int i3 = ((index0 + 2) % np) + 1;

                this.triangleIndices.Add(i1);
                this.triangleIndices.Add(i2);
                this.triangleIndices.Add(index0);

                this.triangleIndices.Add(i1);
                this.triangleIndices.Add(i3);
                this.triangleIndices.Add(i2);
            }
        }