bool AddVertexToEdge( VertexHandle hVertexA, VertexHandle hVertexB, float flParam, HalfEdgeMesh.VertexHandle& pOutNewVertex )

book_4_sparkGenerated
code_blocksInput

Description

The AddVertexToEdge method is used to add a new vertex to an edge defined by two vertices, hVertexA and hVertexB, in a PolygonMesh. The new vertex is placed at a position interpolated between the two vertices based on the parameter flParam. The method returns a boolean indicating whether the operation was successful, and outputs the handle to the newly created vertex through pOutNewVertex.

Usage

To use the AddVertexToEdge method, you need to provide the handles of the two vertices that define the edge, a parameter to determine the position of the new vertex along the edge, and an output variable to receive the handle of the new vertex. The method will return true if the vertex was successfully added, or false otherwise.

Example

// Example usage of AddVertexToEdge
HalfEdgeMesh.VertexHandle vertexA = mesh.VertexHandleFromIndex(0);
HalfEdgeMesh.VertexHandle vertexB = mesh.VertexHandleFromIndex(1);
float parameter = 0.5f; // Midpoint
HalfEdgeMesh.VertexHandle newVertex;

bool success = mesh.AddVertexToEdge(vertexA, vertexB, parameter, out newVertex);

if (success)
{
    // The new vertex was successfully added
    Vector3 newPosition = mesh.GetVertexPosition(newVertex);
    // Use newPosition as needed
}