Table of Contents

Class MeshBuilder

Namespace
HelixToolkit.Geometry
Assembly
HelixToolkit.Geometry.dll

Builds MeshGeometry3D objects.

public sealed class MeshBuilder
Inheritance
MeshBuilder
Inherited Members
Extension Methods

Remarks

Performance tips for MeshGeometry3D (http://msdn.microsoft.com/en-us/library/bb613553.aspx)

High impact: Mesh animation—changing the individual vertices of a mesh on a per-frame basis—is not always efficient in Windows Presentation Foundation (WPF). To minimize the performance impact of change notifications when each vertex is modified, detach the mesh from the visual tree before performing per-vertex modification. Once the mesh has been modified, reattach it to the visual tree. Also, try to minimize the size of meshes that will be animated in this way.

Medium impact: When a mesh is defined as abutting triangles with shared vertices and those vertices have the same position, normal, and texture coordinates, define each shared vertex only once and then define your triangles by index with TriangleIndices.

Low impact: To minimize the construction time of large collections in Windows Presentation Foundation (WPF), such as a MeshGeometry3D’s Positions, Normals, TextureCoordinates, and TriangleIndices, pre-size the collections before value population. If possible, pass the collections’ constructors prepopulated data structures such as arrays or Lists.

Constructors

MeshBuilder()

Initializes a new instance of the MeshBuilder class.

public MeshBuilder()

Remarks

Normal and texture coordinate generation are included.

MeshBuilder(bool, bool, bool)

Initializes a new instance of the MeshBuilder class.

public MeshBuilder(bool generateNormals = true, bool generateTexCoords = true, bool tangentSpace = false)

Parameters

generateNormals bool

Generate normal vectors.

generateTexCoords bool

Generate texture coordinates.

tangentSpace bool

Generate tangents.

Properties

BiTangents

The Bi-Tangents.

public Vector3Collection? BiTangents { get; set; }

Property Value

Vector3Collection

CreateNormals

Gets or sets a value indicating whether to create normal vectors.

public bool CreateNormals { get; set; }

Property Value

bool

true if normal vectors should be created; otherwise, false.

CreateTextureCoordinates

Gets or sets a value indicating whether to create texture coordinates.

public bool CreateTextureCoordinates { get; set; }

Property Value

bool

true if texture coordinates should be created; otherwise, false.

HasNormals

Do we have Normals or not.

public bool HasNormals { get; }

Property Value

bool

HasTangents

Do we have Tangents or not.

public bool HasTangents { get; }

Property Value

bool

HasTexCoords

Do we have Texture Coordinates or not.

public bool HasTexCoords { get; }

Property Value

bool

Normals

The normal vectors.

public Vector3Collection? Normals { get; set; }

Property Value

Vector3Collection

Positions

The positions.

public Vector3Collection Positions { get; set; }

Property Value

Vector3Collection

Tangents

The Tangents.

public Vector3Collection? Tangents { get; set; }

Property Value

Vector3Collection

TextureCoordinates

The texture coordinates.

public Vector2Collection? TextureCoordinates { get; set; }

Property Value

Vector2Collection

TriangleIndices

The triangle indices.

public IntCollection TriangleIndices { get; set; }

Property Value

IntCollection

Methods

AddArrow(Vector3, Vector3, float, float, int)

Adds an arrow to the mesh.

public void AddArrow(Vector3 point1, Vector3 point2, float diameter, float headLength = 3, int thetaDiv = 18)

Parameters

point1 Vector3

The start point.

point2 Vector3

The end point.

diameter float

The diameter of the arrow cylinder.

headLength float

Length of the head (relative to diameter).

thetaDiv int

The number of divisions around the arrow.

AddBoundingBox(BoundingBox, float)

Adds the edges of a bounding box as pipes.

public void AddBoundingBox(BoundingBox boundingBox, float diameter)

Parameters

boundingBox BoundingBox

The bounding box.

diameter float

The diameter of the cylinders.

AddBox(BoundingBox, BoxFaces)

Adds a box aligned with the X, Y and Z axes.

public void AddBox(BoundingBox boundingBox, BoxFaces faces = BoxFaces.All)

Parameters

boundingBox BoundingBox

The bounding box.

faces BoxFaces

The faces to include.

AddBox(Vector3, Vector3, Vector3, float, float, float, BoxFaces)

Adds a box with the specified faces, aligned with the specified axes.

public void AddBox(Vector3 center, Vector3 x, Vector3 y, float xlength, float ylength, float zlength, BoxFaces faces = BoxFaces.All)

Parameters

center Vector3

The center point of the box.

x Vector3

The x axis.

y Vector3

The y axis.

xlength float

The length of the box along the X axis.

ylength float

The length of the box along the Y axis.

zlength float

The length of the box along the Z axis.

faces BoxFaces

The faces to include.

AddBox(Vector3, float, float, float)

Adds a box aligned with the X, Y and Z axes.

public void AddBox(Vector3 center, float xlength, float ylength, float zlength)

Parameters

center Vector3

The center point of the box.

xlength float

The length of the box along the X axis.

ylength float

The length of the box along the Y axis.

zlength float

The length of the box along the Z axis.

AddBox(Vector3, float, float, float, BoxFaces)

Adds a box with the specified faces, aligned with the X, Y and Z axes.

public void AddBox(Vector3 center, float xlength, float ylength, float zlength, BoxFaces faces)

Parameters

center Vector3

The center point of the box.

xlength float

The length of the box along the X axis.

ylength float

The length of the box along the Y axis.

zlength float

The length of the box along the Z axis.

faces BoxFaces

The faces to include.

AddCone(Vector3, Vector3, float, bool, int)

Adds a cone.

public void AddCone(Vector3 origin, Vector3 apex, float baseRadius, bool baseCap, int thetaDiv)

Parameters

origin Vector3

The origin point.

apex Vector3

The apex point.

baseRadius float

The base radius.

baseCap bool

Include a base cap if set to true .

thetaDiv int

The theta div.

AddCone(Vector3, Vector3, float, float, float, bool, bool, int)

Adds a (possibly truncated) cone.

public void AddCone(Vector3 origin, Vector3 direction, float baseRadius, float topRadius, float height, bool baseCap, bool topCap, int thetaDiv)

Parameters

origin Vector3

The origin.

direction Vector3

The direction (normalization not required).

baseRadius float

The base radius.

topRadius float

The top radius.

height float

The height.

baseCap bool

Include a base cap if set to true .

topCap bool

Include the top cap if set to true .

thetaDiv int

The number of divisions around the cone.

Remarks

AddCube(BoxFaces)

Add a Cube, only with specified Faces.

public void AddCube(BoxFaces faces = BoxFaces.All)

Parameters

faces BoxFaces

The Faces to create (default all Faces)

AddCubeFace(Vector3, Vector3, Vector3, float, float, float)

Adds a cube face.

public void AddCubeFace(Vector3 center, Vector3 normal, Vector3 up, float dist, float width, float height)

Parameters

center Vector3

The center of the cube.

normal Vector3

The normal vector for the face.

up Vector3

The up vector for the face.

dist float

The distance from the center of the cube to the face.

width float

The width of the face.

height float

The height of the face.

AddCylinder(Vector3, Vector3, float, int)

Adds a cylinder to the mesh.

public void AddCylinder(Vector3 p1, Vector3 p2, float diameter, int thetaDiv)

Parameters

p1 Vector3

The first point.

p2 Vector3

The second point.

diameter float

The diameters.

thetaDiv int

The number of divisions around the cylinder.

Remarks

AddCylinder(Vector3, Vector3, float, int, bool, bool)

Adds a cylinder to the mesh.

public void AddCylinder(Vector3 p1, Vector3 p2, float radius = 1, int thetaDiv = 32, bool cap1 = true, bool cap2 = true)

Parameters

p1 Vector3

The first point.

p2 Vector3

The second point.

radius float

The diameters.

thetaDiv int

The number of divisions around the cylinder.

cap1 bool

The first Cap.

cap2 bool

The second Cap.

Remarks

AddDodecahedron(Vector3, Vector3, Vector3, float)

Generate a Dodecahedron

public void AddDodecahedron(Vector3 center, Vector3 forward, Vector3 up, float sideLength)

Parameters

center Vector3

The Center of the Dodecahedron

forward Vector3

The Direction to the first Point (normalized).

up Vector3

The Up-Dirextion (normalized, perpendicular to the forward Direction)

sideLength float

Length of the Edges of the Dodecahedron

Remarks

AddEdges(IList<Vector3>, IList<int>, float, int)

Adds a collection of edges as cylinders.

public void AddEdges(IList<Vector3> points, IList<int> edges, float diameter, int thetaDiv)

Parameters

points IList<Vector3>

The points.

edges IList<int>

The edge indices.

diameter float

The diameter of the cylinders.

thetaDiv int

The number of divisions around the cylinders.

AddEllipsoid(Vector3, float, float, float, int, int)

Adds an ellipsoid.

public void AddEllipsoid(Vector3 center, float radiusx, float radiusy, float radiusz, int thetaDiv = 20, int phiDiv = 10)

Parameters

center Vector3

The center of the ellipsoid.

radiusx float

The x radius of the ellipsoid.

radiusy float

The y radius of the ellipsoid.

radiusz float

The z radius of the ellipsoid.

thetaDiv int

The number of divisions around the ellipsoid.

phiDiv int

The number of divisions from top to bottom of the ellipsoid.

AddExtrudedGeometry(IList<Vector2>, Vector3, Vector3, Vector3)

Adds an extruded surface of the specified curve.

public void AddExtrudedGeometry(IList<Vector2> points, Vector3 xaxis, Vector3 p0, Vector3 p1)

Parameters

points IList<Vector2>

The 2D points describing the curve to extrude.

xaxis Vector3

The x-axis.

p0 Vector3

The start origin of the extruded surface.

p1 Vector3

The end origin of the extruded surface.

Remarks

The y-axis is determined by the cross product between the specified x-axis and the p1-origin vector.

AddExtrudedSegments(IList<Vector2>, Vector3, Vector3, Vector3)

Adds an extruded surface of the specified line segments.

public void AddExtrudedSegments(IList<Vector2> points, Vector3 axisX, Vector3 p0, Vector3 p1)

Parameters

points IList<Vector2>

The 2D points describing the line segments to extrude. The number of points must be even.

axisX Vector3

The x-axis.

p0 Vector3

The start origin of the extruded surface.

p1 Vector3

The end origin of the extruded surface.

Remarks

The y-axis is determined by the cross product between the specified x-axis and the p1-origin vector.

AddFaceNX()

Add a Face in negative X-Direction.

public void AddFaceNX()

AddFaceNY()

Add a Face in negative Y-Direction.

public void AddFaceNY()

AddFaceNZ()

Add a Face in negative Z-Direction.

public void AddFaceNZ()

AddFacePX()

Add a Face in positive X-Direction.

public void AddFacePX()

AddFacePY()

Add a Face in positive Y-Direction.

public void AddFacePY()

AddFacePZ()

Add a Face in positive Z-Direction.

public void AddFacePZ()

AddLoftedGeometry(IList<IList<Vector3>>, IList<IList<Vector3>>, IList<IList<Vector2>>)

Adds a lofted surface.

public void AddLoftedGeometry(IList<IList<Vector3>> positionsList, IList<IList<Vector3>> normalList, IList<IList<Vector2>> textureCoordinateList)

Parameters

positionsList IList<IList<Vector3>>

List of lofting sections.

normalList IList<IList<Vector3>>

The normal list.

textureCoordinateList IList<IList<Vector2>>

The texture coordinate list.

Remarks

AddNode(Vector3, Vector3, Vector2)

Adds a single node.

public void AddNode(Vector3 position, Vector3 normal, Vector2 textureCoordinate)

Parameters

position Vector3

The position.

normal Vector3

The normal.

textureCoordinate Vector2

The texture coordinate.

AddOctahedron(Vector3, Vector3, Vector3, float, float)

Adds an octahedron.

public void AddOctahedron(Vector3 center, Vector3 forward, Vector3 up, float sideLength, float height)

Parameters

center Vector3

The center.

forward Vector3

The normal vector.

up Vector3

The up vector.

sideLength float

Length of the side.

height float

The half height of the octahedron.

Remarks

AddPipe(Vector3, Vector3, float, float, int)

Adds a (possibly hollow) pipe.

public void AddPipe(Vector3 point1, Vector3 point2, float innerDiameter, float outerDiameter, int thetaDiv)

Parameters

point1 Vector3

The start point.

point2 Vector3

The end point.

innerDiameter float

The inner diameter.

outerDiameter float

The outer diameter.

thetaDiv int

The number of divisions around the pipe.

AddPipes(IList<Vector3>, IList<int>, float, int)

Adds a collection of edges as cylinders.

public void AddPipes(IList<Vector3> points, IList<int> edges, float diameter = 1, int thetaDiv = 32)

Parameters

points IList<Vector3>

The points.

edges IList<int>

The edge indices.

diameter float

The diameter of the cylinders.

thetaDiv int

The number of divisions around the cylinders.

AddPolygon(IList<int>)

Adds a polygon specified by vertex index (uses a triangle fan).

public void AddPolygon(IList<int> vertexIndices)

Parameters

vertexIndices IList<int>

The vertex indices.

AddPolygon(IList<Vector2>, Vector3, Vector3, Vector3)

Adds a polygon.

public void AddPolygon(IList<Vector2> points, Vector3 axisX, Vector3 axisY, Vector3 origin)

Parameters

points IList<Vector2>

The 2D points defining the polygon.

axisX Vector3

The x axis.

axisY Vector3

The y axis.

origin Vector3

The origin.

AddPolygon(IList<Vector3>)

Adds a polygon.

public void AddPolygon(IList<Vector3> points)

Parameters

points IList<Vector3>

The points of the polygon.

Remarks

If the number of points is greater than 4, a triangle fan is used.

AddPolygonByCuttingEars(IList<int>)

Adds a polygon defined by vertex indices (uses the cutting ears algorithm).

[Obsolete("Please use the faster version AddPolygon instead")]
public void AddPolygonByCuttingEars(IList<int> vertexIndices)

Parameters

vertexIndices IList<int>

The vertex indices.

AddPolygonByTriangulation(IList<int>)

Adds a polygon defined by vertex indices (uses the sweep line algorithm).

public void AddPolygonByTriangulation(IList<int> vertexIndices)

Parameters

vertexIndices IList<int>

The vertex indices.

AddPyramid(Vector3, Vector3, Vector3, float, float, bool)

Adds a pyramid.

public void AddPyramid(Vector3 center, Vector3 forward, Vector3 up, float sideLength, float height, bool closeBase = false)

Parameters

center Vector3

The center.

forward Vector3

The normal vector (normalized).

up Vector3

The 'up' vector (normalized).

sideLength float

Length of the sides of the pyramid.

height float

The height of the pyramid.

closeBase bool

Add triangles to the base of the pyramid or not.

AddPyramid(Vector3, float, float, bool)

Adds a pyramid.

public void AddPyramid(Vector3 center, float sideLength, float height, bool closeBase = false)

Parameters

center Vector3

The center.

sideLength float

Length of the sides of the pyramid.

height float

The height of the pyramid.

closeBase bool

Add triangles to the base of the pyramid or not.

Remarks

AddQuad(IList<int>)

Adds a quad (exactely 4 indices)

public void AddQuad(IList<int> vertexIndices)

Parameters

vertexIndices IList<int>

The vertex indices.

AddQuad(Vector3, Vector3, Vector3, Vector3)

Adds a quadrilateral polygon.

public void AddQuad(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)

Parameters

p0 Vector3

The first point.

p1 Vector3

The second point.

p2 Vector3

The third point.

p3 Vector3

The fourth point.

Remarks

AddQuad(Vector3, Vector3, Vector3, Vector3, Vector2, Vector2, Vector2, Vector2)

Adds a quadrilateral polygon.

public void AddQuad(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, Vector2 uv0, Vector2 uv1, Vector2 uv2, Vector2 uv3)

Parameters

p0 Vector3

The first point.

p1 Vector3

The second point.

p2 Vector3

The third point.

p3 Vector3

The fourth point.

uv0 Vector2

The first texture coordinate.

uv1 Vector2

The second texture coordinate.

uv2 Vector2

The third texture coordinate.

uv3 Vector2

The fourth texture coordinate.

Remarks

AddQuads(IList<Vector3>, IList<Vector3>?, IList<Vector2>?)

Adds a list of quadrilateral polygons.

public void AddQuads(IList<Vector3> quadPositions, IList<Vector3>? quadNormals, IList<Vector2>? quadTextureCoordinates)

Parameters

quadPositions IList<Vector3>

The points.

quadNormals IList<Vector3>

The normal vectors.

quadTextureCoordinates IList<Vector2>

The texture coordinates.

AddRectangularMesh(BoxFaces, int, int, float, float, bool, bool, bool)

Generates a rectangles mesh on the axis-aligned plane given by the box-face.

public void AddRectangularMesh(BoxFaces plane, int columns, int rows, float width, float height, bool flipTriangles = false, bool flipTexCoordsUAxis = false, bool flipTexCoordsVAxis = false)

Parameters

plane BoxFaces

Box face which determines the plane the grid lies on.

columns int

width of the grid, i.e. horizontal resolution

rows int

height of the grid, i.e. vertical resolution

width float

total size in horizontal

height float

total vertical size

flipTriangles bool

flips the triangle faces

flipTexCoordsUAxis bool

flips the u-axis (horizontal) of the texture coords.

flipTexCoordsVAxis bool

flips the v-axis (vertical) of the tex.coords.

AddRectangularMesh(IList<Vector3>, int)

Adds a rectangular mesh (m x n points).

public void AddRectangularMesh(IList<Vector3> points, int columns)

Parameters

points IList<Vector3>

The one-dimensional array of points. The points are stored row-by-row.

columns int

The number of columns in the rectangular mesh.

AddRectangularMesh(IList<Vector3>, int, bool)

Adds a rectangular mesh (m x n points).

public void AddRectangularMesh(IList<Vector3> points, int columns, bool flipTriangles = false)

Parameters

points IList<Vector3>

The one-dimensional array of points. The points are stored row-by-row.

columns int

The number of columns in the rectangular mesh.

flipTriangles bool

Flip the Triangles.

AddRectangularMesh(Vector3[,], Vector2[,]?, bool, bool)

Adds a rectangular mesh defined by a two-dimensional array of points.

public void AddRectangularMesh(Vector3[,] points, Vector2[,]? texCoords = null, bool closed0 = false, bool closed1 = false)

Parameters

points Vector3[,]

The points.

texCoords Vector2[,]

The texture coordinates (optional).

closed0 bool

set to true if the mesh is closed in the first dimension.

closed1 bool

set to true if the mesh is closed in the second dimension.

AddRectangularMeshTriangleIndices(int, int, int, bool)

Add triangle indices for a rectangular mesh.

public void AddRectangularMeshTriangleIndices(int index0, int rows, int columns, bool isSpherical = false)

Parameters

index0 int

The index offset.

rows int

The number of rows.

columns int

The number of columns.

isSpherical bool

set the flag to true to create a sphere mesh (triangles at top and bottom).

AddRectangularMeshTriangleIndices(int, int, int, bool, bool)

Adds triangular indices for a rectangular mesh.

public (int ActualRows, int ActualColumns) AddRectangularMeshTriangleIndices(int index0, int rows, int columns, bool rowsClosed, bool columnsClosed)

Parameters

index0 int

The index 0.

rows int

The rows.

columns int

The columns.

rowsClosed bool

True if rows are closed.

columnsClosed bool

True if columns are closed.

Returns

(int ActualRows, int ActualColumns)

AddRegularIcosahedron(Vector3, float, bool)

Adds a regular icosahedron.

public void AddRegularIcosahedron(Vector3 center, float radius, bool shareVertices)

Parameters

center Vector3

The center.

radius float

The radius.

shareVertices bool

Share vertices if set to true .

Remarks

See Wikipedia and link.

AddRevolvedGeometry(IList<Vector2>, IList<float>?, Vector3, Vector3, int)

Adds a surface of revolution.

public void AddRevolvedGeometry(IList<Vector2> points, IList<float>? textureValues, Vector3 origin, Vector3 direction, int thetaDiv)

Parameters

points IList<Vector2>

The points (x coordinates are distance from the origin along the axis of revolution, y coordinates are radius, )

textureValues IList<float>

The v texture coordinates, one for each point in the points list.

origin Vector3

The origin of the revolution axis.

direction Vector3

The direction of the revolution axis.

thetaDiv int

The number of divisions around the mesh.

Remarks

AddSphere(Vector3, float, int, int)

Adds a sphere.

public void AddSphere(Vector3 center, float radius = 1, int thetaDiv = 32, int phiDiv = 32)

Parameters

center Vector3

The center of the sphere.

radius float

The radius of the sphere.

thetaDiv int

The number of divisions around the sphere.

phiDiv int

The number of divisions from top to bottom of the sphere.

AddSubdivisionSphere(Vector3, float, int)

Adds a sphere (by subdividing a regular icosahedron).

public void AddSubdivisionSphere(Vector3 center, float radius, int subdivisions)

Parameters

center Vector3

The center of the sphere.

radius float

The radius of the sphere.

subdivisions int

The number of triangular subdivisions of the original icosahedron.

Remarks

See link.

AddSurfaceOfRevolution(Vector3, Vector3, IList<Vector2>, IList<int>, int, IList<float>?)

Adds a surface of revolution.

public void AddSurfaceOfRevolution(Vector3 origin, Vector3 axis, IList<Vector2> section, IList<int> sectionIndices, int thetaDiv = 36, IList<float>? textureValues = null)

Parameters

origin Vector3

The origin.

axis Vector3

The axis.

section IList<Vector2>

The points defining the curve to revolve.

sectionIndices IList<int>

The indices of the line segments of the section.

thetaDiv int

The number of divisions.

textureValues IList<float>

The texture values.

AddTetrahedron(Vector3, Vector3, Vector3, float)

Add a tetrahedron.

public void AddTetrahedron(Vector3 center, Vector3 forward, Vector3 up, float sideLength)

Parameters

center Vector3

The Center of Mass.

forward Vector3

Direction to first Base-Point (in Base-Plane).

up Vector3

Up Vector.

sideLength float

The Sidelength.

Remarks

AddTorus(float, float, int, int)

Adds a torus.

public void AddTorus(float torusDiameter, float tubeDiameter, int thetaDiv = 36, int phiDiv = 24)

Parameters

torusDiameter float

The diameter of the torus.

tubeDiameter float

The diameter of the torus "tube".

thetaDiv int

The number of subdivisions around the torus.

phiDiv int

The number of subdividions of the torus' "tube.

AddTriangle(IList<int>)

Adds a triangle (exactely 3 indices)

public void AddTriangle(IList<int> vertexIndices)

Parameters

vertexIndices IList<int>

The vertex indices.

AddTriangle(Vector3, Vector3, Vector3)

Adds a triangle.

public void AddTriangle(Vector3 p0, Vector3 p1, Vector3 p2)

Parameters

p0 Vector3

The first point.

p1 Vector3

The second point.

p2 Vector3

The third point.

AddTriangle(Vector3, Vector3, Vector3, Vector2, Vector2, Vector2)

Adds a triangle.

public void AddTriangle(Vector3 p0, Vector3 p1, Vector3 p2, Vector2 uv0, Vector2 uv1, Vector2 uv2)

Parameters

p0 Vector3

The first point.

p1 Vector3

The second point.

p2 Vector3

The third point.

uv0 Vector2

The first texture coordinate.

uv1 Vector2

The second texture coordinate.

uv2 Vector2

The third texture coordinate.

AddTriangleFan(IList<int>)

Adds a triangle fan.

public void AddTriangleFan(IList<int> vertices)

Parameters

vertices IList<int>

The vertex indices of the triangle fan.

AddTriangleFan(IList<Vector3>, IList<Vector3>?, IList<Vector2>?)

Adds a triangle fan to the mesh

public void AddTriangleFan(IList<Vector3> fanPositions, IList<Vector3>? fanNormals = null, IList<Vector2>? fanTextureCoordinates = null)

Parameters

fanPositions IList<Vector3>

The points of the triangle fan.

fanNormals IList<Vector3>

The normal vectors of the triangle fan.

fanTextureCoordinates IList<Vector2>

The texture coordinates of the triangle fan.

AddTriangleStrip(IList<Vector3>, IList<Vector3>?, IList<Vector2>?)

Adds a triangle strip to the mesh.

public void AddTriangleStrip(IList<Vector3> stripPositions, IList<Vector3>? stripNormals = null, IList<Vector2>? stripTextureCoordinates = null)

Parameters

stripPositions IList<Vector3>

The points of the triangle strip.

stripNormals IList<Vector3>

The normal vectors of the triangle strip.

stripTextureCoordinates IList<Vector2>

The texture coordinates of the triangle strip.

Remarks

AddTriangles(IList<Vector3>, IList<Vector3>?, IList<Vector2>?)

Adds a list of triangles.

public void AddTriangles(IList<Vector3> trianglePositions, IList<Vector3>? triangleNormals = null, IList<Vector2>? triangleTextureCoordinates = null)

Parameters

trianglePositions IList<Vector3>

The points (the number of points must be a multiple of 3).

triangleNormals IList<Vector3>

The normal vectors (corresponding to the points).

triangleTextureCoordinates IList<Vector2>

The texture coordinates (corresponding to the points).

AddTube(IList<Vector3>, IList<float>?, IList<float>?, IList<Vector2>, Vector3?, bool, bool, bool, bool)

Adds a tube with a custom section.

public void AddTube(IList<Vector3> path, IList<float>? values, IList<float>? sectionScales, IList<Vector2> section, Vector3? sectionXAxis, bool isTubeClosed, bool isSectionClosed, bool frontCap = false, bool backCap = false)

Parameters

path IList<Vector3>

A list of points defining the centers of the tube.

values IList<float>

The texture coordinate X values (optional).

sectionScales IList<float>

The scales of the section (optional).

section IList<Vector2>

The section to extrude along the tube path.

sectionXAxis Vector3?

The initial alignment of the x-axis of the section into the 3D viewport

isTubeClosed bool

If the tube is closed set to true .

isSectionClosed bool

if set to true [is section closed].

frontCap bool

Create a front Cap or not.

backCap bool

Create a back Cap or not.

AddTube(IList<Vector3>?, IList<float>?, IList<float>?, IList<float>?, IList<Vector2>, Vector3, bool, bool, bool, bool)

Adds a tube with a custom section.

Limitation: using xTextureCoordinates with isTubeClosed = true or isSectionClosed = true will be incorrect texture at the last of mesh

public void AddTube(IList<Vector3>? path, IList<float>? sectionAngles, IList<float>? xTextureCoordinates, IList<float>? sectionScales, IList<Vector2> section, Vector3 sectionXAxis, bool isTubeClosed, bool isSectionClosed, bool frontCap = false, bool backCap = false)

Parameters

path IList<Vector3>

A list of points defining the centers of the tube.

sectionAngles IList<float>

The rotation of the section as it moves along the path, in radian.

xTextureCoordinates IList<float>

The texture coordinate X values (optional).

sectionScales IList<float>

The scales of the section (optional).

section IList<Vector2>

The section to extrude along the tube path.

sectionXAxis Vector3

The initial alignment of the x-axis of the section into the 3D viewport

isTubeClosed bool

If the tube is closed set to true .

isSectionClosed bool

if set to true [is section closed].

frontCap bool

Create a front Cap or not.

backCap bool

Create a back Cap or not.

AddTube(IList<Vector3>, IList<float>?, IList<float>?, int, bool, bool, bool)

Adds a tube with circle section.

public void AddTube(IList<Vector3> path, IList<float>? values, IList<float>? diameters, int thetaDiv, bool isTubeClosed, bool frontCap = false, bool backCap = false)

Parameters

path IList<Vector3>

A list of points defining the centers of the tube.

values IList<float>

The texture coordinate X-values.

diameters IList<float>

The diameters.

thetaDiv int

The number of divisions around the tube.

isTubeClosed bool

Set to true if the tube path is closed.

frontCap bool

Create a front Cap or not.

backCap bool

Create a back Cap or not.

AddTube(IList<Vector3>, float, int, bool, bool, bool)

Adds a tube with circle section.

public void AddTube(IList<Vector3> path, float diameter, int thetaDiv, bool isTubeClosed, bool frontCap = false, bool backCap = false)

Parameters

path IList<Vector3>

A list of points defining the centers of the tube.

diameter float

The diameter of the tube.

thetaDiv int

The number of divisions around the tube.

isTubeClosed bool

Set to true if the tube path is closed.

frontCap bool

Generate front Cap or not.

backCap bool

Generate back Cap or not.

Append(MeshBuilder?)

Appends the specified mesh.

public void Append(MeshBuilder? mesh)

Parameters

mesh MeshBuilder

The mesh.

Append(MeshGeometry3D?)

Appends the specified mesh.

public void Append(MeshGeometry3D? mesh)

Parameters

mesh MeshGeometry3D

The mesh.

Append(IList<Vector3>, IList<int>, IList<Vector3>?, IList<Vector2>?)

Appends the specified points and triangles.

public void Append(IList<Vector3> positionsToAppend, IList<int> triangleIndicesToAppend, IList<Vector3>? normalsToAppend = null, IList<Vector2>? textureCoordinatesToAppend = null)

Parameters

positionsToAppend IList<Vector3>

The points to append.

triangleIndicesToAppend IList<int>

The triangle indices to append.

normalsToAppend IList<Vector3>

The normal vectors to append.

textureCoordinatesToAppend IList<Vector2>

The texture coordinates to append.

AppendSphere(Vector3, float, int, int)

Tesselates the element and returns a MeshGeometry3D representing the tessellation based on the parameters given

public void AppendSphere(Vector3 center, float radius = 1, int thetaSteps = 64, int phiSteps = 64)

Parameters

center Vector3
radius float
thetaSteps int
phiSteps int

ChamferCorner(Vector3, float, float, IList<Vector3>?)

Chamfers the specified corner (experimental code).

public void ChamferCorner(Vector3 p, float d, float eps = 1E-06, IList<Vector3>? chamferPoints = null)

Parameters

p Vector3

The corner point.

d float

The chamfer distance.

eps float

The corner search limit distance.

chamferPoints IList<Vector3>

If this parameter is provided, the collection will be filled with the generated chamfer points.

CheckPerformanceLimits()

Checks the performance limits.

public void CheckPerformanceLimits()

Remarks

See MSDN. Try to keep mesh sizes under these limits: Positions : 20,001 point instances TriangleIndices : 60,003 integer instances

ComputeNormalsAndTangents(MeshFaces, bool)

Calculate the Normals and Tangents for all MeshFaces.

public void ComputeNormalsAndTangents(MeshFaces meshFaces, bool tangents = false)

Parameters

meshFaces MeshFaces

The MeshFaces.

tangents bool

Also calculate the Tangents or not.

ComputeTangents(MeshFaces)

Calculate the Mesh's Tangents

public void ComputeTangents(MeshFaces meshFaces)

Parameters

meshFaces MeshFaces

The Faces of the Mesh

ComputeTangents(MeshGeometry3D)

Calculate the Tangents for a MeshGeometry3D.

public static void ComputeTangents(MeshGeometry3D meshGeometry)

Parameters

meshGeometry MeshGeometry3D

The MeshGeometry3D.

ComputeTangents(IList<Vector3>?, IList<Vector3>?, IList<Vector2>?, IList<int>, out IList<Vector3>, out IList<Vector3>)

Tangent Space computation for IndexedTriangle meshes Based on: http://www.terathon.com/code/tangent.html

public static void ComputeTangents(IList<Vector3>? positions, IList<Vector3>? normals, IList<Vector2>? textureCoordinates, IList<int> triangleIndices, out IList<Vector3> tangents, out IList<Vector3> bitangents)

Parameters

positions IList<Vector3>
normals IList<Vector3>
textureCoordinates IList<Vector2>
triangleIndices IList<int>
tangents IList<Vector3>
bitangents IList<Vector3>

ComputeTangentsQuads(IList<Vector3>?, IList<Vector3>?, IList<Vector2>?, IList<int>, out IList<Vector3>, out IList<Vector3>)

Calculate the Tangents for a Quad.

public static void ComputeTangentsQuads(IList<Vector3>? positions, IList<Vector3>? normals, IList<Vector2>? textureCoordinates, IList<int> indices, out IList<Vector3> tangents, out IList<Vector3> bitangents)

Parameters

positions IList<Vector3>

The Positions.

normals IList<Vector3>

The Normals.

textureCoordinates IList<Vector2>

The TextureCoordinates.

indices IList<int>

The Indices.

tangents IList<Vector3>

The calculated Tangens.

bitangents IList<Vector3>

The calculated Bi-Tangens.

GetCircle(int, bool)

Gets a unit circle section with radius = 1, (cached).

public static IList<Vector2> GetCircle(int thetaDiv, bool closed = false)

Parameters

thetaDiv int

The number of divisions.

closed bool

Is the circle closed? If true, the last point will be in the same position as the first one.

Returns

IList<Vector2>

A circle.

GetCircleSegment(int, float, float)

Gets a unit circle segment section with radius = 1.

public static IList<Vector2> GetCircleSegment(int thetaDiv, float totalAngle = 6.2831855, float angleOffset = 0)

Parameters

thetaDiv int

The number of division.

totalAngle float

The angle of the circle segment.

angleOffset float

The angle-offset to use,in radian.

Returns

IList<Vector2>

A circle segment.

GetRectangle(float, float)

Get a rectangle section, (cached).

public static IList<Vector2> GetRectangle(float width, float height)

Parameters

width float

The width of rectangle.

height float

The height of rectangle.

Returns

IList<Vector2>

Reset()

public void Reset()

Scale(float, float, float)

Scales the positions (and normal vectors).

public void Scale(float scaleX, float scaleY, float scaleZ)

Parameters

scaleX float

The X scale factor.

scaleY float

The Y scale factor.

scaleZ float

The Z scale factor.

SubdivideLinear(bool)

Performs a linear subdivision of the mesh.

public void SubdivideLinear(bool barycentric = false)

Parameters

barycentric bool

Add a vertex in the center if set to true .

ToMesh()

Converts the geometry to a MeshGeometry3D. All internal mesh builder data are directly assigned to the MeshGeometry3D without copying. User must call Reset() to reset and reuse the mesh builder object to create new meshes.

public MeshGeometry3D ToMesh()

Returns

MeshGeometry3D

A mesh geometry.