Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    Class Tri

    Represents a triangle in the mesh decimation algorithm. Stores triangle vertices, normals, UVs, and adjacency information.

    Inheritance
    object
    Tri
    Namespace: NWH.DWP2.MeshDecimation
    Assembly: NWH.DWP2.dll
    Syntax
    public class Tri

    Constructors

    | Edit this page View Source

    Tri(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 Source

    defaultIndex0

    Original mesh vertex index for vertex 0.

    Declaration
    public int defaultIndex0
    Field Value
    Type Description
    int
    | Edit this page View Source

    defaultIndex1

    Original mesh vertex index for vertex 1.

    Declaration
    public int defaultIndex1
    Field Value
    Type Description
    int
    | Edit this page View Source

    defaultIndex2

    Original mesh vertex index for vertex 2.

    Declaration
    public int defaultIndex2
    Field Value
    Type Description
    int
    | Edit this page View Source

    deleted

    Whether this triangle has been deleted.

    Declaration
    public bool deleted
    Field Value
    Type Description
    bool
    | Edit this page View Source

    id

    Unique identifier for this triangle.

    Declaration
    public int id
    Field Value
    Type Description
    int
    | Edit this page View Source

    normal

    Face normal vector.

    Declaration
    public Vector3 normal
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    uv0

    Texture coordinate for vertex 0.

    Declaration
    public Vector2 uv0
    Field Value
    Type Description
    Vector2
    | Edit this page View Source

    uv1

    Texture coordinate for vertex 1.

    Declaration
    public Vector2 uv1
    Field Value
    Type Description
    Vector2
    | Edit this page View Source

    uv2

    Texture coordinate for vertex 2.

    Declaration
    public Vector2 uv2
    Field Value
    Type Description
    Vector2
    | Edit this page View Source

    v0

    First vertex of the triangle.

    Declaration
    public Vert v0
    Field Value
    Type Description
    Vert
    | Edit this page View Source

    v1

    Second vertex of the triangle.

    Declaration
    public Vert v1
    Field Value
    Type Description
    Vert
    | Edit this page View Source

    v2

    Third vertex of the triangle.

    Declaration
    public Vert v2
    Field Value
    Type Description
    Vert
    | Edit this page View Source

    vn0

    Vertex normal for vertex 0.

    Declaration
    public Vector3 vn0
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    vn1

    Vertex normal for vertex 1.

    Declaration
    public Vector3 vn1
    Field Value
    Type Description
    Vector3
    | Edit this page View Source

    vn2

    Vertex normal for vertex 2.

    Declaration
    public Vector3 vn2
    Field Value
    Type Description
    Vector3

    Methods

    | Edit this page View Source

    HasVertex(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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    RecalculateNormal()

    Recalculates the face normal using cross product of edge vectors.

    Declaration
    public void RecalculateNormal()
    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics