Helper tool to access and edit Mesh data.
    public class MeshDataTool : Reference

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(Godot.ArrayMesh, int). When you are finished editing the data commit the data to a mesh with CommitToSurface(Godot.ArrayMesh).

Below is an example of how MeshDataTool may be used.

[codeblock]

var mdt = MeshDataTool.new()

mdt.create_from_surface(mesh, 0)

for i in range(mdt.get_vertex_count()):

var vertex = mdt.get_vertex(i)

mdt.set_vertex(i, vertex)

mesh.surface_remove(0)

mdt.commit_to_surface(mesh)

[/codeblock]

Inheritance Chain

Constructors

    public MeshDataTool()

Methods

    public void Clear()

Clears all data currently in MeshDataTool.

    public Error CommitToSurface(ArrayMesh mesh)

Adds a new surface to specified Mesh with edited data.

    public Error CreateFromSurface(ArrayMesh mesh, int surface)

Uses specified surface of given Mesh to populate data for MeshDataTool.

Requires Mesh with primitive type [constant Mesh.PRIMITIVE_TRIANGLES].

    public int GetEdgeCount()

Returns the number of edges in this Mesh.

    public int[] GetEdgeFaces(int idx)

Returns array of faces that touch given edge.

    public object GetEdgeMeta(int idx)

Returns meta information assigned to given edge.

    public int GetEdgeVertex(int idx, int 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.

    public int GetFaceCount()

Returns the number of faces in this Mesh.

    public int GetFaceEdge(int idx, int edge)

Returns specified edge associated with given face.

Edge argument must 2 or less because a face only has three edges.

    public object GetFaceMeta(int idx)

Returns the metadata associated with the given face.

    public Vector3 GetFaceNormal(int idx)

Calculates and returns the face normal of the given face.

    public int GetFaceVertex(int idx, int vertex)

Returns the specified vertex of the given face.

Vertex argument must be 2 or less because faces contain three vertices.

    public int 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.

    public Material GetMaterial()

Returns the material assigned to the Mesh.

    public Vector3 GetVertex(int idx)

Returns the vertex at given index.

    public int[] GetVertexBones(int idx)

Returns the bones of the given vertex.

    public Color GetVertexColor(int idx)

Returns the color of the given vertex.

    public int GetVertexCount()

Returns the total number of vertices in Mesh.

    public int[] GetVertexEdges(int idx)

Returns an array of edges that share the given vertex.

    public int[] GetVertexFaces(int idx)

Returns an array of faces that share the given vertex.

    public object GetVertexMeta(int idx)

Returns the metadata associated with the given vertex.

    public Vector3 GetVertexNormal(int idx)

Returns the normal of the given vertex.

    public Plane GetVertexTangent(int idx)

Returns the tangent of the given vertex.

    public Vector2 GetVertexUv(int idx)

Returns the UV of the given vertex.

    public Vector2 GetVertexUv2(int idx)

Returns the UV2 of the given vertex.

    public float[] GetVertexWeights(int idx)

Returns bone weights of the given vertex.

    public void SetEdgeMeta(int idx, object meta)

Sets the metadata of the given edge.

    public void SetFaceMeta(int idx, object meta)

Sets the metadata of the given face.

    public void SetMaterial(Material material)

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

    public void SetVertex(int idx, Vector3 vertex)

Sets the position of the given vertex.

    public void SetVertexBones(int idx, int[] bones)

Sets the bones of the given vertex.

    public void SetVertexColor(int idx, Color color)

Sets the color of the given vertex.

    public void SetVertexMeta(int idx, object meta)

Sets the metadata associated with the given vertex.

    public void SetVertexNormal(int idx, Vector3 normal)

Sets the normal of the given vertex.

    public void SetVertexTangent(int idx, Plane tangent)

Sets the tangent of the given vertex.

    public void SetVertexUv(int idx, Vector2 uv)

Sets the UV of the given vertex.

    public void SetVertexUv2(int idx, Vector2 uv2)

Sets the UV2 of the given vertex.

    public void SetVertexWeights(int idx, float[] weights)

Sets the bone weights of the given vertex.

Tags: