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

The 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 the 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 the 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 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 meta data associated with given face.

    public Vector3 GetFaceNormal(int idx)

Calculates and returns face normal of given face.

    public int GetFaceVertex(int idx, int vertex)

Returns specified vertex of given face.

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

    public int GetFormat()

Returns format of Mesh. 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 ARRAY_FORMAT_VERTEX is 1 and ARRAY_FORMAT_NORMAL is 2.

For list of format flags see ArrayMesh.

    public Material GetMaterial()

Returns 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 array of edges that share given vertex.

    public int[] GetVertexFaces(int idx)

Returns array of faces that share given vertex.

    public object GetVertexMeta(int idx)

Returns meta data associated with given vertex.

    public Vector3 GetVertexNormal(int idx)

Returns normal of given vertex.

    public Plane GetVertexTangent(int idx)

Returns tangent of given vertex.

    public Vector2 GetVertexUv(int idx)

Returns UV of given vertex.

    public Vector2 GetVertexUv2(int idx)

Returns UV2 of given vertex.

    public float[] GetVertexWeights(int idx)

Returns bone weights of given vertex.

    public void SetEdgeMeta(int idx, object meta)

Sets the meta data of given edge.

    public void SetFaceMeta(int idx, object meta)

Sets the meta data of 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 given vertex.

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

Sets the bones of given vertex.

    public void SetVertexColor(int idx, Color color)

Sets the color of given vertex.

    public void SetVertexMeta(int idx, object meta)

Sets the meta data associated with given vertex.

    public void SetVertexNormal(int idx, Vector3 normal)

Sets the normal of given vertex.

    public void SetVertexTangent(int idx, Plane tangent)

Sets the tangent of given vertex.

    public void SetVertexUv(int idx, Vector2 uv)

Sets the UV of given vertex.

    public void SetVertexUv2(int idx, Vector2 uv2)

Sets the UV2 of given vertex.

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

Sets the bone weights of given vertex.

Tags: