unreal.GeometryScript_MeshQueries

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

Bases: BlueprintFunctionLibrary

Geometry Script Library Mesh Query Functions

C++ Source:

  • Plugin: GeometryScripting

  • Module: GeometryScriptingCore

  • File: MeshQueryFunctions.h

classmethod compute_triangle_barycentric_coords(target_mesh, triangle_id, point) -> (DynamicMesh, is_valid_triangle=bool, vertex1=Vector, vertex2=Vector, vertex3=Vector, barycentric_coords=Vector)

Compute the barycentric coordinates (A,B,C) of the Point relative to the specified TriangleID of the TargetMesh. The properties of barycentric coordinates are such that A,B,C are all positive, A+B+C=1.0, and A*Vertex1 + B*Vertex2 + C*Vertex3 = Point. So, the barycentric coordinates can be used to smoothly interpolate/blend any other per-triangle-vertex quantities. The Point must lie in the plane of the Triangle, otherwise the coordinates are somewhat meaningless (but clamped to 0-1 range to avoid catastrophic errors) The Positions of the Triangle Vertices are also returned for convenience (similar to GetTrianglePositions)

Parameters:
Returns:

is_valid_triangle (bool): will be returned true if TriangleID exists in TargetMesh, and otherwise will be returned false

vertex1 (Vector):

vertex2 (Vector):

vertex3 (Vector):

barycentric_coords (Vector):

Return type:

tuple

classmethod get_all_split_u_vs_at_vertex(target_mesh, uv_set_index, vertex_id) -> (DynamicMesh, element_i_ds=Array[int32], element_u_vs=Array[Vector2D], have_valid_u_vs=bool)

Returns the unique UV element IDs and values associated with the mesh vertex, in the specified UV Channel. If the Vertex or UV channel does not exist, the arrays will be empty and bHaveValidUVs will be set to false.

Parameters:
  • target_mesh (DynamicMesh) –

  • uv_set_index (int32) –

  • vertex_id (int32) –

Returns:

element_i_ds (Array[int32]):

element_u_vs (Array[Vector2D]):

have_valid_u_vs (bool):

Return type:

tuple

classmethod get_all_triangle_i_ds(target_mesh) -> (DynamicMesh, triangle_id_list=GeometryScriptIndexList, has_triangle_id_gaps=bool)

Returns an Index List of all Triangle IDs in a mesh.

Parameters:

target_mesh (DynamicMesh) –

Returns:

triangle_id_list (GeometryScriptIndexList):

has_triangle_id_gaps (bool): will be true on return if there are breaks in the sequential numeration of Triangle IDs, as would happen after deleting triangles.

Return type:

tuple

classmethod get_all_triangle_indices(target_mesh, skip_gaps) -> (DynamicMesh, triangle_list=GeometryScriptTriangleList, has_triangle_id_gaps=bool)
  • Returns a TriangleList of all Triangle Vertex ID triplets in a mesh.

Parameters:
  • target_mesh (DynamicMesh) –

  • skip_gaps (bool) – if false there will be a one-to-one correspondence between Triangle ID and entries in the triangle list and invalid triplets of (-1,-1,-1) will correspond to Triangle IDs not found in the Target Mesh. *

Returns:

triangle_list (GeometryScriptTriangleList):

has_triangle_id_gaps (bool): will be false on return if the mesh had no gaps in Triangle IDs or if bSkipGaps was set to true.

Return type:

tuple

classmethod get_all_vertex_i_ds(target_mesh) -> (DynamicMesh, vertex_id_list=GeometryScriptIndexList, has_vertex_id_gaps=bool)

Returns an IndexList of all Vertex IDs in mesh.

Parameters:

target_mesh (DynamicMesh) –

Returns:

vertex_id_list (GeometryScriptIndexList):

has_vertex_id_gaps (bool):

Return type:

tuple

classmethod get_all_vertex_positions(target_mesh, skip_gaps) -> (DynamicMesh, position_list=GeometryScriptVectorList, has_vertex_id_gaps=bool)

Returns a Vector List of all the mesh vertex 3D positions (possibly large!).

Parameters:
  • target_mesh (DynamicMesh) –

  • skip_gaps (bool) – if false there will be a one-to-one correspondence between Vertex ID and entries in the Position List where a zero vector (0,0,0) will correspond to Vertex IDs not found in the Target Mesh.

Returns:

position_list (GeometryScriptVectorList):

has_vertex_id_gaps (bool): will be false if the mesh had no gaps in Vertex IDs or if bSkipGaps was set to true.

Return type:

tuple

classmethod get_has_material_i_ds(target_mesh) bool

Returns true if the mesh has Material IDs available/enabled.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_has_polygroups(target_mesh) bool

Returns true if the mesh has a standard PolyGroup Layer.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_has_triangle_id_gaps(target_mesh) bool

Returns true if there are gaps in the Triangle ID list, such that Get Num Triangle IDs is greater than Get Triangle Count.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_has_triangle_normals(target_mesh) bool
Parameters:

target_mesh (DynamicMesh) –

Returns:

true if the TargetMesh has the Normals Attribute enabled (which allows for storing split normals)

Return type:

bool

classmethod get_has_vertex_colors(target_mesh) bool
Parameters:

target_mesh (DynamicMesh) –

Returns:

true if the TargetMesh has the Vertex Colors attribute enabled

Return type:

bool

classmethod get_has_vertex_id_gaps(target_mesh) bool

Returns true if there are gaps in the Vertex ID list. For example, Get Number of Vertex IDs is greater than Get Vertex Count.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_interpolated_triangle_normal(target_mesh, triangle_id, barycentric_coords) -> (DynamicMesh, tri_has_valid_normals=bool, interpolated_normal=Vector)

Compute the interpolated Normal (A*Normal1 + B*Normal2 + C*Normal3), where (A,B,C)=BarycentricCoords and the Normals are taken from the specified TriangleID in the Normal layer of the TargetMesh.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

  • barycentric_coords (Vector) –

Returns:

tri_has_valid_normals (bool): will be returned true if TriangleID exists in TargetMesh and has Normals set, and otherwise will be returned false.

interpolated_normal (Vector):

Return type:

tuple

classmethod get_interpolated_triangle_normal_tangents(target_mesh, triangle_id, barycentric_coords) -> (DynamicMesh, tri_has_valid_elements=bool, interpolated_normal=Vector, interpolated_tangent=Vector, interpolated_bi_tangent=Vector)

Compute the interpolated Normal and Tangents for the specified specified TriangleID in the Normal and Tangent attributes of the TargetMesh.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

  • barycentric_coords (Vector) –

Returns:

tri_has_valid_elements (bool): will be returned true if TriangleID exists in TargetMesh and has Normals and Tangents set, and otherwise will be returned false

interpolated_normal (Vector):

interpolated_tangent (Vector):

interpolated_bi_tangent (Vector):

Return type:

tuple

classmethod get_interpolated_triangle_position(target_mesh, triangle_id, barycentric_coords) -> (DynamicMesh, is_valid_triangle=bool, interpolated_position=Vector)

Compute the interpolated Position (A*Vertex1 + B*Vertex2 + C*Vertex3), where (A,B,C)=BarycentricCoords and the Vertex positions are taken from the specified TriangleID of the TargetMesh.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

  • barycentric_coords (Vector) –

Returns:

is_valid_triangle (bool): will be returned true if TriangleID exists in TargetMesh, and otherwise will be returned false

interpolated_position (Vector):

Return type:

tuple

classmethod get_interpolated_triangle_uv(target_mesh, uv_set_index, triangle_id, barycentric_coords) -> (DynamicMesh, tri_has_valid_u_vs=bool, interpolated_uv=Vector2D)

Compute the interpolated UV (A*UV1+ B*UV2+ C*UV3), where (A,B,C)=BarycentricCoords and the UV positions are taken from the specified TriangleID in the specified UVSet of the TargetMesh.

Parameters:
  • target_mesh (DynamicMesh) –

  • uv_set_index (int32) –

  • triangle_id (int32) –

  • barycentric_coords (Vector) –

Returns:

tri_has_valid_u_vs (bool):

interpolated_uv (Vector2D):

Return type:

tuple

classmethod get_interpolated_triangle_vertex_color(target_mesh, triangle_id, barycentric_coords, default_color) -> (DynamicMesh, tri_has_valid_vertex_colors=bool, interpolated_color=LinearColor)

Compute the interpolated Vertex Color (A*Color1 + B*Color2 + C*Color3), where (A,B,C)=BarycentricCoords and the Colors are taken from the specified TriangleID in the Vertex Color layer of the TargetMesh.

Parameters:
Returns:

tri_has_valid_vertex_colors (bool): will be returned true if TriangleID exists in TargetMesh and has Colors set, and otherwise will be returned false

interpolated_color (LinearColor):

Return type:

tuple

classmethod get_is_closed_mesh(target_mesh) bool

Returns true if the mesh is closed, such as no topological boundary edges.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_is_dense_mesh(target_mesh) bool

Returns true if the mesh is dense. For example, no gaps in Vertex IDs or Triangle IDs. Note if a mesh is not dense, the Compact Mesh node can be used to removed the gaps.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_mesh_bounding_box(target_mesh) Box

Computes the bounding box of the mesh vertices in the local space of the mesh.

Parameters:

target_mesh (DynamicMesh) –

Return type:

Box

classmethod get_mesh_has_attribute_set(target_mesh) bool

Returns true if the Target Mesh has attributes enabled.

Parameters:

target_mesh (DynamicMesh) –

Return type:

bool

classmethod get_mesh_info_string(target_mesh) str

Returns information about the Target Mesh, such as the vertex and triangle count as well as some attribute information.

Parameters:

target_mesh (DynamicMesh) –

Return type:

str

classmethod get_mesh_volume_area(target_mesh) -> (surface_area=float, volume=float)

Computes the volume and area of the mesh.

Parameters:

target_mesh (DynamicMesh) –

Returns:

surface_area (float):

volume (float):

Return type:

tuple

classmethod get_mesh_volume_area_center(target_mesh) -> (surface_area=float, volume=float, center_of_mass=Vector)

Computes the volume, area and center-of-mass of the mesh.

Parameters:

target_mesh (DynamicMesh) –

Returns:

surface_area (float):

volume (float):

center_of_mass (Vector):

Return type:

tuple

classmethod get_num_connected_components(target_mesh) int32

Returns the number of separate connected components in the mesh, such as “triangle patches” internally connected by shared edges.

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_num_extended_polygroup_layers(target_mesh) int32

Returns the count of extended PolyGroup Layers.

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_num_open_border_edges(target_mesh) int32

Returns the number of topological boundary edges in the mesh, i.e counts edges that only have one adjacent triangle.

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_num_open_border_loops(target_mesh) -> (int32, ambiguous_topology_found=bool)

Returns the number of open border loops, such as “holes” in the mesh.

Parameters:

target_mesh (DynamicMesh) –

Returns:

ambiguous_topology_found (bool):

Return type:

bool

classmethod get_num_triangle_i_ds(target_mesh) int32

Gets the number of Triangle IDs in the mesh. This may be larger than the Triangle Count if the mesh is not dense, even after deleting triangles.

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_num_uv_sets(target_mesh) int32

Gets the number of UV Channels on the Target Mesh.

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_num_vertex_i_ds(target_mesh) int32

Gets the number of Vertex IDs in the mesh, which may be larger than the Vertex Count, if the mesh is not dense (e.g. after deleting vertices).

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_triangle_face_normal(target_mesh, triangle_id) -> (Vector, is_valid_triangle=bool)

Get Triangle Face Normal

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

Returns:

is_valid_triangle (bool):

Return type:

bool

classmethod get_triangle_indices(target_mesh, triangle_id) -> (IntVector, is_valid_triangle=bool)

Returns the Vertex ID triplet for the specified Triangle.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) – indicates the triangle to query on the Target Mesh.

Returns:

is_valid_triangle (bool): will be false on return if the Triangle ID does not exist in the Target Mesh, in that case the returned vertex triplet will be (-1, -1, -1).

Return type:

bool

classmethod get_triangle_normal_tangents(target_mesh, triangle_id) -> (DynamicMesh, tri_has_valid_elements=bool, normals=GeometryScriptTriangle, tangents=GeometryScriptTriangle, bi_tangents=GeometryScriptTriangle)

For the specified Triangle ID of the TargetMesh, get the Normal and Tangent vectors at each vertex of the Triangle. These Normals/Tangents will be taken from the Normal and Tangents Overlays, i.e. they will potentially be split-normals.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

Returns:

tri_has_valid_elements (bool): will be returned true if TriangleID exists in TargetMesh and has Normals and Tangents set.

normals (GeometryScriptTriangle):

tangents (GeometryScriptTriangle):

bi_tangents (GeometryScriptTriangle):

Return type:

tuple

classmethod get_triangle_normals(target_mesh, triangle_id) -> (DynamicMesh, normal1=Vector, normal2=Vector, normal3=Vector, tri_has_valid_normals=bool)

For the specified TriangleID of the Target Mesh, get the Normal vectors at each vertex of the Triangle. These Normals will be taken from the Normal Overlay, i.e. they will potentially be split-normals.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

Returns:

normal1 (Vector):

normal2 (Vector):

normal3 (Vector):

tri_has_valid_normals (bool): will be returned true if TriangleID exists in TargetMesh and has Normals set.

Return type:

tuple

classmethod get_triangle_positions(target_mesh, triangle_id) -> (is_valid_triangle=bool, vertex1=Vector, vertex2=Vector, vertex3=Vector)
  • Returns the 3D positions (in the mesh local space) of the three vertices of the requested triangle.

  • If the Triangle ID is not an element of the Target Mesh, all three vertices will be returned as (0, 0, 0) and bIsValidTriangle will be set to false.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

Returns:

is_valid_triangle (bool):

vertex1 (Vector):

vertex2 (Vector):

vertex3 (Vector):

Return type:

tuple

classmethod get_triangle_u_vs(target_mesh, uv_set_index, triangle_id) -> (uv1=Vector2D, uv2=Vector2D, uv3=Vector2D, have_valid_u_vs=bool)

Returns the UV values associated with the three vertices of the triangle in the specified UV Channel. If the Triangle does not exist in the mesh or if no UVs are set in the specified UV Channel for the triangle, the resulting values will be (0,0) and bHaveValidUVs will be set to false.

Parameters:
  • target_mesh (DynamicMesh) –

  • uv_set_index (int32) –

  • triangle_id (int32) –

Returns:

uv1 (Vector2D):

uv2 (Vector2D):

uv3 (Vector2D):

have_valid_u_vs (bool):

Return type:

tuple

classmethod get_triangle_vertex_colors(target_mesh, triangle_id) -> (DynamicMesh, color1=LinearColor, color2=LinearColor, color3=LinearColor, tri_has_valid_vertex_colors=bool)

For the specified TriangleID of the TargetMesh, get the Vertex Colors at each vertex of the Triangle. These Colors will be taken from the Vertex Color Attribute, ie they will potentially be split-colors.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

Returns:

color1 (LinearColor):

color2 (LinearColor):

color3 (LinearColor):

tri_has_valid_vertex_colors (bool): will be returned true if TriangleID exists in TargetMesh and has Vertex Colors set

Return type:

tuple

classmethod get_uv_set_bounding_box(target_mesh, uv_set_index) -> (Box2D, is_valid_uv_set=bool, uv_set_is_empty=bool)

Gets the 2D bounding box of all UVs in the UV Channel. If the UV Channel does not exist, or if the UV Channel is empty, the resulting box will be invalid.

Parameters:
  • target_mesh (DynamicMesh) –

  • uv_set_index (int32) –

Returns:

is_valid_uv_set (bool):

uv_set_is_empty (bool):

Return type:

tuple

classmethod get_vertex_connected_triangles(target_mesh, vertex_id) -> (DynamicMesh, triangles=Array[int32])

Return array of Triangle IDs connected to the given VertexID, ie the triangle one-ring

Parameters:
Returns:

triangles (Array[int32]):

Return type:

Array[int32]

classmethod get_vertex_connected_vertices(target_mesh, vertex_id) -> (DynamicMesh, vertices=Array[int32])

Return array of Vertex IDs connected via a mesh edge to the given VertexID, ie the vertex one-ring

Parameters:
Returns:

vertices (Array[int32]):

Return type:

Array[int32]

classmethod get_vertex_count(target_mesh) int32

Gets the number of vertices in the mesh. Note this may be less than the number of Vertex IDs used as some vertices may have been deleted.

Parameters:

target_mesh (DynamicMesh) –

Return type:

int32

classmethod get_vertex_position(target_mesh, vertex_id) -> (Vector, is_valid_vertex=bool)

Gets the 3D position of a mesh vertex in the mesh local space, by Vertex ID.

Parameters:
Returns:

is_valid_vertex (bool):

Return type:

bool

classmethod is_valid_triangle_id(target_mesh, triangle_id) bool

Returns true if Triangle ID refers to a valid Triangle in the Target Mesh.

Parameters:
  • target_mesh (DynamicMesh) –

  • triangle_id (int32) –

Return type:

bool

classmethod is_valid_vertex_id(target_mesh, vertex_id) bool

Returns true if Vertex ID refers to a valid vertex in the Target Mesh.

Parameters:
Return type:

bool