Class Tri
Represents a triangle in the mesh decimation algorithm. Stores triangle vertices, normals, UVs, and adjacency information.
Namespace: NWH.DWP2.MeshDecimation
Assembly: NWH.DWP2.dll
Syntax
public class Tri
Constructors
| Edit this page View SourceTri(int, Vert, Vert, Vert, Vector2, Vector2, Vector2)
Initializes a new triangle with vertices, texture coordinates, and establishes vertex relationships.
Declaration
public Tri(int id, Vert v0, Vert v1, Vert v2, Vector2 uv0, Vector2 uv1, Vector2 uv2)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Unique identifier for this triangle. |
| Vert | v0 | First vertex. |
| Vert | v1 | Second vertex. |
| Vert | v2 | Third vertex. |
| Vector2 | uv0 | Texture coordinate for first vertex. |
| Vector2 | uv1 | Texture coordinate for second vertex. |
| Vector2 | uv2 | Texture coordinate for third vertex. |
Fields
| Edit this page View SourcedefaultIndex0
Original mesh vertex index for vertex 0.
Declaration
public int defaultIndex0
Field Value
| Type | Description |
|---|---|
| int |
defaultIndex1
Original mesh vertex index for vertex 1.
Declaration
public int defaultIndex1
Field Value
| Type | Description |
|---|---|
| int |
defaultIndex2
Original mesh vertex index for vertex 2.
Declaration
public int defaultIndex2
Field Value
| Type | Description |
|---|---|
| int |
deleted
Whether this triangle has been deleted.
Declaration
public bool deleted
Field Value
| Type | Description |
|---|---|
| bool |
id
Unique identifier for this triangle.
Declaration
public int id
Field Value
| Type | Description |
|---|---|
| int |
normal
Face normal vector.
Declaration
public Vector3 normal
Field Value
| Type | Description |
|---|---|
| Vector3 |
uv0
Texture coordinate for vertex 0.
Declaration
public Vector2 uv0
Field Value
| Type | Description |
|---|---|
| Vector2 |
uv1
Texture coordinate for vertex 1.
Declaration
public Vector2 uv1
Field Value
| Type | Description |
|---|---|
| Vector2 |
uv2
Texture coordinate for vertex 2.
Declaration
public Vector2 uv2
Field Value
| Type | Description |
|---|---|
| Vector2 |
v0
First vertex of the triangle.
Declaration
public Vert v0
Field Value
| Type | Description |
|---|---|
| Vert |
v1
Second vertex of the triangle.
Declaration
public Vert v1
Field Value
| Type | Description |
|---|---|
| Vert |
v2
Third vertex of the triangle.
Declaration
public Vert v2
Field Value
| Type | Description |
|---|---|
| Vert |
vn0
Vertex normal for vertex 0.
Declaration
public Vector3 vn0
Field Value
| Type | Description |
|---|---|
| Vector3 |
vn1
Vertex normal for vertex 1.
Declaration
public Vector3 vn1
Field Value
| Type | Description |
|---|---|
| Vector3 |
vn2
Vertex normal for vertex 2.
Declaration
public Vector3 vn2
Field Value
| Type | Description |
|---|---|
| Vector3 |
Methods
| Edit this page View SourceHasVertex(Vert)
Checks if this triangle contains a given vertex.
Declaration
public bool HasVertex(Vert v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vert | v | Vertex to check. |
Returns
| Type | Description |
|---|---|
| bool | True if the triangle contains the vertex, false otherwise. |
RecalculateAvgNormals(float)
Recalculates averaged vertex normals based on adjacent face normals. Only called when normal recalculation is enabled. Smooths normals even at UV seams.
Declaration
public void RecalculateAvgNormals(float smoothAngleDot)
Parameters
| Type | Name | Description |
|---|---|---|
| float | smoothAngleDot | Dot product threshold for normal smoothing. |
RecalculateNormal()
Recalculates the face normal using cross product of edge vectors.
Declaration
public void RecalculateNormal()
RemoveTriangle(History)
Removes this triangle and updates vertex relationships. Records the removal in history for potential undo operations.
Declaration
public void RemoveTriangle(History his)
Parameters
| Type | Name | Description |
|---|---|---|
| History | his | History object to record the removal. |
ReplaceVertex(Vert, Vert, Vector2, Vector3, History)
Replaces a vertex in this triangle with a new vertex and updates all relationships. Records the replacement in history for potential undo operations.
Declaration
public void ReplaceVertex(Vert vo, Vert vnew, Vector2 newUV, Vector3 newVN, History his)
Parameters
| Type | Name | Description |
|---|---|---|
| Vert | vo | Old vertex to be replaced. |
| Vert | vnew | New vertex to replace with. |
| Vector2 | newUV | New texture coordinate. |
| Vector3 | newVN | New vertex normal. |
| History | his | History object to record the replacement. |
SetDefaultIndices(int, int, int)
Sets the original mesh vertex indices for this triangle.
Declaration
public void SetDefaultIndices(int n0, int n1, int n2)
Parameters
| Type | Name | Description |
|---|---|---|
| int | n0 | Original index for vertex 0. |
| int | n1 | Original index for vertex 1. |
| int | n2 | Original index for vertex 2. |
normalAt(Vert)
Gets the vertex normal for a given vertex.
Declaration
public Vector3 normalAt(Vert v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vert | v | Vertex to query. |
Returns
| Type | Description |
|---|---|
| Vector3 | Vertex normal for the vertex, or zero vector if not found. |
setUV(Vert, Vector2)
Sets the texture coordinate for a given vertex.
Declaration
public void setUV(Vert v, Vector2 newuv)
Parameters
| Type | Name | Description |
|---|---|---|
| Vert | v | Vertex to update. |
| Vector2 | newuv | New texture coordinate. |
setVN(Vert, Vector3)
Sets the vertex normal for a given vertex.
Declaration
public void setVN(Vert v, Vector3 newNormal)
Parameters
| Type | Name | Description |
|---|---|---|
| Vert | v | Vertex to update. |
| Vector3 | newNormal | New vertex normal. |
uvAt(Vert)
Gets the texture coordinate for a given vertex.
Declaration
public Vector2 uvAt(Vert v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vert | v | Vertex to query. |
Returns
| Type | Description |
|---|---|
| Vector2 | Texture coordinate for the vertex, or zero vector if not found. |