MeshDataTool
Helper tool to access and edit Mesh
data.
class MeshDataTool
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(mesh:surface:)
. When you are finished editing the data commit the data to a mesh with commitToSurface(mesh:compressionFlags:)
.
Below is an example of how MeshDataTool may be used.
See also ArrayMesh
, ImmediateMesh
and SurfaceTool
for procedural geometry generation.
Superclasses
class RefCounted
Base class for reference-counted objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
func clear(
) Clears all data currently in MeshDataTool.
func commitToSurface(mesh: ArrayMesh?, compressionFlags: UInt
) -> GodotError Adds a new surface to specified
Mesh
with edited data.func createFromSurface(mesh: ArrayMesh?, surface: Int32
) -> GodotError Uses specified surface of given
Mesh
to populate data for MeshDataTool.func getEdgeCount(
) -> Int32 Returns the number of edges in this
Mesh
.func getEdgeFaces(idx: Int32
) -> PackedInt32Array Returns array of faces that touch given edge.
func getEdgeMeta(idx: Int32
) -> Variant Returns meta information assigned to given edge.
func getEdgeVertex(idx: Int32, vertex: Int32
) -> Int32 Returns index of specified vertex connected to given edge.
func getFaceCount(
) -> Int32 Returns the number of faces in this
Mesh
.func getFaceEdge(idx: Int32, edge: Int32
) -> Int32 Returns specified edge associated with given face.
func getFaceMeta(idx: Int32
) -> Variant Returns the metadata associated with the given face.
func getFaceNormal(idx: Int32
) -> Vector3 Calculates and returns the face normal of the given face.
func getFaceVertex(idx: Int32, vertex: Int32
) -> Int32 Returns the specified vertex index of the given face.
func getFormat(
) -> UInt Returns the
Mesh
’s format. Format is an integer made up ofMesh
format flags combined together. For example, a mesh containing both vertices and normals would return a format of3
becauseMesh/ArrayFormat/vertex
is1
andMesh/ArrayFormat/normal
is2
.func getMaterial(
) -> Material? Returns the material assigned to the
Mesh
.func getVertex(idx: Int32
) -> Vector3 Returns the position of the given vertex.
func getVertexBones(idx: Int32
) -> PackedInt32Array Returns the bones of the given vertex.
func getVertexColor(idx: Int32
) -> Color Returns the color of the given vertex.
func getVertexCount(
) -> Int32 Returns the total number of vertices in
Mesh
.func getVertexEdges(idx: Int32
) -> PackedInt32Array Returns an array of edges that share the given vertex.
func getVertexFaces(idx: Int32
) -> PackedInt32Array Returns an array of faces that share the given vertex.
func getVertexMeta(idx: Int32
) -> Variant Returns the metadata associated with the given vertex.
func getVertexNormal(idx: Int32
) -> Vector3 Returns the normal of the given vertex.
func getVertexTangent(idx: Int32
) -> Plane Returns the tangent of the given vertex.
func getVertexUv(idx: Int32
) -> Vector2 Returns the UV of the given vertex.
func getVertexUv2(idx: Int32
) -> Vector2 Returns the UV2 of the given vertex.
func getVertexWeights(idx: Int32
) -> PackedFloat32Array Returns bone weights of the given vertex.
func setEdgeMeta(idx: Int32, meta: Variant
) Sets the metadata of the given edge.
func setFaceMeta(idx: Int32, meta: Variant
) Sets the metadata of the given face.
func setMaterial(Material?
) Sets the material to be used by newly-constructed
Mesh
.func setVertex(idx: Int32, vertex: Vector3
) Sets the position of the given vertex.
func setVertexBones(idx: Int32, bones: PackedInt32Array
) Sets the bones of the given vertex.
func setVertexColor(idx: Int32, color: Color
) Sets the color of the given vertex.
func setVertexMeta(idx: Int32, meta: Variant
) Sets the metadata associated with the given vertex.
func setVertexNormal(idx: Int32, normal: Vector3
) Sets the normal of the given vertex.
func setVertexTangent(idx: Int32, tangent: Plane
) Sets the tangent of the given vertex.
func setVertexUv(idx: Int32, uv: Vector2
) Sets the UV of the given vertex.
func setVertexUv2(idx: Int32, uv2: Vector2
) Sets the UV2 of the given vertex.
func setVertexWeights(idx: Int32, weights: PackedFloat32Array
) Sets the bone weights of the given vertex.