Api Sandbox PolygonMesh
class

PolygonMesh

public sealed class PolygonMesh

An editable mesh made up of polygons, triangulated into a model

Constructors

PolygonMesh()

Properties

Name Type Description
IsDirty Boolean Has there been changes to the mesh that need rebuilding?
Transform Transform Where is the mesh in worldspace.
VertexHandles IEnumerable<VertexHandle> All of the vertex handles being used
FaceHandles IEnumerable<FaceHandle> All of the face handles being used
HalfEdgeHandles IEnumerable<HalfEdgeHandle> All of the half edge handles being used

Methods

Boolean BevelEdges(IReadOnlyList<HalfEdgeHandle> edges, BevelEdgesMode edgeRemoveMode, Int32 numSegments, Single distance, Single shape, List<HalfEdgeHandle> outNewOuterEdges = null, List<HalfEdgeHandle> outNewInnerEdges = null, List<FaceHandle> outNewFaces = null, List<FaceHandle> outFacesNeedingUVs = null)
Void ClipFacesByPlaneAndCap(IReadOnlyList<FaceHandle> faces, Plane planeInMeshSpace, Boolean removeFacesBehindPlane, Boolean attemptToCap, List<HalfEdgeHandle> outNewEdges = null, List<FaceHandle> outCapFaces = null)
VertexHandle VertexHandleFromIndex(Int32 index)
HalfEdgeHandle HalfEdgeHandleFromIndex(Int32 index)
FaceHandle FaceHandleFromIndex(Int32 index)
Void MergeMesh(PolygonMesh sourceMesh, Transform transform, Dictionary<VertexHandle, VertexHandle> newVertices, Dictionary<HalfEdgeHandle, HalfEdgeHandle> newHalfEdges, Dictionary<FaceHandle, FaceHandle> newFaces)
Void SetTransform(Transform transform)

Set transform without computing texture parameters from coordinates.

VertexHandle AddVertex(Vector3 position)

Add a vertex to the topology

VertexHandle[] AddVertices(Vector3[] positions)

Add multiple vertices to the topology

FaceHandle AddFace(VertexHandle[] hVertices)

Connect these vertices to make a face

BBox CalculateBounds()

Calculate bounds of all vertices

BBox CalculateBounds(Transform transform)

Calculate bounds of all transformed vertices

Void Scale(Vector3 scale)

Scale all vertices

Void SetFaceMaterial(FaceHandle hFace, Material material)

Assign a material to a face

Void SetFaceMaterial(FaceHandle hFace, String material)

Assign a material to a face

Material GetFaceMaterial(FaceHandle hFace)

Get a material a face is using

EdgeSmoothMode GetEdgeSmoothing(HalfEdgeHandle hEdge)

Get the smoothing of this edge

Void SetEdgeSmoothing(HalfEdgeHandle hEdge, EdgeSmoothMode mode)

Set the smoothing of this edge

Void SetSmoothingAngle(Single smoothingAngle)
FaceHandle TriangleToFace(Int32 triangle)

Convert a triangle index to a face handle

Void ExtrudeFaces(FaceHandle[] faces, List<FaceHandle> newFaces, List<FaceHandle> connectingFaces, Vector3 offset = null)
Void DetachFaces(FaceHandle[] faces, List<FaceHandle> newFaces)
Boolean ExtendEdges(IReadOnlyList<HalfEdgeHandle> edges, Single amount, List<HalfEdgeHandle> newEdges, List<FaceHandle> newFaces)
Boolean AreEdgesCoLinear(HalfEdgeHandle hEdgeA, HalfEdgeHandle hEdgeB, Single flAngleToleranceInDegrees)
Void CombineFaces(IReadOnlyList<FaceHandle> faces)
Void DissolveEdge(HalfEdgeHandle edge)
Void DissolveEdges(IReadOnlyList<HalfEdgeHandle> edges, Boolean bFaceMustBePlanar, DissolveRemoveVertexCondition removeCondition)
Boolean ComputeClosestPointOnEdge(VertexHandle hVertexA, VertexHandle hVertexB, Vector3 vTargetPoint, Single pOutBaseEdgeParam)
Boolean RemoveColinearVertexAndUpdateTable(VertexHandle hVertex, SortedSet<HalfEdgeHandle> edgeTable, Single flColinearAngleTolerance = 5)
Boolean GetEdgesConnectedToVertex(VertexHandle hVertex, List<HalfEdgeHandle> edges)
VertexHandle CreateEdgesConnectingVertexToPoint(VertexHandle hStartVertex, Vector3 vTargetPosition, List<HalfEdgeHandle> pOutEdgeList, Boolean pOutIsLastEdgeConnector, SortedSet<HalfEdgeHandle> pEdgeTable)
Boolean MergeEdges(HalfEdgeHandle hEdgeA, HalfEdgeHandle hEdgeB, HalfEdgeHandle hOutNewEdge)
Void FlipAllFaces()
Int32 MergeVerticesWithinDistance(IReadOnlyList<VertexHandle> originalVertices, Single flMaxDistance, Boolean bPreConnect, Boolean bAveragePositions, List<VertexHandle> pOutFinalVertices)
Boolean CreateFaceInEdgeLoop(HalfEdgeHandle hOpenEdge, FaceHandle hNewFace)

Add a face filling in the open edge loop specified by the provided edge

FaceHandle GetHalfEdgeFace(HalfEdgeHandle hEdge)

Get the face connected to this half edge

Boolean IsEdgeOpen(HalfEdgeHandle hEdge)

Determine if the specified edge is open (only has one connected face)

Void FindEdgeRing(HalfEdgeHandle hEdge, List<HalfEdgeHandle> outEdgeList)
Boolean BridgeEdges(HalfEdgeHandle hEdgeA, HalfEdgeHandle hEdgeB, FaceHandle hOutNewFace)

Bridge two edges (create a face connecting them). The edges must both be open and belong to different faces.

Boolean ConnectEdges(IReadOnlyList<HalfEdgeHandle> edges, List<HalfEdgeHandle> newEdges)
Boolean AddVertexToEdge(VertexHandle hVertexA, VertexHandle hVertexB, Single flParam, VertexHandle pOutNewVertex)
Boolean AddVertexToEdgeAndUpdateTable(VertexHandle hVertexA, VertexHandle hVertexB, Single flParam, VertexHandle pNewVertex, SortedSet<HalfEdgeHandle> pEdgeTable)
Boolean RemoveVertex(VertexHandle hVertex, Boolean removeFreeVerts)
Boolean BevelVertices(IReadOnlyList<VertexHandle> vertices, Single distance, List<VertexHandle> newVertices)
Boolean GetFacesConnectedToVertex(VertexHandle hVertex, List<FaceHandle> faces)
Boolean GetFacesConnectedToFace(FaceHandle hFace, List<FaceHandle> faces)
HalfEdgeHandle FindFaceVertexConnectedToVertex(VertexHandle hVertex, FaceHandle hFace)
HalfEdgeHandle GetNextVertexInFace(HalfEdgeHandle hFaceVertex)
Boolean ConnectVertices(VertexHandle hVertexA, VertexHandle hVertexB, HalfEdgeHandle hNewEdge)
Void FindEdgeLoopForEdges(IReadOnlyList<HalfEdgeHandle> originalEdges, HalfEdgeHandle[] pOutEdgeLoopEdges)
Void FindEdgeIslands(IReadOnlyList<HalfEdgeHandle> edgeList, List<HalfEdgeHandle>> outEdgeList)
Int32 FindEdgeRibs(IReadOnlyList<HalfEdgeHandle> edges, List<HalfEdgeHandle>> outLeftRibs, List<HalfEdgeHandle>> outRightRibs)
Line GetEdgeLine(HalfEdgeHandle hEdge)

Get start and end points of an edge

Void GetEdgeVertices(HalfEdgeHandle hEdge, VertexHandle hVertexA, VertexHandle hVertexB)

Get the two vertices of this half edge

Void SetVertexPosition(VertexHandle hVertex, Vector3 position)

Set the position of a vertex

Vector3 GetVertexPosition(VertexHandle hVertex)

Get the position of a vertex

Void GetVertexPosition(VertexHandle hVertex, Transform transform, Vector3 outPosition)

Get the position of a vertex

IEnumerable<Vector3> GetVertexPositions()

Get the positions of all vertices

Void SetVertexBlend(HalfEdgeHandle hFaceVertex, Color32 blend)

Set the blend of a vertex

Void SetVertexColor(HalfEdgeHandle hFaceVertex, Color32 color)

Set the color of a vertex

Color32 GetVertexColor(HalfEdgeHandle hFaceVertex)

Get the color of a vertex

Color32 GetVertexBlend(HalfEdgeHandle hFaceVertex)

Get the blend of a vertex

Void ComputeFaceNormal(FaceHandle hFace, Vector3 pOutNormal)
Vector3 GetFaceCenter(FaceHandle hFace)

Calculate the center point of a face

IEnumerable<Line> GetEdges()

Get the start and end points of all edges

IEnumerable<Vector3> GetFaceVertexPositions(FaceHandle hFace, Transform transform)
Boolean GetFaceVerticesConnectedToFace(FaceHandle hFace, HalfEdgeHandle[] hEdges)
VertexHandle GetVertexConnectedToFaceVertex(HalfEdgeHandle hFaceVertex)
Void ComputeFaceTextureParametersFromCoordinates()
Void ComputeFaceTextureParametersFromCoordinates(IEnumerable<FaceHandle> faces)
Void ComputeFaceTextureCoordinatesFromParameters()
Void ComputeFaceTextureCoordinatesFromParameters(Transform transform)
Void ComputeFaceTextureCoordinatesFromParameters(IEnumerable<FaceHandle> faces)
Void ComputeFaceTextureParametersFromCoordinates(IEnumerable<FaceHandle> faces, IReadOnlyList<Vector2> textureSizes, Transform transform)
Void ComputeFaceTextureCoordinatesFromParameters(IEnumerable<FaceHandle> faces, Transform transform, IReadOnlyList<Vector2> textureSizes, Single defaultScale)
Void ApplyTransform(Transform transform)

Transform all the vertices

HalfEdgeHandle[] GetFaceEdges(FaceHandle hFace)

Get all edge handles of a face

VertexHandle[] GetFaceVertices(FaceHandle hFace)

Get all vertex handles of a face

Vector2 GetTextureOffset(FaceHandle hFace)

Get texture offset of a face

Void SetTextureOffset(FaceHandle hFace, Vector2 offset)

Set texture offset of a face

Vector2 GetTextureScale(FaceHandle hFace)

Get texture scale of a face

Void SetTextureScale(FaceHandle hFace, Vector2 scale)

Set texture scale of a face

Void TextureAlignToGrid(Transform transform, FaceHandle hFace)

Align face texture properties to grid

Void TextureAlignToFace(Transform transform, FaceHandle hFace)

Align face texture properties to face

Void SetTextureCoord(HalfEdgeHandle faceVertex, Vector2 texcoord)

Set face vertex texture coord

Vector2 GetTextureCoord(HalfEdgeHandle faceVertex)

Get face vertex texture coord

Void SetFaceTextureCoords(FaceHandle hFace, IReadOnlyList<Vector2> texcoords)
Vector2[] GetFaceTextureCoords(FaceHandle hFace)
Void SetFaceTextureParameters(FaceHandle hFace, Vector2 offset, Vector3 uAxis, Vector3 vAxis)

Set face texture properties

Void GetFaceTextureParameters(FaceHandle hFace, Vector4 outAxisU, Vector4 outAxisV, Vector2 outScale)
Void SetFaceTextureParameters(FaceHandle hFace, Vector4 axisU, Vector4 axisV, Vector2 scale)
Void TextureAlignToGrid(Transform transform)

Align all face texture properties to grid

Void RemoveFaces(IEnumerable<FaceHandle> hFaces)
Void RemoveVertices(IEnumerable<VertexHandle> hVertices)
Void RemoveEdges(IEnumerable<HalfEdgeHandle> hEdges)
Boolean CollapseEdge(HalfEdgeHandle hEdge, VertexHandle pOutNewVertex, ValueTuple<HalfEdgeHandle, HalfEdgeHandle>> pOutReplacedEdges)
Boolean CollapseEdge(HalfEdgeHandle hHalfEdgeA, Single flParam, VertexHandle pOutNewVertex, ValueTuple<HalfEdgeHandle, HalfEdgeHandle>> pOutReplacedEdges)
Boolean CollapseFace(FaceHandle hFace, VertexHandle hOutVertex)
Boolean SplitEdges(IReadOnlyList<HalfEdgeHandle> edges, HalfEdgeHandle[] newEdgesA, HalfEdgeHandle[] pOutNewEdgesB)
Void CollapseEdges(IReadOnlyList<HalfEdgeHandle> edges)
Model Rebuild()

Triangulate the polygons into a model

Boolean IsEdgeSmooth(HalfEdgeHandle hEdge)
Boolean GetEdgesConnectedToFace(FaceHandle hFace, List<HalfEdgeHandle> edges)
Boolean GetVerticesConnectedToEdge(HalfEdgeHandle hEdge, FaceHandle hFace, VertexHandle hOutVertexA, VertexHandle hOutVertexB)
Void GetVerticesConnectedToEdge(HalfEdgeHandle hEdge, VertexHandle hOutVertexA, VertexHandle hOutVertexB)
Void GetEdgeVertexPositions(HalfEdgeHandle hEdge, Transform transform, Vector3 outVertexA, Vector3 outVertexB)
FaceHandle GetOppositeFaceConnectedToEdge(HalfEdgeHandle hEdge, FaceHandle hFace)
Boolean GetVerticesConnectedToFace(FaceHandle hFace, VertexHandle[] vertices)
Void FindCornerVerticesForFace(FaceHandle hFace, Single minCornerAngle, List<VertexHandle> outCornerVertices)
Void QuadSliceFaces(IReadOnlyList<FaceHandle> faces, Int32 cutsX, Int32 cutsY, Single minCornerAngleDegrees, List<FaceHandle> outNewFaceList)
Void RemoveBadFaces()
Void AverageEdgeUVs(IReadOnlyList<HalfEdgeHandle> edges)
Void AverageVertexUVs(IReadOnlyList<VertexHandle> vertices)
static Void GetBestPlanesForEdgeBetweenFaces(PolygonMesh pMesh1, FaceHandle hFace1, Transform mLocalToWorld1, PolygonMesh pMesh2, FaceHandle hFace2, Transform mLocalToWorld2, Plane pOutPlane1, Plane pOutPlane2)
static Boolean GetNearestEdgesBetweenFaces(PolygonMesh pMesh1, FaceHandle hFace1, Transform mLocalToWorld1, PolygonMesh pMesh2, FaceHandle hFace2, Transform mLocalToWorld2, HalfEdgeHandle pOutEdge1, HalfEdgeHandle pOutEdge2)
Void GetFacePlaneUsingEdge(FaceHandle hFace, HalfEdgeHandle hEdge, Transform transform, Plane outPlane)
HalfEdgeHandle GetOppositeHalfEdge(HalfEdgeHandle hEdge)
static Void GetTextureExtents(Vector4 vAxisU, Vector4 vAxisV, Vector2 vScale, FaceExtents extents, Vector2 topLeft, Vector2 bottomRight)
Void JustifyFaceTextureParameters(IEnumerable<FaceHandle> hFaces, TextureJustification justification, FaceExtents extents)
Void UnionExtentsForFaces(IEnumerable<FaceHandle> hFaces, Transform transform, FaceExtents extents)
Vertex[] CreateFace(FaceHandle hFace, Transform transform, Color color)
Void GetFacesConnectedToEdge(HalfEdgeHandle hEdge, FaceHandle hOutFaceA, FaceHandle hOutFaceB)
Void FindBoundaryEdgesConnectedToFaces(IReadOnlyList<FaceHandle> faces, List<HalfEdgeHandle> outBoundaryEdges)
Boolean ThickenFaces(IReadOnlyList<FaceHandle> faces, Single amount, List<FaceHandle> outFaces)
Void FindFaceIslands(IReadOnlyList<FaceHandle> faces, List<FaceHandle>> outFaces)
Boolean GetFaceVerticesConnectedToVertex(VertexHandle hVertex, List<HalfEdgeHandle> faceVertices)
Boolean FindHalfEdgesConnectedToFace(FaceHandle face, List<HalfEdgeHandle> halfEdges)
static override Object JsonRead(Utf8JsonReader reader, Type typeToConvert)
static override Void JsonWrite(Object value, Utf8JsonWriter writer)
Void GenerateUVsForFaces(ReadOnlySpan<FaceHandle> faces, Int32 generationMode, Int32 edgeAlignMode, HalfEdgeHandle alignEdgeVertexA, HalfEdgeHandle alignEdgeVertexB, List<HalfEdgeHandle> outFaceVertices, List<Vector2> outFaceVertexUVs)
Void SplitFacesIntoIslandsForUVMapping(IReadOnlyList<FaceHandle> faces, List<FaceHandle>> faceIslands)
Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.PolygonMesh