MeshDataTool

Helper tool to access and edit Mesh data.

MeshDataTool provides access to individual vertices in a Mesh. It allows users to read and edit vertex data of meshes. It also creates an array of faces and edges. To use MeshDataTool, load a mesh with createFromSurface. When you are finished editing the data commit the data to a mesh with commitToSurface. Below is an example of how MeshDataTool may be used.

More...
@GodotBaseClass
struct MeshDataTool {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

clear
void clear()

Clears all data currently in MeshDataTool.

commitToSurface
GodotError commitToSurface(ArrayMesh mesh)

Adds a new surface to specified Mesh with edited data.

createFromSurface
GodotError createFromSurface(ArrayMesh mesh, long surface)

Uses specified surface of given Mesh to populate data for MeshDataTool. Requires Mesh with primitive type constant Mesh.PRIMITIVE_TRIANGLES.

getEdgeCount
long getEdgeCount()

Returns the number of edges in this Mesh.

getEdgeFaces
PoolIntArray getEdgeFaces(long idx)

Returns array of faces that touch given edge.

getEdgeMeta
Variant getEdgeMeta(long idx)

Returns meta information assigned to given edge.

getEdgeVertex
long getEdgeVertex(long idx, long vertex)

Returns index of specified vertex connected to given edge. Vertex argument can only be 0 or 1 because edges are comprised of two vertices.

getFaceCount
long getFaceCount()

Returns the number of faces in this Mesh.

getFaceEdge
long getFaceEdge(long idx, long edge)

Returns specified edge associated with given face. Edge argument must 2 or less because a face only has three edges.

getFaceMeta
Variant getFaceMeta(long idx)

Returns the metadata associated with the given face.

getFaceNormal
Vector3 getFaceNormal(long idx)

Calculates and returns the face normal of the given face.

getFaceVertex
long getFaceVertex(long idx, long vertex)

Returns the specified vertex of the given face. Vertex argument must be 2 or less because faces contain three vertices.

getFormat
long getFormat()

Returns the Mesh's format. Format is an integer made up of Mesh format flags combined together. For example, a mesh containing both vertices and normals would return a format of 3 because constant ArrayMesh.ARRAY_FORMAT_VERTEX is 1 and constant ArrayMesh.ARRAY_FORMAT_NORMAL is 2. See ArrayMesh.arrayformat for a list of format flags.

getMaterial
Ref!Material getMaterial()

Returns the material assigned to the Mesh.

getVertex
Vector3 getVertex(long idx)

Returns the vertex at given index.

getVertexBones
PoolIntArray getVertexBones(long idx)

Returns the bones of the given vertex.

getVertexColor
Color getVertexColor(long idx)

Returns the color of the given vertex.

getVertexCount
long getVertexCount()

Returns the total number of vertices in Mesh.

getVertexEdges
PoolIntArray getVertexEdges(long idx)

Returns an array of edges that share the given vertex.

getVertexFaces
PoolIntArray getVertexFaces(long idx)

Returns an array of faces that share the given vertex.

getVertexMeta
Variant getVertexMeta(long idx)

Returns the metadata associated with the given vertex.

getVertexNormal
Vector3 getVertexNormal(long idx)

Returns the normal of the given vertex.

getVertexTangent
Plane getVertexTangent(long idx)

Returns the tangent of the given vertex.

getVertexUv
Vector2 getVertexUv(long idx)

Returns the UV of the given vertex.

getVertexUv2
Vector2 getVertexUv2(long idx)

Returns the UV2 of the given vertex.

getVertexWeights
PoolRealArray getVertexWeights(long idx)

Returns bone weights of the given vertex.

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(MeshDataTool other)
opEquals
bool opEquals(typeof(null) n)
setEdgeMeta
void setEdgeMeta(long idx, VariantArg1 meta)

Sets the metadata of the given edge.

setFaceMeta
void setFaceMeta(long idx, VariantArg1 meta)

Sets the metadata of the given face.

setMaterial
void setMaterial(Material material)

Sets the material to be used by newly-constructed Mesh.

setVertex
void setVertex(long idx, Vector3 vertex)

Sets the position of the given vertex.

setVertexBones
void setVertexBones(long idx, PoolIntArray bones)

Sets the bones of the given vertex.

setVertexColor
void setVertexColor(long idx, Color color)

Sets the color of the given vertex.

setVertexMeta
void setVertexMeta(long idx, VariantArg1 meta)

Sets the metadata associated with the given vertex.

setVertexNormal
void setVertexNormal(long idx, Vector3 normal)

Sets the normal of the given vertex.

setVertexTangent
void setVertexTangent(long idx, Plane tangent)

Sets the tangent of the given vertex.

setVertexUv
void setVertexUv(long idx, Vector2 uv)

Sets the UV of the given vertex.

setVertexUv2
void setVertexUv2(long idx, Vector2 uv2)

Sets the UV2 of the given vertex.

setVertexWeights
void setVertexWeights(long idx, PoolRealArray weights)

Sets the bone weights of the given vertex.

toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Static functions

_new
MeshDataTool _new()

Construct a new instance of MeshDataTool. Note: use memnew!MeshDataTool instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

var mesh = ArrayMesh.new() mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, CubeMesh.new().get_mesh_arrays()) var mdt = MeshDataTool.new() mdt.create_from_surface(mesh, 0) for i in range(mdt.get_vertex_count()): var vertex = mdt.get_vertex(i) # In this example we extend the mesh by one unit, which results in separated faces as it is flat shaded. vertex += mdt.get_vertex_normal(i) # Save your change. mdt.set_vertex(i, vertex) mesh.surface_remove(0) mdt.commit_to_surface(mesh) var mi = MeshInstance.new() mi.mesh = mesh add_child(mi)

See also ArrayMesh, ImmediateGeometry and SurfaceTool for procedural geometry generation. Note: Godot uses clockwise url=https://learnopengl.com/Advanced-OpenGL/Face-cullingwinding order/url for front faces of triangle primitive modes.

Meta