unreal.GeometryScript_Normals

class unreal.GeometryScript_Normals(outer: Object | None = None, name: Name | str = 'None')

Bases: BlueprintFunctionLibrary

Geometry Script Library Mesh Normals Functions

C++ Source:

  • Plugin: GeometryScripting

  • Module: GeometryScriptingCore

  • File: MeshNormalsFunctions.h

classmethod auto_repair_normals(target_mesh, debug=None) DynamicMesh

Attempt to repair inconsistent normals in TargetMesh. Currently this is done in two passes. In the first pass, triangles with reversed orientation from their neighours are incrementally flipped until each connected component has a consistent orientation, if this is possible (note that this is not always globally possible, eg for a mobius-strip topology there is no consistent orientation). In the second pass, the “global” orientation is detected by casting rays from outside the mesh. This may produce incorrect results for meshes that are not closed.

Parameters:
Return type:

DynamicMesh

classmethod compute_split_normals(target_mesh, split_options, calculate_options, debug=None) DynamicMesh

Recompute hard edges / split-normals for TargetMesh based on the provided SplitOptions, and then recompute the new shared triangle-vertex normals using the given CalculateOptions. The normal recomputation is identical to calling RecomputeNormals.

Parameters:
Return type:

DynamicMesh

classmethod compute_tangents(target_mesh, options, debug=None) DynamicMesh

Recompute Tangents for the TargetMesh, using the method and settings specified by FGeometryScriptTangentsOptions note: If recomputing Tangents for use with a DynamicMeshComponent, it is also necessary to set the Tangents Type on the Component to “Externally Provided”

Parameters:
Return type:

DynamicMesh

classmethod discard_tangents(target_mesh, debug=None) DynamicMesh

Remove any existing Tangents Attribute Layer from the TargetMesh

Parameters:
Return type:

DynamicMesh

classmethod flip_normals(target_mesh, debug=None) DynamicMesh

Flip/Invert the normal vectors of TargetMesh by multiplying them by -1, as well as reversing the mesh triangle orientations, ie triangle (a,b,c) becomes (b,a,c)

Parameters:
Return type:

DynamicMesh

classmethod get_mesh_has_tangents(target_mesh, debug=None) -> (DynamicMesh, has_tangents=bool)

Check if the TargetMesh has a Tangents Attribute Layer enabled

Parameters:
Returns:

has_tangents (bool):

Return type:

bool

classmethod get_mesh_per_vertex_normals(target_mesh, average_split_vertex_values=True) -> (DynamicMesh, normal_list=GeometryScriptVectorList, is_valid_normal_set=bool, has_vertex_id_gaps=bool)

Get a list of single normal vectors for each mesh vertex in the TargetMesh, derived from the Normals Overlay. The Normals Overlay may store multiple normals for a single vertex (ie split normals) In such cases the normals can either be averaged, or the last normal seen will be used, depending on the bAverageSplitVertexValues parameter.

Parameters:
  • target_mesh (DynamicMesh) –

  • average_split_vertex_values (bool) – control how multiple normals at the same vertex should be interpreted

Returns:

normal_list (GeometryScriptVectorList): output normal list will be stored here. Size will be equal to the MaxVertexID of TargetMesh (not the VertexCount!)

is_valid_normal_set (bool): will be set to true if the Normal Overlay was valid

has_vertex_id_gaps (bool): will be set to true if some vertex indices in TargetMesh were invalid, ie MaxVertexID > VertexCount

Return type:

tuple

classmethod get_mesh_per_vertex_tangents(target_mesh, average_split_vertex_values=True) -> (DynamicMesh, tangent_x_list=GeometryScriptVectorList, tangent_y_list=GeometryScriptVectorList, is_valid_tangent_set=bool, has_vertex_id_gaps=bool)

Get a list of single tangent vectors for each mesh vertex in the TargetMesh, derived from the Tangents Overlays. The Tangents Overlay may store multiple tangents for a single vertex (ie split tangents) In such cases the tangents can either be averaged, or the last tangent seen will be used, depending on the bAverageSplitVertexValues parameter.

Parameters:
  • target_mesh (DynamicMesh) –

  • average_split_vertex_values (bool) – control how multiple tangents at the same vertex should be interpreted

Returns:

tangent_x_list (GeometryScriptVectorList): output Tangent “X” vectors list will be stored here. Size will be equal to the MaxVertexID of TargetMesh (not the VertexCount!)

tangent_y_list (GeometryScriptVectorList): output Tangent “Y” vectors (Binormal/Bitangent) list will be stored here. Size will be equal to TangentXList

is_valid_tangent_set (bool): will be set to true if the Tangent Overlay was valid

has_vertex_id_gaps (bool): will be set to true if some vertex indices in TargetMesh were invalid, ie MaxVertexID > VertexCount

Return type:

tuple

classmethod recompute_normals(target_mesh, calculate_options, defer_change_notifications=False, debug=None) DynamicMesh

Recompute the normals of TargetMesh using the given CalculateOptions. This method will preserve any existing hard edges, ie each shared triangle-vertex normal is recomputed by averaging the face normals of triangles that reference that shared triangle-vertex normal

Parameters:
Return type:

DynamicMesh

classmethod recompute_normals_for_mesh_selection(target_mesh, selection, calculate_options, defer_change_notifications=False, debug=None) DynamicMesh

Recompute the normals of TargetMesh on all the triangles/vertices of the given Selection using the given CalculateOptions. This method will preserve any existing hard edges, ie each shared triangle-vertex normal is recomputed by averaging the face normals of triangles that reference that shared triangle-vertex normal

Parameters:
Return type:

DynamicMesh

classmethod set_mesh_per_vertex_normals(target_mesh, vertex_normal_list, debug=None) DynamicMesh

Set all normals in the TargetMesh Normals Overlay to the specified per-vertex normals

Parameters:
Return type:

DynamicMesh

classmethod set_mesh_per_vertex_tangents(target_mesh, tangent_x_list, tangent_y_list, debug=None) DynamicMesh

Set all tangents in the TargetMesh Tangents Overlays to the specified per-vertex tangents note: If setting Tangents for use with a DynamicMeshComponent, it is also necessary to set the Tangents Type on the Component to “Externally Provided”

Parameters:
Return type:

DynamicMesh

classmethod set_mesh_triangle_normals(target_mesh, triangle_id, normals, defer_change_notifications=False) -> (DynamicMesh, is_valid_triangle=bool)

Set the triangle-vertex normals for the given TriangleID on the TargetMesh. This will create unique triangle-vertex normals, ie it will create hard edges / split normals in the normal overlay for each edge of the triangle.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

  • normals (GeometryScriptTriangle) –

  • defer_change_notifications (bool) – if true, no mesh change notification will be sent. Set to true if changing many normals in a loop.

Returns:

is_valid_triangle (bool): will be returned as false if TriangleID does not refer to a valid triangle

Return type:

bool

classmethod set_per_face_normals(target_mesh, debug=None) DynamicMesh

Recompute the normals of TargetMesh by setting the normals of each triangle vertex to the triangle/face normal. Each vertex will have a unique normal in each triangle, ie there will be hard edges / split normals at every mesh edge

Parameters:
Return type:

DynamicMesh

classmethod set_per_vertex_normals(target_mesh, debug=None) DynamicMesh

Recompute the normals of TargetMesh by averaging the triangle/face normals around each vertex, using combined area and angle weighting. Each vertex will have a single normal, ie there will be no hard edges.

Parameters:
Return type:

DynamicMesh

classmethod update_vertex_normal(target_mesh, vertex_id, update_normal=True, new_normal, update_tangents, new_tangent_x, new_tangent_y, merge_split_values, defer_change_notifications=False) -> (DynamicMesh, is_valid_vertex=bool)

Update the Normals and/or Tangents at VertexID of TargetMesh. Note that the specified vertex may have “split normals” or “split tangents”, ie in the case of hard/crease normals, UV seams, and so on. In these situations, by default each of the unique normals/tangents at the vertex will be updated, but they will not be “merged”, ie they will remain split. However if bMergeSplitValues=true, then the vertex will be “un-split”, ie after the function call the vertex will have a single unique shared normal and/or tangents.

Note that this function requires that some normals/tangents already exist on the TargetMesh. If this is not the case, functions like SetPerVertexNormals and ComputeTangents can be used to initialize the normals/tangents first.

Parameters:
  • target_mesh (DynamicMesh) –

  • vertex_id (int32) –

  • update_normal (bool) – if true (default) then the normals overlay is updated

  • new_normal (Vector) – the new normal vector. This vector will not be normalized, it must be normalized by the calling code.

  • update_tangents (bool) – if true then the tangents overlay will be updated. If the tangents overlay does not exist, this function returns an error.

  • new_tangent_x (Vector) – the new tangent vector. This vector will not be normalized, it must be normalized by the calling code.

  • new_tangent_y (Vector) – the new bitangent/binormal vector. This vector will not be normalized, it must be normalized by the calling code.

  • merge_split_values (bool) – if true, any split normals/tangents at the vertex will be cleared, and a unique normal/tangent element will be set in the connected triangles

  • defer_change_notifications (bool) – if true, no mesh change notification will be sent. Set to true if changing many normals in a loop.

Returns:

is_valid_vertex (bool): will be set to true on return if the VertexID was valid, ie had valid normals and tangents

Return type:

bool